2014-01-12 12:10:32 +01:00
|
|
|
//===- IRPrintingPasses.h - Passes to print out IR constructs ---*- C++ -*-===//
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2014-01-12 12:10:32 +01:00
|
|
|
/// \file
|
|
|
|
///
|
|
|
|
/// This file defines passes to print out IR in various granularities. The
|
|
|
|
/// PrintModulePass pass simply prints out the entire module when it is
|
|
|
|
/// executed. The PrintFunctionPass class is designed to be pipelined with
|
|
|
|
/// other FunctionPass's, and prints out the functions of the module as they
|
|
|
|
/// are processed.
|
|
|
|
///
|
2001-10-18 22:31:42 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 18:26:38 +02:00
|
|
|
#ifndef LLVM_IR_IRPRINTINGPASSES_H
|
|
|
|
#define LLVM_IR_IRPRINTINGPASSES_H
|
2001-10-18 22:31:42 +02:00
|
|
|
|
2014-01-12 13:15:39 +01:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2008-10-22 01:33:38 +02:00
|
|
|
#include <string>
|
2001-10-18 22:31:42 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
2014-01-12 13:15:39 +01:00
|
|
|
class BasicBlockPass;
|
|
|
|
class Function;
|
2014-01-12 11:56:57 +01:00
|
|
|
class FunctionPass;
|
2014-01-12 13:15:39 +01:00
|
|
|
class Module;
|
2014-01-12 11:56:57 +01:00
|
|
|
class ModulePass;
|
2014-01-12 13:15:39 +01:00
|
|
|
class PreservedAnalyses;
|
2014-01-12 11:56:57 +01:00
|
|
|
class raw_ostream;
|
2016-08-19 20:36:06 +02:00
|
|
|
template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
|
2014-01-12 11:56:57 +01:00
|
|
|
|
2014-01-12 12:10:32 +01:00
|
|
|
/// \brief Create and return a pass that writes the module to the specified
|
|
|
|
/// \c raw_ostream.
|
2014-01-12 12:30:46 +01:00
|
|
|
ModulePass *createPrintModulePass(raw_ostream &OS,
|
2015-04-15 04:38:06 +02:00
|
|
|
const std::string &Banner = "",
|
|
|
|
bool ShouldPreserveUseListOrder = false);
|
2014-01-12 11:56:57 +01:00
|
|
|
|
2014-01-12 12:10:32 +01:00
|
|
|
/// \brief Create and return a pass that prints functions to the specified
|
|
|
|
/// \c raw_ostream as they are processed.
|
2014-01-12 12:30:46 +01:00
|
|
|
FunctionPass *createPrintFunctionPass(raw_ostream &OS,
|
|
|
|
const std::string &Banner = "");
|
2014-01-12 11:56:57 +01:00
|
|
|
|
2014-01-12 12:10:32 +01:00
|
|
|
/// \brief Create and return a pass that writes the BB to the specified
|
|
|
|
/// \c raw_ostream.
|
2014-01-12 12:30:46 +01:00
|
|
|
BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
|
2014-01-12 11:56:57 +01:00
|
|
|
const std::string &Banner = "");
|
|
|
|
|
2015-07-21 18:50:35 +02:00
|
|
|
/// Print out a name of an LLVM value without any prefixes.
|
|
|
|
///
|
|
|
|
/// The name is surrounded with ""'s and escaped if it has any special or
|
|
|
|
/// non-printable characters in it.
|
|
|
|
void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name);
|
|
|
|
|
2014-01-12 13:15:39 +01:00
|
|
|
/// \brief Pass for printing a Module as LLVM's text IR assembly.
|
|
|
|
///
|
|
|
|
/// Note: This pass is for use with the new pass manager. Use the create...Pass
|
|
|
|
/// functions above to create passes for use with the legacy pass manager.
|
|
|
|
class PrintModulePass {
|
|
|
|
raw_ostream &OS;
|
|
|
|
std::string Banner;
|
2015-04-15 04:38:06 +02:00
|
|
|
bool ShouldPreserveUseListOrder;
|
2014-01-12 13:15:39 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
PrintModulePass();
|
2015-04-15 04:38:06 +02:00
|
|
|
PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
|
|
|
|
bool ShouldPreserveUseListOrder = false);
|
2014-01-12 13:15:39 +01:00
|
|
|
|
2016-06-17 02:11:01 +02:00
|
|
|
PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
|
2014-01-12 13:15:39 +01:00
|
|
|
|
|
|
|
static StringRef name() { return "PrintModulePass"; }
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Pass for printing a Function as LLVM's text IR assembly.
|
|
|
|
///
|
|
|
|
/// Note: This pass is for use with the new pass manager. Use the create...Pass
|
|
|
|
/// functions above to create passes for use with the legacy pass manager.
|
|
|
|
class PrintFunctionPass {
|
|
|
|
raw_ostream &OS;
|
|
|
|
std::string Banner;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PrintFunctionPass();
|
|
|
|
PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
|
|
|
|
|
2016-06-17 02:11:01 +02:00
|
|
|
PreservedAnalyses run(Function &F, AnalysisManager<Function> &);
|
2014-01-12 13:15:39 +01:00
|
|
|
|
|
|
|
static StringRef name() { return "PrintFunctionPass"; }
|
|
|
|
};
|
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
} // End llvm namespace
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2001-10-18 22:31:42 +02:00
|
|
|
#endif
|