agx: Require an immediate for `nest`
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 30 Jul 2023 01:46:52 +0000 (21:46 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 20:31:27 +0000 (20:31 +0000)
There's no good reason to allow non-immediate nesting values, and this lets us
use the (smaller) mov_imm instruction without special casing. This matches what
Metal produces, so it seems like a good preference.

   total bytes in shared programs: 11720338 -> 11717310 (-0.03%)
   bytes in affected programs: 2341580 -> 2338552 (-0.13%)
   helped: 1385
   HURT: 0
   Bytes are helped.

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

src/asahi/compiler/agx_compile.c
src/asahi/compiler/agx_opcodes.py
src/asahi/compiler/agx_register_allocate.c

index 96eb12b..ec5253f 100644 (file)
@@ -1706,7 +1706,7 @@ agx_emit_jump(agx_builder *b, nir_jump_instr *instr)
    }
 
    /* Update the counter and flush */
-   agx_nest(b, agx_immediate(nestings));
+   agx_nest(b, nestings);
 
    /* Jumps must come at the end of a block */
    agx_emit_logical_end(b);
@@ -1960,7 +1960,7 @@ emit_first_cf(agx_context *ctx)
       return;
 
    agx_builder _b = agx_init_builder(ctx, agx_after_block(ctx->current_block));
-   agx_nest(&_b, agx_immediate(0));
+   agx_nest(&_b, 0);
    ctx->any_cf = true;
 }
 
index 78bd18b..ae2cd34 100644 (file)
@@ -403,5 +403,5 @@ op("unit_test", _, dests = 0, srcs = 1, can_eliminate = False)
 # to be coalesced during RA, rather than lowered to a real move. 
 op("preload", _, srcs = 1)
 
-# Set the nesting counter. Lowers to mov r0l, x after RA.
-op("nest", _, dests = 0, srcs = 1, can_eliminate = False)
+# Set the nesting counter. Lowers to mov_imm r0l, #nest after RA.
+op("nest", _, dests = 0, imms = [IMM], can_eliminate = False)
index 1fea6f7..f3a0a56 100644 (file)
@@ -1243,7 +1243,7 @@ agx_ra(agx_context *ctx)
       /* Writes to the nesting counter lowered to the real register */
       case AGX_OPCODE_NEST: {
          agx_builder b = agx_init_builder(ctx, agx_before_instr(I));
-         agx_mov_to(&b, agx_register(0, AGX_SIZE_16), I->src[0]);
+         agx_mov_imm_to(&b, agx_register(0, AGX_SIZE_16), I->imm);
          agx_remove_instruction(I);
          break;
       }