mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +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:
@ -19,6 +19,7 @@
|
||||
#define LLVM_LIB_CODEGEN_MIRYAMLMAPPING_H
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
#include <vector>
|
||||
|
||||
@ -72,6 +73,22 @@ template <> struct ScalarTraits<FlowStringValue> {
|
||||
static bool mustQuote(StringRef Scalar) { return needsQuotes(Scalar); }
|
||||
};
|
||||
|
||||
template <> struct ScalarEnumerationTraits<MachineJumpTableInfo::JTEntryKind> {
|
||||
static void enumeration(yaml::IO &IO,
|
||||
MachineJumpTableInfo::JTEntryKind &EntryKind) {
|
||||
IO.enumCase(EntryKind, "block-address",
|
||||
MachineJumpTableInfo::EK_BlockAddress);
|
||||
IO.enumCase(EntryKind, "gp-rel64-block-address",
|
||||
MachineJumpTableInfo::EK_GPRel64BlockAddress);
|
||||
IO.enumCase(EntryKind, "gp-rel32-block-address",
|
||||
MachineJumpTableInfo::EK_GPRel32BlockAddress);
|
||||
IO.enumCase(EntryKind, "label-difference32",
|
||||
MachineJumpTableInfo::EK_LabelDifference32);
|
||||
IO.enumCase(EntryKind, "inline", MachineJumpTableInfo::EK_Inline);
|
||||
IO.enumCase(EntryKind, "custom32", MachineJumpTableInfo::EK_Custom32);
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace yaml
|
||||
} // end namespace llvm
|
||||
|
||||
@ -206,6 +223,23 @@ template <> struct MappingTraits<FixedMachineStackObject> {
|
||||
static const bool flow = true;
|
||||
};
|
||||
|
||||
struct MachineJumpTable {
|
||||
struct Entry {
|
||||
unsigned ID;
|
||||
std::vector<FlowStringValue> Blocks;
|
||||
};
|
||||
|
||||
MachineJumpTableInfo::JTEntryKind Kind = MachineJumpTableInfo::EK_Custom32;
|
||||
std::vector<Entry> Entries;
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<MachineJumpTable::Entry> {
|
||||
static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry) {
|
||||
YamlIO.mapRequired("id", Entry.ID);
|
||||
YamlIO.mapOptional("blocks", Entry.Blocks);
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace yaml
|
||||
} // end namespace llvm
|
||||
|
||||
@ -213,10 +247,18 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::VirtualRegisterDefinition)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineBasicBlock)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineStackObject)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::FixedMachineStackObject)
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineJumpTable::Entry)
|
||||
|
||||
namespace llvm {
|
||||
namespace yaml {
|
||||
|
||||
template <> struct MappingTraits<MachineJumpTable> {
|
||||
static void mapping(IO &YamlIO, MachineJumpTable &JT) {
|
||||
YamlIO.mapRequired("kind", JT.Kind);
|
||||
YamlIO.mapOptional("entries", JT.Entries);
|
||||
}
|
||||
};
|
||||
|
||||
/// Serializable representation of MachineFrameInfo.
|
||||
///
|
||||
/// Doesn't serialize attributes like 'StackAlignment', 'IsStackRealignable' and
|
||||
@ -278,6 +320,7 @@ struct MachineFunction {
|
||||
MachineFrameInfo FrameInfo;
|
||||
std::vector<FixedMachineStackObject> FixedStackObjects;
|
||||
std::vector<MachineStackObject> StackObjects;
|
||||
MachineJumpTable JumpTableInfo;
|
||||
|
||||
std::vector<MachineBasicBlock> BasicBlocks;
|
||||
};
|
||||
@ -295,6 +338,8 @@ template <> struct MappingTraits<MachineFunction> {
|
||||
YamlIO.mapOptional("frameInfo", MF.FrameInfo);
|
||||
YamlIO.mapOptional("fixedStack", MF.FixedStackObjects);
|
||||
YamlIO.mapOptional("stack", MF.StackObjects);
|
||||
if (!YamlIO.outputting() || !MF.JumpTableInfo.Entries.empty())
|
||||
YamlIO.mapOptional("jumpTable", MF.JumpTableInfo);
|
||||
YamlIO.mapOptional("body", MF.BasicBlocks);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user