xref: /aosp_15_r20/external/llvm/tools/opt/GraphPrinters.cpp (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===- GraphPrinters.cpp - DOT printers for various graph types -----------===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file defines several printers for various different types of graphs used
11*9880d681SAndroid Build Coastguard Worker // by the LLVM infrastructure.  It uses the generic graph interface to convert
12*9880d681SAndroid Build Coastguard Worker // the graph into a .dot graph.  These graphs can then be processed with the
13*9880d681SAndroid Build Coastguard Worker // "dot" tool to convert them to postscript or some other suitable format.
14*9880d681SAndroid Build Coastguard Worker //
15*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Dominators.h"
18*9880d681SAndroid Build Coastguard Worker #include "llvm/Pass.h"
19*9880d681SAndroid Build Coastguard Worker 
20*9880d681SAndroid Build Coastguard Worker using namespace llvm;
21*9880d681SAndroid Build Coastguard Worker 
22*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
23*9880d681SAndroid Build Coastguard Worker //                            DomInfoPrinter Pass
24*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
25*9880d681SAndroid Build Coastguard Worker 
26*9880d681SAndroid Build Coastguard Worker namespace {
27*9880d681SAndroid Build Coastguard Worker   class DomInfoPrinter : public FunctionPass {
28*9880d681SAndroid Build Coastguard Worker   public:
29*9880d681SAndroid Build Coastguard Worker     static char ID; // Pass identification, replacement for typeid
DomInfoPrinter()30*9880d681SAndroid Build Coastguard Worker     DomInfoPrinter() : FunctionPass(ID) {}
31*9880d681SAndroid Build Coastguard Worker 
getAnalysisUsage(AnalysisUsage & AU) const32*9880d681SAndroid Build Coastguard Worker     void getAnalysisUsage(AnalysisUsage &AU) const override {
33*9880d681SAndroid Build Coastguard Worker       AU.setPreservesAll();
34*9880d681SAndroid Build Coastguard Worker       AU.addRequired<DominatorTreeWrapperPass>();
35*9880d681SAndroid Build Coastguard Worker     }
36*9880d681SAndroid Build Coastguard Worker 
runOnFunction(Function & F)37*9880d681SAndroid Build Coastguard Worker     bool runOnFunction(Function &F) override {
38*9880d681SAndroid Build Coastguard Worker       getAnalysis<DominatorTreeWrapperPass>().dump();
39*9880d681SAndroid Build Coastguard Worker       return false;
40*9880d681SAndroid Build Coastguard Worker     }
41*9880d681SAndroid Build Coastguard Worker   };
42*9880d681SAndroid Build Coastguard Worker }
43*9880d681SAndroid Build Coastguard Worker 
44*9880d681SAndroid Build Coastguard Worker char DomInfoPrinter::ID = 0;
45*9880d681SAndroid Build Coastguard Worker static RegisterPass<DomInfoPrinter>
46*9880d681SAndroid Build Coastguard Worker DIP("print-dom-info", "Dominator Info Printer", true, true);
47