1//===- IRPrintingPasses.h - Passes to print out IR constructs ---*- 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/// \file 9/// 10/// This file defines passes to print out IR in various granularities. The 11/// PrintModulePass pass simply prints out the entire module when it is 12/// executed. The PrintFunctionPass class is designed to be pipelined with 13/// other FunctionPass's, and prints out the functions of the module as they 14/// are processed. 15/// 16//===----------------------------------------------------------------------===// 17 18#ifndef LLVM_IRPRINTER_IRPRINTINGPASSES_H 19#define LLVM_IRPRINTER_IRPRINTINGPASSES_H 20 21#include "llvm/IR/PassManager.h" 22#include <string> 23 24namespace llvm { 25class raw_ostream; 26class Function; 27class Module; 28class Pass; 29 30/// Pass (for the new pass manager) for printing a Module as 31/// LLVM's text IR assembly. 32class PrintModulePass : public PassInfoMixin<PrintModulePass> { 33 raw_ostream &OS; 34 std::string Banner; 35 bool ShouldPreserveUseListOrder; 36 bool EmitSummaryIndex; 37 38public: 39 PrintModulePass(); 40 PrintModulePass(raw_ostream &OS, const std::string &Banner = "", 41 bool ShouldPreserveUseListOrder = false, 42 bool EmitSummaryIndex = false); 43 44 PreservedAnalyses run(Module &M, AnalysisManager<Module> &); 45 static bool isRequired() { return true; } 46}; 47 48/// Pass (for the new pass manager) for printing a Function as 49/// LLVM's text IR assembly. 50class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> { 51 raw_ostream &OS; 52 std::string Banner; 53 54public: 55 PrintFunctionPass(); 56 PrintFunctionPass(raw_ostream &OS, const std::string &Banner = ""); 57 58 PreservedAnalyses run(Function &F, AnalysisManager<Function> &); 59 static bool isRequired() { return true; } 60}; 61 62} // namespace llvm 63 64#endif 65