LLVM: lib/CodeGen/MIRPrintingPass.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
20
21using namespace llvm;
22
27
38
39namespace {
40
41
42
44 static char ID;
46 std::string MachineFunctions;
47
50
51 StringRef getPassName() const override { return "MIR Printing Pass"; }
52
53 void getAnalysisUsage(AnalysisUsage &AU) const override {
56 }
57
58 bool runOnMachineFunction(MachineFunction &MF) override {
59 std::string Str;
60 raw_string_ostream StrOS(Str);
61
62 const MachineModuleInfo &MMI =
63 getAnalysis().getMMI();
64
66 MachineFunctions.append(Str);
67 return false;
68 }
69
70 bool doFinalization(Module &M) override {
72 OS << MachineFunctions;
73 return false;
74 }
75};
76
77char MIRPrintingPass::ID = 0;
78
79}
80
82INITIALIZE_PASS(MIRPrintingPass, "mir-printer", "MIR Printer", false, false)
83
85 return new MIRPrintingPass(OS);
86}
Machine Check Debug Module
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Module * getParent()
Get the module that this global value is contained inside of...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Function & getFunction()
Return the LLVM function that this machine code represents.
An analysis that produces MachineModuleInfo for a module.
This class contains meta information specific to a module.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Definition MIRPrintingPass.cpp:28
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM)
Definition MIRPrintingPass.cpp:23
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
LLVM_ABI MachineFunctionPass * createPrintMIRPass(raw_ostream &OS)
MIRPrinting pass - this pass prints out the LLVM IR into the given stream using the MIR serialization...
Definition MIRPrintingPass.cpp:84
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI void printMIR(raw_ostream &OS, const Module &M)
Print LLVM IR using the MIR serialization format to the given output stream.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI char & MIRPrintingPassID
MIRPrintingPass - this pass prints out the LLVM IR using the MIR serialization format.
Definition MIRPrintingPass.cpp:81
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.