Skip to content

Commit 37b5388

Browse files
jwanggit86Jun Wang
and
Jun Wang
authored
[AMDGPU] Incorrect error message regarding SCC modifier (#65660)
For the AMD GFX90A GPU, the SCC instruction modifier is allowed for certain classes of instructions. However, the current assembler generates an error message, "scc is not supported on this GPU", regardless of the instruciton. This fix modifies the message as well as the logic for generating the message. Related tests are moved from gfx90a_err.s to gfx90a_asm_features.s. Co-authored-by: Jun Wang <[email protected]>
1 parent 499f691 commit 37b5388

File tree

3 files changed

+86
-56
lines changed

3 files changed

+86
-56
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4477,11 +4477,17 @@ bool AMDGPUAsmParser::validateCoherencyBits(const MCInst &Inst,
44774477
}
44784478

44794479
if (isGFX90A() && !isGFX940() && (CPol & CPol::SCC)) {
4480-
SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol, Operands);
4481-
StringRef CStr(S.getPointer());
4482-
S = SMLoc::getFromPointer(&CStr.data()[CStr.find("scc")]);
4483-
Error(S, "scc is not supported on this GPU");
4484-
return false;
4480+
const uint64_t AllowSCCModifier = SIInstrFlags::MUBUF |
4481+
SIInstrFlags::MTBUF | SIInstrFlags::MIMG |
4482+
SIInstrFlags::FLAT;
4483+
if (!(TSFlags & AllowSCCModifier)) {
4484+
SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol, Operands);
4485+
StringRef CStr(S.getPointer());
4486+
S = SMLoc::getFromPointer(&CStr.data()[CStr.find("scc")]);
4487+
Error(S,
4488+
"scc modifier is not supported for this instruction on this GPU");
4489+
return false;
4490+
}
44854491
}
44864492

44874493
if (!(TSFlags & (SIInstrFlags::IsAtomicNoRet | SIInstrFlags::IsAtomicRet)))

llvm/test/MC/AMDGPU/gfx90a_asm_features.s

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,3 +1024,78 @@ global_atomic_add_f32 v1, v0, v2, s[0:1] glc ; encoding: [0x00,0x80,0x35,0xdd,0x
10241024
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
10251025
// GFX90A: global_atomic_pk_add_f16 v0, v[0:1], v2, off glc ; encoding: [0x00,0x80,0x39,0xdd,0x00,0x02,0x7f,0x00]
10261026
global_atomic_pk_add_f16 v0, v[0:1], v2, off glc
1027+
1028+
// GFX908: :[[@LINE+3]]:{{[0-9]+}}: error: scc modifier is not supported on this GPU
1029+
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1030+
// GFX90A: global_atomic_add_f32 v0, v[0:1], v2, off glc scc
1031+
global_atomic_add_f32 v0, v[0:1], v2, off glc scc
1032+
1033+
// GFX908: :[[@LINE+3]]:{{[0-9]+}}: error: scc modifier is not supported on this GPU
1034+
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1035+
// GFX90A: global_atomic_add_f32 v[0:1], v2, off scc
1036+
global_atomic_add_f32 v[0:1], v2, off scc
1037+
1038+
// GFX908: :[[@LINE+3]]:{{[0-9]+}}: error: scc modifier is not supported on this GPU
1039+
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1040+
// GFX90A: global_atomic_add_f32 v0, v2, s[0:1] scc
1041+
global_atomic_add_f32 v0, v2, s[0:1] scc
1042+
1043+
// GFX908: :[[@LINE+3]]:{{[0-9]+}}: error: scc modifier is not supported on this GPU
1044+
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1045+
// GFX90A: global_atomic_add_f32 v1, v0, v2, s[0:1] glc scc
1046+
global_atomic_add_f32 v1, v0, v2, s[0:1] glc scc
1047+
1048+
// GFX908: :[[@LINE+3]]:{{[0-9]+}}: error: scc modifier is not supported on this GPU
1049+
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1050+
// GFX90A: global_atomic_pk_add_f16 v0, v[0:1], v2, off glc scc
1051+
global_atomic_pk_add_f16 v0, v[0:1], v2, off glc scc
1052+
1053+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1054+
// GFX90A: flat_atomic_add_f64 v[0:1], v[0:1], v[2:3] glc scc
1055+
flat_atomic_add_f64 v[0:1], v[0:1], v[2:3] glc scc
1056+
1057+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1058+
// GFX90A: flat_atomic_add_f64 v[0:1], v[2:3] scc
1059+
flat_atomic_add_f64 v[0:1], v[2:3] scc
1060+
1061+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1062+
// GFX90A: flat_atomic_min_f64 v[0:1], v[2:3] scc
1063+
flat_atomic_min_f64 v[0:1], v[2:3] scc
1064+
1065+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1066+
// GFX90A: flat_atomic_max_f64 v[0:1], v[2:3] scc
1067+
flat_atomic_max_f64 v[0:1], v[2:3] scc
1068+
1069+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1070+
// GFX90A: global_atomic_add_f64 v[0:1], v[2:3], off scc
1071+
global_atomic_add_f64 v[0:1], v[2:3], off scc
1072+
1073+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1074+
// GFX90A: global_atomic_min_f64 v[0:1], v[2:3], off scc
1075+
global_atomic_min_f64 v[0:1], v[2:3], off scc
1076+
1077+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1078+
// GFX90A: global_atomic_max_f64 v[0:1], v[2:3], off scc
1079+
global_atomic_max_f64 v[0:1], v[2:3], off scc
1080+
1081+
// GFX908: :[[@LINE+3]]:{{[0-9]+}}: error: scc modifier is not supported on this GPU
1082+
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1083+
// GFX90A: buffer_atomic_add_f32 v4, off, s[8:11], s3 scc
1084+
buffer_atomic_add_f32 v4, off, s[8:11], s3 scc
1085+
1086+
// GFX908: :[[@LINE+3]]:{{[0-9]+}}: error: scc modifier is not supported on this GPU
1087+
// GFX1010: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1088+
// GFX90A: buffer_atomic_pk_add_f16 v4, off, s[8:11], s3 scc
1089+
buffer_atomic_pk_add_f16 v4, off, s[8:11], s3 scc
1090+
1091+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1092+
// GFX90A: buffer_atomic_add_f64 v[4:5], off, s[8:11], s3 scc
1093+
buffer_atomic_add_f64 v[4:5], off, s[8:11], s3 scc
1094+
1095+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1096+
// GFX90A: buffer_atomic_max_f64 v[4:5], off, s[8:11], s3 scc
1097+
buffer_atomic_max_f64 v[4:5], off, s[8:11], s3 scc
1098+
1099+
// NOT-GFX90A: :[[@LINE+2]]:{{[0-9]+}}: error: instruction not supported on this GPU
1100+
// GFX90A: buffer_atomic_min_f64 v[4:5], off, s[8:11], s3 scc
1101+
buffer_atomic_min_f64 v[4:5], off, s[8:11], s3 scc

llvm/test/MC/AMDGPU/gfx90a_err.s

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -195,57 +195,6 @@ image_sample_cd v[0:3], v[0:1], s[4:11], s[16:19] dmask:0xf
195195
image_sample_b v[0:3], v[0:1], s[4:11], s[16:19] dmask:0xf
196196
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
197197

198-
global_atomic_add_f32 v0, v[0:1], v2, off glc scc
199-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
200-
201-
global_atomic_add_f32 v[0:1], v2, off scc
202-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
203-
204-
global_atomic_add_f32 v0, v2, s[0:1] scc
205-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
206-
207-
global_atomic_add_f32 v1, v0, v2, s[0:1] glc scc
208-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
209-
210-
global_atomic_pk_add_f16 v0, v[0:1], v2, off glc scc
211-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
212-
213-
flat_atomic_add_f64 v[0:1], v[0:1], v[2:3] glc scc
214-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
215-
216-
flat_atomic_add_f64 v[0:1], v[2:3] scc
217-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
218-
219-
flat_atomic_min_f64 v[0:1], v[2:3] scc
220-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
221-
222-
flat_atomic_max_f64 v[0:1], v[2:3] scc
223-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
224-
225-
global_atomic_add_f64 v[0:1], v[2:3], off scc
226-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
227-
228-
global_atomic_min_f64 v[0:1], v[2:3], off scc
229-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
230-
231-
global_atomic_max_f64 v[0:1], v[2:3], off scc
232-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
233-
234-
buffer_atomic_add_f32 v4, off, s[8:11], s3 scc
235-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
236-
237-
buffer_atomic_pk_add_f16 v4, off, s[8:11], s3 scc
238-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
239-
240-
buffer_atomic_add_f64 v[4:5], off, s[8:11], s3 scc
241-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
242-
243-
buffer_atomic_max_f64 v[4:5], off, s[8:11], s3 scc
244-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
245-
246-
buffer_atomic_min_f64 v[4:5], off, s[8:11], s3 scc
247-
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: scc is not supported on this GPU
248-
249198
v_mov_b32_sdwa v1, src_lds_direct dst_sel:DWORD
250199
// GFX90A: :[[@LINE-1]]:{{[0-9]+}}: error: lds_direct is not supported on this GPU
251200

0 commit comments

Comments
 (0)