diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 2bac35d5e55..f82cce6d1ba 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -55,129 +55,6 @@ bi_pack_header(bi_clause *clause, bi_clause *next_1, bi_clause *next_2, bool tdd return u; } -/* The uniform/constant slot allows loading a contiguous 64-bit immediate or - * pushed uniform per tuple. Figure out which one we need in the tuple (the - * scheduler needs to ensure we only have one type per tuple), validate - * everything, and rewrite away the register/uniform indices to use 3-bit - * sources directly. */ - -static unsigned -bi_lookup_constant(bi_clause *clause, uint32_t cons, bool *hi) -{ - for (unsigned i = 0; i < clause->constant_count; ++i) { - /* Try to apply to top or to bottom */ - uint64_t top = clause->constants[i]; - - /* Constant slots can actually be used by a different - * tuples if the 60 upper bits match since the 4 LSB are - * encoded in the tuple itself. Let's not bother about this - * case until we start scheduling more than one tuple per - * clause. - */ - if (cons == (uint32_t) top) - return i; - - if (cons == (top >> 32ul)) { - *hi = true; - return i; - } - } - - unreachable("Invalid constant accessed"); -} - - -static bool -bi_assign_fau_idx_single(bi_registers *regs, - bi_clause *clause, - bi_instr *ins, - bool assigned, - bool fast_zero) -{ - if (!ins) - return assigned; - - if (ins->op == BI_OPCODE_ATEST) { - /* ATEST FAU index must point to the ATEST parameter datum slot */ - assert(!assigned && !clause->branch_constant); - regs->fau_idx = BIR_FAU_ATEST_PARAM; - return true; - } - - if (ins->branch_target && clause->branch_constant) { - /* By convention branch constant is last XXX: this whole thing - * is a hack, FIXME */ - unsigned idx = clause->constant_count - 1; - - /* We can only jump to clauses which are qword aligned so the - * bottom 4-bits of the offset are necessarily 0 */ - unsigned lo = 0; - - /* Build the constant */ - unsigned C = bi_constant_field(idx) | lo; - - if (assigned && regs->fau_idx != C) - unreachable("Mismatched fau_idx: branch"); - - bi_foreach_src(ins, s) { - if (ins->src[s].type == BI_INDEX_CONSTANT) - ins->src[s] = bi_passthrough(BIFROST_SRC_FAU_HI); - } - - regs->fau_idx = C; - return true; - } - - bi_foreach_src(ins, s) { - if (ins->src[s].type == BI_INDEX_CONSTANT) { - bool hi = false; - uint32_t cons = ins->src[s].value; - unsigned swizzle = ins->src[s].swizzle; - - /* FMA can encode zero for free */ - if (cons == 0 && fast_zero) { - assert(!ins->src[s].abs && !ins->src[s].neg); - ins->src[s] = bi_passthrough(BIFROST_SRC_STAGE); - ins->src[s].swizzle = swizzle; - continue; - } - - unsigned idx = bi_lookup_constant(clause, cons, &hi); - unsigned lo = clause->constants[idx] & 0xF; - unsigned f = bi_constant_field(idx) | lo; - - if (assigned && regs->fau_idx != f) - unreachable("Mismatched uniform/const field: imm"); - - regs->fau_idx = f; - ins->src[s] = bi_passthrough(hi ? BIFROST_SRC_FAU_HI : BIFROST_SRC_FAU_LO); - ins->src[s].swizzle = swizzle; - assigned = true; - } else if (ins->src[s].type == BI_INDEX_FAU) { - bool hi = ins->src[s].offset > 0; - - assert(!assigned || regs->fau_idx == ins->src[s].value); - assert(ins->src[s].swizzle == BI_SWIZZLE_H01); - regs->fau_idx = ins->src[s].value; - ins->src[s] = bi_passthrough(hi ? BIFROST_SRC_FAU_HI : - BIFROST_SRC_FAU_LO); - assigned = true; - } - } - - return assigned; -} - -static void -bi_assign_fau_idx(bi_clause *clause, - bi_tuple *tuple) -{ - bool assigned = - bi_assign_fau_idx_single(&tuple->regs, clause, tuple->fma, false, true); - - bi_assign_fau_idx_single(&tuple->regs, clause, tuple->add, assigned, false); -} - /* Assigns a slot for reading, before anything is written */ static void