Commit 86c2a6b9 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜
Browse files

pan/bi: Fix bi_get_immediate with multiple imms


Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <mesa/mesa!4615>
parent df69304a
......@@ -162,7 +162,7 @@ bi_assign_uniform_constant_single(
if (ins->src[s] & BIR_INDEX_CONSTANT) {
bool hi = false;
bool b64 = nir_alu_type_get_type_size(ins->src_types[s]) > 32;
uint64_t cons = bi_get_immediate(ins, ins->src[s]);
uint64_t cons = bi_get_immediate(ins, s);
unsigned idx = bi_lookup_constant(clause, cons, &hi, b64);
unsigned f = bi_constant_field(idx) | (cons & 0xF);
......@@ -944,7 +944,7 @@ bi_pack_add_ld_vary(bi_clause *clause, bi_instruction *ins, struct bi_registers
if (ins->src[0] & BIR_INDEX_CONSTANT) {
/* Direct uses address field directly */
packed_addr = bi_get_immediate(ins, ins->src[0]);
packed_addr = bi_get_immediate(ins, 0);
assert(packed_addr < 0b1000);
} else {
/* Indirect gets an extra source */
......@@ -1051,7 +1051,7 @@ bi_pack_add_ld_var_addr(bi_clause *clause, bi_instruction *ins, struct bi_regist
struct bifrost_ld_var_addr pack = {
.src0 = bi_get_src(ins, regs, 1, false),
.src1 = bi_get_src(ins, regs, 2, false),
.location = bi_get_immediate(ins, ins->src[0]),
.location = bi_get_immediate(ins, 0),
.type = bi_pack_ldst_type(ins->src_types[3]),
.op = BIFROST_ADD_OP_LD_VAR_ADDR
};
......@@ -1066,7 +1066,7 @@ bi_pack_add_ld_attr(bi_clause *clause, bi_instruction *ins, struct bi_registers
struct bifrost_ld_attr pack = {
.src0 = bi_get_src(ins, regs, 1, false),
.src1 = bi_get_src(ins, regs, 2, false),
.location = bi_get_immediate(ins, ins->src[0]),
.location = bi_get_immediate(ins, 0),
.channels = MALI_POSITIVE(bi_load32_components(ins)),
.type = bi_pack_ldst_type(ins->dest_type),
.op = BIFROST_ADD_OP_LD_ATTR
......
......@@ -185,7 +185,7 @@ bi_print_index(FILE *fp, bi_instruction *ins, unsigned index, unsigned s)
if (index & BIR_INDEX_UNIFORM)
fprintf(fp, "u%u", index & ~BIR_INDEX_UNIFORM);
else if (index & BIR_INDEX_CONSTANT)
fprintf(fp, "#0x%" PRIx64, bi_get_immediate(ins, index));
fprintf(fp, "#0x%" PRIx64, bi_get_immediate(ins, s));
else if (index & BIR_INDEX_ZERO)
fprintf(fp, "#0");
else
......
......@@ -140,9 +140,18 @@ bi_bytemask_of_read_components(bi_instruction *ins, unsigned node)
uint64_t
bi_get_immediate(bi_instruction *ins, unsigned index)
{
assert(index & BIR_INDEX_CONSTANT);
unsigned shift = index & ~BIR_INDEX_CONSTANT;
return ins->constant.u64 >> shift;
unsigned v = ins->src[index];
assert(v & BIR_INDEX_CONSTANT);
unsigned shift = v & ~BIR_INDEX_CONSTANT;
uint64_t shifted = ins->constant.u64 >> shift;
/* Mask off the accessed part */
unsigned sz = nir_alu_type_get_type_size(ins->src_types[index]);
if (sz == 64)
return shifted;
else
return shifted & ((1ull << sz) - 1);
}
bool
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment