diff options
author | Alex Lorenz <arphaman@gmail.com> | 2015-07-10 18:13:57 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2015-07-10 18:13:57 +0000 |
commit | f6bc8667cd05c9a9f8d2eedbb23faf6c6b8d443f (patch) | |
tree | 5dca544db74f502af60dadef6b4740d7e64d1c96 /llvm/lib/CodeGen | |
parent | b73a2ed20ea235e0e52f1088c91b6ecebd0c8722 (diff) | |
download | bcm5719-llvm-f6bc8667cd05c9a9f8d2eedbb23faf6c6b8d443f.tar.gz bcm5719-llvm-f6bc8667cd05c9a9f8d2eedbb23faf6c6b8d443f.zip |
MIR Serialization: Initial serialization of stack objects.
This commit implements the initial serialization of stack objects from the
MachineFrameInfo class. It can only serialize the ordinary stack objects
(including ordinary spill slots), but it doesn't serialize variable sized or
fixed stack objects yet.
The stack objects are serialized using a YAML sequence of YAML inline mappings.
Each mapping has the object's ID, type, size, offset and alignment. The stack
objects are a part of machine function's YAML mapping.
Reviewers: Duncan P. N. Exon Smith
llvm-svn: 241922
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 17 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 25 |
2 files changed, 39 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index d9fd3861d44..0f7673eea07 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -107,7 +107,7 @@ public: const yaml::MachineFunction &YamlMF); bool initializeFrameInfo(MachineFrameInfo &MFI, - const yaml::MachineFrameInfo &YamlMFI); + const yaml::MachineFunction &YamlMF); private: /// Return a MIR diagnostic converted from an MI string diagnostic. @@ -260,7 +260,7 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) { MF.setHasInlineAsm(YamlMF.HasInlineAsm); if (initializeRegisterInfo(MF, MF.getRegInfo(), YamlMF)) return true; - if (initializeFrameInfo(*MF.getFrameInfo(), YamlMF.FrameInfo)) + if (initializeFrameInfo(*MF.getFrameInfo(), YamlMF)) return true; PerFunctionMIParsingState PFS; @@ -354,7 +354,8 @@ bool MIRParserImpl::initializeRegisterInfo( } bool MIRParserImpl::initializeFrameInfo(MachineFrameInfo &MFI, - const yaml::MachineFrameInfo &YamlMFI) { + const yaml::MachineFunction &YamlMF) { + const yaml::MachineFrameInfo &YamlMFI = YamlMF.FrameInfo; MFI.setFrameAddressIsTaken(YamlMFI.IsFrameAddressTaken); MFI.setReturnAddressIsTaken(YamlMFI.IsReturnAddressTaken); MFI.setHasStackMap(YamlMFI.HasStackMap); @@ -369,6 +370,16 @@ bool MIRParserImpl::initializeFrameInfo(MachineFrameInfo &MFI, MFI.setHasOpaqueSPAdjustment(YamlMFI.HasOpaqueSPAdjustment); MFI.setHasVAStart(YamlMFI.HasVAStart); MFI.setHasMustTailInVarArgFunc(YamlMFI.HasMustTailInVarArgFunc); + + // Initialize the frame objects. + for (const auto &Object : YamlMF.StackObjects) { + int ObjectIdx = MFI.CreateStackObject( + Object.Size, Object.Alignment, + Object.Type == yaml::MachineStackObject::SpillSlot); + MFI.setObjectOffset(ObjectIdx, Object.Offset); + // TODO: Store the mapping between object IDs and object indices to parse + // stack object references correctly. + } return false; } diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 3ca98240d94..8e97ce4dbf1 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -47,6 +47,8 @@ public: void convert(yaml::MachineFrameInfo &YamlMFI, const MachineFrameInfo &MFI); void convert(ModuleSlotTracker &MST, yaml::MachineBasicBlock &YamlMBB, const MachineBasicBlock &MBB); + void convertStackObjects(yaml::MachineFunction &MF, + const MachineFrameInfo &MFI); private: void initRegisterMaskIds(const MachineFunction &MF); @@ -98,6 +100,7 @@ void MIRPrinter::print(const MachineFunction &MF) { YamlMF.HasInlineAsm = MF.hasInlineAsm(); convert(YamlMF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo()); convert(YamlMF.FrameInfo, *MF.getFrameInfo()); + convertStackObjects(YamlMF, *MF.getFrameInfo()); int I = 0; ModuleSlotTracker MST(MF.getFunction()->getParent()); @@ -152,6 +155,28 @@ void MIRPrinter::convert(yaml::MachineFrameInfo &YamlMFI, YamlMFI.HasMustTailInVarArgFunc = MFI.hasMustTailInVarArgFunc(); } +void MIRPrinter::convertStackObjects(yaml::MachineFunction &MF, + const MachineFrameInfo &MFI) { + unsigned ID = 0; + for (int I = 0, E = MFI.getObjectIndexEnd(); I < E; ++I) { + if (MFI.isDeadObjectIndex(I)) + continue; + + yaml::MachineStackObject YamlObject; + YamlObject.ID = ID++; + YamlObject.Type = MFI.isSpillSlotObjectIndex(I) + ? yaml::MachineStackObject::SpillSlot + : yaml::MachineStackObject::DefaultType; + YamlObject.Offset = MFI.getObjectOffset(I); + YamlObject.Size = MFI.getObjectSize(I); + YamlObject.Alignment = MFI.getObjectAlignment(I); + + MF.StackObjects.push_back(YamlObject); + // TODO: Store the mapping between object IDs and object indices to print + // the stack object references correctly. + } +} + void MIRPrinter::convert(ModuleSlotTracker &MST, yaml::MachineBasicBlock &YamlMBB, const MachineBasicBlock &MBB) { |