agx: Define p_extract for type converts
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 24 Jul 2021 21:25:40 +0000 (17:25 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 24 Jul 2021 21:25:40 +0000 (17:25 -0400)
Useful for grabbing the high 32-bit word of a 64-bit value.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12053>

src/asahi/compiler/agx_register_allocate.c

index e282ed4..917e476 100644 (file)
@@ -200,8 +200,8 @@ agx_ra(agx_context *ctx)
          agx_remove_instruction(ins);
          continue;
       } else if (ins->op == AGX_OPCODE_P_EXTRACT) {
+         /* Uses the destination size */
          assert(ins->dest[0].type == AGX_INDEX_NORMAL);
-         assert(ins->dest[0].size == ins->src[0].size);
          unsigned base = ins->src[0].value;
 
          if (ins->src[0].type != AGX_INDEX_REGISTER) {
@@ -209,7 +209,7 @@ agx_ra(agx_context *ctx)
             base = alloc[base];
          }
 
-         unsigned size = ins->dest[0].size == AGX_SIZE_32 ? 2 : 1;
+         unsigned size = ins->dest[0].size == AGX_SIZE_64 ? 4 : ins->dest[0].size == AGX_SIZE_32 ? 2 : 1;
          unsigned left = ssa_to_reg[ins->dest[0].value];
          unsigned right = ssa_to_reg[ins->src[0].value] + (size * ins->imm);