Skip to content

Commit a3953fc

Browse files
committed
[AMDGPU][MC] Allow null where 128b or larger dst reg is expected
For GFX10+, currently null cannot be used as dst reg in instructions that expect the dst reg to be 128b or larger (e.g., s_load_dwordx4). This patch fixes this problem.
1 parent 1fe64fe commit a3953fc

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9720,6 +9720,12 @@ unsigned AMDGPUAsmParser::validateTargetOperandClass(MCParsedAsmOperand &Op,
97209720
// The following code enables it for SReg_64 operands
97219721
// used as source and destination. Remaining source
97229722
// operands are handled in isInlinableImm.
9723+
//
9724+
// Additionally, allow null where destination of 128-bit or larger is
9725+
// expected.
9726+
case MCK_SReg_128:
9727+
case MCK_SReg_256:
9728+
case MCK_SReg_512:
97239729
return Operand.isNull() ? Match_Success : Match_InvalidOperand;
97249730
default:
97259731
return Match_InvalidOperand;

llvm/test/MC/AMDGPU/gfx10_asm_smem.s

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,22 @@ s_load_dwordx16 s[20:35], s[2:3], 0x1234 glc dlc
281281
s_load_dwordx16 s[20:35], s[2:3], s0 offset:0x12345 glc dlc
282282
// GFX10: encoding: [0x01,0x45,0x11,0xf4,0x45,0x23,0x01,0x00]
283283

284+
// null as dst
285+
s_load_dword null, s[2:3], s0
286+
// GFX10: encoding: [0x41,0x1f,0x00,0xf4,0x00,0x00,0x00,0x00]
287+
288+
s_load_dwordx2 null, s[2:3], s0
289+
// GFX10: encoding: [0x41,0x1f,0x04,0xf4,0x00,0x00,0x00,0x00]
290+
291+
s_load_dwordx4 null, s[2:3], s0
292+
// GFX10: encoding: [0x41,0x1f,0x08,0xf4,0x00,0x00,0x00,0x00]
293+
294+
s_load_dwordx8 null, s[2:3], s0
295+
// GFX10: encoding: [0x41,0x1f,0x0c,0xf4,0x00,0x00,0x00,0x00]
296+
297+
s_load_dwordx16 null, s[2:3], s0
298+
// GFX10: encoding: [0x41,0x1f,0x10,0xf4,0x00,0x00,0x00,0x00]
299+
284300
s_buffer_load_dword s5, s[4:7], s0
285301
// GFX10: encoding: [0x42,0x01,0x20,0xf4,0x00,0x00,0x00,0x00]
286302

llvm/test/MC/AMDGPU/gfx11_asm_smem.s

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ s_load_b512 s[20:35], s[2:3], s0 glc dlc
239239
s_load_b512 s[20:35], s[2:3], 0x1234 glc dlc
240240
// GFX11: encoding: [0x01,0x65,0x10,0xf4,0x34,0x12,0x00,0xf8]
241241

242+
// null as dst
243+
s_load_b32 null, s[2:3], s0
244+
// GFX11: encoding: [0x01,0x1f,0x00,0xf4,0x00,0x00,0x00,0x00]
245+
246+
s_load_b64 null, s[2:3], s0
247+
// GFX11: encoding: [0x01,0x1f,0x04,0xf4,0x00,0x00,0x00,0x00]
248+
249+
s_load_b128 null, s[2:3], s0
250+
// GFX11: encoding: [0x01,0x1f,0x08,0xf4,0x00,0x00,0x00,0x00]
251+
252+
s_load_b256 null, s[2:3], s0
253+
// GFX11: encoding: [0x01,0x1f,0x0c,0xf4,0x00,0x00,0x00,0x00]
254+
255+
s_load_b512 null, s[2:3], s0
256+
// GFX11: encoding: [0x01,0x1f,0x10,0xf4,0x00,0x00,0x00,0x00]
257+
242258
s_buffer_load_b32 s5, s[4:7], s0
243259
// GFX11: encoding: [0x42,0x01,0x20,0xf4,0x00,0x00,0x00,0x00]
244260

llvm/test/MC/AMDGPU/gfx12_asm_smem.s

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,22 @@ s_load_b512 s[20:35], s[2:3], m0
541541
s_load_b512 s[20:35], s[2:3], 0x0
542542
// GFX12: s_load_b512 s[20:35], s[2:3], 0x0 ; encoding: [0x01,0x85,0x00,0xf4,0x00,0x00,0x00,0xf8]
543543

544+
// null as dst
545+
s_load_b32 null, s[2:3], s0 offset:0x0
546+
// GFX12: encoding: [0x01,0x1f,0x00,0xf4,0x00,0x00,0x00,0x00]
547+
548+
s_load_b64 null, s[2:3], s0 offset:0x0
549+
// GFX12: encoding: [0x01,0x3f,0x00,0xf4,0x00,0x00,0x00,0x00]
550+
551+
s_load_b128 null, s[2:3], s0 offset:0x0
552+
// GFX12: encoding: [0x01,0x5f,0x00,0xf4,0x00,0x00,0x00,0x00]
553+
554+
s_load_b256 null, s[2:3], s0 offset:0x0
555+
// GFX12: encoding: [0x01,0x7f,0x00,0xf4,0x00,0x00,0x00,0x00]
556+
557+
s_load_b512 null, s[2:3], s0 offset:0x0
558+
// GFX12: encoding: [0x01,0x9f,0x00,0xf4,0x00,0x00,0x00,0x00]
559+
544560
s_buffer_load_b32 s5, s[4:7], s0
545561
// GFX12: s_buffer_load_b32 s5, s[4:7], s0 offset:0x0 ; encoding: [0x42,0x01,0x02,0xf4,0x00,0x00,0x00,0x00]
546562

0 commit comments

Comments
 (0)