MIR Serialization: Serialize the jump table index operands.
Reviewers: Duncan P. N. Exon Smith
llvm-svn: 242358
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index c000112..62a3fbe 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -88,6 +88,7 @@
bool parseMBBReference(MachineBasicBlock *&MBB);
bool parseMBBOperand(MachineOperand &Dest);
bool parseGlobalAddressOperand(MachineOperand &Dest);
+ bool parseJumpTableIndexOperand(MachineOperand &Dest);
bool parseMachineOperand(MachineOperand &Dest);
private:
@@ -468,6 +469,20 @@
return false;
}
+bool MIParser::parseJumpTableIndexOperand(MachineOperand &Dest) {
+ assert(Token.is(MIToken::JumpTableIndex));
+ unsigned ID;
+ if (getUnsigned(ID))
+ return true;
+ auto JumpTableEntryInfo = PFS.JumpTableSlots.find(ID);
+ if (JumpTableEntryInfo == PFS.JumpTableSlots.end())
+ return error("use of undefined jump table '%jump-table." + Twine(ID) + "'");
+ lex();
+ // TODO: Parse target flags.
+ Dest = MachineOperand::CreateJTI(JumpTableEntryInfo->second);
+ return false;
+}
+
bool MIParser::parseMachineOperand(MachineOperand &Dest) {
switch (Token.kind()) {
case MIToken::kw_implicit:
@@ -486,6 +501,8 @@
case MIToken::GlobalValue:
case MIToken::NamedGlobalValue:
return parseGlobalAddressOperand(Dest);
+ case MIToken::JumpTableIndex:
+ return parseJumpTableIndexOperand(Dest);
case MIToken::Error:
return true;
case MIToken::Identifier: