[PATCH] D92805: [RISCV] Detect more errors when parsing vsetvli in the assembler

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 8 11:27:30 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb5b611af917: [RISCV] Detect more errors when parsing vsetvli in the assembler (authored by craig.topper).
Herald added a subscriber: jrtc27.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92805/new/

https://reviews.llvm.org/D92805

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
@@ -37,6 +37,15 @@
 vsetvli a2, a0, e8,m1z,tu,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 a2, a0, e8,mf1,tu,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 a2, a0, e8,m1,tu,mut
+# 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 a2, a0, e8,m1,tut,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
@@ -1622,6 +1622,8 @@
     return MatchOperand_NoMatch;
   if (Lmul != 1 && Lmul != 2 && Lmul != 4 && Lmul != 8)
     return MatchOperand_NoMatch;
+  if (Fractional && Lmul == 1)
+    return MatchOperand_NoMatch;
   getLexer().Lex();
 
   if (!getLexer().is(AsmToken::Comma))
@@ -1631,9 +1633,9 @@
   Name = getLexer().getTok().getIdentifier();
   // ta or tu
   bool TailAgnostic;
-  if (Name.consume_front("ta"))
+  if (Name == "ta")
     TailAgnostic = true;
-  else if (Name.consume_front("tu"))
+  else if (Name == "tu")
     TailAgnostic = false;
   else
     return MatchOperand_NoMatch;
@@ -1646,9 +1648,9 @@
   Name = getLexer().getTok().getIdentifier();
   // ma or mu
   bool MaskedoffAgnostic;
-  if (Name.consume_front("ma"))
+  if (Name == "ma")
     MaskedoffAgnostic = true;
-  else if (Name.consume_front("mu"))
+  else if (Name == "mu")
     MaskedoffAgnostic = false;
   else
     return MatchOperand_NoMatch;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92805.310298.patch
Type: text/x-patch
Size: 1955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201208/4ba605c3/attachment.bin>


More information about the llvm-commits mailing list