brw: Let the builder fill the sources of brw_inst

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36730>
This commit is contained in:
Caio Oliveira 2025-08-09 23:14:02 -07:00 committed by Marge Bot
parent 506fce20f0
commit 3ef86a8d00
3 changed files with 13 additions and 10 deletions

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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);