summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRParser/MILexer.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-07-21 16:59:53 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-07-21 16:59:53 +0000
commit6ede37442d263084bc48d6a8e9c9c728c44f583b (patch)
tree5a24007d18fac4edfedb8edb01f23b2ce895fb47 /llvm/lib/CodeGen/MIRParser/MILexer.cpp
parent74ce2e76919bc17ff32c4ba941080732800c35fa (diff)
downloadbcm5719-llvm-6ede37442d263084bc48d6a8e9c9c728c44f583b.tar.gz
bcm5719-llvm-6ede37442d263084bc48d6a8e9c9c728c44f583b.zip
MIR Serialization: Serialize the external symbol machine operands.
Reviewers: Duncan P. N. Exon Smith llvm-svn: 242806
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser/MILexer.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MILexer.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index ee4d59ddcaa..2a1caab5794 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -271,6 +271,36 @@ static Cursor maybeLexGlobalValue(
return C;
}
+static Cursor lexName(
+ Cursor C, MIToken &Token, MIToken::TokenKind Type,
+ MIToken::TokenKind QuotedType, unsigned PrefixLength,
+ function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
+ auto Range = C;
+ C.advance(PrefixLength);
+ if (C.peek() == '"') {
+ if (Cursor R = lexStringConstant(C, ErrorCallback)) {
+ Token = MIToken(QuotedType, Range.upto(R), PrefixLength);
+ return R;
+ }
+ Token = MIToken(MIToken::Error, Range.remaining());
+ return Range;
+ }
+ while (isIdentifierChar(C.peek()))
+ C.advance();
+ Token = MIToken(Type, Range.upto(C), PrefixLength);
+ return C;
+}
+
+static Cursor maybeLexExternalSymbol(
+ Cursor C, MIToken &Token,
+ function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
+ if (C.peek() != '$')
+ return None;
+ return lexName(C, Token, MIToken::ExternalSymbol,
+ MIToken::QuotedExternalSymbol,
+ /*PrefixLength=*/1, ErrorCallback);
+}
+
static Cursor maybeLexIntegerLiteral(Cursor C, MIToken &Token) {
if (!isdigit(C.peek()) && (C.peek() != '-' || !isdigit(C.peek(1))))
return None;
@@ -331,6 +361,8 @@ StringRef llvm::lexMIToken(
return R.remaining();
if (Cursor R = maybeLexGlobalValue(C, Token, ErrorCallback))
return R.remaining();
+ if (Cursor R = maybeLexExternalSymbol(C, Token, ErrorCallback))
+ return R.remaining();
if (Cursor R = maybeLexIntegerLiteral(C, Token))
return R.remaining();
if (Cursor R = maybeLexSymbol(C, Token))
OpenPOWER on IntegriCloud