diff options
author | Chris Lattner <sabre@nondot.org> | 2002-07-29 21:24:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-07-29 21:24:10 +0000 |
commit | 781e6f5f894175a48e21c7b9d443616a7428f1f7 (patch) | |
tree | 12b58de69216fc4bf1f28d794737a44666d429a0 /tools/analyze/analyze.cpp | |
parent | 6eea01ed8e98fddbf950bbd78d688e5372a1b3f5 (diff) | |
download | external_llvm-781e6f5f894175a48e21c7b9d443616a7428f1f7.zip external_llvm-781e6f5f894175a48e21c7b9d443616a7428f1f7.tar.gz external_llvm-781e6f5f894175a48e21c7b9d443616a7428f1f7.tar.bz2 |
Seperate analysis wrapper stuff to AnalysisWrappers.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/analyze/analyze.cpp')
-rw-r--r-- | tools/analyze/analyze.cpp | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index d9423e4..cc3a478 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -11,132 +11,12 @@ //===----------------------------------------------------------------------===// #include "llvm/Module.h" -#include "llvm/iPHINode.h" -#include "llvm/Type.h" #include "llvm/PassManager.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Assembly/Parser.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Analysis/InstForest.h" -#include "llvm/Analysis/Expressions.h" -#include "llvm/Analysis/InductionVariable.h" -#include "llvm/Support/InstIterator.h" #include "llvm/Support/PassNameParser.h" #include <algorithm> -using std::ostream; - -#if 0 - -template <class PassType, class PassName> -class PassPrinter; // Do not implement - -template <class PassName> -class PassPrinter<Pass, PassName> : public Pass { - const AnalysisID ID; -public: - PassPrinter(AnalysisID id) : ID(id) {} - - const char *getPassName() const { return "IP Pass Printer"; } - - virtual bool run(Module &M) { - printPass(getAnalysis<PassName>(ID), std::cout, M); - return false; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(ID); - } -}; - -template <class PassName> -class PassPrinter<FunctionPass, PassName> : public FunctionPass { - const AnalysisID ID; -public: - PassPrinter(AnalysisID id) : ID(id) {} - - const char *getPassName() const { return "Function Pass Printer"; } - - virtual bool runOnFunction(Function &F) { - std::cout << "Running on function '" << F.getName() << "'\n"; - printPass(getAnalysis<PassName>(ID), std::cout, F); - return false; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(ID); - AU.setPreservesAll(); - } -}; - - -struct InstForestHelper : public FunctionPass { - const char *getPassName() const { return "InstForest Printer"; } - - void doit(Function &F) { - std::cout << InstForest<char>(&F); - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } -}; - -struct IndVars : public FunctionPass { - const char *getPassName() const { return "IndVars Printer"; } - - void doit(Function &F) { - LoopInfo &LI = getAnalysis<LoopInfo>(); - for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) - if (PHINode *PN = dyn_cast<PHINode>(*I)) { - InductionVariable IV(PN, &LI); - if (IV.InductionType != InductionVariable::Unknown) - IV.print(std::cout); - } - } - - void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(LoopInfo::ID); - AU.setPreservesAll(); - } -}; - -struct Exprs : public FunctionPass { - const char *getPassName() const { return "Expression Printer"; } - - static void doit(Function &F) { - std::cout << "Classified expressions for: " << F.getName() << "\n"; - for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { - std::cout << *I; - - if ((*I)->getType() == Type::VoidTy) continue; - analysis::ExprType R = analysis::ClassifyExpression(*I); - if (R.Var == *I) continue; // Doesn't tell us anything - - std::cout << "\t\tExpr ="; - switch (R.ExprTy) { - case analysis::ExprType::ScaledLinear: - WriteAsOperand(std::cout << "(", (Value*)R.Scale) << " ) *"; - // fall through - case analysis::ExprType::Linear: - WriteAsOperand(std::cout << "(", R.Var) << " )"; - if (R.Offset == 0) break; - else std::cout << " +"; - // fall through - case analysis::ExprType::Constant: - if (R.Offset) WriteAsOperand(std::cout, (Value*)R.Offset); - else std::cout << " 0"; - break; - } - std::cout << "\n\n"; - } - } - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } -}; -#endif struct ModulePassPrinter : public Pass { Pass *PassToPrint; |