LLVM 24.0.0git
MSP430CodeGenPassBuilder.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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#include "MSP430.h"
10#include "MSP430AsmPrinter.h"
11#include "MSP430TargetMachine.h"
12
15#include "llvm/MC/MCStreamer.h"
19
20using namespace llvm;
21
22namespace {
23
24class MSP430CodeGenPassBuilder : public CodeGenPassBuilder {
25 using Base = CodeGenPassBuilder;
26
27 MSP430TargetMachine &getTM() const {
28 return static_cast<MSP430TargetMachine &>(TM);
29 }
30
31public:
32 explicit MSP430CodeGenPassBuilder(MSP430TargetMachine &TM,
33 const CGPassBuilderOption &Opts,
34 PassInstrumentationCallbacks *PIC)
35 : CodeGenPassBuilder(TM, Opts, PIC) {}
36
37 void addIRPasses(PassManagerWrapper &PMW) override;
38 Error addInstSelector(PassManagerWrapper &PMW) override;
39 void addPreEmitPass(PassManagerWrapper &PMW) override;
40 void addAsmPrinterBegin(PassManagerWrapper &PMW) override;
41 void addAsmPrinter(PassManagerWrapper &PMW) override;
42 void addAsmPrinterEnd(PassManagerWrapper &PMW) override;
43};
44
45void MSP430CodeGenPassBuilder::addIRPasses(PassManagerWrapper &PMW) {
46 addFunctionPass(AtomicExpandPass(TM), PMW);
47
48 Base::addIRPasses(PMW);
49}
50
51Error MSP430CodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) {
52 addMachineFunctionPass(MSP430ISelDAGToDAGPass(getTM(), getOptLevel()), PMW);
53 return Error::success();
54}
55
56void MSP430CodeGenPassBuilder::addPreEmitPass(PassManagerWrapper &PMW) {
57 addMachineFunctionPass(MSP430BranchSelectPass(), PMW);
58}
59
60void MSP430CodeGenPassBuilder::addAsmPrinterBegin(PassManagerWrapper &PMW) {
61 addModulePass(MSP430AsmPrinterBeginPass(), PMW, /*Force=*/true);
62}
63
64void MSP430CodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) {
65 addMachineFunctionPass(MSP430AsmPrinterPass(), PMW);
66}
67
68void MSP430CodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) {
69 addModulePass(MSP430AsmPrinterEndPass(), PMW);
70}
71
72} // namespace
73
75#define GET_PASS_REGISTRY "MSP430PassRegistry.def"
77}
78
81 raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
82 const CGPassBuilderOption &Opt, MCContext &Ctx,
84 auto CGPB = MSP430CodeGenPassBuilder(*this, Opt, PIC);
85 return CGPB.buildPipeline(MPM, MAM, Out, DwoOut, FileType, Ctx);
86}
Interfaces for producing common pass manager configurations.
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
This class provides access to building LLVM's passes.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Context object for machine code objects.
Definition MCContext.h:83
Error buildCodeGenPipeline(ModulePassManager &MPM, ModuleAnalysisManager &MAM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, const CGPassBuilderOption &Opt, MCContext &Ctx, PassInstrumentationCallbacks *PIC) override
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline.
This class provides access to building LLVM's passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
An abstract base class for streams implementations that also support a pwrite operation.
Interfaces for registering analysis passes, producing common pass manager configurations,...
This is an optimization pass for GlobalISel generic memory operations.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:178
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39