summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2020-04-27 18:55:11 -0400
committerMarge Bot <eric+marge@anholt.net>2020-04-29 15:35:54 +0000
commit6757c480ab43d9020fac7a9e6233af6431ad6351 (patch)
tree04f4c217e83d3f73eba114f0c55312a2b9860508
parent742b272314fa6e202ea43b2f5473aee12bf7350e (diff)
pan/mdg: Track ALU src types
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4793>
-rw-r--r--src/panfrost/midgard/midgard_compile.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index c65ce2d97a0..2e10aae117f 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -626,6 +626,15 @@ reg_mode_for_nir(nir_alu_instr *instr)
}
static void
+mir_copy_src(midgard_instruction *ins, nir_alu_instr *instr, unsigned i, unsigned to)
+{
+ unsigned bits = nir_src_bit_size(instr->src[i].src);
+
+ ins->src[to] = nir_src_index(NULL, &instr->src[i].src);
+ ins->src_types[to] = nir_op_infos[instr->op].input_types[i] | bits;
+}
+
+static void
emit_alu(compiler_context *ctx, nir_alu_instr *instr)
{
/* Derivatives end up emitted on the texture pipe, not the ALUs. This
@@ -908,29 +917,22 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
unsigned opcode_props = alu_opcode_props[op].props;
bool quirk_flipped_r24 = opcode_props & QUIRK_FLIPPED_R24;
- /* src0 will always exist afaik, but src1 will not for 1-argument
- * instructions. The latter can only be fetched if the instruction
- * needs it, or else we may segfault. */
-
- unsigned src0 = nir_src_index(ctx, &instr->src[0].src);
- unsigned src1 = nr_inputs >= 2 ? nir_src_index(ctx, &instr->src[1].src) : ~0;
- unsigned src2 = nr_inputs == 3 ? nir_src_index(ctx, &instr->src[2].src) : ~0;
- assert(nr_inputs <= 3);
-
- /* Rather than use the instruction generation helpers, we do it
- * ourselves here to avoid the mess */
-
midgard_instruction ins = {
.type = TAG_ALU_4,
- .src = {
- quirk_flipped_r24 ? ~0 : src0,
- quirk_flipped_r24 ? src0 : src1,
- src2,
- ~0
- },
.dest = dest,
};
+ for (unsigned i = nr_inputs; i < ARRAY_SIZE(ins.src); ++i)
+ ins.src[i] = ~0;
+
+ if (quirk_flipped_r24) {
+ ins.src[0] = ~0;
+ mir_copy_src(&ins, instr, 0, 1);
+ } else {
+ for (unsigned i = 0; i < nr_inputs; ++i)
+ mir_copy_src(&ins, instr, i, quirk_flipped_r24 ? 1 : i);
+ }
+
nir_alu_src *nirmods[3] = { NULL };
if (nr_inputs >= 2) {