Skip to content

Commit f0f8ae7

Browse files
committed
[AMDGPU][AsmParser] Fix matching immediate literals.
Prevents potential matching of literal offsets to non-literal operands. Reviewed By: dp Differential Revision: https://reviews.llvm.org/D142194
1 parent 68adc02 commit f0f8ae7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ class AMDGPUOperand : public MCParsedAsmOperand {
347347
return isImm() && Imm.Type == ImmT;
348348
}
349349

350+
bool isImmLiteral() const { return isImmTy(ImmTyNone); }
351+
350352
bool isImmModifier() const {
351353
return isImm() && Imm.Type != ImmTyNone;
352354
}
@@ -7940,7 +7942,7 @@ void AMDGPUAsmParser::cvtIntersectRay(MCInst &Inst,
79407942
//===----------------------------------------------------------------------===//
79417943

79427944
bool AMDGPUOperand::isSMRDOffset8() const {
7943-
return isImm() && isUInt<8>(getImm());
7945+
return isImmLiteral() && isUInt<8>(getImm());
79447946
}
79457947

79467948
bool AMDGPUOperand::isSMEMOffset() const {
@@ -7951,7 +7953,7 @@ bool AMDGPUOperand::isSMEMOffset() const {
79517953
bool AMDGPUOperand::isSMRDLiteralOffset() const {
79527954
// 32-bit literals are only supported on CI and we only want to use them
79537955
// when the offset is > 8-bits.
7954-
return isImm() && !isUInt<8>(getImm()) && isUInt<32>(getImm());
7956+
return isImmLiteral() && !isUInt<8>(getImm()) && isUInt<32>(getImm());
79557957
}
79567958

79577959
AMDGPUOperand::Ptr AMDGPUAsmParser::defaultSMRDOffset8() const {
@@ -8439,11 +8441,11 @@ bool AMDGPUOperand::isABID() const {
84398441
}
84408442

84418443
bool AMDGPUOperand::isS16Imm() const {
8442-
return isImm() && (isInt<16>(getImm()) || isUInt<16>(getImm()));
8444+
return isImmLiteral() && (isInt<16>(getImm()) || isUInt<16>(getImm()));
84438445
}
84448446

84458447
bool AMDGPUOperand::isU16Imm() const {
8446-
return isImm() && isUInt<16>(getImm());
8448+
return isImmLiteral() && isUInt<16>(getImm());
84478449
}
84488450

84498451
//===----------------------------------------------------------------------===//

llvm/test/MC/AMDGPU/gfx7_err_pos.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ v_and_b32_e64 v0, 0.159154943091895317852646485335, v1
3636
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: literal operands are not supported
3737
// CHECK-NEXT:{{^}}v_and_b32_e64 v0, 0.159154943091895317852646485335, v1
3838
// CHECK-NEXT:{{^}} ^
39+
40+
//==============================================================================
41+
// cache policy is not supported for SMRD instructions
42+
43+
s_load_dword s5, s[2:3], glc
44+
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: cache policy is not supported for SMRD instructions
45+
// CHECK-NEXT:{{^}}s_load_dword s5, s[2:3], glc
46+
// CHECK-NEXT:{{^}} ^

0 commit comments

Comments
 (0)