mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 06:25:18 +00:00
MIR Serialization: Serialize immediate machine operands.
Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10573 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240481 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
bool isEOF() const { return Ptr == End; }
|
||||
|
||||
char peek() const { return isEOF() ? 0 : *Ptr; }
|
||||
char peek(unsigned I = 0) const { return End - Ptr <= I ? 0 : Ptr[I]; }
|
||||
|
||||
void advance() { ++Ptr; }
|
||||
|
||||
@@ -77,6 +77,16 @@ static Cursor lexPercent(Cursor C, MIToken &Token) {
|
||||
return C;
|
||||
}
|
||||
|
||||
static Cursor lexIntegerLiteral(Cursor C, MIToken &Token) {
|
||||
auto Range = C;
|
||||
C.advance();
|
||||
while (isdigit(C.peek()))
|
||||
C.advance();
|
||||
StringRef StrVal = Range.upto(C);
|
||||
Token = MIToken(MIToken::IntegerLiteral, StrVal, APSInt(StrVal));
|
||||
return C;
|
||||
}
|
||||
|
||||
static MIToken::TokenKind symbolToken(char C) {
|
||||
switch (C) {
|
||||
case ',':
|
||||
@@ -109,6 +119,8 @@ StringRef llvm::lexMIToken(
|
||||
return lexIdentifier(C, Token).remaining();
|
||||
if (Char == '%')
|
||||
return lexPercent(C, Token).remaining();
|
||||
if (isdigit(Char) || (Char == '-' && isdigit(C.peek(1))))
|
||||
return lexIntegerLiteral(C, Token).remaining();
|
||||
MIToken::TokenKind Kind = symbolToken(Char);
|
||||
if (Kind != MIToken::Error)
|
||||
return lexSymbol(C, Kind, Token).remaining();
|
||||
|
Reference in New Issue
Block a user