summaryrefslogtreecommitdiff
path: root/tools/analyze
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-20 19:16:29 +0000
committerChris Lattner <sabre@nondot.org>2001-07-20 19:16:29 +0000
commit1546bff42389c921bf1e070f18181d24c9590ee3 (patch)
tree6461c28b03969fffa33d701c4b32f43e48910130 /tools/analyze
parent37bf6308ab839cfc85cc864b99d3e35651b66d94 (diff)
downloadllvm-1546bff42389c921bf1e070f18181d24c9590ee3.tar.gz
llvm-1546bff42389c921bf1e070f18181d24c9590ee3.tar.bz2
llvm-1546bff42389c921bf1e070f18181d24c9590ee3.tar.xz
Update makefile for more accurate deps
Include support to print out Expression types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/analyze')
-rw-r--r--tools/analyze/Makefile6
-rw-r--r--tools/analyze/analyze.cpp35
2 files changed, 38 insertions, 3 deletions
diff --git a/tools/analyze/Makefile b/tools/analyze/Makefile
index d624faff81..b33d40bd69 100644
--- a/tools/analyze/Makefile
+++ b/tools/analyze/Makefile
@@ -5,6 +5,8 @@ all:: analyze
clean ::
rm -f analyze
-analyze : $(ObjectsG) Debug/.dir Depend/.dir
+LIBDEPS = ../../lib/Optimizations/Debug/libopt.a ../../lib/Analysis/Debug/libanalysis.a
+
+analyze : $(ObjectsG) Debug/.dir Depend/.dir $(LIBDEPS)
$(LinkG) -o $@ $(ObjectsG) -lopt -lasmparser \
- -lbcreader -lvmcore -lasmwriter -lanalysis
+ -lbcreader -lvmcore -lasmwriter -lanalysis -lopt
diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp
index 76de37515b..e305052ffe 100644
--- a/tools/analyze/analyze.cpp
+++ b/tools/analyze/analyze.cpp
@@ -11,7 +11,9 @@
//===------------------------------------------------------------------------===
#include <iostream>
+#include "llvm/Instruction.h"
#include "llvm/Module.h"
+#include "llvm/Method.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Assembly/Parser.h"
#include "llvm/Tools/CommandLine.h"
@@ -19,6 +21,7 @@
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/IntervalPartition.h"
+#include "llvm/Analysis/Expressions.h"
static void PrintMethod(Method *M) {
cout << M;
@@ -28,6 +31,34 @@ static void PrintIntervalPartition(Method *M) {
cout << cfg::IntervalPartition(M);
}
+static void PrintClassifiedExprs(Method *M) {
+ cout << "Classified expressions for: " << M->getName() << endl;
+ Method::inst_iterator I = M->inst_begin(), E = M->inst_end();
+ for (; I != E; ++I) {
+ cout << *I;
+
+ if ((*I)->getType() == Type::VoidTy) continue;
+ ExprAnalysisResult R = ClassifyExpression(*I);
+ if (R.Var == *I) continue; // Doesn't tell us anything
+
+ cout << "\t\tExpr =";
+ switch (R.ExprType) {
+ case ExprAnalysisResult::ScaledLinear:
+ WriteAsOperand(cout, (Value*)R.Scale) << " *";
+ // fall through
+ case ExprAnalysisResult::Linear:
+ WriteAsOperand(cout, R.Var);
+ if (R.Offset == 0) break;
+ else cout << " +";
+ // fall through
+ case ExprAnalysisResult::Constant:
+ if (R.Offset) WriteAsOperand(cout, (Value*)R.Offset); else cout << " 0";
+ break;
+ }
+ cout << endl << endl;
+ }
+}
+
static void PrintDominatorSets(Method *M) {
cout << cfg::DominatorSet(M);
@@ -61,6 +92,7 @@ struct {
} AnTable[] = {
{ "-print" , "Print each Method" , PrintMethod },
{ "-intervals" , "Interval Partition" , PrintIntervalPartition },
+ { "-exprclassify" , "Classify Expressions" , PrintClassifiedExprs },
{ "-domset" , "Dominator Sets" , PrintDominatorSets },
{ "-idom" , "Immediate Dominators" , PrintImmediateDominators },
@@ -102,8 +134,9 @@ int main(int argc, char **argv) {
// Loop over all of the methods in the module...
for (Module::iterator I = C->begin(), E = C->end(); I != E; ++I) {
Method *M = *I;
+ if (M->isExternal()) continue;
- // Loop over all of the optimizations to be run...
+ // Loop over all of the analyses to be run...
for (int i = 1; i < argc; i++) {
if (argv[i] == 0) continue;
unsigned j;