mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-21 16:25:23 +00:00
Provide a target override for the cost of using a callee-saved register
for the first time. Thanks Andy for the discussion. rdar://16162005 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204979 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -689,6 +689,11 @@ public:
|
|||||||
/// debugging downstream codegen failures exposed by regalloc.
|
/// debugging downstream codegen failures exposed by regalloc.
|
||||||
virtual bool mayOverrideLocalAssignment() const { return true; }
|
virtual bool mayOverrideLocalAssignment() const { return true; }
|
||||||
|
|
||||||
|
/// Allow the target to override the cost of using a callee-saved register for
|
||||||
|
/// the first time. Default value of 0 means we will use a callee-saved
|
||||||
|
/// register if it is available.
|
||||||
|
virtual unsigned getCSRFirstUseCost() const { return 0; }
|
||||||
|
|
||||||
/// requiresRegisterScavenging - returns true if the target requires (and can
|
/// requiresRegisterScavenging - returns true if the target requires (and can
|
||||||
/// make use of) the register scavenger.
|
/// make use of) the register scavenger.
|
||||||
virtual bool requiresRegisterScavenging(const MachineFunction &MF) const {
|
virtual bool requiresRegisterScavenging(const MachineFunction &MF) const {
|
||||||
|
@@ -2123,7 +2123,10 @@ unsigned RAGreedy::tryAssignCSRFirstTime(LiveInterval &VirtReg,
|
|||||||
unsigned PhysReg,
|
unsigned PhysReg,
|
||||||
unsigned &CostPerUseLimit,
|
unsigned &CostPerUseLimit,
|
||||||
SmallVectorImpl<unsigned> &NewVRegs) {
|
SmallVectorImpl<unsigned> &NewVRegs) {
|
||||||
BlockFrequency CSRCost(CSRFirstTimeCost);
|
// We use the larger one out of the command-line option and the value report
|
||||||
|
// by TRI.
|
||||||
|
BlockFrequency CSRCost(std::max((unsigned)CSRFirstTimeCost,
|
||||||
|
TRI->getCSRFirstUseCost()));
|
||||||
if (getStage(VirtReg) == RS_Spill && VirtReg.isSpillable()) {
|
if (getStage(VirtReg) == RS_Spill && VirtReg.isSpillable()) {
|
||||||
// We choose spill over using the CSR for the first time if the spill cost
|
// We choose spill over using the CSR for the first time if the spill cost
|
||||||
// is lower than CSRCost.
|
// is lower than CSRCost.
|
||||||
@@ -2172,7 +2175,8 @@ unsigned RAGreedy::selectOrSplitImpl(LiveInterval &VirtReg,
|
|||||||
// 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
|
||||||
// register.
|
// register.
|
||||||
if (CSRFirstTimeCost > 0 && CSRFirstUse && NewVRegs.empty()) {
|
if ((CSRFirstTimeCost || TRI->getCSRFirstUseCost()) &&
|
||||||
|
CSRFirstUse && NewVRegs.empty()) {
|
||||||
unsigned CSRReg = tryAssignCSRFirstTime(VirtReg, Order, PhysReg,
|
unsigned CSRReg = tryAssignCSRFirstTime(VirtReg, Order, PhysReg,
|
||||||
CostPerUseLimit, NewVRegs);
|
CostPerUseLimit, NewVRegs);
|
||||||
if (CSRReg || !NewVRegs.empty())
|
if (CSRReg || !NewVRegs.empty())
|
||||||
|
Reference in New Issue
Block a user