diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-28 16:21:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-28 16:21:30 +0000 |
commit | 1b7f7dc4b45a900fae2e9b062d588a995935727a (patch) | |
tree | f0853819719944846cc56e8742935169d838249e /lib/Analysis | |
parent | 8fc2f2072de83665ae20e06929e28317f449bcdf (diff) |
Eliminate the cfg namespace, moving LoopInfo, Dominators, Interval* classes
to the global namespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2370 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/InductionVariable.cpp | 8 | ||||
-rw-r--r-- | lib/Analysis/Interval.cpp | 6 | ||||
-rw-r--r-- | lib/Analysis/IntervalPartition.cpp | 7 | ||||
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 19 | ||||
-rw-r--r-- | lib/Analysis/PostDominators.cpp | 44 | ||||
-rw-r--r-- | lib/Analysis/Writer.cpp | 24 |
6 files changed, 53 insertions, 55 deletions
diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp index 4d4306b9d0..3214b79ce6 100644 --- a/lib/Analysis/InductionVariable.cpp +++ b/lib/Analysis/InductionVariable.cpp @@ -27,7 +27,7 @@ using analysis::ExprType; -static bool isLoopInvariant(const Value *V, const cfg::Loop *L) { +static bool isLoopInvariant(const Value *V, const Loop *L) { if (isa<Constant>(V) || isa<Argument>(V) || isa<GlobalValue>(V)) return true; @@ -39,7 +39,7 @@ static bool isLoopInvariant(const Value *V, const cfg::Loop *L) { enum InductionVariable::iType InductionVariable::Classify(const Value *Start, const Value *Step, - const cfg::Loop *L = 0) { + const Loop *L = 0) { // Check for cannonical and simple linear expressions now... if (ConstantInt *CStart = dyn_cast<ConstantInt>(Start)) if (ConstantInt *CStep = dyn_cast<ConstantInt>(Step)) { @@ -60,7 +60,7 @@ InductionVariable::Classify(const Value *Start, const Value *Step, // Create an induction variable for the specified value. If it is a PHI, and // if it's recognizable, classify it and fill in instance variables. // -InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) { +InductionVariable::InductionVariable(PHINode *P, LoopInfo *LoopInfo) { InductionType = Unknown; // Assume the worst Phi = P; @@ -76,7 +76,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) { // If we have loop information, make sure that this PHI node is in the header // of a loop... // - const cfg::Loop *L = LoopInfo ? LoopInfo->getLoopFor(Phi->getParent()) : 0; + const Loop *L = LoopInfo ? LoopInfo->getLoopFor(Phi->getParent()) : 0; if (L && L->getHeader() != Phi->getParent()) return; diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp index de5d57f85e..a4aa88abdb 100644 --- a/lib/Analysis/Interval.cpp +++ b/lib/Analysis/Interval.cpp @@ -1,7 +1,7 @@ //===- Interval.cpp - Interval class code ------------------------*- C++ -*--=// // -// This file contains the definition of the cfg::Interval class, which -// represents a partition of a control flow graph of some kind. +// This file contains the definition of the Interval class, which represents a +// partition of a control flow graph of some kind. // //===----------------------------------------------------------------------===// @@ -15,7 +15,7 @@ // isLoop - Find out if there is a back edge in this interval... // -bool cfg::Interval::isLoop() const { +bool Interval::isLoop() const { // There is a loop in this interval iff one of the predecessors of the header // node lives in the interval. for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode); diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index bb0f582108..a774c5c2b2 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -1,6 +1,6 @@ //===- IntervalPartition.cpp - Interval Partition module code ----*- C++ -*--=// // -// This file contains the definition of the cfg::IntervalPartition class, which +// This file contains the definition of the IntervalPartition class, which // calculates and represent the interval partition of a function. // //===----------------------------------------------------------------------===// @@ -8,7 +8,6 @@ #include "llvm/Analysis/IntervalIterator.h" #include "Support/STLExtras.h" -using namespace cfg; using std::make_pair; AnalysisID IntervalPartition::ID(AnalysisID::create<IntervalPartition>()); @@ -19,7 +18,7 @@ AnalysisID IntervalPartition::ID(AnalysisID::create<IntervalPartition>()); // destroy - Reset state back to before function was analyzed void IntervalPartition::destroy() { - for_each(begin(), end(), deleter<cfg::Interval>); + for_each(begin(), end(), deleter<Interval>); IntervalMap.clear(); RootInterval = 0; } @@ -42,7 +41,7 @@ void IntervalPartition::addIntervalToPartition(Interval *I) { // run through all of the intervals and propogate successor info as // predecessor info. // -void IntervalPartition::updatePredecessors(cfg::Interval *Int) { +void IntervalPartition::updatePredecessors(Interval *Int) { BasicBlock *Header = Int->getHeaderNode(); for (Interval::succ_iterator I = Int->Successors.begin(), E = Int->Successors.end(); I != E; ++I) diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index bf69172676..244db30649 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -13,16 +13,16 @@ #include "Support/DepthFirstIterator.h" #include <algorithm> -AnalysisID cfg::LoopInfo::ID(AnalysisID::create<cfg::LoopInfo>()); +AnalysisID LoopInfo::ID(AnalysisID::create<LoopInfo>()); //===----------------------------------------------------------------------===// -// cfg::Loop implementation +// Loop implementation // -bool cfg::Loop::contains(BasicBlock *BB) const { +bool Loop::contains(BasicBlock *BB) const { return find(Blocks.begin(), Blocks.end(), BB) != Blocks.end(); } -void cfg::LoopInfo::releaseMemory() { +void LoopInfo::releaseMemory() { for (std::vector<Loop*>::iterator I = TopLevelLoops.begin(), E = TopLevelLoops.end(); I != E; ++I) delete *I; // Delete all of the loops... @@ -33,15 +33,15 @@ void cfg::LoopInfo::releaseMemory() { //===----------------------------------------------------------------------===// -// cfg::LoopInfo implementation +// LoopInfo implementation // -bool cfg::LoopInfo::runOnFunction(Function *F) { +bool LoopInfo::runOnFunction(Function *F) { releaseMemory(); Calculate(getAnalysis<DominatorSet>()); // Update return false; } -void cfg::LoopInfo::Calculate(const DominatorSet &DS) { +void LoopInfo::Calculate(const DominatorSet &DS) { BasicBlock *RootNode = DS.getRoot(); for (df_iterator<BasicBlock*> NI = df_begin(RootNode), @@ -53,15 +53,14 @@ void cfg::LoopInfo::Calculate(const DominatorSet &DS) { TopLevelLoops[i]->setLoopDepth(1); } -void cfg::LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { +void LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired(DominatorSet::ID); AU.addProvided(ID); } -cfg::Loop *cfg::LoopInfo::ConsiderForLoop(BasicBlock *BB, - const DominatorSet &DS) { +Loop *LoopInfo::ConsiderForLoop(BasicBlock *BB, const DominatorSet &DS) { if (BBMap.find(BB) != BBMap.end()) return 0; // Havn't processed this node? std::vector<BasicBlock *> TodoStack; diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index a126083579..30d170b669 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -19,10 +19,10 @@ using std::set; // DominatorSet Implementation //===----------------------------------------------------------------------===// -AnalysisID cfg::DominatorSet::ID(AnalysisID::create<cfg::DominatorSet>()); -AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create<cfg::DominatorSet>()); +AnalysisID DominatorSet::ID(AnalysisID::create<DominatorSet>()); +AnalysisID DominatorSet::PostDomID(AnalysisID::create<DominatorSet>()); -bool cfg::DominatorSet::runOnFunction(Function *F) { +bool DominatorSet::runOnFunction(Function *F) { Doms.clear(); // Reset from the last time we were run... if (isPostDominator()) @@ -36,7 +36,7 @@ bool cfg::DominatorSet::runOnFunction(Function *F) { // calcForwardDominatorSet - This method calculates the forward dominator sets // for the specified function. // -void cfg::DominatorSet::calcForwardDominatorSet(Function *M) { +void DominatorSet::calcForwardDominatorSet(Function *M) { Root = M->getEntryNode(); assert(pred_begin(Root) == pred_end(Root) && "Root node has predecessors in function!"); @@ -80,7 +80,7 @@ void cfg::DominatorSet::calcForwardDominatorSet(Function *M) { // only have a single exit node (return stmt), then calculates the post // dominance sets for the function. // -void cfg::DominatorSet::calcPostDominatorSet(Function *F) { +void DominatorSet::calcPostDominatorSet(Function *F) { // Since we require that the unify all exit nodes pass has been run, we know // that there can be at most one return instruction in the function left. // Get it. @@ -132,7 +132,7 @@ void cfg::DominatorSet::calcPostDominatorSet(Function *F) { // getAnalysisUsage - This obviously provides a dominator set, but it also // uses the UnifyFunctionExitNodes pass if building post-dominators // -void cfg::DominatorSet::getAnalysisUsage(AnalysisUsage &AU) const { +void DominatorSet::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); if (isPostDominator()) { AU.addProvided(PostDomID); @@ -147,12 +147,12 @@ void cfg::DominatorSet::getAnalysisUsage(AnalysisUsage &AU) const { // ImmediateDominators Implementation //===----------------------------------------------------------------------===// -AnalysisID cfg::ImmediateDominators::ID(AnalysisID::create<cfg::ImmediateDominators>()); -AnalysisID cfg::ImmediateDominators::PostDomID(AnalysisID::create<cfg::ImmediateDominators>()); +AnalysisID ImmediateDominators::ID(AnalysisID::create<ImmediateDominators>()); +AnalysisID ImmediateDominators::PostDomID(AnalysisID::create<ImmediateDominators>()); // calcIDoms - Calculate the immediate dominator mapping, given a set of // dominators for every basic block. -void cfg::ImmediateDominators::calcIDoms(const DominatorSet &DS) { +void ImmediateDominators::calcIDoms(const DominatorSet &DS) { // Loop over all of the nodes that have dominators... figuring out the IDOM // for each node... // @@ -191,12 +191,12 @@ void cfg::ImmediateDominators::calcIDoms(const DominatorSet &DS) { // DominatorTree Implementation //===----------------------------------------------------------------------===// -AnalysisID cfg::DominatorTree::ID(AnalysisID::create<cfg::DominatorTree>()); -AnalysisID cfg::DominatorTree::PostDomID(AnalysisID::create<cfg::DominatorTree>()); +AnalysisID DominatorTree::ID(AnalysisID::create<DominatorTree>()); +AnalysisID DominatorTree::PostDomID(AnalysisID::create<DominatorTree>()); // DominatorTree::reset - Free all of the tree node memory. // -void cfg::DominatorTree::reset() { +void DominatorTree::reset() { for (NodeMapType::iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++I) delete I->second; Nodes.clear(); @@ -205,7 +205,7 @@ void cfg::DominatorTree::reset() { #if 0 // Given immediate dominators, we can also calculate the dominator tree -cfg::DominatorTree::DominatorTree(const ImmediateDominators &IDoms) +DominatorTree::DominatorTree(const ImmediateDominators &IDoms) : DominatorBase(IDoms.getRoot()) { const Function *M = Root->getParent(); @@ -230,7 +230,7 @@ cfg::DominatorTree::DominatorTree(const ImmediateDominators &IDoms) } #endif -void cfg::DominatorTree::calculate(const DominatorSet &DS) { +void DominatorTree::calculate(const DominatorSet &DS) { Nodes[Root] = new Node(Root, 0); // Add a node for the root... if (!isPostDominator()) { @@ -325,12 +325,12 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) { // DominanceFrontier Implementation //===----------------------------------------------------------------------===// -AnalysisID cfg::DominanceFrontier::ID(AnalysisID::create<cfg::DominanceFrontier>()); -AnalysisID cfg::DominanceFrontier::PostDomID(AnalysisID::create<cfg::DominanceFrontier>()); +AnalysisID DominanceFrontier::ID(AnalysisID::create<DominanceFrontier>()); +AnalysisID DominanceFrontier::PostDomID(AnalysisID::create<DominanceFrontier>()); -const cfg::DominanceFrontier::DomSetType & -cfg::DominanceFrontier::calcDomFrontier(const DominatorTree &DT, - const DominatorTree::Node *Node) { +const DominanceFrontier::DomSetType & +DominanceFrontier::calcDomFrontier(const DominatorTree &DT, + const DominatorTree::Node *Node) { // Loop over CFG successors to calculate DFlocal[Node] BasicBlock *BB = Node->getNode(); DomSetType &S = Frontiers[BB]; // The new set to fill in... @@ -361,9 +361,9 @@ cfg::DominanceFrontier::calcDomFrontier(const DominatorTree &DT, return S; } -const cfg::DominanceFrontier::DomSetType & -cfg::DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT, - const DominatorTree::Node *Node) { +const DominanceFrontier::DomSetType & +DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT, + const DominatorTree::Node *Node) { // Loop over CFG successors to calculate DFlocal[Node] BasicBlock *BB = Node->getNode(); DomSetType &S = Frontiers[BB]; // The new set to fill in... diff --git a/lib/Analysis/Writer.cpp b/lib/Analysis/Writer.cpp index 05bd7705c2..9b68bfc1cf 100644 --- a/lib/Analysis/Writer.cpp +++ b/lib/Analysis/Writer.cpp @@ -23,7 +23,7 @@ using std::string; // Interval Printing Routines //===----------------------------------------------------------------------===// -void cfg::WriteToOutput(const Interval *I, ostream &o) { +void WriteToOutput(const Interval *I, ostream &o) { o << "-------------------------------------------------------------\n" << "Interval Contents:\n"; @@ -40,7 +40,7 @@ void cfg::WriteToOutput(const Interval *I, ostream &o) { std::ostream_iterator<BasicBlock*>(o, "\n")); } -void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) { +void WriteToOutput(const IntervalPartition &IP, ostream &o) { copy(IP.begin(), IP.end(), std::ostream_iterator<const Interval *>(o, "\n")); } @@ -55,7 +55,7 @@ ostream &operator<<(ostream &o, const set<BasicBlock*> &BBs) { return o; } -void cfg::WriteToOutput(const DominatorSet &DS, ostream &o) { +void WriteToOutput(const DominatorSet &DS, ostream &o) { for (DominatorSet::const_iterator I = DS.begin(), E = DS.end(); I != E; ++I) { o << "=============================--------------------------------\n" << "\nDominator Set For Basic Block\n" << I->first @@ -64,7 +64,7 @@ void cfg::WriteToOutput(const DominatorSet &DS, ostream &o) { } -void cfg::WriteToOutput(const ImmediateDominators &ID, ostream &o) { +void WriteToOutput(const ImmediateDominators &ID, ostream &o) { for (ImmediateDominators::const_iterator I = ID.begin(), E = ID.end(); I != E; ++I) { o << "=============================--------------------------------\n" @@ -74,27 +74,27 @@ void cfg::WriteToOutput(const ImmediateDominators &ID, ostream &o) { } -static ostream &operator<<(ostream &o, const cfg::DominatorTree::Node *Node) { +static ostream &operator<<(ostream &o, const DominatorTree::Node *Node) { return o << Node->getNode() << "\n------------------------------------------\n"; } -static void PrintDomTree(const cfg::DominatorTree::Node *N, ostream &o, - unsigned Lev) { +static void PrintDomTree(const DominatorTree::Node *N, ostream &o, + unsigned Lev) { o << "Level #" << Lev << ": " << N; - for (cfg::DominatorTree::Node::const_iterator I = N->begin(), E = N->end(); + for (DominatorTree::Node::const_iterator I = N->begin(), E = N->end(); I != E; ++I) { PrintDomTree(*I, o, Lev+1); } } -void cfg::WriteToOutput(const DominatorTree &DT, ostream &o) { +void WriteToOutput(const DominatorTree &DT, ostream &o) { o << "=============================--------------------------------\n" << "Inorder Dominator Tree:\n"; PrintDomTree(DT[DT.getRoot()], o, 1); } -void cfg::WriteToOutput(const DominanceFrontier &DF, ostream &o) { +void WriteToOutput(const DominanceFrontier &DF, ostream &o) { for (DominanceFrontier::const_iterator I = DF.begin(), E = DF.end(); I != E; ++I) { o << "=============================--------------------------------\n" @@ -108,7 +108,7 @@ void cfg::WriteToOutput(const DominanceFrontier &DF, ostream &o) { // Loop Printing Routines //===----------------------------------------------------------------------===// -void cfg::WriteToOutput(const Loop *L, ostream &o) { +void WriteToOutput(const Loop *L, ostream &o) { o << string(L->getLoopDepth()*2, ' ') << "Loop Containing: "; for (unsigned i = 0; i < L->getBlocks().size(); ++i) { @@ -121,7 +121,7 @@ void cfg::WriteToOutput(const Loop *L, ostream &o) { std::ostream_iterator<const Loop*>(o, "\n")); } -void cfg::WriteToOutput(const LoopInfo &LI, ostream &o) { +void WriteToOutput(const LoopInfo &LI, ostream &o) { copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(), std::ostream_iterator<const Loop*>(o, "\n")); } |