MIR Serialization: Serialize the jump table index operands.

Reviewers: Duncan P. N. Exon Smith


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242358 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alex Lorenz
2015-07-15 23:38:35 +00:00
parent 81bef8c7a7
commit a2e819fb09
8 changed files with 233 additions and 6 deletions

View File

@@ -115,6 +115,23 @@ static Cursor maybeLexMachineBasicBlock(
return C;
}
static Cursor maybeLexIndex(Cursor C, MIToken &Token, StringRef Rule,
MIToken::TokenKind Kind) {
if (!C.remaining().startswith(Rule) || !isdigit(C.peek(Rule.size())))
return None;
auto Range = C;
C.advance(Rule.size());
auto NumberRange = C;
while (isdigit(C.peek()))
C.advance();
Token = MIToken(Kind, Range.upto(C), APSInt(NumberRange.upto(C)));
return C;
}
static Cursor maybeLexJumpTableIndex(Cursor C, MIToken &Token) {
return maybeLexIndex(C, Token, "%jump-table.", MIToken::JumpTableIndex);
}
static Cursor lexVirtualRegister(Cursor C, MIToken &Token) {
auto Range = C;
C.advance(); // Skip '%'
@@ -209,6 +226,8 @@ StringRef llvm::lexMIToken(
return R.remaining();
if (Cursor R = maybeLexMachineBasicBlock(C, Token, ErrorCallback))
return R.remaining();
if (Cursor R = maybeLexJumpTableIndex(C, Token))
return R.remaining();
if (Cursor R = maybeLexRegister(C, Token))
return R.remaining();
if (Cursor R = maybeLexGlobalValue(C, Token))