mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-19 02:25:01 +00:00
MIR Serialization: Serialize the jump table info.
The jump table info is serialized using a YAML mapping that contains its kind and a YAML sequence of jump table entries. A jump table entry is a YAML mapping that has an ID and an inline YAML sequence of machine basic block references. The testcase 'CodeGen/MIR/X86/jump-table-info.mir' doesn't have any instructions because one of them contains a jump table index operand. The jump table index operands will be serialized in a follow up patch, and the appropriate instructions will be added to this testcase. Reviewers: Duncan P. N. Exon Smith git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242357 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -46,6 +46,8 @@ public:
|
||||
void convert(yaml::MachineFunction &MF, const MachineRegisterInfo &RegInfo,
|
||||
const TargetRegisterInfo *TRI);
|
||||
void convert(yaml::MachineFrameInfo &YamlMFI, const MachineFrameInfo &MFI);
|
||||
void convert(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI,
|
||||
const MachineJumpTableInfo &JTI);
|
||||
void convert(ModuleSlotTracker &MST, yaml::MachineBasicBlock &YamlMBB,
|
||||
const MachineBasicBlock &MBB);
|
||||
void convertStackObjects(yaml::MachineFunction &MF,
|
||||
@@ -116,8 +118,10 @@ void MIRPrinter::print(const MachineFunction &MF) {
|
||||
convert(YamlMF.FrameInfo, *MF.getFrameInfo());
|
||||
convertStackObjects(YamlMF, *MF.getFrameInfo());
|
||||
|
||||
int I = 0;
|
||||
ModuleSlotTracker MST(MF.getFunction()->getParent());
|
||||
if (const auto *JumpTableInfo = MF.getJumpTableInfo())
|
||||
convert(MST, YamlMF.JumpTableInfo, *JumpTableInfo);
|
||||
int I = 0;
|
||||
for (const auto &MBB : MF) {
|
||||
// TODO: Allow printing of non sequentially numbered MBBs.
|
||||
// This is currently needed as the basic block references get their index
|
||||
@@ -218,6 +222,25 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &MF,
|
||||
}
|
||||
}
|
||||
|
||||
void MIRPrinter::convert(ModuleSlotTracker &MST,
|
||||
yaml::MachineJumpTable &YamlJTI,
|
||||
const MachineJumpTableInfo &JTI) {
|
||||
YamlJTI.Kind = JTI.getEntryKind();
|
||||
unsigned ID = 0;
|
||||
for (const auto &Table : JTI.getJumpTables()) {
|
||||
std::string Str;
|
||||
yaml::MachineJumpTable::Entry Entry;
|
||||
Entry.ID = ID++;
|
||||
for (const auto *MBB : Table.MBBs) {
|
||||
raw_string_ostream StrOS(Str);
|
||||
MIPrinter(StrOS, MST, RegisterMaskIds).printMBBReference(*MBB);
|
||||
Entry.Blocks.push_back(StrOS.str());
|
||||
Str.clear();
|
||||
}
|
||||
YamlJTI.Entries.push_back(Entry);
|
||||
}
|
||||
}
|
||||
|
||||
void MIRPrinter::convert(ModuleSlotTracker &MST,
|
||||
yaml::MachineBasicBlock &YamlMBB,
|
||||
const MachineBasicBlock &MBB) {
|
||||
|
Reference in New Issue
Block a user