Continue the exposition
[oota-llvm.git] / tools / analyze / AnalysisWrappers.cpp
1 //===- AnalysisWrappers.cpp - Wrappers around non-pass analyses -----------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines pass wrappers around LLVM analyses that don't make sense to
11 // be passes.  It provides a nice standard pass interface to these classes so
12 // that they can be printed out by analyze.
13 //
14 // These classes are separated out of analyze.cpp so that it is more clear which
15 // code is the integral part of the analyze tool, and which part of the code is
16 // just making it so more passes are available.
17 //
18 //===----------------------------------------------------------------------===//
19
20 #include "llvm/Pass.h"
21 #include "llvm/Analysis/InstForest.h"
22
23 using namespace llvm;
24
25 namespace {
26   struct InstForestHelper : public FunctionPass {
27     Function *F;
28     virtual bool runOnFunction(Function &Func) { F = &Func; return false; }
29
30     void print(std::ostream &OS) const {
31       std::cout << InstForest<char>(F);
32     }
33     
34     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
35       AU.setPreservesAll();
36     }
37   };
38
39   RegisterAnalysis<InstForestHelper> P1("instforest", "InstForest Printer");
40 }