[llvm] 168ccc8 - [AMDGPU][MC][GFX10] Improved errors reporting for invalid MIMG NSA operands
Dmitry Preobrazhensky via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 8 03:04:51 PST 2021
Author: Dmitry Preobrazhensky
Date: 2021-02-08T14:04:28+03:00
New Revision: 168ccc8ecb655614f6dd547e3e21a72d8e89416b
URL: https://github.com/llvm/llvm-project/commit/168ccc8ecb655614f6dd547e3e21a72d8e89416b
DIFF: https://github.com/llvm/llvm-project/commit/168ccc8ecb655614f6dd547e3e21a72d8e89416b.diff
LOG: [AMDGPU][MC][GFX10] Improved errors reporting for invalid MIMG NSA operands
Differential Revision: https://reviews.llvm.org/D96118
Added:
Modified:
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/test/MC/AMDGPU/gfx10_err_pos.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 3d9e322a57f5..9d14a57bc80e 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -4882,16 +4882,21 @@ AMDGPUAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic,
unsigned Prefix = Operands.size();
for (;;) {
+ auto Loc = getLoc();
ResTy = parseReg(Operands);
+ if (ResTy == MatchOperand_NoMatch)
+ Error(Loc, "expected a register");
if (ResTy != MatchOperand_Success)
- return ResTy;
+ return MatchOperand_ParseFail;
RBraceLoc = getLoc();
if (trySkipToken(AsmToken::RBrac))
break;
- if (!trySkipToken(AsmToken::Comma))
+ if (!skipToken(AsmToken::Comma,
+ "expected a comma or a closing square bracket")) {
return MatchOperand_ParseFail;
+ }
}
if (Operands.size() - Prefix > 1) {
diff --git a/llvm/test/MC/AMDGPU/gfx10_err_pos.s b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
index 7f4aba0a05e3..189010892769 100644
--- a/llvm/test/MC/AMDGPU/gfx10_err_pos.s
+++ b/llvm/test/MC/AMDGPU/gfx10_err_pos.s
@@ -295,6 +295,16 @@ s_mov_b64 s[10:11], [s0,s1
// CHECK-NEXT:{{^}}s_mov_b64 s[10:11], [s0,s1
// CHECK-NEXT:{{^}} ^
+image_load_mip v[253:255], [v255, v254 dmask:0xe dim:1D
+// CHECK: error: expected a comma or a closing square bracket
+// CHECK-NEXT:{{^}}image_load_mip v[253:255], [v255, v254 dmask:0xe dim:1D
+// CHECK-NEXT:{{^}} ^
+
+image_load_mip v[253:255], [v255, v254
+// CHECK: error: expected a comma or a closing square bracket
+// CHECK-NEXT:{{^}}image_load_mip v[253:255], [v255, v254
+// CHECK-NEXT:{{^}} ^
+
//==============================================================================
// expected a counter name
@@ -342,6 +352,19 @@ v_pk_add_u16 v1, v2, v3 op_sel:
// CHECK-NEXT:{{^}}v_pk_add_u16 v1, v2, v3 op_sel:
// CHECK-NEXT:{{^}} ^
+//==============================================================================
+// expected a register
+
+image_load v[0:3], [v4, v5, 6], s[8:15] dmask:0xf dim:3D unorm
+// CHECK: error: expected a register
+// CHECK-NEXT:{{^}}image_load v[0:3], [v4, v5, 6], s[8:15] dmask:0xf dim:3D unorm
+// CHECK-NEXT:{{^}} ^
+
+image_load v[0:3], [v4, v5, v], s[8:15] dmask:0xf dim:3D unorm
+// CHECK: error: expected a register
+// CHECK-NEXT:{{^}}image_load v[0:3], [v4, v5, v], s[8:15] dmask:0xf dim:3D unorm
+// CHECK-NEXT:{{^}} ^
+
//==============================================================================
// expected a register or a list of registers
More information about the llvm-commits
mailing list