From 3ef86a8d007f50bbb1d2edcced1c83dd82dffe16 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Sat, 9 Aug 2025 23:14:02 -0700 Subject: [PATCH] brw: Let the builder fill the sources of brw_inst Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_builder.h | 16 +++++++++++----- src/intel/compiler/brw_inst.cpp | 5 +---- src/intel/compiler/brw_shader.h | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/intel/compiler/brw_builder.h b/src/intel/compiler/brw_builder.h index 70da8b8d411..94e13a60340 100644 --- a/src/intel/compiler/brw_builder.h +++ b/src/intel/compiler/brw_builder.h @@ -328,15 +328,18 @@ public: emit(enum opcode opcode, const brw_reg &dst, const brw_reg &src0, const brw_reg &src1, const brw_reg &src2) const { - brw_reg srcs[] = { src0, src1, src2 }; + brw_inst *inst = brw_new_inst(*shader, opcode, dispatch_width(), dst, 3); + inst->src[0] = src0; + inst->src[1] = src1; + inst->src[2] = src2; switch (opcode) { case BRW_OPCODE_BFE: case BRW_OPCODE_BFI2: case BRW_OPCODE_MAD: case BRW_OPCODE_LRP: - for (int i = 0; i < 3; i++) - srcs[i] = fix_3src_operand(srcs[i]); + for (unsigned i = 0; i < 3; i++) + inst->src[i] = fix_3src_operand(inst->src[i]); break; default: @@ -344,7 +347,7 @@ public: break; } - return emit(brw_new_inst(*shader, opcode, dispatch_width(), dst, srcs, 3)); + return emit(inst); } /** @@ -361,7 +364,10 @@ public: if (num_srcs == 3) { return emit(opcode, dst, srcs[0], srcs[1], srcs[2]); } else { - return emit(brw_new_inst(*shader, opcode, dispatch_width(), dst, srcs, num_srcs)); + brw_inst *inst = brw_new_inst(*shader, opcode, dispatch_width(), dst, num_srcs); + for (unsigned i = 0; i < num_srcs; i++) + inst->src[i] = srcs[i]; + return emit(inst); } } diff --git a/src/intel/compiler/brw_inst.cpp b/src/intel/compiler/brw_inst.cpp index 43740bde5fe..53087e0e5da 100644 --- a/src/intel/compiler/brw_inst.cpp +++ b/src/intel/compiler/brw_inst.cpp @@ -29,16 +29,13 @@ brw_alloc_inst(brw_shader &s, unsigned num_srcs) brw_inst * brw_new_inst(brw_shader &s, enum opcode opcode, unsigned exec_size, - const brw_reg &dst, const brw_reg srcs[], unsigned num_srcs) + const brw_reg &dst, unsigned num_srcs) { assert(exec_size != 0); assert(dst.file != IMM && dst.file != UNIFORM); brw_inst *inst = brw_alloc_inst(s, num_srcs); - for (unsigned i = 0; i < num_srcs; i++) - inst->src[i] = srcs[i]; - inst->opcode = opcode; inst->dst = dst; inst->exec_size = exec_size; diff --git a/src/intel/compiler/brw_shader.h b/src/intel/compiler/brw_shader.h index dcb04d8cc19..9ba4a385aec 100644 --- a/src/intel/compiler/brw_shader.h +++ b/src/intel/compiler/brw_shader.h @@ -372,5 +372,5 @@ bool brw_insert_load_reg(brw_shader &s); bool brw_lower_load_reg(brw_shader &s); brw_inst *brw_new_inst(brw_shader &s, enum opcode opcode, unsigned exec_size, - const brw_reg &dst, const brw_reg srcs[], unsigned num_srcs); + const brw_reg &dst, unsigned num_srcs); brw_inst *brw_clone_inst(brw_shader &s, const brw_inst *inst);