mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
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
This commit is contained in:
parent
8fc2f2072d
commit
1b7f7dc4b4
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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...
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace {
|
||||
<< " ********************\n";
|
||||
|
||||
PhyRegAlloc PRA(F, Target, &getAnalysis<FunctionLiveVarInfo>(),
|
||||
&getAnalysis<cfg::LoopInfo>());
|
||||
&getAnalysis<LoopInfo>());
|
||||
PRA.allocateRegisters();
|
||||
|
||||
if (DEBUG_RA) cerr << "\nRegister allocation complete!\n";
|
||||
@ -59,7 +59,7 @@ namespace {
|
||||
}
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired(cfg::LoopInfo::ID);
|
||||
AU.addRequired(LoopInfo::ID);
|
||||
AU.addRequired(FunctionLiveVarInfo::ID);
|
||||
}
|
||||
};
|
||||
@ -72,10 +72,8 @@ Pass *getRegisterAllocator(TargetMachine &T) {
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructor: Init local composite objects and create register classes.
|
||||
//----------------------------------------------------------------------------
|
||||
PhyRegAlloc::PhyRegAlloc(Function *F,
|
||||
const TargetMachine& tm,
|
||||
FunctionLiveVarInfo *Lvi,
|
||||
cfg::LoopInfo *LDC)
|
||||
PhyRegAlloc::PhyRegAlloc(Function *F, const TargetMachine& tm,
|
||||
FunctionLiveVarInfo *Lvi, LoopInfo *LDC)
|
||||
: TM(tm), Meth(F),
|
||||
mcInfo(MachineCodeForMethod::get(F)),
|
||||
LVI(Lvi), LRI(F, tm, RegClassList),
|
||||
|
@ -51,7 +51,7 @@ namespace {
|
||||
<< " ********************\n";
|
||||
|
||||
PhyRegAlloc PRA(F, Target, &getAnalysis<FunctionLiveVarInfo>(),
|
||||
&getAnalysis<cfg::LoopInfo>());
|
||||
&getAnalysis<LoopInfo>());
|
||||
PRA.allocateRegisters();
|
||||
|
||||
if (DEBUG_RA) cerr << "\nRegister allocation complete!\n";
|
||||
@ -59,7 +59,7 @@ namespace {
|
||||
}
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired(cfg::LoopInfo::ID);
|
||||
AU.addRequired(LoopInfo::ID);
|
||||
AU.addRequired(FunctionLiveVarInfo::ID);
|
||||
}
|
||||
};
|
||||
@ -72,10 +72,8 @@ Pass *getRegisterAllocator(TargetMachine &T) {
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructor: Init local composite objects and create register classes.
|
||||
//----------------------------------------------------------------------------
|
||||
PhyRegAlloc::PhyRegAlloc(Function *F,
|
||||
const TargetMachine& tm,
|
||||
FunctionLiveVarInfo *Lvi,
|
||||
cfg::LoopInfo *LDC)
|
||||
PhyRegAlloc::PhyRegAlloc(Function *F, const TargetMachine& tm,
|
||||
FunctionLiveVarInfo *Lvi, LoopInfo *LDC)
|
||||
: TM(tm), Meth(F),
|
||||
mcInfo(MachineCodeForMethod::get(F)),
|
||||
LVI(Lvi), LRI(F, tm, RegClassList),
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
// doADCE() - Run the Agressive Dead Code Elimination algorithm, returning
|
||||
// true if the function was modified.
|
||||
bool doADCE(cfg::DominanceFrontier &CDG);
|
||||
bool doADCE(DominanceFrontier &CDG);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// The implementation of this class
|
||||
@ -77,7 +77,7 @@ private:
|
||||
// doADCE() - Run the Agressive Dead Code Elimination algorithm, returning
|
||||
// true if the function was modified.
|
||||
//
|
||||
bool ADCE::doADCE(cfg::DominanceFrontier &CDG) {
|
||||
bool ADCE::doADCE(DominanceFrontier &CDG) {
|
||||
#ifdef DEBUG_ADCE
|
||||
cerr << "Function: " << M;
|
||||
#endif
|
||||
@ -134,10 +134,10 @@ bool ADCE::doADCE(cfg::DominanceFrontier &CDG) {
|
||||
// this block is control dependant on as being alive also...
|
||||
//
|
||||
AliveBlocks.insert(BB); // Block is now ALIVE!
|
||||
cfg::DominanceFrontier::const_iterator It = CDG.find(BB);
|
||||
DominanceFrontier::const_iterator It = CDG.find(BB);
|
||||
if (It != CDG.end()) {
|
||||
// Get the blocks that this node is control dependant on...
|
||||
const cfg::DominanceFrontier::DomSetType &CDB = It->second;
|
||||
const DominanceFrontier::DomSetType &CDB = It->second;
|
||||
for_each(CDB.begin(), CDB.end(), // Mark all their terminators as live
|
||||
bind_obj(this, &ADCE::markTerminatorLive));
|
||||
}
|
||||
@ -294,12 +294,12 @@ namespace {
|
||||
//
|
||||
virtual bool runOnFunction(Function *F) {
|
||||
return ADCE(F).doADCE(
|
||||
getAnalysis<cfg::DominanceFrontier>(cfg::DominanceFrontier::PostDomID));
|
||||
getAnalysis<DominanceFrontier>(DominanceFrontier::PostDomID));
|
||||
}
|
||||
// getAnalysisUsage - We require post dominance frontiers (aka Control
|
||||
// Dependence Graph)
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired(cfg::DominanceFrontier::PostDomID);
|
||||
AU.addRequired(DominanceFrontier::PostDomID);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "llvm/Support/InstIterator.h"
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
using namespace cfg;
|
||||
|
||||
namespace {
|
||||
class GCSE : public FunctionPass, public InstVisitor<GCSE, bool> {
|
||||
|
@ -33,7 +33,7 @@ static Instruction *InsertCast(Instruction *Val, const Type *Ty,
|
||||
return Cast;
|
||||
}
|
||||
|
||||
static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
|
||||
static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
|
||||
// Transform all subloops before this loop...
|
||||
bool Changed = reduce_apply_bool(Loop->getSubLoops().begin(),
|
||||
Loop->getSubLoops().end(),
|
||||
@ -187,7 +187,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
static bool doit(Function *M, cfg::LoopInfo &Loops) {
|
||||
static bool doit(Function *M, LoopInfo &Loops) {
|
||||
// Induction Variables live in the header nodes of the loops of the function
|
||||
return reduce_apply_bool(Loops.getTopLevelLoops().begin(),
|
||||
Loops.getTopLevelLoops().end(),
|
||||
@ -198,11 +198,11 @@ static bool doit(Function *M, cfg::LoopInfo &Loops) {
|
||||
namespace {
|
||||
struct InductionVariableSimplify : public FunctionPass {
|
||||
virtual bool runOnFunction(Function *F) {
|
||||
return doit(F, getAnalysis<cfg::LoopInfo>());
|
||||
return doit(F, getAnalysis<LoopInfo>());
|
||||
}
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired(cfg::LoopInfo::ID);
|
||||
AU.addRequired(LoopInfo::ID);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ using std::cerr;
|
||||
// isLoopInvariant - Return true if the specified value/basic block source is
|
||||
// an interval invariant computation.
|
||||
//
|
||||
static bool isLoopInvariant(cfg::Interval *Int, Value *V) {
|
||||
static bool isLoopInvariant(Interval *Int, Value *V) {
|
||||
assert(isa<Constant>(V) || isa<Instruction>(V) || isa<Argument>(V));
|
||||
|
||||
if (!isa<Instruction>(V))
|
||||
@ -71,7 +71,7 @@ inline LIVType neg(LIVType T) {
|
||||
return T == isLIV ? isNLIV : isLIV;
|
||||
}
|
||||
//
|
||||
static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V,
|
||||
static LIVType isLinearInductionVariableH(Interval *Int, Value *V,
|
||||
PHINode *PN) {
|
||||
if (V == PN) { return isLIV; } // PHI node references are (0+PHI)
|
||||
if (isLoopInvariant(Int, V)) return isLIC;
|
||||
@ -121,7 +121,7 @@ static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V,
|
||||
// instance of the PHI node and a loop invariant value that is added or
|
||||
// subtracted to the PHI node. This is calculated by walking the SSA graph
|
||||
//
|
||||
static inline bool isLinearInductionVariable(cfg::Interval *Int, Value *V,
|
||||
static inline bool isLinearInductionVariable(Interval *Int, Value *V,
|
||||
PHINode *PN) {
|
||||
return isLinearInductionVariableH(Int, V, PN) == isLIV;
|
||||
}
|
||||
@ -176,7 +176,7 @@ static inline bool isSimpleInductionVar(PHINode *PN) {
|
||||
// TODO: This should inherit the largest type that is being used by the already
|
||||
// present induction variables (instead of always using uint)
|
||||
//
|
||||
static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
|
||||
static PHINode *InjectSimpleInductionVariable(Interval *Int) {
|
||||
std::string PHIName, AddName;
|
||||
|
||||
BasicBlock *Header = Int->getHeaderNode();
|
||||
@ -248,7 +248,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
|
||||
// One a simple induction variable is known, all other induction variables are
|
||||
// modified to refer to the "simple" induction variable.
|
||||
//
|
||||
static bool ProcessInterval(cfg::Interval *Int) {
|
||||
static bool ProcessInterval(Interval *Int) {
|
||||
if (!Int->isLoop()) return false; // Not a loop? Ignore it!
|
||||
|
||||
std::vector<PHINode *> InductionVars;
|
||||
@ -351,13 +351,13 @@ static bool ProcessInterval(cfg::Interval *Int) {
|
||||
// ProcessIntervalPartition - This function loops over the interval partition
|
||||
// processing each interval with ProcessInterval
|
||||
//
|
||||
static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) {
|
||||
static bool ProcessIntervalPartition(IntervalPartition &IP) {
|
||||
// This currently just prints out information about the interval structure
|
||||
// of the function...
|
||||
#if 0
|
||||
static unsigned N = 0;
|
||||
cerr << "\n***********Interval Partition #" << (++N) << "************\n\n";
|
||||
copy(IP.begin(), IP.end(), ostream_iterator<cfg::Interval*>(cerr, "\n"));
|
||||
copy(IP.begin(), IP.end(), ostream_iterator<Interval*>(cerr, "\n"));
|
||||
|
||||
cerr << "\n*********** PERFORMING WORK ************\n\n";
|
||||
#endif
|
||||
@ -372,8 +372,8 @@ static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) {
|
||||
// This function loops over an interval partition of a program, reducing it
|
||||
// until the graph is gone.
|
||||
//
|
||||
bool InductionVariableCannonicalize::doIt(Function *M,
|
||||
cfg::IntervalPartition &IP) {
|
||||
bool InductionVariableCannonicalize::doIt(Function *M, IntervalPartition &IP) {
|
||||
|
||||
bool Changed = false;
|
||||
|
||||
#if 0
|
||||
@ -383,7 +383,7 @@ bool InductionVariableCannonicalize::doIt(Function *M,
|
||||
// Calculate the reduced version of this graph until we get to an
|
||||
// irreducible graph or a degenerate graph...
|
||||
//
|
||||
cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, false);
|
||||
IntervalPartition *NewIP = new IntervalPartition(*IP, false);
|
||||
if (NewIP->size() == IP->size()) {
|
||||
cerr << "IRREDUCIBLE GRAPH FOUND!!!\n";
|
||||
return Changed;
|
||||
@ -399,7 +399,7 @@ bool InductionVariableCannonicalize::doIt(Function *M,
|
||||
|
||||
|
||||
bool InductionVariableCannonicalize::runOnFunction(Function *F) {
|
||||
return doIt(F, getAnalysis<cfg::IntervalPartition>());
|
||||
return doIt(F, getAnalysis<IntervalPartition>());
|
||||
}
|
||||
|
||||
// getAnalysisUsage - This function works on the call graph of a module.
|
||||
@ -407,5 +407,5 @@ bool InductionVariableCannonicalize::runOnFunction(Function *F) {
|
||||
// module.
|
||||
//
|
||||
void InductionVariableCannonicalize::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired(cfg::IntervalPartition::ID);
|
||||
AU.addRequired(IntervalPartition::ID);
|
||||
}
|
||||
|
@ -29,9 +29,6 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
using cfg::DominanceFrontier;
|
||||
|
||||
namespace {
|
||||
|
||||
//instance of the promoter -- to keep all the local function data.
|
||||
|
@ -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...
|
||||
|
Loading…
Reference in New Issue
Block a user