[llvm] [CodeGen][MIR] Support parsing of scalable vectors in MIR (PR #70893)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 16:25:04 PDT 2023


================
@@ -1946,24 +1946,42 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {
 
   // Now we're looking for a vector.
   if (Token.isNot(MIToken::less))
-    return error(Loc,
-                 "expected sN, pA, <M x sN>, or <M x pA> for GlobalISel type");
+    return error(Loc, "expected sN, pA, <M x sN>, <M x pA>, <vscale x M x sN>, "
+                      "or <vscale x M x pA> for GlobalISel type");
   lex();
 
+  bool HasVScale =
+      Token.is(MIToken::Identifier) && Token.stringValue() == "vscale";
+  if (HasVScale) {
+    lex();
+    if (Token.isNot(MIToken::Identifier) || Token.stringValue() != "x")
+      return error("expected <vscale x M x sN> or <vscale x M x pA>");
+    lex();
+  }
+
+  auto GetError = [this, &HasVScale, Loc]() {
----------------
topperc wrote:

If you capture `Loc` by value here, I don't think it update when `lex()` is called. So the location will be stale.

https://github.com/llvm/llvm-project/pull/70893


More information about the llvm-commits mailing list