Skip to content

Commit d55594b

Browse files
committed
[AMDGPU][AsmParser] Forbid TFE modifiers for MBUF stores.
Reviewed By: dp Differential Revision: https://reviews.llvm.org/D137832
1 parent 62b00bf commit d55594b

File tree

6 files changed

+33
-99
lines changed

6 files changed

+33
-99
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
16901690
bool validateCoherencyBits(const MCInst &Inst, const OperandVector &Operands,
16911691
const SMLoc &IDLoc);
16921692
bool validateExeczVcczOperands(const OperandVector &Operands);
1693+
bool validateTFE(const MCInst &Inst, const OperandVector &Operands);
16931694
Optional<StringRef> validateLdsDirect(const MCInst &Inst);
16941695
unsigned getConstantBusLimit(unsigned Opcode) const;
16951696
bool usesConstantBus(const MCInst &Inst, unsigned OpIdx);
@@ -4595,6 +4596,21 @@ bool AMDGPUAsmParser::validateExeczVcczOperands(const OperandVector &Operands) {
45954596
return true;
45964597
}
45974598

4599+
bool AMDGPUAsmParser::validateTFE(const MCInst &Inst,
4600+
const OperandVector &Operands) {
4601+
const MCInstrDesc &Desc = MII.get(Inst.getOpcode());
4602+
if (Desc.mayStore() &&
4603+
(Desc.TSFlags & (SIInstrFlags::MUBUF | SIInstrFlags::MTBUF))) {
4604+
SMLoc Loc = getImmLoc(AMDGPUOperand::ImmTyTFE, Operands);
4605+
if (Loc != getInstLoc(Operands)) {
4606+
Error(Loc, "TFE modifier has no meaning for store instructions");
4607+
return false;
4608+
}
4609+
}
4610+
4611+
return true;
4612+
}
4613+
45984614
bool AMDGPUAsmParser::validateInstruction(const MCInst &Inst,
45994615
const SMLoc &IDLoc,
46004616
const OperandVector &Operands) {
@@ -4710,6 +4726,9 @@ bool AMDGPUAsmParser::validateInstruction(const MCInst &Inst,
47104726
if (!validateExeczVcczOperands(Operands)) {
47114727
return false;
47124728
}
4729+
if (!validateTFE(Inst, Operands)) {
4730+
return false;
4731+
}
47134732

47144733
return true;
47154734
}

llvm/test/MC/AMDGPU/gfx10_err_pos.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,3 +1349,11 @@ v_cndmask_b32_sdwa v5, v1, sext(v2), vcc dst_sel:DWORD dst_unused:UNUSED_PRESERV
13491349
// CHECK: error: not a valid operand.
13501350
// CHECK-NEXT:{{^}}v_cndmask_b32_sdwa v5, v1, sext(v2), vcc dst_sel:DWORD dst_unused:UNUSED_PRESERVE src0_sel:BYTE_0 src1_sel:WORD_0
13511351
// CHECK-NEXT:{{^}} ^
1352+
1353+
//==============================================================================
1354+
// TFE modifier has no meaning for store instructions
1355+
1356+
buffer_store_dword v[1:2], off, s[12:15], s4 tfe
1357+
// CHECK: error: TFE modifier has no meaning for store instructions
1358+
// CHECK-NEXT:{{^}}buffer_store_dword v[1:2], off, s[12:15], s4 tfe
1359+
// CHECK-NEXT:{{^}} ^

llvm/test/MC/AMDGPU/gfx11_asm_err.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ v_fma_mixhi_f16_e64_dpp v5, v1, 0, v4 quad_perm:[3,2,1,0]
101101

102102
v_fma_mixlo_f16_e64_dpp v5, v1, 1, v4 dpp8:[7,6,5,4,3,2,1,0]
103103
// GFX11: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
104+
105+
buffer_store_d16_hi_format_x v[1:2], off, s[12:15], s4 offset:4095 glc slc dlc tfe
106+
// GFX11: [[@LINE-1]]:{{[0-9]+}}: error: TFE modifier has no meaning for store instructions

llvm/test/MC/AMDGPU/gfx11_asm_mubuf.s

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,9 +2410,6 @@ buffer_store_d16_hi_format_x v1, off, s[12:15], s4 offset:4095 dlc
24102410
buffer_store_d16_hi_format_x v1, off, s[12:15], s4 offset:4095 glc slc dlc
24112411
// GFX11: encoding: [0xff,0x7f,0x9c,0xe0,0x00,0x01,0x03,0x04]
24122412

2413-
buffer_store_d16_hi_format_x v[1:2], off, s[12:15], s4 offset:4095 glc slc dlc tfe
2414-
// GFX11: encoding: [0xff,0x7f,0x9c,0xe0,0x00,0x01,0x23,0x04]
2415-
24162413
buffer_store_format_x v1, off, s[12:15], s4 offset:4095
24172414
// GFX11: encoding: [0xff,0x0f,0x10,0xe0,0x00,0x01,0x03,0x04]
24182415

llvm/test/MC/AMDGPU/mubuf-gfx9.s

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ buffer_store_short_d16_hi v1, off, s[4:7], s1
3737
// GFX9: buffer_store_short_d16_hi v1, off, s[4:7], s1 ; encoding: [0x00,0x00,0x6c,0xe0,0x00,0x01,0x01,0x01]
3838
// VI-ERR: error: instruction not supported on this GPU
3939

40-
buffer_store_short_d16_hi v[1:2], off, s[4:7], s1 tfe
41-
// GFX9: buffer_store_short_d16_hi v[1:2], off, s[4:7], s1 tfe ; encoding: [0x00,0x00,0x6c,0xe0,0x00,0x01,0x81,0x01]
42-
// VI-ERR: error: instruction not supported on this GPU
43-
4440
buffer_load_format_d16_hi_x v5, off, s[8:11], s3
4541
// GFX9: buffer_load_format_d16_hi_x v5, off, s[8:11], s3 ; encoding: [0x00,0x00,0x98,0xe0,0x00,0x05,0x02,0x03]
4642
// VI-ERR: error: instruction not supported on this GPU
@@ -77,10 +73,6 @@ buffer_store_format_d16_hi_x v1, v0, s[12:15], s4 idxen offset:4095
7773
// GFX9: buffer_store_format_d16_hi_x v1, v0, s[12:15], s4 idxen offset:4095 ; encoding: [0xff,0x2f,0x9c,0xe0,0x00,0x01,0x03,0x04]
7874
// VI-ERR: error: instruction not supported on this GPU
7975

80-
buffer_store_format_d16_hi_x v[1:2], v0, s[12:15], s4 idxen offset:4095 tfe
81-
// GFX9: buffer_store_format_d16_hi_x v[1:2], v0, s[12:15], s4 idxen offset:4095 tfe ; encoding: [0xff,0x2f,0x9c,0xe0,0x00,0x01,0x83,0x04]
82-
// VI-ERR: error: instruction not supported on this GPU
83-
8476
buffer_store_format_d16_hi_x v1, v0, s[12:15], s4 offen offset:4095
8577
// GFX9: buffer_store_format_d16_hi_x v1, v0, s[12:15], s4 offen offset:4095 ; encoding: [0xff,0x1f,0x9c,0xe0,0x00,0x01,0x03,0x04]
8678
// VI-ERR: error: instruction not supported on this GPU

llvm/test/MC/AMDGPU/mubuf.s

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -222,26 +222,6 @@ buffer_store_dword v1, off, s[4:7], s1 offset:4 slc
222222
// SICI: buffer_store_dword v1, off, s[4:7], s1 offset:4 slc ; encoding: [0x04,0x00,0x70,0xe0,0x00,0x01,0x41,0x01]
223223
// VI: buffer_store_dword v1, off, s[4:7], s1 offset:4 slc ; encoding: [0x04,0x00,0x72,0xe0,0x00,0x01,0x01,0x01]
224224

225-
buffer_store_dword v[1:2], off, s[4:7], s1 offset:4 tfe
226-
// SICI: buffer_store_dword v[1:2], off, s[4:7], s1 offset:4 tfe ; encoding: [0x04,0x00,0x70,0xe0,0x00,0x01,0x81,0x01]
227-
// VI: buffer_store_dword v[1:2], off, s[4:7], s1 offset:4 tfe ; encoding: [0x04,0x00,0x70,0xe0,0x00,0x01,0x81,0x01]
228-
229-
buffer_store_dword v[1:2], off, s[4:7], s1 glc tfe
230-
// SICI: buffer_store_dword v[1:2], off, s[4:7], s1 glc tfe ; encoding: [0x00,0x40,0x70,0xe0,0x00,0x01,0x81,0x01]
231-
// VI: buffer_store_dword v[1:2], off, s[4:7], s1 glc tfe ; encoding: [0x00,0x40,0x70,0xe0,0x00,0x01,0x81,0x01]
232-
233-
buffer_store_dword v[1:2], off, s[4:7], s1 offset:4 glc slc tfe
234-
// SICI: buffer_store_dword v[1:2], off, s[4:7], s1 offset:4 glc slc tfe ; encoding: [0x04,0x40,0x70,0xe0,0x00,0x01,0xc1,0x01]
235-
// VI: buffer_store_dword v[1:2], off, s[4:7], s1 offset:4 glc slc tfe ; encoding: [0x04,0x40,0x72,0xe0,0x00,0x01,0x81,0x01]
236-
237-
buffer_store_dword v[1:2], off, ttmp[4:7], ttmp1 offset:4 glc slc tfe
238-
// SICI: buffer_store_dword v[1:2], off, ttmp[4:7], ttmp1 offset:4 glc slc tfe ; encoding: [0x04,0x40,0x70,0xe0,0x00,0x01,0xdd,0x71]
239-
// VI: buffer_store_dword v[1:2], off, ttmp[4:7], ttmp1 offset:4 glc slc tfe ; encoding: [0x04,0x40,0x72,0xe0,0x00,0x01,0x9d,0x71]
240-
241-
buffer_store_dwordx2 v[1:3], off, ttmp[4:7], ttmp1 offset:4 glc slc tfe
242-
// SICI: buffer_store_dwordx2 v[1:3], off, ttmp[4:7], ttmp1 offset:4 glc slc tfe ; encoding: [0x04,0x40,0x74,0xe0,0x00,0x01,0xdd,0x71]
243-
// VI: buffer_store_dwordx2 v[1:3], off, ttmp[4:7], ttmp1 offset:4 glc slc tfe ; encoding: [0x04,0x40,0x76,0xe0,0x00,0x01,0x9d,0x71]
244-
245225
//===----------------------------------------------------------------------===//
246226
// store - vgpr offset
247227
//===----------------------------------------------------------------------===//
@@ -262,26 +242,6 @@ buffer_store_dword v1, v2, s[4:7], s1 offen offset:4 slc
262242
// SICI: buffer_store_dword v1, v2, s[4:7], s1 offen offset:4 slc ; encoding: [0x04,0x10,0x70,0xe0,0x02,0x01,0x41,0x01]
263243
// VI: buffer_store_dword v1, v2, s[4:7], s1 offen offset:4 slc ; encoding: [0x04,0x10,0x72,0xe0,0x02,0x01,0x01,0x01]
264244

265-
buffer_store_dword v[1:2], v2, s[4:7], s1 offen offset:4 tfe
266-
// SICI: buffer_store_dword v[1:2], v2, s[4:7], s1 offen offset:4 tfe ; encoding: [0x04,0x10,0x70,0xe0,0x02,0x01,0x81,0x01]
267-
// VI: buffer_store_dword v[1:2], v2, s[4:7], s1 offen offset:4 tfe ; encoding: [0x04,0x10,0x70,0xe0,0x02,0x01,0x81,0x01]
268-
269-
buffer_store_dword v[1:2], v2, s[4:7], s1 offen glc tfe
270-
// SICI: buffer_store_dword v[1:2], v2, s[4:7], s1 offen glc tfe ; encoding: [0x00,0x50,0x70,0xe0,0x02,0x01,0x81,0x01]
271-
// VI: buffer_store_dword v[1:2], v2, s[4:7], s1 offen glc tfe ; encoding: [0x00,0x50,0x70,0xe0,0x02,0x01,0x81,0x01]
272-
273-
buffer_store_dword v[1:2], v2, s[4:7], s1 offen offset:4 glc slc tfe
274-
// SICI: buffer_store_dword v[1:2], v2, s[4:7], s1 offen offset:4 glc slc tfe ; encoding: [0x04,0x50,0x70,0xe0,0x02,0x01,0xc1,0x01]
275-
// VI: buffer_store_dword v[1:2], v2, s[4:7], s1 offen offset:4 glc slc tfe ; encoding: [0x04,0x50,0x72,0xe0,0x02,0x01,0x81,0x01]
276-
277-
buffer_store_dword v[1:2], v2, ttmp[4:7], ttmp1 offen offset:4 glc slc tfe
278-
// SICI: buffer_store_dword v[1:2], v2, ttmp[4:7], ttmp1 offen offset:4 glc slc tfe ; encoding: [0x04,0x50,0x70,0xe0,0x02,0x01,0xdd,0x71]
279-
// VI: buffer_store_dword v[1:2], v2, ttmp[4:7], ttmp1 offen offset:4 glc slc tfe ; encoding: [0x04,0x50,0x72,0xe0,0x02,0x01,0x9d,0x71]
280-
281-
buffer_store_dwordx3 v[1:4], v2, ttmp[4:7], ttmp1 offen offset:4 glc slc tfe
282-
// SICI: buffer_store_dwordx3 v[1:4], v2, ttmp[4:7], ttmp1 offen offset:4 glc slc tfe ; encoding: [0x04,0x50,0x7c,0xe0,0x02,0x01,0xdd,0x71]
283-
// VI: buffer_store_dwordx3 v[1:4], v2, ttmp[4:7], ttmp1 offen offset:4 glc slc tfe ; encoding: [0x04,0x50,0x7a,0xe0,0x02,0x01,0x9d,0x71]
284-
285245
//===----------------------------------------------------------------------===//
286246
// store - vgpr index
287247
//===----------------------------------------------------------------------===//
@@ -302,22 +262,6 @@ buffer_store_dword v1, v2, s[4:7], s1 idxen offset:4 slc
302262
// SICI: buffer_store_dword v1, v2, s[4:7], s1 idxen offset:4 slc ; encoding: [0x04,0x20,0x70,0xe0,0x02,0x01,0x41,0x01]
303263
// VI: buffer_store_dword v1, v2, s[4:7], s1 idxen offset:4 slc ; encoding: [0x04,0x20,0x72,0xe0,0x02,0x01,0x01,0x01]
304264

305-
buffer_store_dword v[1:2], v2, s[4:7], s1 idxen offset:4 tfe
306-
// SICI: buffer_store_dword v[1:2], v2, s[4:7], s1 idxen offset:4 tfe ; encoding: [0x04,0x20,0x70,0xe0,0x02,0x01,0x81,0x01]
307-
// VI: buffer_store_dword v[1:2], v2, s[4:7], s1 idxen offset:4 tfe ; encoding: [0x04,0x20,0x70,0xe0,0x02,0x01,0x81,0x01]
308-
309-
buffer_store_dword v[1:2], v2, s[4:7], s1 idxen glc tfe
310-
// SICI: buffer_store_dword v[1:2], v2, s[4:7], s1 idxen glc tfe ; encoding: [0x00,0x60,0x70,0xe0,0x02,0x01,0x81,0x01]
311-
// VI: buffer_store_dword v[1:2], v2, s[4:7], s1 idxen glc tfe ; encoding: [0x00,0x60,0x70,0xe0,0x02,0x01,0x81,0x01]
312-
313-
buffer_store_dword v[1:2], v2, s[4:7], s1 idxen offset:4 glc slc tfe
314-
// SICI: buffer_store_dword v[1:2], v2, s[4:7], s1 idxen offset:4 glc slc tfe ; encoding: [0x04,0x60,0x70,0xe0,0x02,0x01,0xc1,0x01]
315-
// VI: buffer_store_dword v[1:2], v2, s[4:7], s1 idxen offset:4 glc slc tfe ; encoding: [0x04,0x60,0x72,0xe0,0x02,0x01,0x81,0x01]
316-
317-
buffer_store_dword v[1:2], v2, ttmp[4:7], ttmp1 idxen offset:4 glc slc tfe
318-
// SICI: buffer_store_dword v[1:2], v2, ttmp[4:7], ttmp1 idxen offset:4 glc slc tfe ; encoding: [0x04,0x60,0x70,0xe0,0x02,0x01,0xdd,0x71]
319-
// VI: buffer_store_dword v[1:2], v2, ttmp[4:7], ttmp1 idxen offset:4 glc slc tfe ; encoding: [0x04,0x60,0x72,0xe0,0x02,0x01,0x9d,0x71]
320-
321265
//===----------------------------------------------------------------------===//
322266
// store - vgpr index and offset
323267
//===----------------------------------------------------------------------===//
@@ -338,22 +282,6 @@ buffer_store_dword v1, v[2:3], s[4:7], s1 idxen offen offset:4 slc
338282
// SICI: buffer_store_dword v1, v[2:3], s[4:7], s1 idxen offen offset:4 slc ; encoding: [0x04,0x30,0x70,0xe0,0x02,0x01,0x41,0x01]
339283
// VI: buffer_store_dword v1, v[2:3], s[4:7], s1 idxen offen offset:4 slc ; encoding: [0x04,0x30,0x72,0xe0,0x02,0x01,0x01,0x01]
340284

341-
buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen offset:4 tfe
342-
// SICI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen offset:4 tfe ; encoding: [0x04,0x30,0x70,0xe0,0x02,0x01,0x81,0x01]
343-
// VI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen offset:4 tfe ; encoding: [0x04,0x30,0x70,0xe0,0x02,0x01,0x81,0x01]
344-
345-
buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen glc tfe
346-
// SICI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen glc tfe ; encoding: [0x00,0x70,0x70,0xe0,0x02,0x01,0x81,0x01]
347-
// VI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen glc tfe ; encoding: [0x00,0x70,0x70,0xe0,0x02,0x01,0x81,0x01]
348-
349-
buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen offset:4 glc slc tfe
350-
// SICI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen offset:4 glc slc tfe ; encoding: [0x04,0x70,0x70,0xe0,0x02,0x01,0xc1,0x01]
351-
// VI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 idxen offen offset:4 glc slc tfe ; encoding: [0x04,0x70,0x72,0xe0,0x02,0x01,0x81,0x01]
352-
353-
buffer_store_dword v[1:2], v[2:3], ttmp[4:7], ttmp1 idxen offen offset:4 glc slc tfe
354-
// SICI: buffer_store_dword v[1:2], v[2:3], ttmp[4:7], ttmp1 idxen offen offset:4 glc slc tfe ; encoding: [0x04,0x70,0x70,0xe0,0x02,0x01,0xdd,0x71]
355-
// VI: buffer_store_dword v[1:2], v[2:3], ttmp[4:7], ttmp1 idxen offen offset:4 glc slc tfe ; encoding: [0x04,0x70,0x72,0xe0,0x02,0x01,0x9d,0x71]
356-
357285
//===----------------------------------------------------------------------===//
358286
// store - addr64
359287
//===----------------------------------------------------------------------===//
@@ -374,22 +302,6 @@ buffer_store_dword v1, v[2:3], s[4:7], s1 addr64 offset:4 slc
374302
// SICI: buffer_store_dword v1, v[2:3], s[4:7], s1 addr64 offset:4 slc ; encoding: [0x04,0x80,0x70,0xe0,0x02,0x01,0x41,0x01]
375303
// NOVI: error: operands are not valid for this GPU or mode
376304

377-
buffer_store_dword v[1:2], v[2:3], s[4:7], s1 addr64 offset:4 tfe
378-
// SICI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 addr64 offset:4 tfe ; encoding: [0x04,0x80,0x70,0xe0,0x02,0x01,0x81,0x01]
379-
// NOVI: error: operands are not valid for this GPU or mode
380-
381-
buffer_store_dword v[1:2], v[2:3], s[4:7], s1 addr64 glc tfe
382-
// SICI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 addr64 glc tfe ; encoding: [0x00,0xc0,0x70,0xe0,0x02,0x01,0x81,0x01]
383-
// NOVI: error: operands are not valid for this GPU or mode
384-
385-
buffer_store_dword v[1:2], v[2:3], s[4:7], s1 addr64 offset:4 glc slc tfe
386-
// SICI: buffer_store_dword v[1:2], v[2:3], s[4:7], s1 addr64 offset:4 glc slc tfe ; encoding: [0x04,0xc0,0x70,0xe0,0x02,0x01,0xc1,0x01]
387-
// NOVI: error: operands are not valid for this GPU or mode
388-
389-
buffer_store_dword v[1:2], v[2:3], ttmp[4:7], ttmp1 addr64 offset:4 glc slc tfe
390-
// SICI: buffer_store_dword v[1:2], v[2:3], ttmp[4:7], ttmp1 addr64 offset:4 glc slc tfe ; encoding: [0x04,0xc0,0x70,0xe0,0x02,0x01,0xdd,0x71]
391-
// NOVI: error: operands are not valid for this GPU or mode
392-
393305
//===----------------------------------------------------------------------===//
394306
// Instructions
395307
//===----------------------------------------------------------------------===//
@@ -882,3 +794,6 @@ buffer_load_dword off, s[8:11], s3
882794

883795
buffer_load_dword off, s[8:11], s3 offset:1
884796
// NOSICIVI: error: too few operands for instruction
797+
798+
buffer_store_dword v[1:2], off, s[4:7], s1 tfe
799+
// NOSICIVI: error: TFE modifier has no meaning for store instructions

0 commit comments

Comments
 (0)