summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRParser/MILexer.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-08-17 22:05:15 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-08-17 22:05:15 +0000
commita617c9162dcc23e1b974c7e30509ef4e303fce33 (patch)
tree8092334818f2afc9894269449bf4138bb0324e7e /llvm/lib/CodeGen/MIRParser/MILexer.cpp
parent05ddbffbf3eba8ef2cac067b0cf8e9c53b78855e (diff)
downloadbcm5719-llvm-a617c9162dcc23e1b974c7e30509ef4e303fce33.tar.gz
bcm5719-llvm-a617c9162dcc23e1b974c7e30509ef4e303fce33.zip
MIR Serialization: Serialize the memory operand's TBAA metadata node.
llvm-svn: 245244
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MILexer.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index f607edddecc..f4c9786d421 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -442,6 +442,33 @@ static Cursor maybeLexNumericalLiteral(Cursor C, MIToken &Token) {
return C;
}
+static MIToken::TokenKind getMetadataKeywordKind(StringRef Identifier) {
+ return StringSwitch<MIToken::TokenKind>(Identifier)
+ .Case("!tbaa", MIToken::md_tbaa)
+ .Default(MIToken::Error);
+}
+
+static Cursor maybeLexExlaim(
+ Cursor C, MIToken &Token,
+ function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
+ if (C.peek() != '!')
+ return None;
+ auto Range = C;
+ C.advance(1);
+ if (isdigit(C.peek()) || !isIdentifierChar(C.peek())) {
+ Token.reset(MIToken::exclaim, Range.upto(C));
+ return C;
+ }
+ while (isIdentifierChar(C.peek()))
+ C.advance();
+ StringRef StrVal = Range.upto(C);
+ Token.reset(getMetadataKeywordKind(StrVal), StrVal);
+ if (Token.isError())
+ ErrorCallback(Token.location(),
+ "use of unknown metadata keyword '" + StrVal + "'");
+ return C;
+}
+
static MIToken::TokenKind symbolToken(char C) {
switch (C) {
case ',':
@@ -450,8 +477,6 @@ static MIToken::TokenKind symbolToken(char C) {
return MIToken::equal;
case ':':
return MIToken::colon;
- case '!':
- return MIToken::exclaim;
case '(':
return MIToken::lparen;
case ')':
@@ -531,6 +556,8 @@ StringRef llvm::lexMIToken(
return R.remaining();
if (Cursor R = maybeLexNumericalLiteral(C, Token))
return R.remaining();
+ if (Cursor R = maybeLexExlaim(C, Token, ErrorCallback))
+ return R.remaining();
if (Cursor R = maybeLexSymbol(C, Token))
return R.remaining();
if (Cursor R = maybeLexNewline(C, Token))
OpenPOWER on IntegriCloud