mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
TargetRegisterInfo: Provide a way to check assigned registers in getRegAllocationHints()
Pass a const reference to LiveRegMatrix to getRegAllocationHints() because some targets can prodive better hints if they can test whether a physreg has been used for register allocation yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242340 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
71da3635d9
commit
2aa5727755
@ -32,6 +32,7 @@ class RegScavenger;
|
|||||||
template<class T> class SmallVectorImpl;
|
template<class T> class SmallVectorImpl;
|
||||||
class VirtRegMap;
|
class VirtRegMap;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
class LiveRegMatrix;
|
||||||
|
|
||||||
class TargetRegisterClass {
|
class TargetRegisterClass {
|
||||||
public:
|
public:
|
||||||
@ -709,7 +710,9 @@ public:
|
|||||||
ArrayRef<MCPhysReg> Order,
|
ArrayRef<MCPhysReg> Order,
|
||||||
SmallVectorImpl<MCPhysReg> &Hints,
|
SmallVectorImpl<MCPhysReg> &Hints,
|
||||||
const MachineFunction &MF,
|
const MachineFunction &MF,
|
||||||
const VirtRegMap *VRM = nullptr) const;
|
const VirtRegMap *VRM = nullptr,
|
||||||
|
const LiveRegMatrix *Matrix = nullptr)
|
||||||
|
const;
|
||||||
|
|
||||||
/// updateRegAllocHint - A callback to allow target a chance to update
|
/// updateRegAllocHint - A callback to allow target a chance to update
|
||||||
/// register allocation hints when a register is "changed" (e.g. coalesced)
|
/// register allocation hints when a register is "changed" (e.g. coalesced)
|
||||||
|
@ -29,12 +29,13 @@ using namespace llvm;
|
|||||||
// Compare VirtRegMap::getRegAllocPref().
|
// Compare VirtRegMap::getRegAllocPref().
|
||||||
AllocationOrder::AllocationOrder(unsigned VirtReg,
|
AllocationOrder::AllocationOrder(unsigned VirtReg,
|
||||||
const VirtRegMap &VRM,
|
const VirtRegMap &VRM,
|
||||||
const RegisterClassInfo &RegClassInfo)
|
const RegisterClassInfo &RegClassInfo,
|
||||||
|
const LiveRegMatrix *Matrix)
|
||||||
: Pos(0) {
|
: Pos(0) {
|
||||||
const MachineFunction &MF = VRM.getMachineFunction();
|
const MachineFunction &MF = VRM.getMachineFunction();
|
||||||
const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo();
|
const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo();
|
||||||
Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg));
|
Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg));
|
||||||
TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM);
|
TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM, Matrix);
|
||||||
rewind();
|
rewind();
|
||||||
|
|
||||||
DEBUG({
|
DEBUG({
|
||||||
|
@ -24,6 +24,7 @@ namespace llvm {
|
|||||||
|
|
||||||
class RegisterClassInfo;
|
class RegisterClassInfo;
|
||||||
class VirtRegMap;
|
class VirtRegMap;
|
||||||
|
class LiveRegMatrix;
|
||||||
|
|
||||||
class LLVM_LIBRARY_VISIBILITY AllocationOrder {
|
class LLVM_LIBRARY_VISIBILITY AllocationOrder {
|
||||||
SmallVector<MCPhysReg, 16> Hints;
|
SmallVector<MCPhysReg, 16> Hints;
|
||||||
@ -37,7 +38,8 @@ public:
|
|||||||
/// @param RegClassInfo Information about reserved and allocatable registers.
|
/// @param RegClassInfo Information about reserved and allocatable registers.
|
||||||
AllocationOrder(unsigned VirtReg,
|
AllocationOrder(unsigned VirtReg,
|
||||||
const VirtRegMap &VRM,
|
const VirtRegMap &VRM,
|
||||||
const RegisterClassInfo &RegClassInfo);
|
const RegisterClassInfo &RegClassInfo,
|
||||||
|
const LiveRegMatrix *Matrix);
|
||||||
|
|
||||||
/// Get the allocation order without reordered hints.
|
/// Get the allocation order without reordered hints.
|
||||||
ArrayRef<MCPhysReg> getOrder() const { return Order; }
|
ArrayRef<MCPhysReg> getOrder() const { return Order; }
|
||||||
|
@ -223,7 +223,7 @@ unsigned RABasic::selectOrSplit(LiveInterval &VirtReg,
|
|||||||
SmallVector<unsigned, 8> PhysRegSpillCands;
|
SmallVector<unsigned, 8> PhysRegSpillCands;
|
||||||
|
|
||||||
// Check for an available register in this class.
|
// Check for an available register in this class.
|
||||||
AllocationOrder Order(VirtReg.reg, *VRM, RegClassInfo);
|
AllocationOrder Order(VirtReg.reg, *VRM, RegClassInfo, Matrix);
|
||||||
while (unsigned PhysReg = Order.next()) {
|
while (unsigned PhysReg = Order.next()) {
|
||||||
// Check for interference in PhysReg
|
// Check for interference in PhysReg
|
||||||
switch (Matrix->checkInterference(VirtReg, PhysReg)) {
|
switch (Matrix->checkInterference(VirtReg, PhysReg)) {
|
||||||
|
@ -637,7 +637,7 @@ unsigned RAGreedy::tryAssign(LiveInterval &VirtReg,
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
unsigned RAGreedy::canReassign(LiveInterval &VirtReg, unsigned PrevReg) {
|
unsigned RAGreedy::canReassign(LiveInterval &VirtReg, unsigned PrevReg) {
|
||||||
AllocationOrder Order(VirtReg.reg, *VRM, RegClassInfo);
|
AllocationOrder Order(VirtReg.reg, *VRM, RegClassInfo, Matrix);
|
||||||
unsigned PhysReg;
|
unsigned PhysReg;
|
||||||
while ((PhysReg = Order.next())) {
|
while ((PhysReg = Order.next())) {
|
||||||
if (PhysReg == PrevReg)
|
if (PhysReg == PrevReg)
|
||||||
@ -2450,7 +2450,7 @@ unsigned RAGreedy::selectOrSplitImpl(LiveInterval &VirtReg,
|
|||||||
unsigned Depth) {
|
unsigned Depth) {
|
||||||
unsigned CostPerUseLimit = ~0u;
|
unsigned CostPerUseLimit = ~0u;
|
||||||
// First try assigning a free register.
|
// First try assigning a free register.
|
||||||
AllocationOrder Order(VirtReg.reg, *VRM, RegClassInfo);
|
AllocationOrder Order(VirtReg.reg, *VRM, RegClassInfo, Matrix);
|
||||||
if (unsigned PhysReg = tryAssign(VirtReg, Order, NewVRegs)) {
|
if (unsigned PhysReg = tryAssign(VirtReg, Order, NewVRegs)) {
|
||||||
// When NewVRegs is not empty, we may have made decisions such as evicting
|
// When NewVRegs is not empty, we may have made decisions such as evicting
|
||||||
// a virtual register, go with the earlier decisions and use the physical
|
// a virtual register, go with the earlier decisions and use the physical
|
||||||
|
@ -266,7 +266,8 @@ TargetRegisterInfo::getRegAllocationHints(unsigned VirtReg,
|
|||||||
ArrayRef<MCPhysReg> Order,
|
ArrayRef<MCPhysReg> Order,
|
||||||
SmallVectorImpl<MCPhysReg> &Hints,
|
SmallVectorImpl<MCPhysReg> &Hints,
|
||||||
const MachineFunction &MF,
|
const MachineFunction &MF,
|
||||||
const VirtRegMap *VRM) const {
|
const VirtRegMap *VRM,
|
||||||
|
const LiveRegMatrix *Matrix) const {
|
||||||
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
||||||
std::pair<unsigned, unsigned> Hint = MRI.getRegAllocationHint(VirtReg);
|
std::pair<unsigned, unsigned> Hint = MRI.getRegAllocationHint(VirtReg);
|
||||||
|
|
||||||
|
@ -225,7 +225,8 @@ ARMBaseRegisterInfo::getRegAllocationHints(unsigned VirtReg,
|
|||||||
ArrayRef<MCPhysReg> Order,
|
ArrayRef<MCPhysReg> Order,
|
||||||
SmallVectorImpl<MCPhysReg> &Hints,
|
SmallVectorImpl<MCPhysReg> &Hints,
|
||||||
const MachineFunction &MF,
|
const MachineFunction &MF,
|
||||||
const VirtRegMap *VRM) const {
|
const VirtRegMap *VRM,
|
||||||
|
const LiveRegMatrix *Matrix) const {
|
||||||
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
const MachineRegisterInfo &MRI = MF.getRegInfo();
|
||||||
std::pair<unsigned, unsigned> Hint = MRI.getRegAllocationHint(VirtReg);
|
std::pair<unsigned, unsigned> Hint = MRI.getRegAllocationHint(VirtReg);
|
||||||
|
|
||||||
|
@ -126,7 +126,8 @@ public:
|
|||||||
ArrayRef<MCPhysReg> Order,
|
ArrayRef<MCPhysReg> Order,
|
||||||
SmallVectorImpl<MCPhysReg> &Hints,
|
SmallVectorImpl<MCPhysReg> &Hints,
|
||||||
const MachineFunction &MF,
|
const MachineFunction &MF,
|
||||||
const VirtRegMap *VRM) const override;
|
const VirtRegMap *VRM,
|
||||||
|
const LiveRegMatrix *Matrix) const override;
|
||||||
|
|
||||||
void updateRegAllocHint(unsigned Reg, unsigned NewReg,
|
void updateRegAllocHint(unsigned Reg, unsigned NewReg,
|
||||||
MachineFunction &MF) const override;
|
MachineFunction &MF) const override;
|
||||||
|
Loading…
Reference in New Issue
Block a user