mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-15 03:26:05 +00:00
MIR Serialization: Serialize the external symbol machine operands.
Reviewers: Duncan P. N. Exon Smith git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242806 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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))
|
||||
|
Reference in New Issue
Block a user