diff options
author | Alex Lorenz <arphaman@gmail.com> | 2015-07-24 20:35:40 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2015-07-24 20:35:40 +0000 |
commit | ab4cbcfda7c7cf7aa7805881f94c6877be231354 (patch) | |
tree | 4dfba9dadc2b4b9ecd6a05986dba13428c8d542b /llvm/lib | |
parent | bd210e638aca82850ff77832b5be8579d9950c87 (diff) | |
download | bcm5719-llvm-ab4cbcfda7c7cf7aa7805881f94c6877be231354.tar.gz bcm5719-llvm-ab4cbcfda7c7cf7aa7805881f94c6877be231354.zip |
MIR Serialization: Serialize the simple virtual register allocation hints.
This commit serializes the virtual register allocations hints of type 0.
These hints specify the preferred physical registers for allocations.
llvm-svn: 243156
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 30 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 9 |
2 files changed, 27 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp index 383fde1101a..67c939cc562 100644 --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -103,11 +103,9 @@ public: const yaml::MachineBasicBlock &YamlMBB, const PerFunctionMIParsingState &PFS); - bool - initializeRegisterInfo(const MachineFunction &MF, - MachineRegisterInfo &RegInfo, - const yaml::MachineFunction &YamlMF, - DenseMap<unsigned, unsigned> &VirtualRegisterSlots); + bool initializeRegisterInfo(MachineFunction &MF, MachineRegisterInfo &RegInfo, + const yaml::MachineFunction &YamlMF, + PerFunctionMIParsingState &PFS); bool initializeFrameInfo(const Function &F, MachineFrameInfo &MFI, const yaml::MachineFunction &YamlMF, @@ -273,8 +271,7 @@ bool MIRParserImpl::initializeMachineFunction(MachineFunction &MF) { MF.setExposesReturnsTwice(YamlMF.ExposesReturnsTwice); MF.setHasInlineAsm(YamlMF.HasInlineAsm); PerFunctionMIParsingState PFS; - if (initializeRegisterInfo(MF, MF.getRegInfo(), YamlMF, - PFS.VirtualRegisterSlots)) + if (initializeRegisterInfo(MF, MF.getRegInfo(), YamlMF, PFS)) return true; if (initializeFrameInfo(*MF.getFunction(), *MF.getFrameInfo(), YamlMF, PFS.StackObjectSlots, PFS.FixedStackObjectSlots)) @@ -368,10 +365,10 @@ bool MIRParserImpl::initializeMachineBasicBlock( return false; } -bool MIRParserImpl::initializeRegisterInfo( - const MachineFunction &MF, MachineRegisterInfo &RegInfo, - const yaml::MachineFunction &YamlMF, - DenseMap<unsigned, unsigned> &VirtualRegisterSlots) { +bool MIRParserImpl::initializeRegisterInfo(MachineFunction &MF, + MachineRegisterInfo &RegInfo, + const yaml::MachineFunction &YamlMF, + PerFunctionMIParsingState &PFS) { assert(RegInfo.isSSA()); if (!YamlMF.IsSSA) RegInfo.leaveSSA(); @@ -380,6 +377,7 @@ bool MIRParserImpl::initializeRegisterInfo( RegInfo.invalidateLiveness(); RegInfo.enableSubRegLiveness(YamlMF.TracksSubRegLiveness); + SMDiagnostic Error; // Parse the virtual register information. for (const auto &VReg : YamlMF.VirtualRegisters) { const auto *RC = getRegClass(MF, VReg.Class.Value); @@ -390,7 +388,15 @@ bool MIRParserImpl::initializeRegisterInfo( unsigned Reg = RegInfo.createVirtualRegister(RC); // TODO: Report an error when the same virtual register with the same ID is // redefined. - VirtualRegisterSlots.insert(std::make_pair(VReg.ID, Reg)); + PFS.VirtualRegisterSlots.insert(std::make_pair(VReg.ID, Reg)); + if (!VReg.PreferredRegister.Value.empty()) { + unsigned PreferredReg = 0; + if (parseNamedRegisterReference(PreferredReg, SM, MF, + VReg.PreferredRegister.Value, PFS, + IRSlots, Error)) + return error(Error, VReg.PreferredRegister.SourceRange); + RegInfo.setSimpleHint(Reg, PreferredReg); + } } return false; } diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 2ae5466392f..574a0ddee1b 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -140,6 +140,12 @@ static void printReg(unsigned Reg, raw_ostream &OS, llvm_unreachable("Can't print this kind of register yet"); } +static void printReg(unsigned Reg, yaml::StringValue &Dest, + const TargetRegisterInfo *TRI) { + raw_string_ostream OS(Dest.Value); + printReg(Reg, OS, TRI); +} + void MIRPrinter::print(const MachineFunction &MF) { initRegisterMaskIds(MF); @@ -188,6 +194,9 @@ void MIRPrinter::convert(yaml::MachineFunction &MF, VReg.ID = I; VReg.Class = StringRef(TRI->getRegClassName(RegInfo.getRegClass(Reg))).lower(); + unsigned PreferredReg = RegInfo.getSimpleHint(Reg); + if (PreferredReg) + printReg(PreferredReg, VReg.PreferredRegister, TRI); MF.VirtualRegisters.push_back(VReg); } } |