LLVM  14.0.0git
IRPrintingPasses.h
Go to the documentation of this file.
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_IR_IRPRINTINGPASSES_H
19 #define LLVM_IR_IRPRINTINGPASSES_H
20 
21 #include "llvm/IR/PassManager.h"
22 #include <string>
23 
24 namespace llvm {
25 class raw_ostream;
26 class StringRef;
27 
28 /// Create and return a pass that writes the module to the specified
29 /// \c raw_ostream.
30 ModulePass *createPrintModulePass(raw_ostream &OS,
31  const std::string &Banner = "",
32  bool ShouldPreserveUseListOrder = false);
33 
34 /// Create and return a pass that prints functions to the specified
35 /// \c raw_ostream as they are processed.
36 FunctionPass *createPrintFunctionPass(raw_ostream &OS,
37  const std::string &Banner = "");
38 
39 /// Print out a name of an LLVM value without any prefixes.
40 ///
41 /// The name is surrounded with ""'s and escaped if it has any special or
42 /// non-printable characters in it.
43 void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name);
44 
45 /// Return true if a pass is for IR printing.
46 bool isIRPrintingPass(Pass *P);
47 
48 /// Pass for printing a Module as LLVM's text IR assembly.
49 ///
50 /// Note: This pass is for use with the new pass manager. Use the create...Pass
51 /// functions above to create passes for use with the legacy pass manager.
52 class PrintModulePass : public PassInfoMixin<PrintModulePass> {
53  raw_ostream &OS;
54  std::string Banner;
55  bool ShouldPreserveUseListOrder;
56 
57 public:
59  PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
60  bool ShouldPreserveUseListOrder = false);
61 
63  static bool isRequired() { return true; }
64 };
65 
66 /// Pass for printing a Function as LLVM's text IR assembly.
67 ///
68 /// Note: This pass is for use with the new pass manager. Use the create...Pass
69 /// functions above to create passes for use with the legacy pass manager.
70 class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> {
71  raw_ostream &OS;
72  std::string Banner;
73 
74 public:
76  PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
77 
79  static bool isRequired() { return true; }
80 };
81 
82 } // namespace llvm
83 
84 #endif
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::PrintFunctionPass
Pass for printing a Function as LLVM's text IR assembly.
Definition: IRPrintingPasses.h:70
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:1966
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:61
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::printLLVMNameWithoutPrefix
void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name)
Print out a name of an LLVM value without any prefixes.
Definition: AsmWriter.cpp:349
llvm::PrintFunctionPass::run
PreservedAnalyses run(Function &F, AnalysisManager< Function > &)
Definition: IRPrintingPasses.cpp:56
llvm::PrintModulePass::isRequired
static bool isRequired()
Definition: IRPrintingPasses.h:63
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::PrintModulePass::PrintModulePass
PrintModulePass()
Definition: IRPrintingPasses.cpp:25
llvm::PrintModulePass::run
PreservedAnalyses run(Module &M, AnalysisManager< Module > &)
Definition: IRPrintingPasses.cpp:31
llvm::PrintFunctionPass::PrintFunctionPass
PrintFunctionPass()
Definition: IRPrintingPasses.cpp:52
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::PrintFunctionPass::isRequired
static bool isRequired()
Definition: IRPrintingPasses.h:79
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::isIRPrintingPass
bool isIRPrintingPass(Pass *P)
Return true if a pass is for IR printing.
Definition: IRPrintingPasses.cpp:135
PassManager.h
llvm::PrintModulePass
Pass for printing a Module as LLVM's text IR assembly.
Definition: IRPrintingPasses.h:52
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::createPrintFunctionPass
FunctionPass * createPrintFunctionPass(raw_ostream &OS, const std::string &Banner="")
Create and return a pass that prints functions to the specified raw_ostream as they are processed.
Definition: IRPrintingPasses.cpp:130
llvm::createPrintModulePass
ModulePass * createPrintModulePass(raw_ostream &OS, const std::string &Banner="", bool ShouldPreserveUseListOrder=false)
Create and return a pass that writes the module to the specified raw_ostream.