[PATCH] D92085: [AMDGPU][MC][GFX10] Improved diagnistic message for image instructions w/o DIM modifier

Dmitry Preobrazhensky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 02:48:23 PST 2020


dp created this revision.
dp added a reviewer: rampitec.
Herald added subscribers: llvm-commits, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.
dp requested review of this revision.
Herald added a subscriber: wdng.

See bug 48241 <https://bugs.llvm.org/show_bug.cgi?id=48241>


https://reviews.llvm.org/D92085

Files:
  llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
  llvm/test/MC/AMDGPU/gfx10_asm_mimg_err.s
  llvm/test/MC/AMDGPU/gfx10_err_pos.s


Index: llvm/test/MC/AMDGPU/gfx10_err_pos.s
===================================================================
--- llvm/test/MC/AMDGPU/gfx10_err_pos.s
+++ llvm/test/MC/AMDGPU/gfx10_err_pos.s
@@ -759,6 +759,14 @@
 // CHECK-NEXT:{{^}}s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP, 0)
 // CHECK-NEXT:{{^}}                                          ^
 
+//==============================================================================
+// missing dim modifier
+
+image_load v[0:3], v0, s[0:7] dmask:0xf unorm
+// CHECK: error: missing dim modifier
+// CHECK-NEXT:{{^}}image_load v[0:3], v0, s[0:7] dmask:0xf unorm
+// CHECK-NEXT:{{^}}^
+
 //==============================================================================
 // missing message operation
 
Index: llvm/test/MC/AMDGPU/gfx10_asm_mimg_err.s
===================================================================
--- llvm/test/MC/AMDGPU/gfx10_asm_mimg_err.s
+++ llvm/test/MC/AMDGPU/gfx10_asm_mimg_err.s
@@ -1,8 +1,7 @@
 // RUN: not llvm-mc -arch=amdgcn -mcpu=gfx1010 %s 2>&1 | FileCheck --check-prefixes=NOGFX10 --implicit-check-not=error: %s
 
-// TODO: more helpful error message for missing dim operand
 image_load v[0:3], v0, s[0:7] dmask:0xf unorm
-// NOGFX10: :[[@LINE-1]]:{{[0-9]+}}: error: operands are not valid for this GPU or mode
+// NOGFX10: :[[@LINE-1]]:{{[0-9]+}}: error: missing dim modifier
 
 image_load v[0:3], v0, s[0:7] dmask:0xf dim:SQ_RSRC_IMG_1D da
 // NOGFX10: :[[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
Index: llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -4023,11 +4023,17 @@
 
   switch (Result) {
   default: break;
-  case Match_MissingFeature:
+  case Match_MissingFeature: {
     // It has been verified that the specified instruction
     // mnemonic is valid. A match was found but it requires
     // features which are not supported on this GPU.
+    bool IsMIMG = Mnemo.startswith("image_");
+    if (IsMIMG && isGFX10() &&
+        getImmLoc(AMDGPUOperand::ImmTyDim, Operands) == IDLoc) {
+      return Error(IDLoc, "missing dim modifier");
+    }
     return Error(IDLoc, "operands are not valid for this GPU or mode");
+  }
 
   case Match_InvalidOperand: {
     SMLoc ErrorLoc = IDLoc;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92085.307560.patch
Type: text/x-patch
Size: 2385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201125/60f15933/attachment.bin>


More information about the llvm-commits mailing list