ir3: add ldg.a,stg.a which allow complex in-place offset calculation
authorDanylo Piliaiev <dpiliaiev@igalia.com>
Wed, 16 Jun 2021 11:43:19 +0000 (14:43 +0300)
committerMarge Bot <eric+marge@anholt.net>
Fri, 25 Jun 2021 15:39:51 +0000 (15:39 +0000)
commitfdc0f489e098d320593a1c6837a19726c84d90e9
treebe5a34ed76eb7ae31b475ca8a6508a33999c398f
parent4b06db0548603a719c836070b7b8959bce45a2c2
ir3: add ldg.a,stg.a which allow complex in-place offset calculation

The full form for ldg.a/stg.a offset is:
 g[reg_address + reg_offset << (imm_shift + 2) + imm_offset << 2]

where imm_shift is in [0, 3] and imm_offset is in [0, 3]

a6xx blob was found to produce a bit simplier offset calculations
for TES/TCS shaders in GTA V:

 [c002000a_03c14215] ldg.a.f32 r2.z, g[r1.y+((r2.z+1)<<2)], 3;
 [c0020004_01c14609] ldg.a.f32 r1.x, g[r1.y+((r1.x+3)<<2)], 1;

Our new syntax:
 stg.a.u32 g[r2.x+(r1.x+1)<<2], r5.x, 1
 stg.a.u32 g[r2.x+r1.x<<4+3<<2], r5.x, 1
 ldg.a.f32 r1.w, g[r1.y+(r1.w+1)<<2], 3
 ldg.a.f32 r1.w, g[r1.y+r1.w<<5+2<<2], 3

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11431>
14 files changed:
src/freedreno/computerator/examples/stg_ldg_offset.asm [new file with mode: 0644]
src/freedreno/ir3/disasm-a3xx.c
src/freedreno/ir3/instr-a3xx.h
src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_a4xx.c
src/freedreno/ir3/ir3_a6xx.c
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_context.h
src/freedreno/ir3/ir3_lexer.l
src/freedreno/ir3/ir3_parser.y
src/freedreno/ir3/ir3_validate.c
src/freedreno/ir3/tests/disasm.c
src/freedreno/isa/ir3-cat6.xml