@@ -1946,24 +1946,41 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {
1946
1946
1947
1947
// Now we're looking for a vector.
1948
1948
if (Token.isNot (MIToken::less))
1949
- return error (Loc,
1950
- " expected sN, pA, <M x sN>, or <M x pA> for GlobalISel type" );
1949
+ return error (Loc, " expected sN, pA, <M x sN>, <M x pA>, <vscale x M x sN>, "
1950
+ " or <vscale x M x pA> for GlobalISel type" );
1951
1951
lex ();
1952
1952
1953
+ bool HasVScale = Token.stringValue () == " vscale" ;
1954
+ if (HasVScale) {
1955
+ lex ();
1956
+ if (Token.stringValue () != " x" )
1957
+ return error (" expected <vscale x M x sN> or <vscale x M x pA>" );
1958
+ lex ();
1959
+ }
1960
+
1961
+ auto GetError = [&](bool HasVScale, StringRef::iterator Loc) {
1962
+ if (HasVScale)
1963
+ return error (
1964
+ Loc, " expected <vscale x M x sN> or <vscale M x pA> for vector type" );
1965
+ else
1966
+ return error (Loc, " expected <M x sN> or <M x pA> for vector type" );
1967
+ };
1968
+
1953
1969
if (Token.isNot (MIToken::IntegerLiteral))
1954
- return error (Loc, " expected <M x sN> or <M x pA> for vector type " );
1970
+ return GetError (HasVScale, Loc );
1955
1971
uint64_t NumElements = Token.integerValue ().getZExtValue ();
1956
1972
if (!verifyVectorElementCount (NumElements))
1957
1973
return error (" invalid number of vector elements" );
1958
1974
1959
1975
lex ();
1960
1976
1961
1977
if (Token.isNot (MIToken::Identifier) || Token.stringValue () != " x" )
1962
- return error (Loc, " expected <M x sN> or <M x pA> for vector type " );
1978
+ return GetError (HasVScale, Loc );
1963
1979
lex ();
1964
1980
1965
1981
if (Token.range ().front () != ' s' && Token.range ().front () != ' p' )
1966
- return error (Loc, " expected <M x sN> or <M x pA> for vector type" );
1982
+ return GetError (HasVScale, Loc);
1983
+
1967
1984
StringRef SizeStr = Token.range ().drop_front ();
1968
1985
if (SizeStr.size () == 0 || !llvm::all_of (SizeStr, isdigit))
1969
1986
return error (" expected integers after 's'/'p' type character" );
@@ -1981,14 +1998,18 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {
1981
1998
1982
1999
Ty = LLT::pointer (AS, DL.getPointerSizeInBits (AS));
1983
2000
} else
1984
- return error (Loc, " expected <M x sN> or <M x pA> for vector type " );
2001
+ return GetError (HasVScale, Loc );
1985
2002
lex ();
1986
2003
1987
2004
if (Token.isNot (MIToken::greater))
1988
- return error (Loc, " expected <M x sN> or <M x pA> for vector type" );
2005
+ return GetError (HasVScale, Loc);
2006
+
1989
2007
lex ();
1990
2008
1991
- Ty = LLT::fixed_vector (NumElements, Ty);
2009
+ if (HasVScale)
2010
+ Ty = LLT::scalable_vector (NumElements, Ty);
2011
+ else
2012
+ Ty = LLT::fixed_vector (NumElements, Ty);
1992
2013
return false ;
1993
2014
}
1994
2015
0 commit comments