[llvm] r194417 - CalcSpillWeights: allow overidding the spill weight normalizing function
Arnaud A. de Grandmaison
arnaud.adegm at gmail.com
Mon Nov 11 11:56:14 PST 2013
Author: aadg
Date: Mon Nov 11 13:56:14 2013
New Revision: 194417
URL: http://llvm.org/viewvc/llvm-project?rev=194417&view=rev
Log:
CalcSpillWeights: allow overidding the spill weight normalizing function
This will enable the PBQP register allocator to provide its own normalizing function.
No functionnal change.
Modified:
llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h
llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp
Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h?rev=194417&r1=194416&r2=194417&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h (original)
+++ llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h Mon Nov 11 13:56:14 2013
@@ -43,16 +43,23 @@ namespace llvm {
/// \brief Calculate auxiliary information for a virtual register such as its
/// spill weight and allocation hint.
class VirtRegAuxInfo {
+ public:
+ typedef float (*NormalizingFn)(float, unsigned);
+
+ private:
MachineFunction &MF;
LiveIntervals &LIS;
const MachineLoopInfo &Loops;
const MachineBlockFrequencyInfo &MBFI;
DenseMap<unsigned, float> Hint;
+ NormalizingFn normalize;
+
public:
VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis,
const MachineLoopInfo &loops,
- const MachineBlockFrequencyInfo &mbfi)
- : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi) {}
+ const MachineBlockFrequencyInfo &mbfi,
+ NormalizingFn norm = normalizeSpillWeight)
+ : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi), normalize(norm) {}
/// \brief (re)compute li's spill weight and allocation hint.
void calculateSpillWeightAndHint(LiveInterval &li);
@@ -62,7 +69,9 @@ namespace llvm {
/// live intervals.
void calculateSpillWeightsAndHints(LiveIntervals &LIS, MachineFunction &MF,
const MachineLoopInfo &MLI,
- const MachineBlockFrequencyInfo &MBFI);
+ const MachineBlockFrequencyInfo &MBFI,
+ VirtRegAuxInfo::NormalizingFn norm =
+ normalizeSpillWeight);
}
#endif // LLVM_CODEGEN_CALCSPILLWEIGHTS_H
Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=194417&r1=194416&r2=194417&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original)
+++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Mon Nov 11 13:56:14 2013
@@ -25,12 +25,13 @@ using namespace llvm;
void llvm::calculateSpillWeightsAndHints(LiveIntervals &LIS,
MachineFunction &MF,
const MachineLoopInfo &MLI,
- const MachineBlockFrequencyInfo &MBFI) {
+ const MachineBlockFrequencyInfo &MBFI,
+ VirtRegAuxInfo::NormalizingFn norm) {
DEBUG(dbgs() << "********** Compute Spill Weights **********\n"
<< "********** Function: " << MF.getName() << '\n');
MachineRegisterInfo &MRI = MF.getRegInfo();
- VirtRegAuxInfo VRAI(MF, LIS, MLI, MBFI);
+ VirtRegAuxInfo VRAI(MF, LIS, MLI, MBFI, norm);
for (unsigned i = 0, e = MRI.getNumVirtRegs(); i != e; ++i) {
unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
if (MRI.reg_nodbg_empty(Reg))
@@ -182,5 +183,5 @@ VirtRegAuxInfo::calculateSpillWeightAndH
if (isRematerializable(li, LIS, *MF.getTarget().getInstrInfo()))
totalWeight *= 0.5F;
- li.weight = normalizeSpillWeight(totalWeight, li.getSize());
+ li.weight = normalize(totalWeight, li.getSize());
}
More information about the llvm-commits
mailing list