[llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Jan 30 16:09:11 PST 2004
Changes in directory llvm/lib/CodeGen:
LiveVariables.cpp updated: 1.15 -> 1.16
---
Log message:
Finegrainify namespacification
Implement LiveVariables::getIndexMachineBasicBlock
---
Diffs of the changes: (+17 -4)
Index: llvm/lib/CodeGen/LiveVariables.cpp
diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.15 llvm/lib/CodeGen/LiveVariables.cpp:1.16
--- llvm/lib/CodeGen/LiveVariables.cpp:1.15 Tue Jan 13 15:16:25 2004
+++ llvm/lib/CodeGen/LiveVariables.cpp Fri Jan 30 16:08:53 2004
@@ -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 @@
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 @@
return false;
}
-
-} // End llvm namespace
More information about the llvm-commits
mailing list