summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRParser
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-07-24 22:22:50 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-07-24 22:22:50 +0000
commit1bb48de1f945c8814999e255834d9b3964325471 (patch)
tree1d4fc528e5fbff8bbef3fc247952ff622bb8e7d0 /llvm/lib/CodeGen/MIRParser
parentdc8a83b53b6b930177fc5821b733e255d6e42023 (diff)
downloadbcm5719-llvm-1bb48de1f945c8814999e255834d9b3964325471.tar.gz
bcm5719-llvm-1bb48de1f945c8814999e255834d9b3964325471.zip
MIR Serialization: Serialize MachineFrameInfo's callee saved information.
This commit serializes the callee saved information from the class 'MachineFrameInfo'. This commit extends the YAML mappings for the fixed and the ordinary stack objects and adds an optional 'callee-saved-register' attribute. This attribute is used to serialize the callee save information. llvm-svn: 243173
Diffstat (limited to 'llvm/lib/CodeGen/MIRParser')
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIRParser.cpp53
1 files changed, 41 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 67c939cc562..7f226713817 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -107,10 +107,15 @@ public:
const yaml::MachineFunction &YamlMF,
PerFunctionMIParsingState &PFS);
- bool initializeFrameInfo(const Function &F, MachineFrameInfo &MFI,
+ bool initializeFrameInfo(MachineFunction &MF, MachineFrameInfo &MFI,
const yaml::MachineFunction &YamlMF,
- DenseMap<unsigned, int> &StackObjectSlots,
- DenseMap<unsigned, int> &FixedStackObjectSlots);
+ PerFunctionMIParsingState &PFS);
+
+ bool parseCalleeSavedRegister(MachineFunction &MF,
+ PerFunctionMIParsingState &PFS,
+ std::vector<CalleeSavedInfo> &CSIInfo,
+ const yaml::StringValue &RegisterSource,
+ int FrameIdx);
bool initializeConstantPool(MachineConstantPool &ConstantPool,
const yaml::MachineFunction &YamlMF,
@@ -273,8 +278,7 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) {
PerFunctionMIParsingState PFS;
if (initializeRegisterInfo(MF, MF.getRegInfo(), YamlMF, PFS))
return true;
- if (initializeFrameInfo(*MF.getFunction(), *MF.getFrameInfo(), YamlMF,
- PFS.StackObjectSlots, PFS.FixedStackObjectSlots))
+ if (initializeFrameInfo(MF, *MF.getFrameInfo(), YamlMF, PFS))
return true;
if (!YamlMF.Constants.empty()) {
auto *ConstantPool = MF.getConstantPool();
@@ -401,11 +405,11 @@ bool MIRParserImpl::initializeRegisterInfo(MachineFunction &MF,
return false;
}
-bool MIRParserImpl::initializeFrameInfo(
- const Function &F, MachineFrameInfo &MFI,
- const yaml::MachineFunction &YamlMF,
- DenseMap<unsigned, int> &StackObjectSlots,
- DenseMap<unsigned, int> &FixedStackObjectSlots) {
+bool MIRParserImpl::initializeFrameInfo(MachineFunction &MF,
+ MachineFrameInfo &MFI,
+ const yaml::MachineFunction &YamlMF,
+ PerFunctionMIParsingState &PFS) {
+ const Function &F = *MF.getFunction();
const yaml::MachineFrameInfo &YamlMFI = YamlMF.FrameInfo;
MFI.setFrameAddressIsTaken(YamlMFI.IsFrameAddressTaken);
MFI.setReturnAddressIsTaken(YamlMFI.IsReturnAddressTaken);
@@ -422,6 +426,7 @@ bool MIRParserImpl::initializeFrameInfo(
MFI.setHasVAStart(YamlMFI.HasVAStart);
MFI.setHasMustTailInVarArgFunc(YamlMFI.HasMustTailInVarArgFunc);
+ std::vector<CalleeSavedInfo> CSIInfo;
// Initialize the fixed frame objects.
for (const auto &Object : YamlMF.FixedStackObjects) {
int ObjectIdx;
@@ -432,7 +437,10 @@ bool MIRParserImpl::initializeFrameInfo(
ObjectIdx = MFI.CreateFixedSpillStackObject(Object.Size, Object.Offset);
MFI.setObjectAlignment(ObjectIdx, Object.Alignment);
// TODO: Report an error when objects are redefined.
- FixedStackObjectSlots.insert(std::make_pair(Object.ID, ObjectIdx));
+ PFS.FixedStackObjectSlots.insert(std::make_pair(Object.ID, ObjectIdx));
+ if (parseCalleeSavedRegister(MF, PFS, CSIInfo, Object.CalleeSavedRegister,
+ ObjectIdx))
+ return true;
}
// Initialize the ordinary frame objects.
@@ -457,8 +465,29 @@ bool MIRParserImpl::initializeFrameInfo(
Object.Type == yaml::MachineStackObject::SpillSlot, Alloca);
MFI.setObjectOffset(ObjectIdx, Object.Offset);
// TODO: Report an error when objects are redefined.
- StackObjectSlots.insert(std::make_pair(Object.ID, ObjectIdx));
+ PFS.StackObjectSlots.insert(std::make_pair(Object.ID, ObjectIdx));
+ if (parseCalleeSavedRegister(MF, PFS, CSIInfo, Object.CalleeSavedRegister,
+ ObjectIdx))
+ return true;
}
+ MFI.setCalleeSavedInfo(CSIInfo);
+ if (!CSIInfo.empty())
+ MFI.setCalleeSavedInfoValid(true);
+ return false;
+}
+
+bool MIRParserImpl::parseCalleeSavedRegister(
+ MachineFunction &MF, PerFunctionMIParsingState &PFS,
+ std::vector<CalleeSavedInfo> &CSIInfo,
+ const yaml::StringValue &RegisterSource, int FrameIdx) {
+ if (RegisterSource.Value.empty())
+ return false;
+ unsigned Reg = 0;
+ SMDiagnostic Error;
+ if (parseNamedRegisterReference(Reg, SM, MF, RegisterSource.Value, PFS,
+ IRSlots, Error))
+ return error(Error, RegisterSource.SourceRange);
+ CSIInfo.push_back(CalleeSavedInfo(Reg, FrameIdx));
return false;
}
OpenPOWER on IntegriCloud