diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-01-30 22:08:53 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-01-30 22:08:53 +0000 |
| commit | 0770862334c7e4ba0aa9860aa1a1980325d55578 (patch) | |
| tree | a3d1000edb0477ca6a58ab00793d4e30b06160fb /llvm/lib/CodeGen/LiveVariables.cpp | |
| parent | bc699a10d147ce39a793afc2aededc0d4180cce8 (diff) | |
| download | bcm5719-llvm-0770862334c7e4ba0aa9860aa1a1980325d55578.tar.gz bcm5719-llvm-0770862334c7e4ba0aa9860aa1a1980325d55578.zip | |
Finegrainify namespacification
Implement LiveVariables::getIndexMachineBasicBlock
llvm-svn: 11018
Diffstat (limited to 'llvm/lib/CodeGen/LiveVariables.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/LiveVariables.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp index bf78c53214c..845af13a30b 100644 --- a/llvm/lib/CodeGen/LiveVariables.cpp +++ b/llvm/lib/CodeGen/LiveVariables.cpp @@ -32,8 +32,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" - -namespace llvm { +using namespace llvm; static RegisterAnalysis<LiveVariables> X("livevars", "Live Variable Analysis"); @@ -41,6 +40,22 @@ const std::pair<MachineBasicBlock*, unsigned> & LiveVariables::getMachineBasicBlockInfo(MachineBasicBlock *MBB) const{ return BBMap.find(MBB->getBasicBlock())->second; } + +/// getIndexMachineBasicBlock() - Given a block index, return the +/// MachineBasicBlock corresponding to it. +MachineBasicBlock *LiveVariables::getIndexMachineBasicBlock(unsigned Idx) { + if (BBIdxMap.empty()) { + BBIdxMap.resize(BBMap.size()); + for (std::map<const BasicBlock*, std::pair<MachineBasicBlock*, unsigned> > + ::iterator I = BBMap.begin(), E = BBMap.end(); I != E; ++I) { + assert(BBIdxMap.size() > I->second.second &&"Indices are not sequential"); + assert(BBIdxMap[I->second.second] == 0 && "Multiple idx collision!"); + BBIdxMap[I->second.second] = I->second.first; + } + } + assert(Idx < BBIdxMap.size() && "BB Index out of range!"); + return BBIdxMap[Idx]; +} LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) { assert(RegIdx >= MRegisterInfo::FirstVirtualRegister && @@ -300,5 +315,3 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) { return false; } - -} // End llvm namespace |

