X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FCodeGen%2FMIRYamlMapping.h;h=14d3744741c5c0a5701762fe88813ae23fd6352e;hb=7de9f7a2205f7e5041a4ecc8fdae8d6961be68ca;hp=7ef4c6b6e39e2433a18a2cccf1b62a7e9609d40a;hpb=fbd94791e6881aad4ed1e3fd13c6abbdd2178df4;p=oota-llvm.git diff --git a/include/llvm/CodeGen/MIRYamlMapping.h b/include/llvm/CodeGen/MIRYamlMapping.h index 7ef4c6b6e39..14d3744741c 100644 --- a/include/llvm/CodeGen/MIRYamlMapping.h +++ b/include/llvm/CodeGen/MIRYamlMapping.h @@ -73,6 +73,20 @@ template <> struct ScalarTraits { static bool mustQuote(StringRef Scalar) { return needsQuotes(Scalar); } }; +struct BlockStringValue { + StringValue Value; +}; + +template <> struct BlockScalarTraits { + static void output(const BlockStringValue &S, void *Ctx, raw_ostream &OS) { + return ScalarTraits::output(S.Value, Ctx, OS); + } + + static StringRef input(StringRef Scalar, void *Ctx, BlockStringValue &S) { + return ScalarTraits::input(Scalar, Ctx, S.Value); + } +}; + /// A wrapper around unsigned which contains a source range that's being set /// during parsing. struct UnsignedValue { @@ -131,7 +145,7 @@ namespace llvm { namespace yaml { struct VirtualRegisterDefinition { - unsigned ID; + UnsignedValue ID; StringValue Class; StringValue PreferredRegister; // TODO: Serialize the target specific register hints. @@ -164,47 +178,16 @@ template <> struct MappingTraits { static const bool flow = true; }; -struct MachineBasicBlock { - unsigned ID; - StringValue Name; - StringValue IRBlock; - unsigned Alignment = 0; - bool IsLandingPad = false; - bool AddressTaken = false; - std::vector Successors; - std::vector SuccessorWeights; - std::vector LiveIns; - std::vector Instructions; -}; - -template <> struct MappingTraits { - static void mapping(IO &YamlIO, MachineBasicBlock &MBB) { - YamlIO.mapRequired("id", MBB.ID); - YamlIO.mapOptional("name", MBB.Name, - StringValue()); // Don't print out an empty name. - YamlIO.mapOptional("ir-block", MBB.IRBlock, - StringValue()); // Don't print out an empty BB reference. - YamlIO.mapOptional("alignment", MBB.Alignment); - YamlIO.mapOptional("isLandingPad", MBB.IsLandingPad); - YamlIO.mapOptional("addressTaken", MBB.AddressTaken); - YamlIO.mapOptional("successors", MBB.Successors); - YamlIO.mapOptional("weights", MBB.SuccessorWeights); - YamlIO.mapOptional("liveins", MBB.LiveIns); - YamlIO.mapOptional("instructions", MBB.Instructions); - } -}; - /// Serializable representation of stack object from the MachineFrameInfo class. /// /// The flags 'isImmutable' and 'isAliased' aren't serialized, as they are /// determined by the object's type and frame information flags. /// Dead stack objects aren't serialized. /// -/// TODO: Determine isPreallocated flag by mapping between objects and local -/// objects (Serialize local objects). +/// The 'isPreallocated' flag is determined by the local offset. struct MachineStackObject { enum ObjectType { DefaultType, SpillSlot, VariableSized }; - unsigned ID; + UnsignedValue ID; StringValue Name; // TODO: Serialize unnamed LLVM alloca reference. ObjectType Type = DefaultType; @@ -212,6 +195,10 @@ struct MachineStackObject { uint64_t Size = 0; unsigned Alignment = 0; StringValue CalleeSavedRegister; + Optional LocalOffset; + StringValue DebugVar; + StringValue DebugExpr; + StringValue DebugLoc; }; template <> struct ScalarEnumerationTraits { @@ -236,6 +223,13 @@ template <> struct MappingTraits { YamlIO.mapOptional("alignment", Object.Alignment); 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("di-variable", Object.DebugVar, + StringValue()); // Don't print it out when it's empty. + YamlIO.mapOptional("di-expression", Object.DebugExpr, + StringValue()); // Don't print it out when it's empty. + YamlIO.mapOptional("di-location", Object.DebugLoc, + StringValue()); // Don't print it out when it's empty. } static const bool flow = true; @@ -245,7 +239,7 @@ template <> struct MappingTraits { /// MachineFrameInfo class. struct FixedMachineStackObject { enum ObjectType { DefaultType, SpillSlot }; - unsigned ID; + UnsignedValue ID; ObjectType Type = DefaultType; int64_t Offset = 0; uint64_t Size = 0; @@ -285,7 +279,7 @@ template <> struct MappingTraits { }; struct MachineConstantPoolValue { - unsigned ID; + UnsignedValue ID; StringValue Value; unsigned Alignment = 0; }; @@ -300,7 +294,7 @@ template <> struct MappingTraits { struct MachineJumpTable { struct Entry { - unsigned ID; + UnsignedValue ID; std::vector Blocks; }; @@ -320,7 +314,6 @@ template <> struct MappingTraits { LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::MachineFunctionLiveIn) 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::MachineConstantPoolValue) @@ -353,9 +346,9 @@ struct MachineFrameInfo { unsigned MaxAlignment = 0; bool AdjustsStack = false; bool HasCalls = false; - // TODO: Serialize StackProtectorIdx and FunctionContextIdx + StringValue StackProtector; + // TODO: Serialize FunctionContextIdx unsigned MaxCallFrameSize = 0; - // TODO: Serialize local frame objects. bool HasOpaqueSPAdjustment = false; bool HasVAStart = false; bool HasMustTailInVarArgFunc = false; @@ -374,6 +367,8 @@ template <> struct MappingTraits { YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment); YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack); YamlIO.mapOptional("hasCalls", MFI.HasCalls); + 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); @@ -396,6 +391,7 @@ struct MachineFunction { bool TracksSubRegLiveness = false; std::vector VirtualRegisters; std::vector LiveIns; + Optional> CalleeSavedRegisters; // TODO: Serialize the various register masks. // Frame information MachineFrameInfo FrameInfo; @@ -403,8 +399,7 @@ struct MachineFunction { std::vector StackObjects; std::vector Constants; /// Constant pool. MachineJumpTable JumpTableInfo; - - std::vector BasicBlocks; + BlockStringValue Body; }; template <> struct MappingTraits { @@ -418,13 +413,14 @@ template <> struct MappingTraits { YamlIO.mapOptional("tracksSubRegLiveness", MF.TracksSubRegLiveness); 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); if (!YamlIO.outputting() || !MF.JumpTableInfo.Entries.empty()) YamlIO.mapOptional("jumpTable", MF.JumpTableInfo); - YamlIO.mapOptional("body", MF.BasicBlocks); + YamlIO.mapOptional("body", MF.Body); } };