xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
17a6dacacSDimitry Andric //===-- X86CodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=//
27a6dacacSDimitry Andric //
37a6dacacSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47a6dacacSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
57a6dacacSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67a6dacacSDimitry Andric //
77a6dacacSDimitry Andric //===----------------------------------------------------------------------===//
87a6dacacSDimitry Andric /// \file
97a6dacacSDimitry Andric /// This file contains X86 CodeGen pipeline builder.
107a6dacacSDimitry Andric /// TODO: Port CodeGen passes to new pass manager.
117a6dacacSDimitry Andric //===----------------------------------------------------------------------===//
127a6dacacSDimitry Andric 
13*0fca6ea1SDimitry Andric #include "X86ISelDAGToDAG.h"
147a6dacacSDimitry Andric #include "X86TargetMachine.h"
157a6dacacSDimitry Andric 
167a6dacacSDimitry Andric #include "llvm/MC/MCStreamer.h"
17*0fca6ea1SDimitry Andric #include "llvm/Passes/CodeGenPassBuilder.h"
18*0fca6ea1SDimitry Andric #include "llvm/Passes/PassBuilder.h"
197a6dacacSDimitry Andric 
207a6dacacSDimitry Andric using namespace llvm;
217a6dacacSDimitry Andric 
227a6dacacSDimitry Andric namespace {
237a6dacacSDimitry Andric 
24*0fca6ea1SDimitry Andric class X86CodeGenPassBuilder
25*0fca6ea1SDimitry Andric     : public CodeGenPassBuilder<X86CodeGenPassBuilder, X86TargetMachine> {
267a6dacacSDimitry Andric public:
X86CodeGenPassBuilder(X86TargetMachine & TM,const CGPassBuilderOption & Opts,PassInstrumentationCallbacks * PIC)27*0fca6ea1SDimitry Andric   explicit X86CodeGenPassBuilder(X86TargetMachine &TM,
28*0fca6ea1SDimitry Andric                                  const CGPassBuilderOption &Opts,
297a6dacacSDimitry Andric                                  PassInstrumentationCallbacks *PIC)
307a6dacacSDimitry Andric       : CodeGenPassBuilder(TM, Opts, PIC) {}
317a6dacacSDimitry Andric   void addPreISel(AddIRPass &addPass) const;
327a6dacacSDimitry Andric   void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
337a6dacacSDimitry Andric   Error addInstSelector(AddMachinePass &) const;
347a6dacacSDimitry Andric };
357a6dacacSDimitry Andric 
addPreISel(AddIRPass & addPass) const367a6dacacSDimitry Andric void X86CodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
377a6dacacSDimitry Andric   // TODO: Add passes pre instruction selection.
387a6dacacSDimitry Andric }
397a6dacacSDimitry Andric 
addAsmPrinter(AddMachinePass & addPass,CreateMCStreamer) const407a6dacacSDimitry Andric void X86CodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
417a6dacacSDimitry Andric                                           CreateMCStreamer) const {
427a6dacacSDimitry Andric   // TODO: Add AsmPrinter.
437a6dacacSDimitry Andric }
447a6dacacSDimitry Andric 
addInstSelector(AddMachinePass & addPass) const45*0fca6ea1SDimitry Andric Error X86CodeGenPassBuilder::addInstSelector(AddMachinePass &addPass) const {
46*0fca6ea1SDimitry Andric   // TODO: Add instruction selector related passes.
47*0fca6ea1SDimitry Andric   addPass(X86ISelDAGToDAGPass(TM));
487a6dacacSDimitry Andric   return Error::success();
497a6dacacSDimitry Andric }
507a6dacacSDimitry Andric 
517a6dacacSDimitry Andric } // namespace
527a6dacacSDimitry Andric 
registerPassBuilderCallbacks(PassBuilder & PB)53*0fca6ea1SDimitry Andric void X86TargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
54*0fca6ea1SDimitry Andric #define GET_PASS_REGISTRY "X86PassRegistry.def"
55*0fca6ea1SDimitry Andric #include "llvm/Passes/TargetPassRegistry.inc"
56*0fca6ea1SDimitry Andric }
57*0fca6ea1SDimitry Andric 
buildCodeGenPipeline(ModulePassManager & MPM,raw_pwrite_stream & Out,raw_pwrite_stream * DwoOut,CodeGenFileType FileType,const CGPassBuilderOption & Opt,PassInstrumentationCallbacks * PIC)587a6dacacSDimitry Andric Error X86TargetMachine::buildCodeGenPipeline(
59*0fca6ea1SDimitry Andric     ModulePassManager &MPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
60*0fca6ea1SDimitry Andric     CodeGenFileType FileType, const CGPassBuilderOption &Opt,
61*0fca6ea1SDimitry Andric     PassInstrumentationCallbacks *PIC) {
627a6dacacSDimitry Andric   auto CGPB = X86CodeGenPassBuilder(*this, Opt, PIC);
63*0fca6ea1SDimitry Andric   return CGPB.buildPipeline(MPM, Out, DwoOut, FileType);
647a6dacacSDimitry Andric }
65