1 //===- ViewOpGraph.h - View/write op graphviz graphs ------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Defines interface to produce Graphviz outputs of MLIR op within block. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef MLIR_TRANSFORMS_VIEWOPGRAPH_H_ 14 #define MLIR_TRANSFORMS_VIEWOPGRAPH_H_ 15 16 #include "mlir/Support/LLVM.h" 17 #include "llvm/Support/GraphWriter.h" 18 #include "llvm/Support/raw_ostream.h" 19 20 namespace mlir { 21 class Block; 22 class ModuleOp; 23 template <typename T> class OperationPass; 24 25 /// Displays the graph in a window. This is for use from the debugger and 26 /// depends on Graphviz to generate the graph. 27 void viewGraph(Block &block, const Twine &name, bool shortNames = false, 28 const Twine &title = "", 29 llvm::GraphProgram::Name program = llvm::GraphProgram::DOT); 30 31 raw_ostream &writeGraph(raw_ostream &os, Block &block, bool shortNames = false, 32 const Twine &title = ""); 33 34 /// Creates a pass to print op graphs. 35 std::unique_ptr<OperationPass<ModuleOp>> 36 createPrintOpGraphPass(raw_ostream &os = llvm::errs(), bool shortNames = false, 37 const Twine &title = ""); 38 39 } // end namespace mlir 40 41 #endif // MLIR_TRANSFORMS_VIEWOPGRAPH_H_ 42