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);
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 */
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
};
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
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
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