Skip to content

Commit 41528ff

Browse files
committed
[X86] Add CodeGenBuilder for test
1 parent d023044 commit 41528ff

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

llvm/lib/Target/X86/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ set(sources
2929
X86CallFrameOptimization.cpp
3030
X86CallingConv.cpp
3131
X86CmovConversion.cpp
32+
X86CodeGenPassBuilder.cpp
3233
X86DomainReassignment.cpp
3334
X86DiscriminateMemOps.cpp
3435
X86LowerTileCopy.cpp
@@ -98,9 +99,11 @@ add_llvm_target(X86CodeGen ${sources}
9899
CodeGenTypes
99100
Core
100101
GlobalISel
102+
IRPrinter
101103
Instrumentation
102104
MC
103105
ProfileData
106+
Scalar
104107
SelectionDAG
105108
Support
106109
Target
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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/CodeGen/CodeGenPassBuilder.h"
16+
#include "llvm/MC/MCStreamer.h"
17+
18+
using namespace llvm;
19+
20+
namespace {
21+
22+
class X86CodeGenPassBuilder : public CodeGenPassBuilder<X86CodeGenPassBuilder> {
23+
public:
24+
explicit X86CodeGenPassBuilder(LLVMTargetMachine &TM,
25+
CGPassBuilderOption Opts,
26+
PassInstrumentationCallbacks *PIC)
27+
: CodeGenPassBuilder(TM, Opts, PIC) {}
28+
void addPreISel(AddIRPass &addPass) const;
29+
void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
30+
Error addInstSelector(AddMachinePass &) const;
31+
};
32+
33+
void X86CodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
34+
// TODO: Add passes pre instruction selection.
35+
}
36+
37+
void X86CodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
38+
CreateMCStreamer) const {
39+
// TODO: Add AsmPrinter.
40+
}
41+
42+
Error X86CodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
43+
// TODO: Add instruction selector.
44+
return Error::success();
45+
}
46+
47+
} // namespace
48+
49+
Error X86TargetMachine::buildCodeGenPipeline(
50+
ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
51+
MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
52+
raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
53+
CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
54+
auto CGPB = X86CodeGenPassBuilder(*this, Opt, PIC);
55+
return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
56+
}

llvm/lib/Target/X86/X86TargetMachine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ class X86TargetMachine final : public LLVMTargetMachine {
5858
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
5959
const TargetSubtargetInfo *STI) const override;
6060

61+
Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
62+
MachineFunctionAnalysisManager &,
63+
raw_pwrite_stream &, raw_pwrite_stream *,
64+
CodeGenFileType, CGPassBuilderOption,
65+
PassInstrumentationCallbacks *) override;
66+
6167
bool isJIT() const { return IsJIT; }
6268

6369
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;

0 commit comments

Comments
 (0)