* Standardize how analysis results/passes as printed with the print() virtual

methods
* Eliminate AnalysisID:  Now it is just a typedef for const PassInfo*
* Simplify how AnalysisID's are initialized
* Eliminate Analysis/Writer.cpp/.h: incorporate printing functionality into
  the analyses themselves.

llvm-svn: 3115
This commit is contained in:
Chris Lattner 2002-07-27 01:12:15 +00:00
parent 5768f01926
commit 96a0dfa33e
15 changed files with 48 additions and 97 deletions

View File

@ -342,7 +342,7 @@ public:
}
// print - Print out the analysis results...
void print(std::ostream &O, Module *M) const;
void print(std::ostream &O, const Module *M) const;
// If the pass pipeline is done with this pass, we can release our memory...
virtual void releaseMemory();
@ -377,7 +377,7 @@ public:
}
// print - Print out the analysis results...
void print(std::ostream &O, Module *M) const;
void print(std::ostream &O, const Module *M) const;
// If the pass pipeline is done with this pass, we can release our memory...
virtual void releaseMemory();
@ -419,7 +419,7 @@ public:
}
// print - Print out the analysis results...
void print(std::ostream &O, Module *M) const;
void print(std::ostream &O, const Module *M) const;
// If the pass pipeline is done with this pass, we can release our memory...
virtual void releaseMemory();

View File

@ -82,6 +82,9 @@ public:
return getDominators(B).count(A) != 0;
}
// print - Convert to human readable form
virtual void print(std::ostream &OS) const;
// dominates - Return true if A dominates B. This performs the special checks
// neccesary if A and B are in the same basic block.
//
@ -157,6 +160,9 @@ public:
std::map<BasicBlock*, BasicBlock*>::const_iterator I = IDoms.find(BB);
return I != IDoms.end() ? I->second : 0;
}
// print - Convert to human readable form
virtual void print(std::ostream &OS) const;
};
//===-------------------------------------
@ -259,6 +265,9 @@ public:
NodeMapType::const_iterator i = Nodes.find(BB);
return (i != Nodes.end()) ? i->second : 0;
}
// print - Convert to human readable form
virtual void print(std::ostream &OS) const;
};
@ -336,6 +345,9 @@ public:
inline const_iterator begin() const { return Frontiers.begin(); }
inline const_iterator end() const { return Frontiers.end(); }
inline const_iterator find(BasicBlock* B) const { return Frontiers.find(B); }
// print - Convert to human readable form
virtual void print(std::ostream &OS) const;
};

View File

@ -39,10 +39,9 @@ public:
//
virtual bool run(Module &M);
// printResults - Loop over the results of the analysis, printing out unsafe
// types.
// print - Loop over the results of the analysis, printing out unsafe types.
//
void printResults(const Module *Mod, std::ostream &o) const;
void print(std::ostream &o, const Module *Mod) const;
// getAnalysisUsage - Of course, we provide ourself...
//

View File

@ -29,7 +29,7 @@ public:
// passed in, then the types are printed symbolically if possible, using the
// symbol table from the module.
//
void printTypes(std::ostream &o, const Module *M = 0) const;
void print(std::ostream &o, const Module *M) const;
private:
// IncorporateType - Incorporate one type and all of its subtypes into the

View File

@ -19,6 +19,7 @@
#ifndef LLVM_ANALYSIS_INDUCTIONVARIABLE_H
#define LLVM_ANALYSIS_INDUCTIONVARIABLE_H
#include <iosfwd>
class Value;
class PHINode;
class Instruction;
@ -45,6 +46,8 @@ public:
// Classify Induction
static enum iType Classify(const Value *Start, const Value *Step,
const Loop *L = 0);
void print(std::ostream &OS) const;
};
#endif

View File

@ -14,6 +14,7 @@
#define LLVM_INTERVAL_H
#include <vector>
#include <iosfwd>
class BasicBlock;
@ -85,6 +86,9 @@ public:
// isLoop - Find out if there is a back edge in this interval...
bool isLoop() const;
// print - Show contents in human readable format...
void print(std::ostream &O) const;
};
// succ_begin/succ_end - define methods so that Intervals may be used

View File

@ -51,6 +51,9 @@ public:
// Destructor - Free memory
~IntervalPartition() { destroy(); }
// print - Show contents in human readable format...
virtual void print(std::ostream &O) const;
// getRootInterval() - Return the root interval that contains the starting
// block of the function.
inline Interval *getRootInterval() { return RootInterval; }

View File

@ -40,6 +40,7 @@ public:
inline const std::vector<Loop*> &getSubLoops() const { return SubLoops; }
inline const std::vector<BasicBlock*> &getBlocks() const { return Blocks; }
void print(std::ostream &O) const;
private:
friend class LoopInfo;
inline Loop(BasicBlock *BB) { Blocks.push_back(BB); LoopDepth = 0; }
@ -105,6 +106,7 @@ public:
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
void print(std::ostream &O) const;
// getAnalysisUsage - Provide loop info, require dominator set
//

View File

@ -1,76 +0,0 @@
//===-- llvm/Analysis/Writer.h - Printer for Analysis routines ---*- C++ -*--=//
//
// This library provides routines to print out various analysis results to
// an output stream.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_WRITER_H
#define LLVM_ANALYSIS_WRITER_H
#include <iosfwd>
// This library provides support for printing out Intervals.
class Interval;
class IntervalPartition;
void WriteToOutput(const Interval *I, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o, const Interval *I) {
WriteToOutput(I, o); return o;
}
void WriteToOutput(const IntervalPartition &IP, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o,
const IntervalPartition &IP) {
WriteToOutput(IP, o); return o;
}
// Stuff for printing out Dominator data structures...
class DominatorSetBase;
class ImmediateDominatorsBase;
class DominatorTreeBase;
class DominanceFrontierBase;
void WriteToOutput(const DominatorSetBase &, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o, const DominatorSetBase &DS) {
WriteToOutput(DS, o); return o;
}
void WriteToOutput(const ImmediateDominatorsBase &, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o,
const ImmediateDominatorsBase &ID) {
WriteToOutput(ID, o); return o;
}
void WriteToOutput(const DominatorTreeBase &, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o, const DominatorTreeBase &DT) {
WriteToOutput(DT, o); return o;
}
void WriteToOutput(const DominanceFrontierBase &, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o,
const DominanceFrontierBase &DF) {
WriteToOutput(DF, o); return o;
}
// Stuff for printing out Loop information
class Loop;
class LoopInfo;
void WriteToOutput(const LoopInfo &, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o, const LoopInfo &LI) {
WriteToOutput(LI, o); return o;
}
void WriteToOutput(const Loop *, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o, const Loop *L) {
WriteToOutput(L, o); return o;
}
class InductionVariable;
void WriteToOutput(const InductionVariable &, std::ostream &o);
inline std::ostream &operator <<(std::ostream &o, const InductionVariable &IV) {
WriteToOutput(IV, o); return o;
}
#endif

View File

@ -15,7 +15,7 @@ using std::map;
static RegisterAnalysis<BUDataStructures>
X("budatastructure", "Bottom-Up Data Structure Analysis Closure");
AnalysisID BUDataStructures::ID(AnalysisID::create<BUDataStructures>());
AnalysisID BUDataStructures::ID = X;
// releaseMemory - If the pass pipeline is done with this pass, we can release
// our memory... here...

View File

@ -15,10 +15,6 @@
using std::vector;
static RegisterAnalysis<LocalDataStructures>
X("datastructure", "Local Data Structure Analysis");
AnalysisID LocalDataStructures::ID(AnalysisID::create<LocalDataStructures>());
//===----------------------------------------------------------------------===//
// DSNode Implementation
//===----------------------------------------------------------------------===//

View File

@ -18,6 +18,10 @@
using std::map;
using std::vector;
static RegisterAnalysis<LocalDataStructures>
X("datastructure", "Local Data Structure Analysis");
AnalysisID LocalDataStructures::ID = X;
//===----------------------------------------------------------------------===//
// GraphBuilder Class
//===----------------------------------------------------------------------===//

View File

@ -147,16 +147,21 @@ void DSGraph::print(std::ostream &O) const {
}
template <typename Collection>
static void printCollection(const Collection &C, std::ostream &O, Module *M,
const string &Prefix) {
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
static void printCollection(const Collection &C, std::ostream &O,
const Module *M, const string &Prefix) {
if (M == 0) {
O << "Null Module pointer, cannot continue!\n";
return;
}
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
if (!I->isExternal()) {
string Filename = Prefix + "." + I->getName() + ".dot";
O << "Writing '" << Filename << "'...";
std::ofstream F(Filename.c_str());
if (F.good()) {
DSGraph &Graph = C.getDSGraph(*I);
DSGraph &Graph = C.getDSGraph((Function&)*I);
Graph.print(F);
O << " [" << Graph.getGraphSize() << "+"
<< Graph.getFunctionCalls().size() << "]\n";
@ -168,10 +173,10 @@ static void printCollection(const Collection &C, std::ostream &O, Module *M,
// print - Print out the analysis results...
void LocalDataStructures::print(std::ostream &O, Module *M) const {
void LocalDataStructures::print(std::ostream &O, const Module *M) const {
printCollection(*this, O, M, "ds");
}
void BUDataStructures::print(std::ostream &O, Module *M) const {
void BUDataStructures::print(std::ostream &O, const Module *M) const {
printCollection(*this, O, M, "bu");
}

View File

@ -17,7 +17,7 @@
static RegisterAnalysis<FunctionLiveVarInfo>
X("livevar", "Live Variable Analysis");
AnalysisID FunctionLiveVarInfo::ID(AnalysisID::create<FunctionLiveVarInfo>());
AnalysisID FunctionLiveVarInfo::ID = X;
LiveVarDebugLevel_t DEBUG_LV;

View File

@ -15,10 +15,9 @@
#include "llvm/Type.h"
using std::vector;
AnalysisID UnifyFunctionExitNodes::ID(AnalysisID::create<UnifyFunctionExitNodes>());
static RegisterOpt<UnifyFunctionExitNodes>
X("mergereturn", "Unify function exit nodes");
AnalysisID UnifyFunctionExitNodes::ID = X;
// UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new
// BasicBlock, and converting all returns to unconditional branches to this