From 80f878b103c7113ab2ef80068b4c3e2aaceb3748 Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Tue, 21 Feb 2023 15:50:52 +0100 Subject: [PATCH] ir3/a7xx: Add new form of stg.a/ldg.a addressing The new stg.a/ldg.a addressing form supersedes the a6xx's one. The new form is: ldg.a.f32 r4.y, g[c0.z+r4.y+2], 4 There are no shift comparing to the a6xx: ldg.a.f32 r4.y, g[r0.z+(r4.y)<<2], 4 Also on a7xx the first src is allowed to be both const and gpr. Signed-off-by: Danylo Piliaiev Part-of: --- src/freedreno/ir3/ir3_parser.y | 32 +++++++----- src/freedreno/ir3/tests/disasm.c | 6 +++ src/freedreno/isa/ir3-cat6.xml | 106 +++++++++++++++++++++++++++++++++++---- 3 files changed, 123 insertions(+), 21 deletions(-) diff --git a/src/freedreno/ir3/ir3_parser.y b/src/freedreno/ir3/ir3_parser.y index 5da14bc..199aca1 100644 --- a/src/freedreno/ir3/ir3_parser.y +++ b/src/freedreno/ir3/ir3_parser.y @@ -1120,20 +1120,28 @@ cat6_dst_offset: offset { instr->cat6.dst_offset = $1; } cat6_immed: integer { instr->cat6.iim_val = $1; } -cat6_stg_ldg_a6xx_offset: - '+' '(' src offset ')' '<' '<' integer { - assert($8 == 2); - new_src(0, IR3_REG_IMMED)->uim_val = 0; +cat6_a6xx_global_address_pt3: + '<' '<' integer offset '<' '<' integer { + assert($7 == 2); + new_src(0, IR3_REG_IMMED)->uim_val = $3 - 2; new_src(0, IR3_REG_IMMED)->uim_val = $4; - } -| '+' src '<' '<' integer offset '<' '<' integer { - assert($9 == 2); - new_src(0, IR3_REG_IMMED)->uim_val = $5 - 2; - new_src(0, IR3_REG_IMMED)->uim_val = $6; - } + } +| '+' cat6_reg_or_immed + +cat6_a6xx_global_address_pt2: + '(' src offset ')' '<' '<' integer { + assert($7 == 2); + new_src(0, IR3_REG_IMMED)->uim_val = 0; + new_src(0, IR3_REG_IMMED)->uim_val = $3; + } + +| src cat6_a6xx_global_address_pt3 + +cat6_a6xx_global_address: + src_reg_or_const '+' cat6_a6xx_global_address_pt2 cat6_load: T_OP_LDG { new_instr(OPC_LDG); } cat6_type dst_reg ',' 'g' '[' src cat6_offset ']' ',' immediate -| T_OP_LDG_A { new_instr(OPC_LDG_A); } cat6_type dst_reg ',' 'g' '[' src cat6_stg_ldg_a6xx_offset ']' ',' immediate +| T_OP_LDG_A { new_instr(OPC_LDG_A); } cat6_type dst_reg ',' 'g' '[' cat6_a6xx_global_address ']' ',' immediate | T_OP_LDP { new_instr(OPC_LDP); } cat6_type dst_reg ',' 'p' '[' src cat6_offset ']' ',' immediate | T_OP_LDL { new_instr(OPC_LDL); } cat6_type dst_reg ',' 'l' '[' src cat6_offset ']' ',' immediate | T_OP_LDLW { new_instr(OPC_LDLW); } cat6_type dst_reg ',' 'l' '[' src cat6_offset ']' ',' immediate @@ -1142,7 +1150,7 @@ cat6_load: T_OP_LDG { new_instr(OPC_LDG); } cat6_type dst_reg ',' 'g } ',' immediate cat6_store: T_OP_STG { new_instr(OPC_STG); dummy_dst(); } cat6_type 'g' '[' src cat6_imm_offset ']' ',' src ',' immediate -| T_OP_STG_A { new_instr(OPC_STG_A); dummy_dst(); } cat6_type 'g' '[' src cat6_stg_ldg_a6xx_offset ']' ',' src ',' immediate +| T_OP_STG_A { new_instr(OPC_STG_A); dummy_dst(); } cat6_type 'g' '[' cat6_a6xx_global_address ']' ',' src ',' immediate | T_OP_STP { new_instr(OPC_STP); dummy_dst(); } cat6_type 'p' '[' src cat6_dst_offset ']' ',' src ',' immediate | T_OP_STL { new_instr(OPC_STL); dummy_dst(); } cat6_type 'l' '[' src cat6_dst_offset ']' ',' src ',' immediate | T_OP_STLW { new_instr(OPC_STLW); dummy_dst(); } cat6_type 'l' '[' src cat6_dst_offset ']' ',' src ',' immediate diff --git a/src/freedreno/ir3/tests/disasm.c b/src/freedreno/ir3/tests/disasm.c index 3d02aa1..76fad0d 100644 --- a/src/freedreno/ir3/tests/disasm.c +++ b/src/freedreno/ir3/tests/disasm.c @@ -211,6 +211,9 @@ static const struct test { INSTR_6XX(c0d61104_01800228, "stg.a.u32 g[r2.x+(r1.x+1)<<2], r5.x, 1"), INSTR_6XX(c0d61104_01802628, "stg.a.u32 g[r2.x+r1.x<<4+3<<2], r5.x, 1"), + INSTR_7XX(c0d20505_07bfc006, "stg.a.f32 g[r0.z+r1.y+255], r0.w, 7"), + INSTR_7XX(c0d20507_04812006, "stg.a.f32 g[c0.z+r1.w+4], r0.w, 4"), + INSTR_6XX(c0020011_04c08023, "ldg.a.f32 r4.y, g[r0.z+(r4.y)<<2], 4"), /* ldg.a.f32 r4.y, g[r0.z+(r4.y<<2)], 4 */ INSTR_6XX(c0060006_01c18017, "ldg.a.u32 r1.z, g[r1.z+(r2.w)<<2], 1"), /* ldg.a.u32 r1.z, g[r1.z+(r2.w<<2)], 1 */ INSTR_6XX(c0060006_0181800f, "ldg.u32 r1.z, g[r1.z+7], 1"), @@ -230,6 +233,9 @@ static const struct test { INSTR_6XX(c0060006_0181800f, "ldg.u32 r1.z, g[r1.z+7], 1"), INSTR_6XX(c0060006_01818001, "ldg.u32 r1.z, g[r1.z], 1"), + INSTR_7XX(c0020411_04c08023, "ldg.a.f32 r4.y, g[r0.z+r4.y+2], 4"), + INSTR_7XX(c0004006_01c1a017, "ldg.a.f16 hr1.z, g[c1.z+r2.w+32], 1"), + /* dEQP-GLES3.functional.ubo.random.basic_arrays.0 */ INSTR_6XX(c7020020_01800000, "stc.f32 c[32], r0.x, 1"), /* stc c[32], r0.x, 1 */ /* dEQP-VK.image.image_size.cube_array.readonly_writeonly_1x1x12 */ diff --git a/src/freedreno/isa/ir3-cat6.xml b/src/freedreno/isa/ir3-cat6.xml index 9d6048b..ccee2e2 100644 --- a/src/freedreno/isa/ir3-cat6.xml +++ b/src/freedreno/isa/ir3-cat6.xml @@ -54,13 +54,18 @@ SOFTWARE. 1 - + + + 1 - + + 00xxx - xxxxxxxxx + x 00 00000 + + @@ -74,6 +79,7 @@ SOFTWARE. 0 + xxxxxxxx extract_reg_iim(src->srcs[1]) @@ -86,7 +92,7 @@ SOFTWARE. LoaD Global - + {SY}{JP}{NAME}.{TYPE} {TYPE_HALF}{DST}, g[{SRC1}+({SRC2}{OFF})<<{SRC2_BYTE_SHIFT}], {SIZE} @@ -104,6 +110,7 @@ SOFTWARE. 0 1 + xxxxxxxx {SRC2_ADD_DWORD_SHIFT} + 2 @@ -117,17 +124,45 @@ SOFTWARE. + + + LoaD Global + + + + + + {SY}{JP}{NAME}.{TYPE} {TYPE_HALF}{DST}, g[{SRC1}+{SRC2}+{OFF}], {SIZE} + + + + xxxx + + 1 + + + + src->srcs[1] + extract_reg_uim(src->srcs[2]) + extract_reg_uim(src->srcs[3]) + !!(src->srcs[0]->flags & IR3_REG_CONST) + + + x - xxxxxxxx - 1x - + + 00xxx - + + + x 00011 + + 1 @@ -147,6 +182,8 @@ SOFTWARE. + xxxxxxxx + 1x 0 @@ -163,7 +200,7 @@ SOFTWARE. STore Global - + {SY}{JP}{NAME}.{TYPE} g[{SRC1}+({SRC2}{OFF})<<{DST_BYTE_SHIFT}], {TYPE_HALF}{SRC3}, {SIZE} @@ -183,6 +220,8 @@ SOFTWARE. 0 + xxxxxxxx + 1x 1 @@ -195,6 +234,34 @@ SOFTWARE. + + + STore Global + + + + + + {SY}{JP}{NAME}.{TYPE} g[{SRC1}+{SRC2}+{OFF}], {TYPE_HALF}{SRC3}, {SIZE} + + + xxxx + + + 0 + 1 + + 1 + + + src->srcs[1] + extract_reg_uim(src->srcs[2]) + src->srcs[3] + extract_reg_uim(src->srcs[4]) + !!(src->srcs[0]->flags & IR3_REG_CONST) + + + 1 @@ -1216,6 +1283,27 @@ SOFTWARE. + + + Source value that can be either const reg or gpr + + + {SRC_CONST} + + c{GPR}.{SWIZ} + + + + r{GPR}.{SWIZ} + + + + + src->num >> 2 + src->num & 0x3 + + + {MODE} == 0 -- 2.7.4