[llvm] [AArch64][SVE]Add error message in the AsmParser for SVEPattern (PR #82668)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 10:15:37 PST 2024


https://github.com/CarolineConcatto created https://github.com/llvm/llvm-project/pull/82668

All assembly instructions that have an operand using sve_pred_enum and mistakenly use '#' in front of it would fail without an error message.

>From e7e98021e50ded7741d3b66b06a55a94e611b56d Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Thu, 22 Feb 2024 17:28:44 +0000
Subject: [PATCH] [AArch64][SVE]Add error message in the AsmParser for
 SVEPattern

All assembly instructions that have an operand using sve_pred_enum and
mistakenly use '#' in front of it would fail without an error message.
---
 llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 2 +-
 llvm/test/MC/AArch64/SVE/cntb-diagnostics.s            | 5 +++++
 llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s           | 5 +++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 9774b5491ef11c..9ac60b2cc4323f 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -7939,7 +7939,7 @@ ParseStatus AArch64AsmParser::tryParseSVEPattern(OperandVector &Operands) {
 
     auto *MCE = dyn_cast<MCConstantExpr>(ImmVal);
     if (!MCE)
-      return ParseStatus::Failure;
+      return TokError("expected immediate operand");
 
     Pattern = MCE->getValue();
   } else {
diff --git a/llvm/test/MC/AArch64/SVE/cntb-diagnostics.s b/llvm/test/MC/AArch64/SVE/cntb-diagnostics.s
index 90ec58809fdd9a..53f80330af7123 100644
--- a/llvm/test/MC/AArch64/SVE/cntb-diagnostics.s
+++ b/llvm/test/MC/AArch64/SVE/cntb-diagnostics.s
@@ -55,3 +55,8 @@ cntb  x0, vl512
 // CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
 // CHECK-NEXT: cntb  x0, vl512
 // CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+cntb  x0, #all, mul #1
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: expected immediate operand
+// CHECK-NEXT: cntb  x0, #all, mul #1
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
diff --git a/llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s b/llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s
index 51001265acbc71..c9e259c31d7870 100644
--- a/llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s
+++ b/llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s
@@ -27,3 +27,8 @@ ptrue p0.s, #32
 // CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid predicate pattern
 // CHECK-NEXT: ptrue p0.s, #32
 // CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:
+
+ptrue p0.s, #all
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: expected immediate operand
+// CHECK-NEXT: ptrue p0.s, #all
+// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:$



More information about the llvm-commits mailing list