diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2003-12-21 20:19:10 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2003-12-21 20:19:10 +0000 |
commit | 2665d9c6f90b768fc21eb6208e08136cc78fd63b (patch) | |
tree | bdfca043242056725b3d303f43bc4fa0b6d241ba /llvm/lib/CodeGen/LiveIntervals.cpp | |
parent | 7b432f77acad493fbf44e7cfa4f70888c5aa444f (diff) | |
download | bcm5719-llvm-2665d9c6f90b768fc21eb6208e08136cc78fd63b.tar.gz bcm5719-llvm-2665d9c6f90b768fc21eb6208e08136cc78fd63b.zip |
Change weight into a float so that we can take into account the
nesting level when computing it. Right now the allocator uses:
w = sum_over_defs_uses( 10 ^ nesting level );
llvm-svn: 10569
Diffstat (limited to 'llvm/lib/CodeGen/LiveIntervals.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveIntervals.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp index 2a0ab9e35d2..05b4f5a1245 100644 --- a/llvm/lib/CodeGen/LiveIntervals.cpp +++ b/llvm/lib/CodeGen/LiveIntervals.cpp @@ -18,6 +18,7 @@ #define DEBUG_TYPE "liveintervals" #include "llvm/CodeGen/LiveIntervals.h" #include "llvm/Function.h" +#include "llvm/Analysis/LoopInfo.h" #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" @@ -32,8 +33,9 @@ #include "Support/Debug.h" #include "Support/DepthFirstIterator.h" #include "Support/Statistic.h" -#include <limits> +#include <cmath> #include <iostream> +#include <limits> using namespace llvm; @@ -51,6 +53,7 @@ void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const AU.addPreservedID(PHIEliminationID); AU.addRequiredID(PHIEliminationID); AU.addRequiredID(TwoAddressInstructionPassID); + AU.addRequired<LoopInfo>(); MachineFunctionPass::getAnalysisUsage(AU); } @@ -251,12 +254,17 @@ void LiveIntervals::computeIntervals() { DEBUG(std::cerr << "computing live intervals:\n"); + const LoopInfo& loopInfo = getAnalysis<LoopInfo>(); + for (MbbIndex2MbbMap::iterator it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end(); it != itEnd; ++it) { MachineBasicBlock* mbb = it->second; DEBUG(std::cerr << "machine basic block: " << mbb->getBasicBlock()->getName() << "\n"); + + unsigned loopDepth = loopInfo.getLoopDepth(mbb->getBasicBlock()); + for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end(); mi != miEnd; ++mi) { MachineInstr* instr = *mi; @@ -292,7 +300,7 @@ void LiveIntervals::computeIntervals() Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg); if (r2iit != r2iMap_.end() && reg >= MRegisterInfo::FirstVirtualRegister) - ++intervals_[r2iit->second].weight; + intervals_[r2iit->second].weight += pow(10.0F, loopDepth); } } } @@ -305,7 +313,7 @@ void LiveIntervals::computeIntervals() LiveIntervals::Interval::Interval(unsigned r) : reg(r), weight((r < MRegisterInfo::FirstVirtualRegister ? - std::numeric_limits<unsigned>::max() : 0)) + std::numeric_limits<float>::max() : 0.0F)) { } |