diff options
author | Chris Lattner <sabre@nondot.org> | 2002-07-27 01:12:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-07-27 01:12:17 +0000 |
commit | a59cbb2043c08f3cfb8fb379f0d336e21e070be8 (patch) | |
tree | 19ace2fcd6b60628e49d6c65ca1015cbff960916 /lib/Analysis/Writer.cpp | |
parent | 97f51a3024a72ef8500e95b90e6361e6783160fd (diff) |
* 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/Writer.cpp')
-rw-r--r-- | lib/Analysis/Writer.cpp | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/lib/Analysis/Writer.cpp b/lib/Analysis/Writer.cpp deleted file mode 100644 index 80a8f91e47..0000000000 --- a/lib/Analysis/Writer.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//===-- Analysis/Writer.cpp - Printing routines for analyses -----*- C++ -*--=// -// -// This library file implements analysis result printing support for -// llvm/Analysis/Writer.h -// -//===----------------------------------------------------------------------===// - -#include "llvm/Analysis/Writer.h" -#include "llvm/Analysis/IntervalPartition.h" -#include "llvm/Analysis/Dominators.h" -#include "llvm/Analysis/LoopInfo.h" -#include "llvm/Analysis/InductionVariable.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Module.h" -#include <iterator> -#include <algorithm> -#include <string> -#include <iostream> -using std::ostream; -using std::set; -using std::vector; -using std::string; - -//===----------------------------------------------------------------------===// -// Interval Printing Routines -//===----------------------------------------------------------------------===// - -void WriteToOutput(const Interval *I, ostream &o) { - o << "-------------------------------------------------------------\n" - << "Interval Contents:\n"; - - // Print out all of the basic blocks in the interval... - copy(I->Nodes.begin(), I->Nodes.end(), - std::ostream_iterator<BasicBlock*>(o, "\n")); - - o << "Interval Predecessors:\n"; - copy(I->Predecessors.begin(), I->Predecessors.end(), - std::ostream_iterator<BasicBlock*>(o, "\n")); - - o << "Interval Successors:\n"; - copy(I->Successors.begin(), I->Successors.end(), - std::ostream_iterator<BasicBlock*>(o, "\n")); -} - -void WriteToOutput(const IntervalPartition &IP, ostream &o) { - copy(IP.begin(), IP.end(), std::ostream_iterator<const Interval *>(o, "\n")); -} - - - -//===----------------------------------------------------------------------===// -// Dominator Printing Routines -//===----------------------------------------------------------------------===// - -ostream &operator<<(ostream &o, const set<BasicBlock*> &BBs) { - for (set<BasicBlock*>::const_iterator I = BBs.begin(), E = BBs.end(); - I != E; ++I) { - o << " "; - WriteAsOperand(o, (Value*)*I, false); - o << "\n"; - } - return o; -} - -void WriteToOutput(const DominatorSetBase &DS, ostream &o) { - for (DominatorSetBase::const_iterator I = DS.begin(), E = DS.end(); - I != E; ++I) { - o << "=============================--------------------------------\n" - << "\nDominator Set For Basic Block\n" << I->first - << "-------------------------------\n" << I->second << "\n"; - } -} - - -void WriteToOutput(const ImmediateDominatorsBase &ID, ostream &o) { - for (ImmediateDominatorsBase::const_iterator I = ID.begin(), E = ID.end(); - I != E; ++I) { - o << "=============================--------------------------------\n" - << "\nImmediate Dominator For Basic Block\n" << *I->first - << "is: \n" << *I->second << "\n"; - } -} - - -static ostream &operator<<(ostream &o, const DominatorTreeBase::Node *Node) { - return o << Node->getNode() << "\n------------------------------------------\n"; - -} - -static void PrintDomTree(const DominatorTreeBase::Node *N, ostream &o, - unsigned Lev) { - o << "Level #" << Lev << ": " << N; - for (DominatorTreeBase::Node::const_iterator I = N->begin(), E = N->end(); - I != E; ++I) { - PrintDomTree(*I, o, Lev+1); - } -} - -void WriteToOutput(const DominatorTreeBase &DT, ostream &o) { - o << "=============================--------------------------------\n" - << "Inorder Dominator Tree:\n"; - PrintDomTree(DT[DT.getRoot()], o, 1); -} - -void WriteToOutput(const DominanceFrontierBase &DF, ostream &o) { - for (DominanceFrontierBase::const_iterator I = DF.begin(), E = DF.end(); - I != E; ++I) { - o << "=============================--------------------------------\n" - << "\nDominance Frontier For Basic Block\n"; - WriteAsOperand(o, (Value*)I->first, false); - o << " is: \n" << I->second << "\n"; - } -} - - -//===----------------------------------------------------------------------===// -// Loop Printing Routines -//===----------------------------------------------------------------------===// - -void WriteToOutput(const Loop *L, ostream &o) { - o << string(L->getLoopDepth()*2, ' ') << "Loop Containing: "; - - for (unsigned i = 0; i < L->getBlocks().size(); ++i) { - if (i) o << ","; - WriteAsOperand(o, (const Value*)L->getBlocks()[i]); - } - o << "\n"; - - copy(L->getSubLoops().begin(), L->getSubLoops().end(), - std::ostream_iterator<const Loop*>(o, "\n")); -} - -void WriteToOutput(const LoopInfo &LI, ostream &o) { - copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(), - std::ostream_iterator<const Loop*>(o, "\n")); -} - - - -//===----------------------------------------------------------------------===// -// Induction Variable Printing Routines -//===----------------------------------------------------------------------===// - -void WriteToOutput(const InductionVariable &IV, ostream &o) { - switch (IV.InductionType) { - case InductionVariable::Cannonical: o << "Cannonical "; break; - case InductionVariable::SimpleLinear: o << "SimpleLinear "; break; - case InductionVariable::Linear: o << "Linear "; break; - case InductionVariable::Unknown: o << "Unrecognized "; break; - } - o << "Induction Variable"; - if (IV.Phi) { - WriteAsOperand(o, (const Value*)IV.Phi); - o << ":\n" << (const Value*)IV.Phi; - } else { - o << "\n"; - } - if (IV.InductionType == InductionVariable::Unknown) return; - - o << " Start ="; WriteAsOperand(o, IV.Start); - o << " Step =" ; WriteAsOperand(o, IV.Step); - o << "\n"; -} |