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