From 442e29890defd98faa0c24738381db543a36c294 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 19 Nov 2022 15:07:52 -0500 Subject: [PATCH] agx: Implement nir_op_pack_64_2x32_split This maps to a collect where the dest size is 64 and the src size is 32. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 6 ++++++ src/asahi/compiler/agx_register_allocate.c | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 020947d0229..a7f062c1987 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -1088,6 +1088,12 @@ agx_emit_alu(agx_builder *b, nir_alu_instr *instr) return agx_convert_to(b, dst, agx_immediate(mode), s0, AGX_ROUND_RTE); } + case nir_op_pack_64_2x32_split: + { + agx_index idx[] = { s0, s1 }; + return agx_emit_collect_to(b, dst, 2, idx); + } + /* Split a 64-bit word into 32-bit parts. Do not use null destinations to * let us CSE (and coalesce) the splits when both x and y are split. */ diff --git a/src/asahi/compiler/agx_register_allocate.c b/src/asahi/compiler/agx_register_allocate.c index 8aeceb48c0b..4ac3db81f61 100644 --- a/src/asahi/compiler/agx_register_allocate.c +++ b/src/asahi/compiler/agx_register_allocate.c @@ -61,7 +61,7 @@ agx_write_registers(agx_instr *I, unsigned d) case AGX_OPCODE_LDCF: return 6; case AGX_OPCODE_COLLECT: - return I->nr_srcs * size; + return I->nr_srcs * agx_size_align_16(I->src[0].size); default: return size; } @@ -178,6 +178,10 @@ pick_regs(struct ra_ctx *rctx, agx_instr *I, unsigned d) if (base >= rctx->bound || (base + count) > rctx->bound) continue; + /* Unaligned destinations can happen when dest size > src size */ + if (base % align) + continue; + if (!BITSET_TEST_RANGE(rctx->used_regs, base, base + count - 1)) return base; } @@ -424,7 +428,7 @@ agx_ra(agx_context *ctx) if (ins->op == AGX_OPCODE_COLLECT) { assert(ins->dest[0].type == AGX_INDEX_REGISTER); unsigned base = ins->dest[0].value; - unsigned width = agx_size_align_16(ins->dest[0].size); + unsigned width = agx_size_align_16(ins->src[0].size); struct agx_copy *copies = alloca(sizeof(copies[0]) * ins->nr_srcs); unsigned n = 0; @@ -432,7 +436,7 @@ agx_ra(agx_context *ctx) /* Move the sources */ agx_foreach_src(ins, i) { if (agx_is_null(ins->src[i])) continue; - assert(ins->src[i].size == ins->dest[0].size); + assert(ins->src[i].size == ins->src[0].size); copies[n++] = (struct agx_copy) { .dest = base + (i * width),