[PATCH] D124161: [RISCV][AsmParser] Fix parsing of the components of the vtype immediate of vsetvli
Roger Ferrer Ibanez via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 05:32:39 PDT 2022
rogfer01 created this revision.
rogfer01 added reviewers: StephenFan, craig.topper.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
rogfer01 requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.
This was discovered due to a typo in an assembly file when using an assertion-enabled build.
We are getting the tokens as "identifiers". This triggers an assertion failure when the token is not a proper identifier (e.g an integer literal) and also has the side-effect that we were accepting quoted syntax.
https://reviews.llvm.org/D124161
Files:
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/rvv/invalid.s
Index: llvm/test/MC/RISCV/rvv/invalid.s
===================================================================
--- llvm/test/MC/RISCV/rvv/invalid.s
+++ llvm/test/MC/RISCV/rvv/invalid.s
@@ -77,6 +77,24 @@
vsetvli a2, a0, e8,m1,ta
# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+vsetvli zero, zero, 1, m1, ta, mu
+# CHECK-ERROR: error: invalid operand for instruction
+
+vsetvli zero, zero, e32, 2, ta, mu
+# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
+vsetvli zero, zero, e32, m1, 3, mu
+# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
+vsetvli zero, zero, e32, m1, ta, 4
+# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
+vsetvli zero, zero, "e32", m1, ta, mu
+# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
+vsetvli zero, zero, e32, "m1", ta, mu
+# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
vadd.vv v1, v3, v2, v4.t
# CHECK-ERROR: operand must be v0.t
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===================================================================
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1736,7 +1736,7 @@
// The VTypeIElements layout is:
// SEW comma LMUL comma TA comma MA
// 0 1 2 3 4 5 6
- StringRef Name = VTypeIElements[0].getIdentifier();
+ StringRef Name = VTypeIElements[0].getString();
if (!Name.consume_front("e"))
goto MatchFail;
unsigned Sew;
@@ -1745,7 +1745,7 @@
if (!RISCVVType::isValidSEW(Sew))
goto MatchFail;
- Name = VTypeIElements[2].getIdentifier();
+ Name = VTypeIElements[2].getString();
if (!Name.consume_front("m"))
goto MatchFail;
// "m" or "mf"
@@ -1757,7 +1757,7 @@
goto MatchFail;
// ta or tu
- Name = VTypeIElements[4].getIdentifier();
+ Name = VTypeIElements[4].getString();
bool TailAgnostic;
if (Name == "ta")
TailAgnostic = true;
@@ -1767,7 +1767,7 @@
goto MatchFail;
// ma or mu
- Name = VTypeIElements[6].getIdentifier();
+ Name = VTypeIElements[6].getString();
bool MaskAgnostic;
if (Name == "ma")
MaskAgnostic = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124161.424162.patch
Type: text/x-patch
Size: 2453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220421/9074a794/attachment-0001.bin>
More information about the llvm-commits
mailing list