summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h')
-rw-r--r--contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h144
1 files changed, 102 insertions, 42 deletions
diff --git a/contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index 778f72c..1b1ba6a 100644
--- a/contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/contrib/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -55,7 +55,7 @@ template <> struct ScalarTraits<StringValue> {
struct FlowStringValue : StringValue {
FlowStringValue() {}
- FlowStringValue(std::string Value) : StringValue(Value) {}
+ FlowStringValue(std::string Value) : StringValue(std::move(Value)) {}
};
template <> struct ScalarTraits<FlowStringValue> {
@@ -72,6 +72,9 @@ template <> struct ScalarTraits<FlowStringValue> {
struct BlockStringValue {
StringValue Value;
+ bool operator==(const BlockStringValue &Other) const {
+ return Value == Other.Value;
+ }
};
template <> struct BlockScalarTraits<BlockStringValue> {
@@ -146,6 +149,10 @@ struct VirtualRegisterDefinition {
StringValue Class;
StringValue PreferredRegister;
// TODO: Serialize the target specific register hints.
+ bool operator==(const VirtualRegisterDefinition &Other) const {
+ return ID == Other.ID && Class == Other.Class &&
+ PreferredRegister == Other.PreferredRegister;
+ }
};
template <> struct MappingTraits<VirtualRegisterDefinition> {
@@ -162,6 +169,10 @@ template <> struct MappingTraits<VirtualRegisterDefinition> {
struct MachineFunctionLiveIn {
StringValue Register;
StringValue VirtualRegister;
+ bool operator==(const MachineFunctionLiveIn &Other) const {
+ return Register == Other.Register &&
+ VirtualRegister == Other.VirtualRegister;
+ }
};
template <> struct MappingTraits<MachineFunctionLiveIn> {
@@ -196,6 +207,14 @@ struct MachineStackObject {
StringValue DebugVar;
StringValue DebugExpr;
StringValue DebugLoc;
+ bool operator==(const MachineStackObject &Other) const {
+ return ID == Other.ID && Name == Other.Name && Type == Other.Type &&
+ Offset == Other.Offset && Size == Other.Size &&
+ Alignment == Other.Alignment &&
+ CalleeSavedRegister == Other.CalleeSavedRegister &&
+ LocalOffset == Other.LocalOffset && DebugVar == Other.DebugVar &&
+ DebugExpr == Other.DebugExpr && DebugLoc == Other.DebugLoc;
+ }
};
template <> struct ScalarEnumerationTraits<MachineStackObject::ObjectType> {
@@ -214,13 +233,13 @@ template <> struct MappingTraits<MachineStackObject> {
YamlIO.mapOptional(
"type", Object.Type,
MachineStackObject::DefaultType); // Don't print the default type.
- YamlIO.mapOptional("offset", Object.Offset);
+ YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
if (Object.Type != MachineStackObject::VariableSized)
YamlIO.mapRequired("size", Object.Size);
- YamlIO.mapOptional("alignment", Object.Alignment);
+ YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
StringValue()); // Don't print it out when it's empty.
- YamlIO.mapOptional("local-offset", Object.LocalOffset);
+ YamlIO.mapOptional("local-offset", Object.LocalOffset, Optional<int64_t>());
YamlIO.mapOptional("di-variable", Object.DebugVar,
StringValue()); // Don't print it out when it's empty.
YamlIO.mapOptional("di-expression", Object.DebugExpr,
@@ -244,6 +263,12 @@ struct FixedMachineStackObject {
bool IsImmutable = false;
bool IsAliased = false;
StringValue CalleeSavedRegister;
+ bool operator==(const FixedMachineStackObject &Other) const {
+ return ID == Other.ID && Type == Other.Type && Offset == Other.Offset &&
+ Size == Other.Size && Alignment == Other.Alignment &&
+ IsImmutable == Other.IsImmutable && IsAliased == Other.IsAliased &&
+ CalleeSavedRegister == Other.CalleeSavedRegister;
+ }
};
template <>
@@ -261,12 +286,12 @@ template <> struct MappingTraits<FixedMachineStackObject> {
YamlIO.mapOptional(
"type", Object.Type,
FixedMachineStackObject::DefaultType); // Don't print the default type.
- YamlIO.mapOptional("offset", Object.Offset);
- YamlIO.mapOptional("size", Object.Size);
- YamlIO.mapOptional("alignment", Object.Alignment);
+ YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
+ YamlIO.mapOptional("size", Object.Size, (uint64_t)0);
+ YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
if (Object.Type != FixedMachineStackObject::SpillSlot) {
- YamlIO.mapOptional("isImmutable", Object.IsImmutable);
- YamlIO.mapOptional("isAliased", Object.IsAliased);
+ YamlIO.mapOptional("isImmutable", Object.IsImmutable, false);
+ YamlIO.mapOptional("isAliased", Object.IsAliased, false);
}
YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
StringValue()); // Don't print it out when it's empty.
@@ -279,13 +304,17 @@ struct MachineConstantPoolValue {
UnsignedValue ID;
StringValue Value;
unsigned Alignment = 0;
+ bool operator==(const MachineConstantPoolValue &Other) const {
+ return ID == Other.ID && Value == Other.Value &&
+ Alignment == Other.Alignment;
+ }
};
template <> struct MappingTraits<MachineConstantPoolValue> {
static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant) {
YamlIO.mapRequired("id", Constant.ID);
- YamlIO.mapOptional("value", Constant.Value);
- YamlIO.mapOptional("alignment", Constant.Alignment);
+ YamlIO.mapOptional("value", Constant.Value, StringValue());
+ YamlIO.mapOptional("alignment", Constant.Alignment, (unsigned)0);
}
};
@@ -293,16 +322,22 @@ struct MachineJumpTable {
struct Entry {
UnsignedValue ID;
std::vector<FlowStringValue> Blocks;
+ bool operator==(const Entry &Other) const {
+ return ID == Other.ID && Blocks == Other.Blocks;
+ }
};
MachineJumpTableInfo::JTEntryKind Kind = MachineJumpTableInfo::EK_Custom32;
std::vector<Entry> Entries;
+ bool operator==(const MachineJumpTable &Other) const {
+ return Kind == Other.Kind && Entries == Other.Entries;
+ }
};
template <> struct MappingTraits<MachineJumpTable::Entry> {
static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry) {
YamlIO.mapRequired("id", Entry.ID);
- YamlIO.mapOptional("blocks", Entry.Blocks);
+ YamlIO.mapOptional("blocks", Entry.Blocks, std::vector<FlowStringValue>());
}
};
@@ -322,7 +357,8 @@ namespace yaml {
template <> struct MappingTraits<MachineJumpTable> {
static void mapping(IO &YamlIO, MachineJumpTable &JT) {
YamlIO.mapRequired("kind", JT.Kind);
- YamlIO.mapOptional("entries", JT.Entries);
+ YamlIO.mapOptional("entries", JT.Entries,
+ std::vector<MachineJumpTable::Entry>());
}
};
@@ -345,31 +381,49 @@ struct MachineFrameInfo {
bool HasCalls = false;
StringValue StackProtector;
// TODO: Serialize FunctionContextIdx
- unsigned MaxCallFrameSize = 0;
+ unsigned MaxCallFrameSize = ~0u; ///< ~0u means: not computed yet.
bool HasOpaqueSPAdjustment = false;
bool HasVAStart = false;
bool HasMustTailInVarArgFunc = false;
StringValue SavePoint;
StringValue RestorePoint;
+ bool operator==(const MachineFrameInfo &Other) const {
+ return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
+ IsReturnAddressTaken == Other.IsReturnAddressTaken &&
+ HasStackMap == Other.HasStackMap &&
+ HasPatchPoint == Other.HasPatchPoint &&
+ StackSize == Other.StackSize &&
+ OffsetAdjustment == Other.OffsetAdjustment &&
+ MaxAlignment == Other.MaxAlignment &&
+ AdjustsStack == Other.AdjustsStack && HasCalls == Other.HasCalls &&
+ StackProtector == Other.StackProtector &&
+ MaxCallFrameSize == Other.MaxCallFrameSize &&
+ HasOpaqueSPAdjustment == Other.HasOpaqueSPAdjustment &&
+ HasVAStart == Other.HasVAStart &&
+ HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
+ SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint;
+ }
};
template <> struct MappingTraits<MachineFrameInfo> {
static void mapping(IO &YamlIO, MachineFrameInfo &MFI) {
- YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken);
- YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken);
- YamlIO.mapOptional("hasStackMap", MFI.HasStackMap);
- YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint);
- YamlIO.mapOptional("stackSize", MFI.StackSize);
- YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment);
- YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment);
- YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack);
- YamlIO.mapOptional("hasCalls", MFI.HasCalls);
+ YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken, false);
+ YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken, false);
+ YamlIO.mapOptional("hasStackMap", MFI.HasStackMap, false);
+ YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint, false);
+ YamlIO.mapOptional("stackSize", MFI.StackSize, (uint64_t)0);
+ YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment, (int)0);
+ YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment, (unsigned)0);
+ YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack, false);
+ YamlIO.mapOptional("hasCalls", MFI.HasCalls, false);
YamlIO.mapOptional("stackProtector", MFI.StackProtector,
StringValue()); // Don't print it out when it's empty.
- YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize);
- YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment);
- YamlIO.mapOptional("hasVAStart", MFI.HasVAStart);
- YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc);
+ YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, (unsigned)~0);
+ YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment,
+ false);
+ YamlIO.mapOptional("hasVAStart", MFI.HasVAStart, false);
+ YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc,
+ false);
YamlIO.mapOptional("savePoint", MFI.SavePoint,
StringValue()); // Don't print it out when it's empty.
YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
@@ -403,22 +457,28 @@ struct MachineFunction {
template <> struct MappingTraits<MachineFunction> {
static void mapping(IO &YamlIO, MachineFunction &MF) {
YamlIO.mapRequired("name", MF.Name);
- YamlIO.mapOptional("alignment", MF.Alignment);
- YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice);
- YamlIO.mapOptional("legalized", MF.Legalized);
- YamlIO.mapOptional("regBankSelected", MF.RegBankSelected);
- YamlIO.mapOptional("selected", MF.Selected);
- YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness);
- YamlIO.mapOptional("registers", MF.VirtualRegisters);
- YamlIO.mapOptional("liveins", MF.LiveIns);
- YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters);
- YamlIO.mapOptional("frameInfo", MF.FrameInfo);
- YamlIO.mapOptional("fixedStack", MF.FixedStackObjects);
- YamlIO.mapOptional("stack", MF.StackObjects);
- YamlIO.mapOptional("constants", MF.Constants);
+ YamlIO.mapOptional("alignment", MF.Alignment, (unsigned)0);
+ YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice, false);
+ YamlIO.mapOptional("legalized", MF.Legalized, false);
+ YamlIO.mapOptional("regBankSelected", MF.RegBankSelected, false);
+ YamlIO.mapOptional("selected", MF.Selected, false);
+ YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness, false);
+ YamlIO.mapOptional("registers", MF.VirtualRegisters,
+ std::vector<VirtualRegisterDefinition>());
+ YamlIO.mapOptional("liveins", MF.LiveIns,
+ std::vector<MachineFunctionLiveIn>());
+ YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters,
+ Optional<std::vector<FlowStringValue>>());
+ YamlIO.mapOptional("frameInfo", MF.FrameInfo, MachineFrameInfo());
+ YamlIO.mapOptional("fixedStack", MF.FixedStackObjects,
+ std::vector<FixedMachineStackObject>());
+ YamlIO.mapOptional("stack", MF.StackObjects,
+ std::vector<MachineStackObject>());
+ YamlIO.mapOptional("constants", MF.Constants,
+ std::vector<MachineConstantPoolValue>());
if (!YamlIO.outputting() || !MF.JumpTableInfo.Entries.empty())
- YamlIO.mapOptional("jumpTable", MF.JumpTableInfo);
- YamlIO.mapOptional("body", MF.Body);
+ YamlIO.mapOptional("jumpTable", MF.JumpTableInfo, MachineJumpTable());
+ YamlIO.mapOptional("body", MF.Body, BlockStringValue());
}
};
OpenPOWER on IntegriCloud