[llvm] [AArch64][SVE]Add error message in the AsmParser for SVEPattern (PR #82668)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 01:52:27 PST 2024
https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/82668
>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 1/2] [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]+}}:$
>From 44f3c18b650dc18ec55197f9719f7a76d9e9b129 Mon Sep 17 00:00:00 2001
From: Caroline Concatto <caroline.concatto at arm.com>
Date: Fri, 23 Feb 2024 09:15:22 +0000
Subject: [PATCH 2/2] Change error message to be same as typos in predicate
patterns
---
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 2 +-
llvm/test/MC/AArch64/SVE/cntb-diagnostics.s | 2 +-
llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 9ac60b2cc4323f..b807aaf76fdb00 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 TokError("expected immediate operand");
+ return TokError("invalid operand for instruction");
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 53f80330af7123..d338deb636eaab 100644
--- a/llvm/test/MC/AArch64/SVE/cntb-diagnostics.s
+++ b/llvm/test/MC/AArch64/SVE/cntb-diagnostics.s
@@ -57,6 +57,6 @@ cntb x0, vl512
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
cntb x0, #all, mul #1
-// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: expected immediate operand
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
// 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 c9e259c31d7870..02a94b23661e62 100644
--- a/llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s
+++ b/llvm/test/MC/AArch64/SVE/ptrue-diagnostics.s
@@ -29,6 +29,6 @@ ptrue p0.s, #32
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:
ptrue p0.s, #all
-// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: expected immediate operand
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
// CHECK-NEXT: ptrue p0.s, #all
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:$
More information about the llvm-commits
mailing list