]> granicus.if.org Git - llvm/commitdiff
[AMDGPU][MC] Corrected error message for s_waitcnt helpers
authorDmitry Preobrazhensky <dmitry.preobrazhensky@amd.com>
Wed, 7 Jun 2017 16:08:02 +0000 (16:08 +0000)
committerDmitry Preobrazhensky <dmitry.preobrazhensky@amd.com>
Wed, 7 Jun 2017 16:08:02 +0000 (16:08 +0000)
See Bug 32711: https://bugs.llvm.org//show_bug.cgi?id=32711

Reviewers: artem.tamazov

Differential Revision: https://reviews.llvm.org/D33781

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304922 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
test/MC/AMDGPU/sopp-err.s

index cd4a98acf340a49bc350bbd59794c5fb4f7bc12b..16e3b7b4ebee5b3c815ae02e839269307261d12e 100644 (file)
@@ -2849,6 +2849,7 @@ bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
   if (getLexer().isNot(AsmToken::Integer))
     return true;
 
+  SMLoc ValLoc = Parser.getTok().getLoc();
   if (getParser().parseAbsoluteExpression(CntVal))
     return true;
 
@@ -2866,21 +2867,24 @@ bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
     Failed = encodeCnt(ISA, IntVal, CntVal, Sat, encodeLgkmcnt, decodeLgkmcnt);
   }
 
-  // To improve diagnostics, do not skip delimiters on errors
-  if (!Failed) {
-    if (getLexer().isNot(AsmToken::RParen)) {
-      return true;
-    }
-    Parser.Lex();
-    if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma)) {
-      const AsmToken NextToken = getLexer().peekTok();
-      if (NextToken.is(AsmToken::Identifier)) {
-        Parser.Lex();
-      }
+  if (Failed) {
+    Error(ValLoc, "too large value for " + CntName);
+    return true;
+  }
+
+  if (getLexer().isNot(AsmToken::RParen)) {
+    return true;
+  }
+
+  Parser.Lex();
+  if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma)) {
+    const AsmToken NextToken = getLexer().peekTok();
+    if (NextToken.is(AsmToken::Identifier)) {
+      Parser.Lex();
     }
   }
 
-  return Failed;
+  return false;
 }
 
 OperandMatchResultTy
index fac0d322290924c9ab56984484b14c0008b09ddd..d65e54344031b46c9ef398a339c3d8777ab8c3d2 100644 (file)
@@ -75,16 +75,16 @@ s_sendmsg sendmsg(MSG_SYSMSG, 5)
 // GCN: error: invalid/unsupported code of SYSMSG_OP
 
 s_waitcnt lgkmcnt(16)
-// GCN: error: failed parsing operand
+// GCN: error: too large value for lgkmcnt
 
 s_waitcnt expcnt(8)
-// GCN: error: failed parsing operand
+// GCN: error: too large value for expcnt
 
 s_waitcnt vmcnt(16)
-// GCN: error: failed parsing operand
+// GCN: error: too large value for vmcnt
 
 s_waitcnt vmcnt(0xFFFFFFFFFFFF0000)
-// GCN: error: failed parsing operand
+// GCN: error: too large value for vmcnt
 
 s_waitcnt vmcnt(0), expcnt(0), lgkmcnt(0),
 // GCN: error: failed parsing operand