[llvm] r245469 - [AArch64] Improve short-form diags on long-form Match_InvalidOperand.

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 10:40:19 PDT 2015


Author: ab
Date: Wed Aug 19 12:40:19 2015
New Revision: 245469

URL: http://llvm.org/viewvc/llvm-project?rev=245469&view=rev
Log:
[AArch64] Improve short-form diags on long-form Match_InvalidOperand.

Since r244955, we try to use the short-form ErrorInfo when both
tries failed, and the long-form match failed on a suffix operand.
However, this means we sometimes mix ErrorInfo and MatchResult
(one manifestation of this being PR24498). Instead, restore both.

Modified:
    llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/trunk/test/MC/AArch64/noneon-diagnostics.s

Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=245469&r1=245468&r2=245469&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Wed Aug 19 12:40:19 2015
@@ -3929,12 +3929,27 @@ bool AArch64AsmParser::MatchAndEmitInstr
 
   // If that fails, try against the alternate table containing long-form NEON:
   // "fadd v0.2s, v1.2s, v2.2s"
-  // But first, save the ErrorInfo: we can use it in case this try also fails.
-  uint64_t ShortFormNEONErrorInfo = ErrorInfo;
-  if (MatchResult != Match_Success)
+  if (MatchResult != Match_Success) {
+    // But first, save the short-form match result: we can use it in case the
+    // long-form match also fails.
+    auto ShortFormNEONErrorInfo = ErrorInfo;
+    auto ShortFormNEONMatchResult = MatchResult;
+
     MatchResult =
         MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm, 0);
 
+    // Now, both matches failed, and the long-form match failed on the mnemonic
+    // suffix token operand.  The short-form match failure is probably more
+    // relevant: use it instead.
+    if (MatchResult == Match_InvalidOperand && ErrorInfo == 1 &&
+        ((AArch64Operand &)*Operands[1]).isToken() &&
+        ((AArch64Operand &)*Operands[1]).isTokenSuffix()) {
+      MatchResult = ShortFormNEONMatchResult;
+      ErrorInfo = ShortFormNEONErrorInfo;
+    }
+  }
+
+
   switch (MatchResult) {
   case Match_Success: {
     // Perform range checking and other semantic validations
@@ -3969,13 +3984,6 @@ bool AArch64AsmParser::MatchAndEmitInstr
   case Match_InvalidOperand: {
     SMLoc ErrorLoc = IDLoc;
 
-    // If the long-form match failed on the mnemonic suffix token operand,
-    // the short-form match failure is probably more relevant: use it instead.
-    if (ErrorInfo == 1 &&
-        ((AArch64Operand &)*Operands[1]).isToken() &&
-        ((AArch64Operand &)*Operands[1]).isTokenSuffix())
-      ErrorInfo = ShortFormNEONErrorInfo;
-
     if (ErrorInfo != ~0ULL) {
       if (ErrorInfo >= Operands.size())
         return Error(IDLoc, "too few operands for instruction");

Modified: llvm/trunk/test/MC/AArch64/noneon-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/noneon-diagnostics.s?rev=245469&r1=245468&r2=245469&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/noneon-diagnostics.s (original)
+++ llvm/trunk/test/MC/AArch64/noneon-diagnostics.s Wed Aug 19 12:40:19 2015
@@ -27,3 +27,18 @@
 // CHECK-ERROR-NEXT: error: instruction requires: neon
 // CHECK-ERROR-NEXT:    fmls v9.2s, v9.2s, v0.2s
 // CHECK-ERROR-NEXT:    ^
+
+
+        fmls.4s v3, v12, v17
+        fmls.2d v1, v30, v20
+        fmls.2s v9, v9, v0
+
+// CHECK-ERROR: error: instruction requires: neon
+// CHECK-ERROR-NEXT:    fmls.4s v3, v12, v17
+// CHECK-ERROR-NEXT:    ^
+// CHECK-ERROR-NEXT: error: instruction requires: neon
+// CHECK-ERROR-NEXT:    fmls.2d v1, v30, v20
+// CHECK-ERROR-NEXT:    ^
+// CHECK-ERROR-NEXT: error: instruction requires: neon
+// CHECK-ERROR-NEXT:    fmls.2s v9, v9, v0
+// CHECK-ERROR-NEXT:    ^




More information about the llvm-commits mailing list