LLVM 22.0.0git
|
RegAllocBase provides the register allocation driver and interface that can be extended to add interesting heuristics. More...
#include "CodeGen/RegAllocBase.h"
Static Public Attributes | |
static bool | VerifyEnabled = false |
VerifyEnabled - True when -verify-regalloc is given. | |
Protected Member Functions | |
RegAllocBase (const RegAllocFilterFunc F=nullptr) | |
virtual | ~RegAllocBase ()=default |
void | init (VirtRegMap &vrm, LiveIntervals &lis, LiveRegMatrix &mat) |
bool | shouldAllocateRegister (Register Reg) |
Get whether a given register should be allocated. | |
void | allocatePhysRegs () |
virtual void | postOptimization () |
void | cleanupFailedVReg (Register FailedVReg, MCRegister PhysReg, SmallVectorImpl< Register > &SplitRegs) |
Perform cleanups on registers that failed to allocate. | |
virtual Spiller & | spiller ()=0 |
virtual void | enqueueImpl (const LiveInterval *LI)=0 |
enqueue - Add VirtReg to the priority queue of unassigned registers. | |
void | enqueue (const LiveInterval *LI) |
enqueue - Add VirtReg to the priority queue of unassigned registers. | |
virtual const LiveInterval * | dequeue ()=0 |
dequeue - Return the next unassigned register, or NULL. | |
virtual MCRegister | selectOrSplit (const LiveInterval &VirtReg, SmallVectorImpl< Register > &splitLVRs)=0 |
MCPhysReg | getErrorAssignment (const TargetRegisterClass &RC, const MachineInstr *CtxMI=nullptr) |
Query a physical register to use as a filler in contexts where the allocation has failed. | |
virtual void | aboutToRemoveInterval (const LiveInterval &LI) |
Method called when the allocator is about to remove a LiveInterval. | |
Protected Attributes | |
const TargetRegisterInfo * | TRI = nullptr |
MachineRegisterInfo * | MRI = nullptr |
VirtRegMap * | VRM = nullptr |
LiveIntervals * | LIS = nullptr |
LiveRegMatrix * | Matrix = nullptr |
RegisterClassInfo | RegClassInfo |
SmallPtrSet< MachineInstr *, 32 > | DeadRemats |
Inst which is a def of an original reg and whose defs are already all dead after remat is saved in DeadRemats. | |
SmallSet< Register, 2 > | FailedVRegs |
Static Protected Attributes | |
static const char | TimerGroupName [] = "regalloc" |
static const char | TimerGroupDescription [] = "Register Allocation" |
RegAllocBase provides the register allocation driver and interface that can be extended to add interesting heuristics.
Register allocators must override the selectOrSplit() method to implement live range splitting. They must also override enqueue/dequeue to provide an assignment order.
Definition at line 63 of file RegAllocBase.h.
|
inlineprotected |
Definition at line 86 of file RegAllocBase.h.
|
protectedvirtualdefault |
|
inlineprotectedvirtual |
Method called when the allocator is about to remove a LiveInterval.
Reimplemented in llvm::RAGreedy.
Definition at line 144 of file RegAllocBase.h.
Referenced by allocatePhysRegs().
|
protected |
Definition at line 87 of file RegAllocBase.cpp.
References aboutToRemoveInterval(), assert(), llvm::LiveRegMatrix::assign(), cleanupFailedVReg(), llvm::dbgs(), dequeue(), llvm::LiveRange::empty(), enqueue(), getErrorAssignment(), llvm::LiveIntervals::getInterval(), llvm::MachineRegisterInfo::getRegClass(), llvm::TargetRegisterInfo::getRegClassName(), llvm::LiveIntervals::hasInterval(), llvm::VirtRegMap::hasPhys(), llvm::LiveRegMatrix::invalidateVirtRegs(), llvm::Register::isVirtual(), LIS, LLVM_DEBUG, Matrix, MI, MRI, llvm::LiveInterval::reg(), llvm::MachineRegisterInfo::reg_instructions(), llvm::MachineRegisterInfo::reg_nodbg_empty(), llvm::LiveIntervals::removeInterval(), selectOrSplit(), TRI, and VRM.
Referenced by llvm::RAGreedy::run(), and llvm::RABasic::runOnMachineFunction().
|
protected |
Perform cleanups on registers that failed to allocate.
This hacks on the liveness in order to avoid spurious verifier errors in later passes.
Definition at line 165 of file RegAllocBase.cpp.
References llvm::MachineRegisterInfo::isReserved(), llvm::MCRegAliasIterator::isValid(), LIS, MRI, llvm::MachineRegisterInfo::reg_operands(), llvm::LiveIntervals::removeInterval(), llvm::MachineRegisterInfo::replaceRegWith(), and TRI.
Referenced by allocatePhysRegs().
|
protectedpure virtual |
dequeue - Return the next unassigned register, or NULL.
Implemented in llvm::RABasic, and llvm::RAGreedy.
Referenced by allocatePhysRegs().
|
protected |
enqueue - Add VirtReg to the priority queue of unassigned registers.
Definition at line 194 of file RegAllocBase.cpp.
References assert(), llvm::dbgs(), enqueueImpl(), llvm::VirtRegMap::hasPhys(), LLVM_DEBUG, llvm::printReg(), llvm::LiveInterval::reg(), shouldAllocateRegister(), TRI, and VRM.
Referenced by allocatePhysRegs().
|
protectedpure virtual |
enqueue - Add VirtReg to the priority queue of unassigned registers.
Implemented in llvm::RABasic, and llvm::RAGreedy.
Referenced by enqueue().
|
protected |
Query a physical register to use as a filler in contexts where the allocation has failed.
This will raise an error, but not abort the compilation.
Definition at line 211 of file RegAllocBase.cpp.
References assert(), Context, llvm::MachineInstr::emitInlineAsmError(), llvm::ArrayRef< T >::empty(), llvm::ArrayRef< T >::front(), llvm::Function::getContext(), llvm::MachineInstr::getDebugLoc(), llvm::MachineFunction::getFunction(), llvm::VirtRegMap::getMachineFunction(), llvm::RegisterClassInfo::getOrder(), llvm::MachineFunction::getProperties(), llvm::TargetRegisterClass::getRegisters(), llvm::MachineInstr::isInlineAsm(), RegClassInfo, and VRM.
Referenced by allocatePhysRegs().
|
protected |
Definition at line 59 of file RegAllocBase.cpp.
References FailedVRegs, llvm::MachineRegisterInfo::freezeReservedRegs(), llvm::VirtRegMap::getMachineFunction(), llvm::VirtRegMap::getRegInfo(), llvm::VirtRegMap::getTargetRegInfo(), LIS, Matrix, MRI, RegClassInfo, llvm::RegisterClassInfo::runOnMachineFunction(), TRI, and VRM.
Referenced by llvm::RAGreedy::run(), and llvm::RABasic::runOnMachineFunction().
|
protectedvirtual |
Definition at line 156 of file RegAllocBase.cpp.
References DeadRemats, LIS, llvm::Spiller::postOptimization(), llvm::LiveIntervals::RemoveMachineInstrFromMaps(), and spiller().
Referenced by llvm::RAGreedy::run(), and llvm::RABasic::runOnMachineFunction().
|
protectedpure virtual |
Implemented in llvm::RAGreedy, and llvm::RABasic.
Referenced by allocatePhysRegs().
|
protectedpure virtual |
Implemented in llvm::RABasic, and llvm::RAGreedy.
Referenced by postOptimization().
|
protected |
Inst which is a def of an original reg and whose defs are already all dead after remat is saved in DeadRemats.
The deletion of such inst is postponed till all the allocations are done, so its remat expr is always available for the remat of all the siblings of the original reg.
Definition at line 83 of file RegAllocBase.h.
Referenced by postOptimization(), llvm::RABasic::selectOrSplit(), and llvm::RABasic::spillInterferences().
Definition at line 85 of file RegAllocBase.h.
Referenced by init().
|
protected |
Definition at line 70 of file RegAllocBase.h.
Referenced by allocatePhysRegs(), cleanupFailedVReg(), init(), postOptimization(), llvm::RAGreedy::RAGreedy(), llvm::RAGreedy::RequiredAnalyses::RequiredAnalyses(), llvm::RAGreedy::run(), llvm::RABasic::runOnMachineFunction(), llvm::RABasic::selectOrSplit(), and llvm::RABasic::spillInterferences().
|
protected |
Definition at line 71 of file RegAllocBase.h.
Referenced by allocatePhysRegs(), llvm::RegAllocEvictionAdvisor::canReassign(), init(), llvm::RegAllocEvictionAdvisor::isUnusedCalleeSavedReg(), llvm::RAGreedy::RAGreedy(), llvm::RAGreedy::run(), llvm::RABasic::selectOrSplit(), and llvm::RABasic::spillInterferences().
|
protected |
Definition at line 68 of file RegAllocBase.h.
Referenced by allocatePhysRegs(), cleanupFailedVReg(), getInstReadLaneMask(), llvm::RegAllocEvictionAdvisor::getOrderLimit(), hasTiedDef(), init(), readsLaneSubset(), and shouldAllocateRegister().
|
protected |
Definition at line 72 of file RegAllocBase.h.
Referenced by llvm::RegAllocEvictionAdvisor::canAllocatePhysReg(), llvm::RegAllocEvictionAdvisor::canReassign(), getErrorAssignment(), llvm::RegAllocEvictionAdvisor::getOrderLimit(), init(), llvm::RegAllocEvictionAdvisor::isUnusedCalleeSavedReg(), and llvm::RABasic::selectOrSplit().
Definition at line 141 of file RegAllocBase.h.
Definition at line 140 of file RegAllocBase.h.
|
protected |
Definition at line 67 of file RegAllocBase.h.
Referenced by allocatePhysRegs(), assignedRegPartiallyOverlaps(), llvm::RegAllocEvictionAdvisor::canAllocatePhysReg(), llvm::RegAllocEvictionAdvisor::canReassign(), cleanupFailedVReg(), enqueue(), getInstReadLaneMask(), getNumAllocatableRegsForConstraints(), llvm::RegAllocEvictionAdvisor::getOrderLimit(), init(), readsLaneSubset(), llvm::RAGreedy::run(), shouldAllocateRegister(), and llvm::RABasic::spillInterferences().
|
static |
VerifyEnabled - True when -verify-regalloc is given.
Definition at line 148 of file RegAllocBase.h.
Referenced by llvm::RAGreedy::run().
|
protected |
Definition at line 69 of file RegAllocBase.h.
Referenced by allocatePhysRegs(), assignedRegPartiallyOverlaps(), llvm::RegAllocEvictionAdvisor::canReassign(), enqueue(), getErrorAssignment(), init(), llvm::RAGreedy::RAGreedy(), llvm::RAGreedy::RequiredAnalyses::RequiredAnalyses(), llvm::RAGreedy::run(), llvm::RABasic::runOnMachineFunction(), llvm::RABasic::selectOrSplit(), and llvm::RABasic::spillInterferences().