diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-03-11 07:19:34 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-03-11 07:19:34 +0000 |
commit | 676dd7c80b6f91178452535ac45ca58feb23cc42 (patch) | |
tree | 33282790f7a542b3ef2f3af7a23646d8f8514a1c /lib/CodeGen/VirtRegMap.h | |
parent | 204496d58e7e740f0da6d41c6214a91d67950d26 (diff) | |
download | external_llvm-676dd7c80b6f91178452535ac45ca58feb23cc42.zip external_llvm-676dd7c80b6f91178452535ac45ca58feb23cc42.tar.gz external_llvm-676dd7c80b6f91178452535ac45ca58feb23cc42.tar.bz2 |
When the register allocator runs out of registers, spill a physical register around the def's and use's of the interval being allocated to make it possible for the interval to target a register and spill it right away and restore a register for uses. This likely generates terrible code but is before than aborting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegMap.h')
-rw-r--r-- | lib/CodeGen/VirtRegMap.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/CodeGen/VirtRegMap.h b/lib/CodeGen/VirtRegMap.h index d1c14f6..7ebf31e 100644 --- a/lib/CodeGen/VirtRegMap.h +++ b/lib/CodeGen/VirtRegMap.h @@ -93,6 +93,17 @@ namespace llvm { /// splitting. std::map<MachineInstr*, std::vector<unsigned> > RestorePt2VirtMap; + /// EmergencySpillMap - This records the physical registers that should + /// be spilled / restored around the MachineInstr since the register + /// allocator has run out of registers. + std::map<MachineInstr*, std::vector<unsigned> > EmergencySpillMap; + + /// EmergencySpillSlots - This records emergency spill slots used to + /// spill physical registers when the register allocator runs out of + /// registers. Ideally only one stack slot is used per function per + /// register class. + std::map<const TargetRegisterClass*, int> EmergencySpillSlots; + /// ReMatId - Instead of assigning a stack slot to a to be rematerialized /// virtual register, an unique id is being assigned. This keeps track of /// the highest id used so far. Note, this starts at (1<<18) to avoid @@ -293,6 +304,8 @@ namespace llvm { } } + /// @brief - transfer restore point information from one instruction to + /// another. void transferRestorePts(MachineInstr *Old, MachineInstr *New) { std::map<MachineInstr*,std::vector<unsigned> >::iterator I = RestorePt2VirtMap.find(Old); @@ -306,6 +319,33 @@ namespace llvm { RestorePt2VirtMap.erase(I); } + /// @brief records that the specified physical register must be spilled + /// around the specified machine instr. + void addEmergencySpill(unsigned PhysReg, MachineInstr *MI) { + if (EmergencySpillMap.find(MI) != EmergencySpillMap.end()) + EmergencySpillMap[MI].push_back(PhysReg); + else { + std::vector<unsigned> PhysRegs; + PhysRegs.push_back(PhysReg); + EmergencySpillMap.insert(std::make_pair(MI, PhysRegs)); + } + } + + /// @brief returns true if one or more physical registers must be spilled + /// around the specified instruction. + bool hasEmergencySpills(MachineInstr *MI) const { + return EmergencySpillMap.find(MI) != EmergencySpillMap.end(); + } + + /// @brief returns the physical registers to be spilled and restored around + /// the instruction. + std::vector<unsigned> &getEmergencySpills(MachineInstr *MI) { + return EmergencySpillMap[MI]; + } + + /// @brief return or get a emergency spill slot for the register class. + int getEmergencySpillSlot(const TargetRegisterClass *RC); + /// @brief Return lowest spill slot index. int getLowSpillSlot() const { return LowSpillSlot; |