15 #define DEBUG_TYPE "regalloc"
48 struct CompSpillWeight {
68 std::priority_queue<LiveInterval*, std::vector<LiveInterval*>,
69 CompSpillWeight> Queue;
79 virtual const char* getPassName()
const {
80 return "Basic Register Allocator";
86 virtual void releaseMemory();
88 virtual Spiller &spiller() {
return *SpillerInstance; }
113 bool spillInterferences(
LiveInterval &VirtReg,
unsigned PhysReg,
157 MachineFunctionPass::getAnalysisUsage(AU);
160 void RABasic::releaseMemory() {
161 SpillerInstance.reset(0);
168 bool RABasic::spillInterferences(
LiveInterval &VirtReg,
unsigned PhysReg,
187 DEBUG(
dbgs() <<
"spilling " << TRI->getName(PhysReg) <<
188 " interferences with " << VirtReg <<
"\n");
189 assert(!Intfs.
empty() &&
"expected interference");
192 for (
unsigned i = 0, e = Intfs.
size(); i != e; ++i) {
196 if (!VRM->hasPhys(Spill.
reg))
205 spiller().spill(LRE);
229 while (
unsigned PhysReg = Order.next()) {
231 switch (
Matrix->checkInterference(VirtReg, PhysReg)) {
232 case LiveRegMatrix::IK_Free:
236 case LiveRegMatrix::IK_VirtReg:
249 PhysRegE = PhysRegSpillCands.
end(); PhysRegI != PhysRegE; ++PhysRegI) {
250 if (!spillInterferences(VirtReg, *PhysRegI, SplitVRegs))
253 assert(!
Matrix->checkInterference(VirtReg, *PhysRegI) &&
254 "Interference after spill.");
260 DEBUG(
dbgs() <<
"spilling: " << VirtReg <<
'\n');
264 spiller().spill(LRE);
272 DEBUG(
dbgs() <<
"********** BASIC REGISTER ALLOCATION **********\n"
273 <<
"********** Function: "
278 getAnalysis<LiveIntervals>(),
279 getAnalysis<LiveRegMatrix>());
282 getAnalysis<MachineLoopInfo>(),
283 getAnalysis<MachineBlockFrequencyInfo>());
290 DEBUG(
dbgs() <<
"Post alloc VirtRegMap:\n" << *VRM <<
"\n");
298 return new RABasic();
void push_back(const T &Elt)
AnalysisUsage & addPreserved()
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
void initializeLiveDebugVariablesPass(PassRegistry &)
bool isSpillable() const
isSpillable - Can this interval be spilled?
void initializeMachineLoopInfoPass(PassRegistry &)
void calculateSpillWeightsAndHints(LiveIntervals &LIS, MachineFunction &MF, const MachineLoopInfo &MLI, const MachineBlockFrequencyInfo &MBFI, VirtRegAuxInfo::NormalizingFn norm=normalizeSpillWeight)
Compute spill weights and allocation hints for all virtual register live intervals.
void initializeRegisterCoalescerPass(PassRegistry &)
LoopInfoBase< BlockT, LoopT > * LI
AnalysisUsage & addRequired()
static RegisterRegAlloc basicRegAlloc("basic","basic register allocator", createBasicRegisterAllocator)
ID
LLVM Calling Convention Representation.
const SmallVectorImpl< LiveInterval * > & interferingVRegs() const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
AnalysisUsage & addPreservedID(const void *ID)
void initializeMachineDominatorTreePass(PassRegistry &)
initializer< Ty > init(const Ty &Val)
void initializeSlotIndexesPass(PassRegistry &)
void initializeLiveStacksPass(PassRegistry &)
void initializeLiveIntervalsPass(PassRegistry &)
AnalysisUsage & addRequiredID(const void *ID)
FunctionPass * createBasicRegisterAllocator()
bool seenUnspillableVReg() const
void initializeMachineSchedulerPass(PassRegistry &)
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
void initializeVirtRegMapPass(PassRegistry &)
Spiller * createInlineSpiller(MachineFunctionPass &pass, MachineFunction &mf, VirtRegMap &vrm)
void initializeLiveRegMatrixPass(PassRegistry &)
unsigned collectInterferingVRegs(unsigned MaxInterferingRegs=UINT_MAX)
StringRef getName() const