// Compare VirtRegMap::getRegAllocPref(). AllocationOrder::AllocationOrder(unsigned VirtReg, const VirtRegMap &VRM, const BitVector &ReservedRegs) : Pos(0), Reserved(ReservedRegs) { const TargetRegisterClass *RC = VRM.getRegInfo().getRegClass(VirtReg); std::pair<unsigned, unsigned> HintPair = VRM.getRegInfo().getRegAllocationHint(VirtReg); // HintPair.second is a register, phys or virt. Hint = HintPair.second; // Translate to physreg, or 0 if not assigned yet. if (TargetRegisterInfo::isVirtualRegister(Hint)) Hint = VRM.getPhys(Hint); // The remaining allocation order may depend on the hint. tie(Begin, End) = VRM.getTargetRegInfo() .getAllocationOrder(RC, HintPair.first, Hint, VRM.getMachineFunction()); // Target-dependent hints require resolution. if (HintPair.first) Hint = VRM.getTargetRegInfo().ResolveRegAllocHint(HintPair.first, Hint, VRM.getMachineFunction()); // The hint must be a valid physreg for allocation. if (Hint && (!TargetRegisterInfo::isPhysicalRegister(Hint) || !RC->contains(Hint) || ReservedRegs.test(Hint))) Hint = 0; }
void RegAllocBase::init(VirtRegMap &vrm, LiveIntervals &lis, LiveRegMatrix &mat) { TRI = &vrm.getTargetRegInfo(); MRI = &vrm.getRegInfo(); VRM = &vrm; LIS = &lis; Matrix = &mat; MRI->freezeReservedRegs(vrm.getMachineFunction()); RegClassInfo.runOnMachineFunction(vrm.getMachineFunction()); }
/// Create a new SplitEditor for editing the LiveInterval analyzed by SA. SplitEditor::SplitEditor(SplitAnalysis &sa, LiveIntervals &lis, VirtRegMap &vrm, MachineDominatorTree &mdt) : SA(sa), LIS(lis), VRM(vrm), MRI(vrm.getMachineFunction().getRegInfo()), MDT(mdt), TII(*vrm.getMachineFunction().getTarget().getInstrInfo()), TRI(*vrm.getMachineFunction().getTarget().getRegisterInfo()), Edit(0), OpenIdx(0), SpillMode(SM_Partition), RegAssign(Allocator) {}
void RegAllocBase::init(VirtRegMap &vrm, LiveIntervals &lis) { NamedRegionTimer T("Initialize", TimerGroupName, TimePassesIsEnabled); TRI = &vrm.getTargetRegInfo(); MRI = &vrm.getRegInfo(); VRM = &vrm; LIS = &lis; MRI->freezeReservedRegs(vrm.getMachineFunction()); RegClassInfo.runOnMachineFunction(vrm.getMachineFunction()); const unsigned NumRegs = TRI->getNumRegs(); if (NumRegs != PhysReg2LiveUnion.numRegs()) { PhysReg2LiveUnion.init(UnionAllocator, NumRegs); // Cache an interferece query for each physical reg Queries.reset(new LiveIntervalUnion::Query[PhysReg2LiveUnion.numRegs()]); } }
/// Create a new SplitEditor for editing the LiveInterval analyzed by SA. SplitEditor::SplitEditor(SplitAnalysis &sa, LiveIntervals &lis, VirtRegMap &vrm, SmallVectorImpl<LiveInterval*> &intervals) : sa_(sa), lis_(lis), vrm_(vrm), mri_(vrm.getMachineFunction().getRegInfo()), tii_(*vrm.getMachineFunction().getTarget().getInstrInfo()), curli_(sa_.getCurLI()), dupli_(0), openli_(0), intervals_(intervals), firstInterval(intervals_.size()) { assert(curli_ && "SplitEditor created from empty SplitAnalysis"); // Make sure curli_ is assigned a stack slot, so all our intervals get the // same slot as curli_. if (vrm_.getStackSlot(curli_->reg) == VirtRegMap::NO_STACK_SLOT) vrm_.assignVirt2StackSlot(curli_->reg); }
SplitAnalysis::SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis, const MachineLoopInfo &mli) : MF(vrm.getMachineFunction()), VRM(vrm), LIS(lis), Loops(mli), TII(*MF.getTarget().getInstrInfo()), CurLI(0), LastSplitPoint(MF.getNumBlockIDs()) {}
// Compare VirtRegMap::getRegAllocPref(). AllocationOrder::AllocationOrder(unsigned VirtReg, const VirtRegMap &VRM, const RegisterClassInfo &RegClassInfo) : Pos(0) { const MachineFunction &MF = VRM.getMachineFunction(); const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo(); Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg)); TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM); rewind(); DEBUG({ if (!Hints.empty()) { dbgs() << "hints:"; for (unsigned I = 0, E = Hints.size(); I != E; ++I) dbgs() << ' ' << PrintReg(Hints[I], TRI); dbgs() << '\n'; } });
// Compare VirtRegMap::getRegAllocPref(). AllocationOrder::AllocationOrder(unsigned VirtReg, const VirtRegMap &VRM, const RegisterClassInfo &RegClassInfo, const LiveRegMatrix *Matrix) : Pos(0), HardHints(false) { const MachineFunction &MF = VRM.getMachineFunction(); const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo(); Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg)); if (TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM, Matrix)) HardHints = true; rewind(); LLVM_DEBUG({ if (!Hints.empty()) { dbgs() << "hints:"; for (unsigned I = 0, E = Hints.size(); I != E; ++I) dbgs() << ' ' << printReg(Hints[I], TRI); dbgs() << '\n'; } });