| 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 "X86ISelDAGToDAG.h" |
| 14 | #include "X86TargetMachine.h" |
| 15 | |
| 16 | #include "llvm/MC/MCStreamer.h" |
| 17 | #include "llvm/Passes/CodeGenPassBuilder.h" |
| 18 | #include "llvm/Passes/PassBuilder.h" |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
| 22 | namespace { |
| 23 | |
| 24 | class X86CodeGenPassBuilder |
| 25 | : public CodeGenPassBuilder<X86CodeGenPassBuilder, X86TargetMachine> { |
| 26 | public: |
| 27 | explicit X86CodeGenPassBuilder(X86TargetMachine &TM, |
| 28 | const CGPassBuilderOption &Opts, |
| 29 | PassInstrumentationCallbacks *PIC) |
| 30 | : CodeGenPassBuilder(TM, Opts, PIC) {} |
| 31 | void addPreISel(AddIRPass &addPass) const; |
| 32 | void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const; |
| 33 | Error addInstSelector(AddMachinePass &) const; |
| 34 | }; |
| 35 | |
| 36 | void X86CodeGenPassBuilder::addPreISel(AddIRPass &addPass) const { |
| 37 | // TODO: Add passes pre instruction selection. |
| 38 | } |
| 39 | |
| 40 | void X86CodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass, |
| 41 | CreateMCStreamer) const { |
| 42 | // TODO: Add AsmPrinter. |
| 43 | } |
| 44 | |
| 45 | Error X86CodeGenPassBuilder::addInstSelector(AddMachinePass &addPass) const { |
| 46 | // TODO: Add instruction selector related passes. |
| 47 | addPass(X86ISelDAGToDAGPass(TM)); |
| 48 | return Error::success(); |
| 49 | } |
| 50 | |
| 51 | } // namespace |
| 52 | |
| 53 | void X86TargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { |
| 54 | #define GET_PASS_REGISTRY "X86PassRegistry.def" |
| 55 | #include "llvm/Passes/TargetPassRegistry.inc" |
| 56 | } |
| 57 | |
| 58 | Error X86TargetMachine::buildCodeGenPipeline( |
| 59 | ModulePassManager &MPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, |
| 60 | CodeGenFileType FileType, const CGPassBuilderOption &Opt, |
| 61 | PassInstrumentationCallbacks *PIC) { |
| 62 | auto CGPB = X86CodeGenPassBuilder(*this, Opt, PIC); |
| 63 | return CGPB.buildPipeline(MPM, Out, DwoOut, FileType); |
| 64 | } |
| 65 | |