xref: /netbsd-src/external/apache2/llvm/dist/llvm/tools/opt/GraphPrinters.cpp (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1*7330f729Sjoerg //===- GraphPrinters.cpp - DOT printers for various graph types -----------===//
2*7330f729Sjoerg //
3*7330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
5*7330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7330f729Sjoerg //
7*7330f729Sjoerg //===----------------------------------------------------------------------===//
8*7330f729Sjoerg //
9*7330f729Sjoerg // This file defines several printers for various different types of graphs used
10*7330f729Sjoerg // by the LLVM infrastructure.  It uses the generic graph interface to convert
11*7330f729Sjoerg // the graph into a .dot graph.  These graphs can then be processed with the
12*7330f729Sjoerg // "dot" tool to convert them to postscript or some other suitable format.
13*7330f729Sjoerg //
14*7330f729Sjoerg //===----------------------------------------------------------------------===//
15*7330f729Sjoerg 
16*7330f729Sjoerg #include "llvm/IR/Dominators.h"
17*7330f729Sjoerg #include "llvm/Pass.h"
18*7330f729Sjoerg 
19*7330f729Sjoerg using namespace llvm;
20*7330f729Sjoerg 
21*7330f729Sjoerg //===----------------------------------------------------------------------===//
22*7330f729Sjoerg //                            DomInfoPrinter Pass
23*7330f729Sjoerg //===----------------------------------------------------------------------===//
24*7330f729Sjoerg 
25*7330f729Sjoerg namespace {
26*7330f729Sjoerg   class DomInfoPrinter : public FunctionPass {
27*7330f729Sjoerg   public:
28*7330f729Sjoerg     static char ID; // Pass identification, replacement for typeid
DomInfoPrinter()29*7330f729Sjoerg     DomInfoPrinter() : FunctionPass(ID) {}
30*7330f729Sjoerg 
getAnalysisUsage(AnalysisUsage & AU) const31*7330f729Sjoerg     void getAnalysisUsage(AnalysisUsage &AU) const override {
32*7330f729Sjoerg       AU.setPreservesAll();
33*7330f729Sjoerg       AU.addRequired<DominatorTreeWrapperPass>();
34*7330f729Sjoerg     }
35*7330f729Sjoerg 
runOnFunction(Function & F)36*7330f729Sjoerg     bool runOnFunction(Function &F) override {
37*7330f729Sjoerg       getAnalysis<DominatorTreeWrapperPass>().print(dbgs());
38*7330f729Sjoerg       return false;
39*7330f729Sjoerg     }
40*7330f729Sjoerg   };
41*7330f729Sjoerg }
42*7330f729Sjoerg 
43*7330f729Sjoerg char DomInfoPrinter::ID = 0;
44*7330f729Sjoerg static RegisterPass<DomInfoPrinter>
45*7330f729Sjoerg DIP("print-dom-info", "Dominator Info Printer", true, true);
46