aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-27 21:22:48 +0000
committerDan Gohman <gohman@apple.com>2009-06-27 21:22:48 +0000
commit9b0abfe769b6e8ebddba457ac2d1631df204c8ad (patch)
tree7a6435cbcafd6e8867ec89dfa8ab90f371f323bd
parentc6475cbe49a1f956e001a7cc5b695a92f6603aee (diff)
downloadexternal_llvm-9b0abfe769b6e8ebddba457ac2d1631df204c8ad.zip
external_llvm-9b0abfe769b6e8ebddba457ac2d1631df204c8ad.tar.gz
external_llvm-9b0abfe769b6e8ebddba457ac2d1631df204c8ad.tar.bz2
Eliminate a layer of indirection in LoopInfo and MachineLoopInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74394 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/LoopInfo.h52
-rw-r--r--include/llvm/CodeGen/MachineLoopInfo.h48
-rw-r--r--lib/Analysis/LoopInfo.cpp2
-rw-r--r--lib/CodeGen/MachineLoopInfo.cpp2
4 files changed, 52 insertions, 52 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h
index 9e5f57e..8b293cb 100644
--- a/include/llvm/Analysis/LoopInfo.h
+++ b/include/llvm/Analysis/LoopInfo.h
@@ -662,7 +662,9 @@ class LoopInfoBase {
std::map<BlockT*, LoopBase<BlockT>*> BBMap;
std::vector<LoopBase<BlockT>*> TopLevelLoops;
friend class LoopBase<BlockT>;
-
+
+ void operator=(const LoopInfoBase &); // do not implement
+ LoopInfoBase(const LoopInfo &); // do not implement
public:
LoopInfoBase() { }
~LoopInfoBase() { releaseMemory(); }
@@ -962,61 +964,59 @@ public:
};
class LoopInfo : public FunctionPass {
- LoopInfoBase<BasicBlock>* LI;
+ LoopInfoBase<BasicBlock> LI;
friend class LoopBase<BasicBlock>;
-
+
+ void operator=(const LoopInfo &); // do not implement
+ LoopInfo(const LoopInfo &); // do not implement
public:
static char ID; // Pass identification, replacement for typeid
- LoopInfo() : FunctionPass(&ID) {
- LI = new LoopInfoBase<BasicBlock>();
- }
-
- ~LoopInfo() { delete LI; }
+ LoopInfo() : FunctionPass(&ID) {}
- LoopInfoBase<BasicBlock>& getBase() { return *LI; }
+ LoopInfoBase<BasicBlock>& getBase() { return LI; }
/// iterator/begin/end - The interface to the top-level loops in the current
/// function.
///
- typedef std::vector<Loop*>::const_iterator iterator;
- inline iterator begin() const { return LI->begin(); }
- inline iterator end() const { return LI->end(); }
- bool empty() const { return LI->empty(); }
+ typedef LoopInfoBase<BasicBlock>::iterator iterator;
+ inline iterator begin() const { return LI.begin(); }
+ inline iterator end() const { return LI.end(); }
+ bool empty() const { return LI.empty(); }
/// getLoopFor - Return the inner most loop that BB lives in. If a basic
/// block is in no loop (for example the entry node), null is returned.
///
inline Loop *getLoopFor(const BasicBlock *BB) const {
- return LI->getLoopFor(BB);
+ return LI.getLoopFor(BB);
}
/// operator[] - same as getLoopFor...
///
inline const Loop *operator[](const BasicBlock *BB) const {
- return LI->getLoopFor(BB);
+ return LI.getLoopFor(BB);
}
/// getLoopDepth - Return the loop nesting level of the specified block. A
/// depth of 0 means the block is not inside any loop.
///
inline unsigned getLoopDepth(const BasicBlock *BB) const {
- return LI->getLoopDepth(BB);
+ return LI.getLoopDepth(BB);
}
// isLoopHeader - True if the block is a loop header node
inline bool isLoopHeader(BasicBlock *BB) const {
- return LI->isLoopHeader(BB);
+ return LI.isLoopHeader(BB);
}
/// runOnFunction - Calculate the natural loop information.
///
virtual bool runOnFunction(Function &F);
- virtual void releaseMemory() { LI->releaseMemory(); }
+ virtual void releaseMemory() { LI.releaseMemory(); }
virtual void print(std::ostream &O, const Module* M = 0) const {
- if (O) LI->print(O, M);
+ LI.print(O, M);
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
@@ -1024,32 +1024,32 @@ public:
/// removeLoop - This removes the specified top-level loop from this loop info
/// object. The loop is not deleted, as it will presumably be inserted into
/// another loop.
- inline Loop *removeLoop(iterator I) { return LI->removeLoop(I); }
+ inline Loop *removeLoop(iterator I) { return LI.removeLoop(I); }
/// changeLoopFor - Change the top-level loop that contains BB to the
/// specified loop. This should be used by transformations that restructure
/// the loop hierarchy tree.
inline void changeLoopFor(BasicBlock *BB, Loop *L) {
- LI->changeLoopFor(BB, L);
+ LI.changeLoopFor(BB, L);
}
/// changeTopLevelLoop - Replace the specified loop in the top-level loops
/// list with the indicated loop.
inline void changeTopLevelLoop(Loop *OldLoop, Loop *NewLoop) {
- LI->changeTopLevelLoop(OldLoop, NewLoop);
+ LI.changeTopLevelLoop(OldLoop, NewLoop);
}
/// addTopLevelLoop - This adds the specified loop to the collection of
/// top-level loops.
inline void addTopLevelLoop(Loop *New) {
- LI->addTopLevelLoop(New);
+ LI.addTopLevelLoop(New);
}
/// removeBlock - This method completely removes BB from all data structures,
/// including all of the Loop objects it is nested in and our mapping from
/// BasicBlocks to loops.
void removeBlock(BasicBlock *BB) {
- LI->removeBlock(BB);
+ LI.removeBlock(BB);
}
};
@@ -1057,7 +1057,7 @@ public:
// Allow clients to walk the list of nested loops...
template <> struct GraphTraits<const Loop*> {
typedef const Loop NodeType;
- typedef std::vector<Loop*>::const_iterator ChildIteratorType;
+ typedef LoopInfo::iterator ChildIteratorType;
static NodeType *getEntryNode(const Loop *L) { return L; }
static inline ChildIteratorType child_begin(NodeType *N) {
@@ -1070,7 +1070,7 @@ template <> struct GraphTraits<const Loop*> {
template <> struct GraphTraits<Loop*> {
typedef Loop NodeType;
- typedef std::vector<Loop*>::const_iterator ChildIteratorType;
+ typedef LoopInfo::iterator ChildIteratorType;
static NodeType *getEntryNode(Loop *L) { return L; }
static inline ChildIteratorType child_begin(NodeType *N) {
diff --git a/include/llvm/CodeGen/MachineLoopInfo.h b/include/llvm/CodeGen/MachineLoopInfo.h
index 8c96308..2d19d7a 100644
--- a/include/llvm/CodeGen/MachineLoopInfo.h
+++ b/include/llvm/CodeGen/MachineLoopInfo.h
@@ -70,88 +70,88 @@ inline bool LoopBase<MachineBasicBlock>::isLCSSAForm() const {
typedef LoopBase<MachineBasicBlock> MachineLoop;
class MachineLoopInfo : public MachineFunctionPass {
- LoopInfoBase<MachineBasicBlock>* LI;
+ LoopInfoBase<MachineBasicBlock> LI;
friend class LoopBase<MachineBasicBlock>;
-
- LoopInfoBase<MachineBasicBlock>& getBase() { return *LI; }
+
+ void operator=(const MachineLoopInfo &); // do not implement
+ MachineLoopInfo(const MachineLoopInfo &); // do not implement
+
+ LoopInfoBase<MachineBasicBlock>& getBase() { return LI; }
+
public:
static char ID; // Pass identification, replacement for typeid
- MachineLoopInfo() : MachineFunctionPass(&ID) {
- LI = new LoopInfoBase<MachineBasicBlock>();
- }
-
- ~MachineLoopInfo() { delete LI; }
+ MachineLoopInfo() : MachineFunctionPass(&ID) {}
/// iterator/begin/end - The interface to the top-level loops in the current
/// function.
///
- typedef std::vector<MachineLoop*>::const_iterator iterator;
- inline iterator begin() const { return LI->begin(); }
- inline iterator end() const { return LI->end(); }
- bool empty() const { return LI->empty(); }
+ typedef LoopInfoBase<MachineBasicBlock>::iterator iterator;
+ inline iterator begin() const { return LI.begin(); }
+ inline iterator end() const { return LI.end(); }
+ bool empty() const { return LI.empty(); }
/// getLoopFor - Return the inner most loop that BB lives in. If a basic
/// block is in no loop (for example the entry node), null is returned.
///
inline MachineLoop *getLoopFor(const MachineBasicBlock *BB) const {
- return LI->getLoopFor(BB);
+ return LI.getLoopFor(BB);
}
/// operator[] - same as getLoopFor...
///
inline const MachineLoop *operator[](const MachineBasicBlock *BB) const {
- return LI->getLoopFor(BB);
+ return LI.getLoopFor(BB);
}
/// getLoopDepth - Return the loop nesting level of the specified block...
///
inline unsigned getLoopDepth(const MachineBasicBlock *BB) const {
- return LI->getLoopDepth(BB);
+ return LI.getLoopDepth(BB);
}
// isLoopHeader - True if the block is a loop header node
inline bool isLoopHeader(MachineBasicBlock *BB) const {
- return LI->isLoopHeader(BB);
+ return LI.isLoopHeader(BB);
}
/// runOnFunction - Calculate the natural loop information.
///
virtual bool runOnMachineFunction(MachineFunction &F);
- virtual void releaseMemory() { LI->releaseMemory(); }
+ virtual void releaseMemory() { LI.releaseMemory(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
/// removeLoop - This removes the specified top-level loop from this loop info
/// object. The loop is not deleted, as it will presumably be inserted into
/// another loop.
- inline MachineLoop *removeLoop(iterator I) { return LI->removeLoop(I); }
+ inline MachineLoop *removeLoop(iterator I) { return LI.removeLoop(I); }
/// changeLoopFor - Change the top-level loop that contains BB to the
/// specified loop. This should be used by transformations that restructure
/// the loop hierarchy tree.
inline void changeLoopFor(MachineBasicBlock *BB, MachineLoop *L) {
- LI->changeLoopFor(BB, L);
+ LI.changeLoopFor(BB, L);
}
/// changeTopLevelLoop - Replace the specified loop in the top-level loops
/// list with the indicated loop.
inline void changeTopLevelLoop(MachineLoop *OldLoop, MachineLoop *NewLoop) {
- LI->changeTopLevelLoop(OldLoop, NewLoop);
+ LI.changeTopLevelLoop(OldLoop, NewLoop);
}
/// addTopLevelLoop - This adds the specified loop to the collection of
/// top-level loops.
inline void addTopLevelLoop(MachineLoop *New) {
- LI->addTopLevelLoop(New);
+ LI.addTopLevelLoop(New);
}
/// removeBlock - This method completely removes BB from all data structures,
/// including all of the Loop objects it is nested in and our mapping from
/// MachineBasicBlocks to loops.
void removeBlock(MachineBasicBlock *BB) {
- LI->removeBlock(BB);
+ LI.removeBlock(BB);
}
};
@@ -159,7 +159,7 @@ public:
// Allow clients to walk the list of nested loops...
template <> struct GraphTraits<const MachineLoop*> {
typedef const MachineLoop NodeType;
- typedef std::vector<MachineLoop*>::const_iterator ChildIteratorType;
+ typedef MachineLoopInfo::iterator ChildIteratorType;
static NodeType *getEntryNode(const MachineLoop *L) { return L; }
static inline ChildIteratorType child_begin(NodeType *N) {
@@ -172,7 +172,7 @@ template <> struct GraphTraits<const MachineLoop*> {
template <> struct GraphTraits<MachineLoop*> {
typedef MachineLoop NodeType;
- typedef std::vector<MachineLoop*>::const_iterator ChildIteratorType;
+ typedef MachineLoopInfo::iterator ChildIteratorType;
static NodeType *getEntryNode(MachineLoop *L) { return L; }
static inline ChildIteratorType child_begin(NodeType *N) {
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index a0d3974..bb53589 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -39,7 +39,7 @@ X("loops", "Natural Loop Information", true, true);
//
bool LoopInfo::runOnFunction(Function &) {
releaseMemory();
- LI->Calculate(getAnalysis<DominatorTree>().getBase()); // Update
+ LI.Calculate(getAnalysis<DominatorTree>().getBase()); // Update
return false;
}
diff --git a/lib/CodeGen/MachineLoopInfo.cpp b/lib/CodeGen/MachineLoopInfo.cpp
index 68ddb7b..ff56f4d 100644
--- a/lib/CodeGen/MachineLoopInfo.cpp
+++ b/lib/CodeGen/MachineLoopInfo.cpp
@@ -30,7 +30,7 @@ const PassInfo *const llvm::MachineLoopInfoID = &X;
bool MachineLoopInfo::runOnMachineFunction(MachineFunction &) {
releaseMemory();
- LI->Calculate(getAnalysis<MachineDominatorTree>().getBase()); // Update
+ LI.Calculate(getAnalysis<MachineDominatorTree>().getBase()); // Update
return false;
}