aco: Make num_workgroups and local_invocation_ids one argument each
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 12 Nov 2019 10:06:39 +0000 (11:06 +0100)
committerConnor Abbott <cwabbott0@gmail.com>
Mon, 25 Nov 2019 13:17:51 +0000 (14:17 +0100)
To match the LLVM argument setup code.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
src/amd/compiler/aco_instruction_selection.cpp
src/amd/compiler/aco_instruction_selection_setup.cpp

index 3b5bf0cc7636a52cad277b7ec431867b6ed4a073..856e73366dbd7e0b42d1b673683f88998a428403 100644 (file)
@@ -5494,17 +5494,21 @@ void visit_intrinsic(isel_context *ctx, nir_intrinsic_instr *instr)
    case nir_intrinsic_memory_barrier_shared:
       emit_memory_barrier(ctx, instr);
       break;
-   case nir_intrinsic_load_num_work_groups:
-   case nir_intrinsic_load_work_group_id:
+   case nir_intrinsic_load_num_work_groups: {
+      Temp dst = get_ssa_temp(ctx, &instr->dest.ssa);
+      bld.copy(Definition(dst), Operand(ctx->num_workgroups));
+      emit_split_vector(ctx, dst, 3);
+      break;
+   }
    case nir_intrinsic_load_local_invocation_id: {
       Temp dst = get_ssa_temp(ctx, &instr->dest.ssa);
-      Temp* ids;
-      if (instr->intrinsic == nir_intrinsic_load_num_work_groups)
-         ids = ctx->num_workgroups;
-      else if (instr->intrinsic == nir_intrinsic_load_work_group_id)
-         ids = ctx->workgroup_ids;
-      else
-         ids = ctx->local_invocation_ids;
+      bld.copy(Definition(dst), Operand(ctx->local_invocation_ids));
+      emit_split_vector(ctx, dst, 3);
+      break;
+   }
+   case nir_intrinsic_load_work_group_id: {
+      Temp dst = get_ssa_temp(ctx, &instr->dest.ssa);
+      Temp* ids = ctx->workgroup_ids;
       bld.pseudo(aco_opcode::p_create_vector, Definition(dst),
                  ids[0].id() ? Operand(ids[0]) : Operand(1u),
                  ids[1].id() ? Operand(ids[1]) : Operand(1u),
index 5c9c0e925acf0530e092d527a5ca2b2ef806cc45..c3f2832fa8ffac6f069221f8397c6c8159f4f623 100644 (file)
@@ -125,10 +125,10 @@ struct isel_context {
    bool needs_instance_id;
 
    /* CS inputs */
-   Temp num_workgroups[3] = {Temp(0, s1), Temp(0, s1), Temp(0, s1)};
+   Temp num_workgroups = Temp(0, s3);
    Temp workgroup_ids[3] = {Temp(0, s1), Temp(0, s1), Temp(0, s1)};
    Temp tg_size = Temp(0, s1);
-   Temp local_invocation_ids[3] = {Temp(0, v1), Temp(0, v1), Temp(0, v1)};
+   Temp local_invocation_ids = Temp(0, v3);
 
    /* VS output information */
    unsigned num_clip_distances;
@@ -992,9 +992,7 @@ Pseudo_instruction *add_startpgm(struct isel_context *ctx)
       declare_global_input_sgprs(ctx, &user_sgpr_info, &args, ctx->descriptor_sets);
 
       if (ctx->program->info->cs.uses_grid_size) {
-         add_arg(&args, s1, &ctx->num_workgroups[0], user_sgpr_info.user_sgpr_idx);
-         add_arg(&args, s1, &ctx->num_workgroups[1], user_sgpr_info.user_sgpr_idx + 1);
-         add_arg(&args, s1, &ctx->num_workgroups[2], user_sgpr_info.user_sgpr_idx + 2);
+         add_arg(&args, s3, &ctx->num_workgroups, user_sgpr_info.user_sgpr_idx);
          set_loc_shader(ctx, AC_UD_CS_GRID_SIZE, &user_sgpr_info.user_sgpr_idx, 3);
       }
       assert(user_sgpr_info.user_sgpr_idx == user_sgpr_info.num_sgpr);
@@ -1009,9 +1007,7 @@ Pseudo_instruction *add_startpgm(struct isel_context *ctx)
       if (ctx->options->supports_spill || ctx->scratch_enabled)
          add_arg(&args, s1, &ctx->program->scratch_offset, idx++);
 
-      add_arg(&args, v1, &ctx->local_invocation_ids[0], vgpr_idx++);
-      add_arg(&args, v1, &ctx->local_invocation_ids[1], vgpr_idx++);
-      add_arg(&args, v1, &ctx->local_invocation_ids[2], vgpr_idx++);
+      add_arg(&args, v3, &ctx->local_invocation_ids, vgpr_idx++);
       break;
    }
    default: