LLVM 22.0.0git
X86CodeGenPassBuilder.cpp
Go to the documentation of this file.
1//===-- X86CodeGenPassBuilder.cpp ---------------------------------*- 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/// This file contains X86 CodeGen pipeline builder.
10/// TODO: Port CodeGen passes to new pass manager.
11//===----------------------------------------------------------------------===//
12
13#include "X86.h"
14#include "X86ISelDAGToDAG.h"
15#include "X86TargetMachine.h"
16
17#include "llvm/MC/MCStreamer.h"
20
21using namespace llvm;
22
23namespace {
24
25class X86CodeGenPassBuilder
26 : public CodeGenPassBuilder<X86CodeGenPassBuilder, X86TargetMachine> {
27public:
28 explicit X86CodeGenPassBuilder(X86TargetMachine &TM,
29 const CGPassBuilderOption &Opts,
30 PassInstrumentationCallbacks *PIC)
31 : CodeGenPassBuilder(TM, Opts, PIC) {}
32 void addPreISel(PassManagerWrapper &PMW) const;
33 void addAsmPrinter(PassManagerWrapper &PMW, CreateMCStreamer) const;
34 Error addInstSelector(PassManagerWrapper &PMW) const;
35 void addPreSched2(PassManagerWrapper &PMW) const;
36};
37
38void X86CodeGenPassBuilder::addPreISel(PassManagerWrapper &PMW) const {
39 // TODO: Add passes pre instruction selection.
40}
41
42void X86CodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW,
43 CreateMCStreamer) const {
44 // TODO: Add AsmPrinter.
45}
46
47Error X86CodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) const {
48 // TODO: Add instruction selector related passes.
49 addMachineFunctionPass(X86ISelDAGToDAGPass(TM), PMW);
50 return Error::success();
51}
52
53void X86CodeGenPassBuilder::addPreSched2(PassManagerWrapper &PMW) const {
54 addMachineFunctionPass(X86ExpandPseudoPass(), PMW);
55}
56
57} // namespace
58
60#define GET_PASS_REGISTRY "X86PassRegistry.def"
62}
63
66 CodeGenFileType FileType, const CGPassBuilderOption &Opt,
68 auto CGPB = X86CodeGenPassBuilder(*this, Opt, PIC);
69 return CGPB.buildPipeline(MPM, Out, DwoOut, FileType);
70}
Interfaces for producing common pass manager configurations.
PassInstrumentationCallbacks PIC
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
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
This class provides access to building LLVM's passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline.
Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, const CGPassBuilderOption &, PassInstrumentationCallbacks *) override
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.
Definition Types.h:26
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:111
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.