Skip to content

Commit d80b7b0

Browse files
committed
[True16][MC] support V_SWAP_B16 true16 format in asm/disasm for GFX11/12
1 parent d27ee36 commit d80b7b0

File tree

10 files changed

+3689
-5
lines changed

10 files changed

+3689
-5
lines changed

llvm/lib/Target/AMDGPU/SIInstrFormats.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ def VOPDstOperand_t16Lo128 : VOPDstOperand <VGPR_16_Lo128> {
321321
let DecoderMethod = "DecodeVGPR_16_Lo128RegisterClass";
322322
}
323323

324+
// Source-encoded destination operand for instructions like v_swap_b16.
325+
def VOPSrcEncodedDstOperand_t16Lo128 : VOPDstOperand <VGPR_16_Lo128> {
326+
let EncoderMethod = VSrcT_b16_Lo128.EncoderMethod;
327+
let DecoderMethod = VSrcT_b16_Lo128.DecoderMethod;
328+
}
329+
324330
class VINTRPe <bits<2> op> : Enc32 {
325331
bits<8> vdst;
326332
bits<8> vsrc;

llvm/lib/Target/AMDGPU/VOP1Instructions.td

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,21 @@ def V_ACCVGPR_MOV_B32 : VOP1_Pseudo<"v_accvgpr_mov_b32", VOPProfileAccMov, [], 1
729729
let isAsCheapAsAMove = 1;
730730
}
731731

732+
def VOP_SWAP_I16 : VOPProfile_True16<VOP_I16_I16> {
733+
let Outs32 = (outs VOPDstOperand_t16Lo128:$vdst,
734+
VOPSrcEncodedDstOperand_t16Lo128:$vdst1);
735+
let Ins32 = (ins VOPSrcEncodedDstOperand_t16Lo128:$src0,
736+
VOPDstOperand_t16Lo128:$src1);
737+
let Asm32 = " $vdst, $src0";
738+
}
739+
732740
let SubtargetPredicate = isGFX11Plus in {
741+
def V_SWAP_B16 : VOP1_Pseudo<"v_swap_b16", VOP_SWAP_I16, [], /* VOP1Only= */true> {
742+
let Constraints = "$vdst = $src1, $vdst1 = $src0";
743+
let DisableEncoding = "$vdst1, $src1";
744+
let SchedRW = [Write64Bit, Write64Bit];
745+
let True16Predicate = UseRealTrue16Insts;
746+
}
733747
// Restrict src0 to be VGPR
734748
def V_PERMLANE64_B32 : VOP1_Pseudo<"v_permlane64_b32", VOP_MOVRELS,
735749
[], /*VOP1Only=*/ 1> {
@@ -952,7 +966,8 @@ defm V_CTZ_I32_B32 : VOP1_Real_FULL_with_name_gfx11_gfx12<0x03a,
952966
"V_FFBL_B32", "v_ctz_i32_b32">;
953967
defm V_CLS_I32 : VOP1_Real_FULL_with_name_gfx11_gfx12<0x03b,
954968
"V_FFBH_I32", "v_cls_i32">;
955-
defm V_PERMLANE64_B32 : VOP1Only_Real_gfx11_gfx12<0x067>;
969+
defm V_SWAP_B16 : VOP1Only_Real_gfx11_gfx12<0x066>;
970+
defm V_PERMLANE64_B32 : VOP1Only_Real_gfx11_gfx12<0x067>;
956971
defm V_MOV_B16_t16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x01c, "v_mov_b16">;
957972
defm V_NOT_B16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x069, "v_not_b16">;
958973
defm V_CVT_I32_I16_fake16 : VOP1_Real_FULL_t16_gfx11_gfx12<0x06a, "v_cvt_i32_i16">;

llvm/test/MC/AMDGPU/gfx10_unsupported.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,6 +3287,9 @@ v_subrev_u32_e64 v255, s[12:13], v1, v2
32873287
v_subrev_u32_sdwa v1, vcc, v2, v3 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:BYTE_2
32883288
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
32893289

3290+
v_swap_b16 v0.l, v0.l
3291+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
3292+
32903293
v_wmma_bf16_16x16x16_bf16 v[16:19], 1.0, v[8:15], v[16:19]
32913294
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
32923295

llvm/test/MC/AMDGPU/gfx11_asm_vop1.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,6 +3448,15 @@ v_sqrt_f64 v[5:6], src_scc
34483448
v_sqrt_f64 v[254:255], 0xaf123456
34493449
// GFX11: encoding: [0xff,0x68,0xfc,0x7f,0x56,0x34,0x12,0xaf]
34503450

3451+
v_swap_b16 v5.l, v1.h
3452+
// GFX11: encoding: [0x81,0xcd,0x0a,0x7e]
3453+
3454+
v_swap_b16 v5.h, v1.l
3455+
// GFX11: encoding: [0x01,0xcd,0x0a,0x7f]
3456+
3457+
v_swap_b16 v127.l, v127.l
3458+
// GFX11: encoding: [0x7f,0xcd,0xfe,0x7e]
3459+
34513460
v_swap_b32 v5, v1
34523461
// GFX11: encoding: [0x01,0xcb,0x0a,0x7e]
34533462

llvm/test/MC/AMDGPU/gfx11_asm_vop1_t16_err.s

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ v_sqrt_f16_e32 v255.l, v1.l
211211
v_sqrt_f16_e32 v5.l, v199.l
212212
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
213213

214+
v_swap_b16_e32 v128.l, v0.l
215+
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
216+
217+
v_swap_b16_e32 v0.l, s0
218+
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
219+
220+
v_swap_b16_e32 v0.l, 0
221+
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
222+
223+
v_swap_b16_e32 v0.l, 0xfe0b
224+
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
225+
214226
v_trunc_f16_e32 v128, 0xfe0b
215227
// GFX11: :[[@LINE-1]]:{{[0-9]+}}: error: operands are not valid for this GPU or mode
216228

0 commit comments

Comments
 (0)