summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.cpp19
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.h3
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIParser.cpp25
3 files changed, 18 insertions, 29 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index 64531b281de..da05c9a2278 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -179,23 +179,6 @@ static Cursor lexName(Cursor C, MIToken &Token, MIToken::TokenKind Type,
return C;
}
-static Cursor maybeLexIntegerOrScalarType(Cursor C, MIToken &Token) {
- if ((C.peek() != 'i' && C.peek() != 's' && C.peek() != 'p') ||
- !isdigit(C.peek(1)))
- return None;
- char Kind = C.peek();
- auto Range = C;
- C.advance(); // Skip 'i', 's', or 'p'
- while (isdigit(C.peek()))
- C.advance();
-
- Token.reset(Kind == 'i'
- ? MIToken::IntegerType
- : (Kind == 's' ? MIToken::ScalarType : MIToken::PointerType),
- Range.upto(C));
- return C;
-}
-
static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
return StringSwitch<MIToken::TokenKind>(Identifier)
.Case("_", MIToken::underscore)
@@ -650,8 +633,6 @@ StringRef llvm::lexMIToken(StringRef Source, MIToken &Token,
return C.remaining();
}
- if (Cursor R = maybeLexIntegerOrScalarType(C, Token))
- return R.remaining();
if (Cursor R = maybeLexMachineBasicBlock(C, Token, ErrorCallback))
return R.remaining();
if (Cursor R = maybeLexIdentifier(C, Token))
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h
index 0f89adcf70b..e21c71532f7 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.h
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.h
@@ -123,13 +123,10 @@ struct MIToken {
// Identifier tokens
Identifier,
- IntegerType,
NamedRegister,
NamedVirtualRegister,
MachineBasicBlockLabel,
MachineBasicBlock,
- PointerType,
- ScalarType,
StackObject,
FixedStackObject,
NamedGlobalValue,
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 59cd623d556..3cc42582e4d 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1303,11 +1303,17 @@ bool MIParser::parseIRConstant(StringRef::iterator Loc, const Constant *&C) {
}
bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {
- if (Token.is(MIToken::ScalarType)) {
+ if (Token.range().front() == 's' || Token.range().front() == 'p')
+ if (!llvm::all_of(Token.range().drop_front(), isdigit))
+ return error("Expected integers after 's'/'p' type character");
+ if (!llvm::all_of(Token.range().drop_front(), isdigit))
+ return error("Expected integers after 's'/'p' type character");
+
+ if (Token.range().front() == 's') {
Ty = LLT::scalar(APSInt(Token.range().drop_front()).getZExtValue());
lex();
return false;
- } else if (Token.is(MIToken::PointerType)) {
+ } else if (Token.range().front() == 'p') {
const DataLayout &DL = MF.getDataLayout();
unsigned AS = APSInt(Token.range().drop_front()).getZExtValue();
Ty = LLT::pointer(AS, DL.getPointerSizeInBits(AS));
@@ -1331,8 +1337,10 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {
return error(Loc, "expected '<N x sM>' for vector type");
lex();
- if (Token.isNot(MIToken::ScalarType))
+ if (Token.range().front() != 's')
return error(Loc, "expected '<N x sM>' for vector type");
+ if (!llvm::all_of(Token.range().drop_front(), isdigit))
+ return error("Expected integers after 's' type character");
uint64_t ScalarSize = APSInt(Token.range().drop_front()).getZExtValue();
lex();
@@ -1345,7 +1353,10 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {
}
bool MIParser::parseTypedImmediateOperand(MachineOperand &Dest) {
- assert(Token.is(MIToken::IntegerType));
+ assert(Token.is(MIToken::Identifier));
+ if (!llvm::all_of(Token.range().drop_front(), isdigit))
+ return error("Expected integers after 'i'/'s'/'p' type character");
+
auto Loc = Token.location();
lex();
if (Token.isNot(MIToken::IntegerLiteral))
@@ -2004,8 +2015,6 @@ bool MIParser::parseMachineOperand(MachineOperand &Dest,
return parseRegisterOperand(Dest, TiedDefIdx);
case MIToken::IntegerLiteral:
return parseImmediateOperand(Dest);
- case MIToken::IntegerType:
- return parseTypedImmediateOperand(Dest);
case MIToken::kw_half:
case MIToken::kw_float:
case MIToken::kw_double:
@@ -2066,8 +2075,10 @@ bool MIParser::parseMachineOperand(MachineOperand &Dest,
Dest = MachineOperand::CreateRegMask(RegMask);
lex();
break;
- } else
+ } else if (Token.stringValue() == "CustomRegMask") {
return parseCustomRegisterMaskOperand(Dest);
+ } else
+ return parseTypedImmediateOperand(Dest);
default:
// FIXME: Parse the MCSymbol machine operand.
return error("expected a machine operand");
OpenPOWER on IntegriCloud