[llvm] [CodeGen] Add code new pm code stubs for all backends (PR #78552)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 00:57:20 PST 2024
https://github.com/paperchalice created https://github.com/llvm/llvm-project/pull/78552
Just add dummy methods here, so `llc` will not throw error when building codegen pipeline.
>From 4ad8cf15b02d2c83ee4975cdc4dd705649e870ed Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Thu, 18 Jan 2024 15:05:49 +0800
Subject: [PATCH 1/2] [Target] Make buildCodeGenPipeline pure virtual
---
llvm/include/llvm/Target/TargetMachine.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index 1fe47dec70b163..0d4444b484d690 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -457,10 +457,7 @@ class LLVMTargetMachine : public TargetMachine {
MachineFunctionAnalysisManager &,
raw_pwrite_stream &, raw_pwrite_stream *,
CodeGenFileType, CGPassBuilderOption,
- PassInstrumentationCallbacks *) {
- return make_error<StringError>("buildCodeGenPipeline is not overridden",
- inconvertibleErrorCode());
- }
+ PassInstrumentationCallbacks *) = 0;
virtual std::pair<StringRef, bool> getPassNameFromLegacyName(StringRef) {
llvm_unreachable(
>From d54b41df684a95b5dcb091808c1729a4c18f0fdb Mon Sep 17 00:00:00 2001
From: PaperChalice <liujunchang97 at outlook.com>
Date: Thu, 18 Jan 2024 16:48:42 +0800
Subject: [PATCH 2/2] [CodeGen] Add code new pm code stubs for all backends
---
.../AArch64/AArch64CodeGenPassBuilder.cpp | 57 +++++++++++++++++++
.../lib/Target/AArch64/AArch64TargetMachine.h | 6 ++
llvm/lib/Target/AArch64/CMakeLists.txt | 2 +
.../AMDGPU/AMDGPUCodeGenPassBuilder.cpp | 56 ++++++++++++++++++
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h | 6 ++
llvm/lib/Target/AMDGPU/CMakeLists.txt | 2 +
llvm/lib/Target/ARC/ARCCodeGenPassBuilder.cpp | 56 ++++++++++++++++++
llvm/lib/Target/ARC/ARCTargetMachine.h | 6 ++
llvm/lib/Target/ARC/CMakeLists.txt | 3 +
llvm/lib/Target/ARM/ARMCodeGenPassBuilder.cpp | 56 ++++++++++++++++++
llvm/lib/Target/ARM/ARMTargetMachine.h | 6 ++
llvm/lib/Target/ARM/CMakeLists.txt | 2 +
llvm/lib/Target/AVR/AVRCodeGenPassBuilder.cpp | 56 ++++++++++++++++++
llvm/lib/Target/AVR/AVRTargetMachine.h | 6 ++
llvm/lib/Target/AVR/CMakeLists.txt | 5 ++
llvm/lib/Target/BPF/BPFCodeGenPassBuilder.cpp | 56 ++++++++++++++++++
llvm/lib/Target/BPF/BPFTargetMachine.h | 6 ++
llvm/lib/Target/BPF/CMakeLists.txt | 2 +
llvm/lib/Target/CSKY/CMakeLists.txt | 4 ++
.../Target/CSKY/CSKYCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/CSKY/CSKYTargetMachine.h | 6 ++
llvm/lib/Target/DirectX/CMakeLists.txt | 3 +
.../DirectX/DirectXCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
.../lib/Target/DirectX/DirectXTargetMachine.h | 6 ++
llvm/lib/Target/Hexagon/CMakeLists.txt | 2 +
.../Hexagon/HexagonCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
.../lib/Target/Hexagon/HexagonTargetMachine.h | 6 ++
llvm/lib/Target/Lanai/CMakeLists.txt | 3 +
.../Target/Lanai/LanaiCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/Lanai/LanaiTargetMachine.h | 6 ++
llvm/lib/Target/LoongArch/CMakeLists.txt | 3 +
.../LoongArch/LoongArchCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
.../Target/LoongArch/LoongArchTargetMachine.h | 6 ++
llvm/lib/Target/M68k/CMakeLists.txt | 4 ++
.../Target/M68k/M68kCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/M68k/M68kTargetMachine.h | 6 ++
llvm/lib/Target/MSP430/CMakeLists.txt | 5 ++
.../MSP430/MSP430CodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/MSP430/MSP430TargetMachine.h | 6 ++
llvm/lib/Target/Mips/CMakeLists.txt | 4 ++
.../Target/Mips/MipsCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/Mips/MipsTargetMachine.h | 6 ++
llvm/lib/Target/NVPTX/CMakeLists.txt | 2 +
.../Target/NVPTX/NVPTXCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/NVPTX/NVPTXTargetMachine.h | 6 ++
llvm/lib/Target/PowerPC/CMakeLists.txt | 2 +
.../Target/PowerPC/PPCCodeGenPassBuilder.cpp | 56 ++++++++++++++++++
llvm/lib/Target/PowerPC/PPCTargetMachine.h | 6 ++
llvm/lib/Target/RISCV/CMakeLists.txt | 2 +
.../Target/RISCV/RISCVCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/RISCV/RISCVTargetMachine.h | 6 ++
llvm/lib/Target/SPIRV/CMakeLists.txt | 3 +
.../Target/SPIRV/SPIRVCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/SPIRV/SPIRVTargetMachine.h | 6 ++
llvm/lib/Target/Sparc/CMakeLists.txt | 5 ++
.../Target/Sparc/SparcCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/Sparc/SparcTargetMachine.h | 6 ++
llvm/lib/Target/SystemZ/CMakeLists.txt | 3 +
.../SystemZ/SystemZCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
.../lib/Target/SystemZ/SystemZTargetMachine.h | 6 ++
llvm/lib/Target/VE/CMakeLists.txt | 4 ++
llvm/lib/Target/VE/VECodeGenPassBuilder.cpp | 55 ++++++++++++++++++
llvm/lib/Target/VE/VETargetMachine.h | 6 ++
llvm/lib/Target/WebAssembly/CMakeLists.txt | 2 +
.../WebAssemblyCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
.../WebAssembly/WebAssemblyTargetMachine.h | 6 ++
llvm/lib/Target/X86/CMakeLists.txt | 3 +
llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp | 56 ++++++++++++++++++
llvm/lib/Target/X86/X86TargetMachine.h | 6 ++
llvm/lib/Target/XCore/CMakeLists.txt | 3 +
.../Target/XCore/XCoreCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/XCore/XCoreTargetMachine.h | 6 ++
llvm/lib/Target/Xtensa/CMakeLists.txt | 5 ++
.../Xtensa/XtensaCodeGenPassBuilder.cpp | 57 +++++++++++++++++++
llvm/lib/Target/Xtensa/XtensaTargetMachine.h | 6 ++
75 files changed, 1644 insertions(+)
create mode 100644 llvm/lib/Target/AArch64/AArch64CodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/AMDGPU/AMDGPUCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/ARC/ARCCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/ARM/ARMCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/AVR/AVRCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/BPF/BPFCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/CSKY/CSKYCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/DirectX/DirectXCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/Hexagon/HexagonCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/Lanai/LanaiCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/LoongArch/LoongArchCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/M68k/M68kCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/MSP430/MSP430CodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/Mips/MipsCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/NVPTX/NVPTXCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/PowerPC/PPCCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/RISCV/RISCVCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/Sparc/SparcCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/VE/VECodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/WebAssembly/WebAssemblyCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/XCore/XCoreCodeGenPassBuilder.cpp
create mode 100644 llvm/lib/Target/Xtensa/XtensaCodeGenPassBuilder.cpp
diff --git a/llvm/lib/Target/AArch64/AArch64CodeGenPassBuilder.cpp b/llvm/lib/Target/AArch64/AArch64CodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..ca916d43b8291f
--- /dev/null
+++ b/llvm/lib/Target/AArch64/AArch64CodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- AArch64CodeGenPassBuilder.cpp -----------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains AArch64 CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "AArch64TargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class AArch64CodeGenPassBuilder
+ : public CodeGenPassBuilder<AArch64CodeGenPassBuilder> {
+public:
+ explicit AArch64CodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void AArch64CodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void AArch64CodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error AArch64CodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error AArch64TargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = AArch64CodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.h b/llvm/lib/Target/AArch64/AArch64TargetMachine.h
index 8fb68b06f13780..55dc92f07f2d9d 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.h
@@ -71,6 +71,12 @@ class AArch64TargetMachine : public LLVMTargetMachine {
return true;
}
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
+
private:
bool isLittle;
};
diff --git a/llvm/lib/Target/AArch64/CMakeLists.txt b/llvm/lib/Target/AArch64/CMakeLists.txt
index cb5f85801c65b7..ab553454f1d4f8 100644
--- a/llvm/lib/Target/AArch64/CMakeLists.txt
+++ b/llvm/lib/Target/AArch64/CMakeLists.txt
@@ -46,6 +46,7 @@ add_llvm_target(AArch64CodeGen
AArch64BranchTargets.cpp
AArch64CallingConvention.cpp
AArch64CleanupLocalDynamicTLSPass.cpp
+ AArch64CodeGenPassBuilder.cpp
AArch64CollectLOH.cpp
AArch64CondBrTuning.cpp
AArch64ConditionalCompares.cpp
@@ -103,6 +104,7 @@ add_llvm_target(AArch64CodeGen
CodeGenTypes
Core
GlobalISel
+ IRPrinter
MC
Scalar
SelectionDAG
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPassBuilder.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..1f7155c44c8c6a
--- /dev/null
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPassBuilder.cpp
@@ -0,0 +1,56 @@
+//===-- AMDGPUCodeGenPassBuilder.cpp ------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains AMDGPU CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+#include "AMDGPUTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class AMDGPUCodeGenPassBuilder
+ : public CodeGenPassBuilder<AMDGPUCodeGenPassBuilder> {
+public:
+ explicit AMDGPUCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void AMDGPUCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void AMDGPUCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error AMDGPUCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error AMDGPUTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = AMDGPUCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
index 99c9db3e654a64..ae8576d7df998b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
@@ -66,6 +66,12 @@ class AMDGPUTargetMachine : public LLVMTargetMachine {
getPredicatedAddrSpace(const Value *V) const override;
unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Target/AMDGPU/CMakeLists.txt b/llvm/lib/Target/AMDGPU/CMakeLists.txt
index 2c92e7a0738855..3bc67d31af474b 100644
--- a/llvm/lib/Target/AMDGPU/CMakeLists.txt
+++ b/llvm/lib/Target/AMDGPU/CMakeLists.txt
@@ -50,6 +50,7 @@ add_llvm_target(AMDGPUCodeGen
AMDGPUAtomicOptimizer.cpp
AMDGPUAttributor.cpp
AMDGPUCallLowering.cpp
+ AMDGPUCodeGenPassBuilder.cpp
AMDGPUCodeGenPrepare.cpp
AMDGPUCombinerHelper.cpp
AMDGPUCtorDtorLowering.cpp
@@ -180,6 +181,7 @@ add_llvm_target(AMDGPUCodeGen
GlobalISel
HipStdPar
IPO
+ IRPrinter
MC
MIRParser
Passes
diff --git a/llvm/lib/Target/ARC/ARCCodeGenPassBuilder.cpp b/llvm/lib/Target/ARC/ARCCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..bdec0148bd6486
--- /dev/null
+++ b/llvm/lib/Target/ARC/ARCCodeGenPassBuilder.cpp
@@ -0,0 +1,56 @@
+//===-- ARCCodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains ARC CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "ARCTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class ARCCodeGenPassBuilder : public CodeGenPassBuilder<ARCCodeGenPassBuilder> {
+public:
+ explicit ARCCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void ARCCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void ARCCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error ARCCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error ARCTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = ARCCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/ARC/ARCTargetMachine.h b/llvm/lib/Target/ARC/ARCTargetMachine.h
index 0fc4243ab44a72..e2df4ef7fa6b6b 100644
--- a/llvm/lib/Target/ARC/ARCTargetMachine.h
+++ b/llvm/lib/Target/ARC/ARCTargetMachine.h
@@ -49,6 +49,12 @@ class ARCTargetMachine : public LLVMTargetMachine {
MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/ARC/CMakeLists.txt b/llvm/lib/Target/ARC/CMakeLists.txt
index 9f3c1787c5635e..3522df427b5ee5 100644
--- a/llvm/lib/Target/ARC/CMakeLists.txt
+++ b/llvm/lib/Target/ARC/CMakeLists.txt
@@ -15,6 +15,7 @@ add_public_tablegen_target(ARCCommonTableGen)
add_llvm_target(ARCCodeGen
ARCAsmPrinter.cpp
ARCBranchFinalize.cpp
+ ARCCodeGenPassBuilder.cpp
ARCExpandPseudos.cpp
ARCFrameLowering.cpp
ARCInstrInfo.cpp
@@ -35,7 +36,9 @@ add_llvm_target(ARCCodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
+ Scalar
SelectionDAG
Support
Target
diff --git a/llvm/lib/Target/ARM/ARMCodeGenPassBuilder.cpp b/llvm/lib/Target/ARM/ARMCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..42134477e25d12
--- /dev/null
+++ b/llvm/lib/Target/ARM/ARMCodeGenPassBuilder.cpp
@@ -0,0 +1,56 @@
+//===-- ARMCodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains ARM CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "ARMTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class ARMCodeGenPassBuilder : public CodeGenPassBuilder<ARMCodeGenPassBuilder> {
+public:
+ explicit ARMCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void ARMCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void ARMCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error ARMCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error ARMBaseTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = ARMCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.h b/llvm/lib/Target/ARM/ARMTargetMachine.h
index 69d8fa8ada6498..07f044c25e9c09 100644
--- a/llvm/lib/Target/ARM/ARMTargetMachine.h
+++ b/llvm/lib/Target/ARM/ARMTargetMachine.h
@@ -91,6 +91,12 @@ class ARMBaseTargetMachine : public LLVMTargetMachine {
PerFunctionMIParsingState &PFS,
SMDiagnostic &Error,
SMRange &SourceRange) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
/// ARM/Thumb little endian target machine.
diff --git a/llvm/lib/Target/ARM/CMakeLists.txt b/llvm/lib/Target/ARM/CMakeLists.txt
index 3d6af28b437538..9f94963c1da56a 100644
--- a/llvm/lib/Target/ARM/CMakeLists.txt
+++ b/llvm/lib/Target/ARM/CMakeLists.txt
@@ -28,6 +28,7 @@ add_llvm_target(ARMCodeGen
ARMBranchTargets.cpp
ARMCallingConv.cpp
ARMCallLowering.cpp
+ ARMCodeGenPassBuilder.cpp
ARMConstantIslandPass.cpp
ARMConstantPoolValue.cpp
ARMExpandPseudoInsts.cpp
@@ -81,6 +82,7 @@ add_llvm_target(ARMCodeGen
Core
GlobalISel
IPO
+ IRPrinter
MC
Scalar
SelectionDAG
diff --git a/llvm/lib/Target/AVR/AVRCodeGenPassBuilder.cpp b/llvm/lib/Target/AVR/AVRCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..50dd940961994d
--- /dev/null
+++ b/llvm/lib/Target/AVR/AVRCodeGenPassBuilder.cpp
@@ -0,0 +1,56 @@
+//===-- AVRCodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains AVR CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "AVRTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class AVRCodeGenPassBuilder : public CodeGenPassBuilder<AVRCodeGenPassBuilder> {
+public:
+ explicit AVRCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void AVRCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void AVRCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error AVRCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error AVRTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = AVRCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.h b/llvm/lib/Target/AVR/AVRTargetMachine.h
index c19df2bc301ea4..4e9c029f8547e6 100644
--- a/llvm/lib/Target/AVR/AVRTargetMachine.h
+++ b/llvm/lib/Target/AVR/AVRTargetMachine.h
@@ -57,6 +57,12 @@ class AVRTargetMachine : public LLVMTargetMachine {
return getPointerSize(SrcAs) == getPointerSize(DestAs);
}
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
+
private:
std::unique_ptr<TargetLoweringObjectFile> TLOF;
AVRSubtarget SubTarget;
diff --git a/llvm/lib/Target/AVR/CMakeLists.txt b/llvm/lib/Target/AVR/CMakeLists.txt
index 817ba739d8418a..678dd6575dafcc 100644
--- a/llvm/lib/Target/AVR/CMakeLists.txt
+++ b/llvm/lib/Target/AVR/CMakeLists.txt
@@ -16,6 +16,7 @@ add_public_tablegen_target(AVRCommonTableGen)
add_llvm_target(AVRCodeGen
AVRAsmPrinter.cpp
+ AVRCodeGenPassBuilder.cpp
AVRExpandPseudoInsts.cpp
AVRFrameLowering.cpp
AVRInstrInfo.cpp
@@ -34,14 +35,18 @@ add_llvm_target(AVRCodeGen
LINK_COMPONENTS
AVRDesc
AVRInfo
+ Analysis
AsmPrinter
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
+ Scalar
SelectionDAG
Support
Target
+ TransformUtils
ADD_TO_COMPONENT
AVR
diff --git a/llvm/lib/Target/BPF/BPFCodeGenPassBuilder.cpp b/llvm/lib/Target/BPF/BPFCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..754ad4415cf4cd
--- /dev/null
+++ b/llvm/lib/Target/BPF/BPFCodeGenPassBuilder.cpp
@@ -0,0 +1,56 @@
+//===-- BPFCodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains BPF CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "BPFTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class BPFCodeGenPassBuilder : public CodeGenPassBuilder<BPFCodeGenPassBuilder> {
+public:
+ explicit BPFCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void BPFCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void BPFCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error BPFCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error BPFTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = BPFCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.h b/llvm/lib/Target/BPF/BPFTargetMachine.h
index 0a28394463b26a..74228d55fd1e5f 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.h
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.h
@@ -44,6 +44,12 @@ class BPFTargetMachine : public LLVMTargetMachine {
void registerPassBuilderCallbacks(PassBuilder &PB,
bool PopulateClassToPassNames) override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
}
diff --git a/llvm/lib/Target/BPF/CMakeLists.txt b/llvm/lib/Target/BPF/CMakeLists.txt
index d88e7ade40b9a0..e649fd6a02c262 100644
--- a/llvm/lib/Target/BPF/CMakeLists.txt
+++ b/llvm/lib/Target/BPF/CMakeLists.txt
@@ -24,6 +24,7 @@ add_llvm_target(BPFCodeGen
BPFAbstractMemberAccess.cpp
BPFAdjustOpt.cpp
BPFAsmPrinter.cpp
+ BPFCodeGenPassBuilder.cpp
BPFCheckAndAdjustIR.cpp
BPFFrameLowering.cpp
BPFInstrInfo.cpp
@@ -52,6 +53,7 @@ add_llvm_target(BPFCodeGen
Core
GlobalISel
IPO
+ IRPrinter
MC
Scalar
SelectionDAG
diff --git a/llvm/lib/Target/CSKY/CMakeLists.txt b/llvm/lib/Target/CSKY/CMakeLists.txt
index cdce80591a2fd2..aeb116eddab785 100644
--- a/llvm/lib/Target/CSKY/CMakeLists.txt
+++ b/llvm/lib/Target/CSKY/CMakeLists.txt
@@ -18,6 +18,7 @@ add_public_tablegen_target(CSKYCommonTableGen)
add_llvm_target(CSKYCodeGen
CSKYAsmPrinter.cpp
+ CSKYCodeGenPassBuilder.cpp
CSKYConstantIslandPass.cpp
CSKYConstantPoolValue.cpp
CSKYFrameLowering.cpp
@@ -38,10 +39,13 @@ add_llvm_target(CSKYCodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
+ Scalar
SelectionDAG
Support
Target
+ TransformUtils
ADD_TO_COMPONENT
CSKY
diff --git a/llvm/lib/Target/CSKY/CSKYCodeGenPassBuilder.cpp b/llvm/lib/Target/CSKY/CSKYCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..2dfd7e3a113c2c
--- /dev/null
+++ b/llvm/lib/Target/CSKY/CSKYCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- CSKYCodeGenPassBuilder.cpp --------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains CSKY CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "CSKYTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class CSKYCodeGenPassBuilder
+ : public CodeGenPassBuilder<CSKYCodeGenPassBuilder> {
+public:
+ explicit CSKYCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void CSKYCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void CSKYCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error CSKYCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error CSKYTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = CSKYCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/CSKY/CSKYTargetMachine.h b/llvm/lib/Target/CSKY/CSKYTargetMachine.h
index e47b514ae9ddc5..3d80b5ea92bcfd 100644
--- a/llvm/lib/Target/CSKY/CSKYTargetMachine.h
+++ b/llvm/lib/Target/CSKY/CSKYTargetMachine.h
@@ -46,6 +46,12 @@ class CSKYTargetMachine : public LLVMTargetMachine {
MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/DirectX/CMakeLists.txt b/llvm/lib/Target/DirectX/CMakeLists.txt
index bf93280779bf8b..51ce57ad8e323f 100644
--- a/llvm/lib/Target/DirectX/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/CMakeLists.txt
@@ -14,6 +14,7 @@ add_public_tablegen_target(DirectXCommonTableGen)
add_llvm_target(DirectXCodeGen
CBufferDataLayout.cpp
DirectXAsmPrinter.cpp
+ DirectXCodeGenPassBuilder.cpp
DirectXInstrInfo.cpp
DirectXRegisterInfo.cpp
DirectXSubtarget.cpp
@@ -40,7 +41,9 @@ add_llvm_target(DirectXCodeGen
DirectXInfo
DirectXPointerTypeAnalysis
FrontendHLSL
+ IRPrinter
MC
+ Scalar
SelectionDAG
Support
Target
diff --git a/llvm/lib/Target/DirectX/DirectXCodeGenPassBuilder.cpp b/llvm/lib/Target/DirectX/DirectXCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..73d672da3e76dc
--- /dev/null
+++ b/llvm/lib/Target/DirectX/DirectXCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- DirectXCodeGenPassBuilder.cpp -----------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains DirectX CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "DirectXTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class DirectXCodeGenPassBuilder
+ : public CodeGenPassBuilder<DirectXCodeGenPassBuilder> {
+public:
+ explicit DirectXCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void DirectXCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void DirectXCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error DirectXCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error DirectXTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = DirectXCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.h b/llvm/lib/Target/DirectX/DirectXTargetMachine.h
index 428beaf61cd0a8..4cddbb542edf1f 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetMachine.h
+++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.h
@@ -49,6 +49,12 @@ class DirectXTargetMachine : public LLVMTargetMachine {
TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
void registerPassBuilderCallbacks(PassBuilder &PB,
bool PopulateClassToPassNames) override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/Hexagon/CMakeLists.txt b/llvm/lib/Target/Hexagon/CMakeLists.txt
index 76f99b4d3ec580..d7311dd9c037e8 100644
--- a/llvm/lib/Target/Hexagon/CMakeLists.txt
+++ b/llvm/lib/Target/Hexagon/CMakeLists.txt
@@ -24,6 +24,7 @@ add_llvm_target(HexagonCodeGen
HexagonBranchRelaxation.cpp
HexagonCFGOptimizer.cpp
HexagonCommonGEP.cpp
+ HexagonCodeGenPassBuilder.cpp
HexagonConstExtenders.cpp
HexagonConstPropagation.cpp
HexagonCopyToCombine.cpp
@@ -78,6 +79,7 @@ add_llvm_target(HexagonCodeGen
HexagonDesc
HexagonInfo
IPO
+ IRPrinter
MC
Scalar
SelectionDAG
diff --git a/llvm/lib/Target/Hexagon/HexagonCodeGenPassBuilder.cpp b/llvm/lib/Target/Hexagon/HexagonCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..9b01926eb9bcb9
--- /dev/null
+++ b/llvm/lib/Target/Hexagon/HexagonCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- HexagonCodeGenPassBuilder.cpp -----------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains Hexagon CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "HexagonTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class HexagonCodeGenPassBuilder
+ : public CodeGenPassBuilder<HexagonCodeGenPassBuilder> {
+public:
+ explicit HexagonCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void HexagonCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void HexagonCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error HexagonCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error HexagonTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = HexagonCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
index c5fed0cd65a814..af14180ff82749 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
@@ -46,6 +46,12 @@ class HexagonTargetMachine : public LLVMTargetMachine {
MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/Lanai/CMakeLists.txt b/llvm/lib/Target/Lanai/CMakeLists.txt
index 16d5f727043fe9..0b53f2b862d26c 100644
--- a/llvm/lib/Target/Lanai/CMakeLists.txt
+++ b/llvm/lib/Target/Lanai/CMakeLists.txt
@@ -16,6 +16,7 @@ add_public_tablegen_target(LanaiCommonTableGen)
add_llvm_target(LanaiCodeGen
LanaiAsmPrinter.cpp
+ LanaiCodeGenPassBuilder.cpp
LanaiDelaySlotFiller.cpp
LanaiFrameLowering.cpp
LanaiInstrInfo.cpp
@@ -36,10 +37,12 @@ add_llvm_target(LanaiCodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
LanaiAsmParser
LanaiDesc
LanaiInfo
MC
+ Scalar
SelectionDAG
Support
Target
diff --git a/llvm/lib/Target/Lanai/LanaiCodeGenPassBuilder.cpp b/llvm/lib/Target/Lanai/LanaiCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..23ab14358686db
--- /dev/null
+++ b/llvm/lib/Target/Lanai/LanaiCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- LanaiCodeGenPassBuilder.cpp -------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains Lanai CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "LanaiTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class LanaiCodeGenPassBuilder
+ : public CodeGenPassBuilder<LanaiCodeGenPassBuilder> {
+public:
+ explicit LanaiCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void LanaiCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void LanaiCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error LanaiCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error LanaiTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = LanaiCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.h b/llvm/lib/Target/Lanai/LanaiTargetMachine.h
index c5c351b36b3169..c8f4c328244ef3 100644
--- a/llvm/lib/Target/Lanai/LanaiTargetMachine.h
+++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.h
@@ -55,6 +55,12 @@ class LanaiTargetMachine : public LLVMTargetMachine {
bool isMachineVerifierClean() const override {
return false;
}
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/LoongArch/CMakeLists.txt b/llvm/lib/Target/LoongArch/CMakeLists.txt
index 62e5a0ab61b3fd..cf90cedab51f9e 100644
--- a/llvm/lib/Target/LoongArch/CMakeLists.txt
+++ b/llvm/lib/Target/LoongArch/CMakeLists.txt
@@ -16,6 +16,7 @@ add_public_tablegen_target(LoongArchCommonTableGen)
add_llvm_target(LoongArchCodeGen
LoongArchAsmPrinter.cpp
+ LoongArchCodeGenPassBuilder.cpp
LoongArchExpandAtomicPseudoInsts.cpp
LoongArchExpandPseudoInsts.cpp
LoongArchFrameLowering.cpp
@@ -34,6 +35,7 @@ add_llvm_target(LoongArchCodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
LoongArchDesc
LoongArchInfo
MC
@@ -42,6 +44,7 @@ add_llvm_target(LoongArchCodeGen
Support
Target
TargetParser
+ TransformUtils
ADD_TO_COMPONENT
LoongArch
diff --git a/llvm/lib/Target/LoongArch/LoongArchCodeGenPassBuilder.cpp b/llvm/lib/Target/LoongArch/LoongArchCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..91f8ec0f278024
--- /dev/null
+++ b/llvm/lib/Target/LoongArch/LoongArchCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- LoongArchCodeGenPassBuilder.cpp ---------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains LoongArch CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "LoongArchTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class LoongArchCodeGenPassBuilder
+ : public CodeGenPassBuilder<LoongArchCodeGenPassBuilder> {
+public:
+ explicit LoongArchCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void LoongArchCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void LoongArchCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error LoongArchCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error LoongArchTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = LoongArchCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h
index 7d39d47e86b363..374005085051b4 100644
--- a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h
+++ b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h
@@ -45,6 +45,12 @@ class LoongArchTargetMachine : public LLVMTargetMachine {
MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/M68k/CMakeLists.txt b/llvm/lib/Target/M68k/CMakeLists.txt
index 1661dccece3dd8..f3e8df1eeda4cb 100644
--- a/llvm/lib/Target/M68k/CMakeLists.txt
+++ b/llvm/lib/Target/M68k/CMakeLists.txt
@@ -23,6 +23,7 @@ add_llvm_target(M68kCodeGen
GISel/M68kLegalizerInfo.cpp
GISel/M68kRegisterBankInfo.cpp
M68kAsmPrinter.cpp
+ M68kCodeGenPassBuilder.cpp
M68kCollapseMOVEMPass.cpp
M68kExpandPseudo.cpp
M68kFrameLowering.cpp
@@ -43,12 +44,15 @@ add_llvm_target(M68kCodeGen
CodeGenTypes
Core
GlobalISel
+ IRPrinter
M68kDesc
M68kInfo
MC
+ Scalar
SelectionDAG
Support
Target
+ TransformUtils
ADD_TO_COMPONENT
M68k
diff --git a/llvm/lib/Target/M68k/M68kCodeGenPassBuilder.cpp b/llvm/lib/Target/M68k/M68kCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..4cfde2e1b339c1
--- /dev/null
+++ b/llvm/lib/Target/M68k/M68kCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- M68kCodeGenPassBuilder.cpp --------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains M68k CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "M68kTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class M68kCodeGenPassBuilder
+ : public CodeGenPassBuilder<M68kCodeGenPassBuilder> {
+public:
+ explicit M68kCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void M68kCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void M68kCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error M68kCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error M68kTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = M68kCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/M68k/M68kTargetMachine.h b/llvm/lib/Target/M68k/M68kTargetMachine.h
index 4ff4c4cb46b809..ff31bfd49c8e84 100644
--- a/llvm/lib/Target/M68k/M68kTargetMachine.h
+++ b/llvm/lib/Target/M68k/M68kTargetMachine.h
@@ -57,6 +57,12 @@ class M68kTargetMachine : public LLVMTargetMachine {
TargetLoweringObjectFile *getObjFileLowering() const override {
return TLOF.get();
}
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/MSP430/CMakeLists.txt b/llvm/lib/Target/MSP430/CMakeLists.txt
index 1dfe8635acb32b..4dade8968e3941 100644
--- a/llvm/lib/Target/MSP430/CMakeLists.txt
+++ b/llvm/lib/Target/MSP430/CMakeLists.txt
@@ -16,6 +16,7 @@ add_public_tablegen_target(MSP430CommonTableGen)
add_llvm_target(MSP430CodeGen
MSP430BranchSelector.cpp
+ MSP430CodeGenPassBuilder.cpp
MSP430ISelDAGToDAG.cpp
MSP430ISelLowering.cpp
MSP430InstrInfo.cpp
@@ -28,16 +29,20 @@ add_llvm_target(MSP430CodeGen
MSP430MCInstLower.cpp
LINK_COMPONENTS
+ Analysis
AsmPrinter
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
MSP430Desc
MSP430Info
+ Scalar
SelectionDAG
Support
Target
+ TransformUtils
ADD_TO_COMPONENT
MSP430
diff --git a/llvm/lib/Target/MSP430/MSP430CodeGenPassBuilder.cpp b/llvm/lib/Target/MSP430/MSP430CodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..cd9c135afcebc8
--- /dev/null
+++ b/llvm/lib/Target/MSP430/MSP430CodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- MSP430CodeGenPassBuilder.cpp ------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains MSP430 CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "MSP430TargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class MSP430CodeGenPassBuilder
+ : public CodeGenPassBuilder<MSP430CodeGenPassBuilder> {
+public:
+ explicit MSP430CodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void MSP430CodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void MSP430CodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error MSP430CodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error MSP430TargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = MSP430CodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/MSP430/MSP430TargetMachine.h b/llvm/lib/Target/MSP430/MSP430TargetMachine.h
index f9af9a7e26f696..12095e761eef4a 100644
--- a/llvm/lib/Target/MSP430/MSP430TargetMachine.h
+++ b/llvm/lib/Target/MSP430/MSP430TargetMachine.h
@@ -47,6 +47,12 @@ class MSP430TargetMachine : public LLVMTargetMachine {
MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
}; // MSP430TargetMachine.
} // end namespace llvm
diff --git a/llvm/lib/Target/Mips/CMakeLists.txt b/llvm/lib/Target/Mips/CMakeLists.txt
index 3a9031b5ad00d6..6986ffc390e20e 100644
--- a/llvm/lib/Target/Mips/CMakeLists.txt
+++ b/llvm/lib/Target/Mips/CMakeLists.txt
@@ -33,6 +33,7 @@ add_llvm_target(MipsCodeGen
MipsAsmPrinter.cpp
MipsCallLowering.cpp
MipsCCState.cpp
+ MipsCodeGenPassBuilder.cpp
MipsConstantIslandPass.cpp
MipsDelaySlotFiller.cpp
MipsExpandPseudo.cpp
@@ -72,13 +73,16 @@ add_llvm_target(MipsCodeGen
CodeGenTypes
Core
GlobalISel
+ IRPrinter
MC
MipsDesc
MipsInfo
+ Scalar
SelectionDAG
Support
Target
TargetParser
+ TransformUtils
ADD_TO_COMPONENT
Mips
diff --git a/llvm/lib/Target/Mips/MipsCodeGenPassBuilder.cpp b/llvm/lib/Target/Mips/MipsCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..12a6f322dd78ac
--- /dev/null
+++ b/llvm/lib/Target/Mips/MipsCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- MipsCodeGenPassBuilder.cpp --------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains Mips CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "MipsTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class MipsCodeGenPassBuilder
+ : public CodeGenPassBuilder<MipsCodeGenPassBuilder> {
+public:
+ explicit MipsCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void MipsCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void MipsCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error MipsCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error MipsTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = MipsCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.h b/llvm/lib/Target/Mips/MipsTargetMachine.h
index 0ad239e3bed128..daf0085be29c87 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.h
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.h
@@ -68,6 +68,12 @@ class MipsTargetMachine : public LLVMTargetMachine {
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
+
/// Returns true if a cast between SrcAS and DestAS is a noop.
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
// Mips doesn't have any special address spaces so we just reserve
diff --git a/llvm/lib/Target/NVPTX/CMakeLists.txt b/llvm/lib/Target/NVPTX/CMakeLists.txt
index 693365161330f5..05759a82711e65 100644
--- a/llvm/lib/Target/NVPTX/CMakeLists.txt
+++ b/llvm/lib/Target/NVPTX/CMakeLists.txt
@@ -16,6 +16,7 @@ set(NVPTXCodeGen_sources
NVPTXAtomicLower.cpp
NVPTXAsmPrinter.cpp
NVPTXAssignValidGlobalNames.cpp
+ NVPTXCodeGenPassBuilder.cpp
NVPTXFrameLowering.cpp
NVPTXGenericToNVVM.cpp
NVPTXISelDAGToDAG.cpp
@@ -51,6 +52,7 @@ add_llvm_target(NVPTXCodeGen
CodeGenTypes
Core
IPO
+ IRPrinter
MC
NVPTXDesc
NVPTXInfo
diff --git a/llvm/lib/Target/NVPTX/NVPTXCodeGenPassBuilder.cpp b/llvm/lib/Target/NVPTX/NVPTXCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..10ceb94351ce72
--- /dev/null
+++ b/llvm/lib/Target/NVPTX/NVPTXCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- NVPTXCodeGenPassBuilder.cpp -------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains NVPTX CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "NVPTXTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class NVPTXCodeGenPassBuilder
+ : public CodeGenPassBuilder<NVPTXCodeGenPassBuilder> {
+public:
+ explicit NVPTXCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void NVPTXCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void NVPTXCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error NVPTXCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error NVPTXTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = NVPTXCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
index 9e6bf929badba2..3c4dfdd53d5a67 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
@@ -80,6 +80,12 @@ class NVPTXTargetMachine : public LLVMTargetMachine {
std::pair<const Value *, unsigned>
getPredicatedAddrSpace(const Value *V) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
}; // NVPTXTargetMachine.
class NVPTXTargetMachine32 : public NVPTXTargetMachine {
diff --git a/llvm/lib/Target/PowerPC/CMakeLists.txt b/llvm/lib/Target/PowerPC/CMakeLists.txt
index d866ef6b88a1d6..0b0d18f28f4ee1 100644
--- a/llvm/lib/Target/PowerPC/CMakeLists.txt
+++ b/llvm/lib/Target/PowerPC/CMakeLists.txt
@@ -25,6 +25,7 @@ add_llvm_target(PowerPCCodeGen
PPCBranchSelector.cpp
PPCBranchCoalescing.cpp
PPCCallingConv.cpp
+ PPCCodeGenPassBuilder.cpp
PPCCCState.cpp
PPCCTRLoops.cpp
PPCCTRLoopsVerify.cpp
@@ -70,6 +71,7 @@ add_llvm_target(PowerPCCodeGen
CodeGenTypes
Core
GlobalISel
+ IRPrinter
MC
PowerPCDesc
PowerPCInfo
diff --git a/llvm/lib/Target/PowerPC/PPCCodeGenPassBuilder.cpp b/llvm/lib/Target/PowerPC/PPCCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..1f1fcc584e1969
--- /dev/null
+++ b/llvm/lib/Target/PowerPC/PPCCodeGenPassBuilder.cpp
@@ -0,0 +1,56 @@
+//===-- PPCCodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains PPC CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "PPCTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class PPCCodeGenPassBuilder : public CodeGenPassBuilder<PPCCodeGenPassBuilder> {
+public:
+ explicit PPCCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void PPCCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void PPCCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error PPCCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error PPCTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = PPCCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.h b/llvm/lib/Target/PowerPC/PPCTargetMachine.h
index 56145a2eb39ce4..520cd0e7f910e3 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.h
+++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.h
@@ -77,6 +77,12 @@ class PPCTargetMachine final : public LLVMTargetMachine {
bool isLittleEndian() const;
int unqualifiedInlineAsmVariant() const override { return 1; }
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/RISCV/CMakeLists.txt b/llvm/lib/Target/RISCV/CMakeLists.txt
index a0c3345ec1bbd7..eec768ab81f614 100644
--- a/llvm/lib/Target/RISCV/CMakeLists.txt
+++ b/llvm/lib/Target/RISCV/CMakeLists.txt
@@ -28,6 +28,7 @@ add_public_tablegen_target(RISCVCommonTableGen)
add_llvm_target(RISCVCodeGen
RISCVAsmPrinter.cpp
+ RISCVCodeGenPassBuilder.cpp
RISCVCodeGenPrepare.cpp
RISCVDeadRegisterDefinitions.cpp
RISCVMakeCompressible.cpp
@@ -72,6 +73,7 @@ add_llvm_target(RISCVCodeGen
Core
GlobalISel
IPO
+ IRPrinter
MC
RISCVDesc
RISCVInfo
diff --git a/llvm/lib/Target/RISCV/RISCVCodeGenPassBuilder.cpp b/llvm/lib/Target/RISCV/RISCVCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..e479b83fb227cf
--- /dev/null
+++ b/llvm/lib/Target/RISCV/RISCVCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- RISCVCodeGenPassBuilder.cpp -------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains RISCV CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "RISCVTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class RISCVCodeGenPassBuilder
+ : public CodeGenPassBuilder<RISCVCodeGenPassBuilder> {
+public:
+ explicit RISCVCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void RISCVCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void RISCVCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error RISCVCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error RISCVTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = RISCVCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.h b/llvm/lib/Target/RISCV/RISCVTargetMachine.h
index 68dfb3c81f2fec..43e3abb8b1726d 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetMachine.h
+++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.h
@@ -59,6 +59,12 @@ class RISCVTargetMachine : public LLVMTargetMachine {
PerFunctionMIParsingState &PFS,
SMDiagnostic &Error,
SMRange &SourceRange) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/SPIRV/CMakeLists.txt b/llvm/lib/Target/SPIRV/CMakeLists.txt
index 7d17c307db13a0..cbfdcfabd29913 100644
--- a/llvm/lib/Target/SPIRV/CMakeLists.txt
+++ b/llvm/lib/Target/SPIRV/CMakeLists.txt
@@ -17,6 +17,7 @@ add_llvm_target(SPIRVCodeGen
SPIRVAsmPrinter.cpp
SPIRVBuiltins.cpp
SPIRVCallLowering.cpp
+ SPIRVCodeGenPassBuilder.cpp
SPIRVDuplicatesTracker.cpp
SPIRVEmitIntrinsics.cpp
SPIRVGlobalRegistry.cpp
@@ -44,9 +45,11 @@ add_llvm_target(SPIRVCodeGen
Core
Demangle
GlobalISel
+ IRPrinter
MC
SPIRVDesc
SPIRVInfo
+ Scalar
SelectionDAG
Support
Target
diff --git a/llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp b/llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..e7270252ebb9e8
--- /dev/null
+++ b/llvm/lib/Target/SPIRV/SPIRVCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- SPIRVCodeGenPassBuilder.cpp -------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains SPIRV CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "SPIRVTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class SPIRVCodeGenPassBuilder
+ : public CodeGenPassBuilder<SPIRVCodeGenPassBuilder> {
+public:
+ explicit SPIRVCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void SPIRVCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void SPIRVCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error SPIRVCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error SPIRVTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = SPIRVCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h
index a1a9f26846153b..e6dcfb0c1cd85d 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h
@@ -43,6 +43,12 @@ class SPIRVTargetMachine : public LLVMTargetMachine {
TargetLoweringObjectFile *getObjFileLowering() const override {
return TLOF.get();
}
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/Sparc/CMakeLists.txt b/llvm/lib/Target/Sparc/CMakeLists.txt
index bf76ed9d671b97..9bdb0f07f58606 100644
--- a/llvm/lib/Target/Sparc/CMakeLists.txt
+++ b/llvm/lib/Target/Sparc/CMakeLists.txt
@@ -19,6 +19,7 @@ add_llvm_target(SparcCodeGen
DelaySlotFiller.cpp
LeonPasses.cpp
SparcAsmPrinter.cpp
+ SparcCodeGenPassBuilder.cpp
SparcInstrInfo.cpp
SparcISelDAGToDAG.cpp
SparcISelLowering.cpp
@@ -31,17 +32,21 @@ add_llvm_target(SparcCodeGen
SparcTargetObjectFile.cpp
LINK_COMPONENTS
+ Analysis
AsmPrinter
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
+ Scalar
SelectionDAG
SparcDesc
SparcInfo
Support
Target
TargetParser
+ TransformUtils
ADD_TO_COMPONENT
Sparc
diff --git a/llvm/lib/Target/Sparc/SparcCodeGenPassBuilder.cpp b/llvm/lib/Target/Sparc/SparcCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..b32abab3de7bbb
--- /dev/null
+++ b/llvm/lib/Target/Sparc/SparcCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- SparcCodeGenPassBuilder.cpp -------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains Sparc CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "SparcTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class SparcCodeGenPassBuilder
+ : public CodeGenPassBuilder<SparcCodeGenPassBuilder> {
+public:
+ explicit SparcCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void SparcCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void SparcCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error SparcCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error SparcTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = SparcCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.h b/llvm/lib/Target/Sparc/SparcTargetMachine.h
index 497d5f6623cd30..cf6fed5c2856f1 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.h
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.h
@@ -44,6 +44,12 @@ class SparcTargetMachine : public LLVMTargetMachine {
MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
/// Sparc 32-bit target machine
diff --git a/llvm/lib/Target/SystemZ/CMakeLists.txt b/llvm/lib/Target/SystemZ/CMakeLists.txt
index 0776cfcaf21b3c..8f972a7db78bcf 100644
--- a/llvm/lib/Target/SystemZ/CMakeLists.txt
+++ b/llvm/lib/Target/SystemZ/CMakeLists.txt
@@ -17,6 +17,7 @@ add_public_tablegen_target(SystemZCommonTableGen)
add_llvm_target(SystemZCodeGen
SystemZAsmPrinter.cpp
SystemZCallingConv.cpp
+ SystemZCodeGenPassBuilder.cpp
SystemZConstantPoolValue.cpp
SystemZCopyPhysRegs.cpp
SystemZElimCompare.cpp
@@ -45,6 +46,7 @@ add_llvm_target(SystemZCodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
Scalar
SelectionDAG
@@ -53,6 +55,7 @@ add_llvm_target(SystemZCodeGen
SystemZInfo
Target
TargetParser
+ TransformUtils
ADD_TO_COMPONENT
SystemZ
diff --git a/llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp b/llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..9aca85000e378b
--- /dev/null
+++ b/llvm/lib/Target/SystemZ/SystemZCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- SystemZCodeGenPassBuilder.cpp -----------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains SystemZ CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "SystemZTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class SystemZCodeGenPassBuilder
+ : public CodeGenPassBuilder<SystemZCodeGenPassBuilder> {
+public:
+ explicit SystemZCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void SystemZCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void SystemZCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error SystemZCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error SystemZTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = SystemZCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.h b/llvm/lib/Target/SystemZ/SystemZTargetMachine.h
index 75e5d68e74eef4..509c441df49d63 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.h
+++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.h
@@ -56,6 +56,12 @@ class SystemZTargetMachine : public LLVMTargetMachine {
const TargetSubtargetInfo *STI) const override;
bool targetSchedulesPostRAScheduling() const override { return true; };
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/VE/CMakeLists.txt b/llvm/lib/Target/VE/CMakeLists.txt
index 45f8293cfd22f6..05a8c40e3ef57d 100644
--- a/llvm/lib/Target/VE/CMakeLists.txt
+++ b/llvm/lib/Target/VE/CMakeLists.txt
@@ -16,6 +16,7 @@ add_public_tablegen_target(VECommonTableGen)
add_llvm_target(VECodeGen
LVLGen.cpp
VEAsmPrinter.cpp
+ VECodeGenPassBuilder.cpp
VECustomDAG.cpp
VEFrameLowering.cpp
VEISelDAGToDAG.cpp
@@ -34,10 +35,13 @@ add_llvm_target(VECodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
+ Scalar
SelectionDAG
Support
Target
+ TransformUtils
VEDesc
VEInfo
diff --git a/llvm/lib/Target/VE/VECodeGenPassBuilder.cpp b/llvm/lib/Target/VE/VECodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..2687b53c4a6845
--- /dev/null
+++ b/llvm/lib/Target/VE/VECodeGenPassBuilder.cpp
@@ -0,0 +1,55 @@
+//===-- VECodeGenPassBuilder.cpp ----------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains VE CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "VETargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class VECodeGenPassBuilder : public CodeGenPassBuilder<VECodeGenPassBuilder> {
+public:
+ explicit VECodeGenPassBuilder(LLVMTargetMachine &TM, CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void VECodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void VECodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error VECodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error VETargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = VECodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/VE/VETargetMachine.h b/llvm/lib/Target/VE/VETargetMachine.h
index fd838296b9dd02..3cbf232acfdde0 100644
--- a/llvm/lib/Target/VE/VETargetMachine.h
+++ b/llvm/lib/Target/VE/VETargetMachine.h
@@ -58,6 +58,12 @@ class VETargetMachine : public LLVMTargetMachine {
TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
unsigned getSjLjDataSize() const override { return 64; }
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // namespace llvm
diff --git a/llvm/lib/Target/WebAssembly/CMakeLists.txt b/llvm/lib/Target/WebAssembly/CMakeLists.txt
index bb2ccea5c14598..2042ffb7100b9a 100644
--- a/llvm/lib/Target/WebAssembly/CMakeLists.txt
+++ b/llvm/lib/Target/WebAssembly/CMakeLists.txt
@@ -20,6 +20,7 @@ add_llvm_target(WebAssemblyCodeGen
WebAssemblyAsmPrinter.cpp
WebAssemblyCFGStackify.cpp
WebAssemblyCFGSort.cpp
+ WebAssemblyCodeGenPassBuilder.cpp
WebAssemblyDebugFixup.cpp
WebAssemblyDebugValueManager.cpp
WebAssemblyLateEHPrepare.cpp
@@ -69,6 +70,7 @@ add_llvm_target(WebAssemblyCodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
Scalar
SelectionDAG
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCodeGenPassBuilder.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..e6f2e7dfb6eabb
--- /dev/null
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- WebAssemblyCodeGenPassBuilder.cpp -------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains WebAssembly CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "WebAssemblyTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class WebAssemblyCodeGenPassBuilder
+ : public CodeGenPassBuilder<WebAssemblyCodeGenPassBuilder> {
+public:
+ explicit WebAssemblyCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void WebAssemblyCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void WebAssemblyCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error WebAssemblyCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error WebAssemblyTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = WebAssemblyCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h
index 2e8cd43840e3be..07c70cf08eae6a 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h
@@ -62,6 +62,12 @@ class WebAssemblyTargetMachine final : public LLVMTargetMachine {
PerFunctionMIParsingState &PFS,
SMDiagnostic &Error,
SMRange &SourceRange) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/X86/CMakeLists.txt b/llvm/lib/Target/X86/CMakeLists.txt
index 4d6300cad2a7a8..610999f0cc3cf0 100644
--- a/llvm/lib/Target/X86/CMakeLists.txt
+++ b/llvm/lib/Target/X86/CMakeLists.txt
@@ -29,6 +29,7 @@ set(sources
X86CallFrameOptimization.cpp
X86CallingConv.cpp
X86CmovConversion.cpp
+ X86CodeGenPassBuilder.cpp
X86DomainReassignment.cpp
X86DiscriminateMemOps.cpp
X86LowerTileCopy.cpp
@@ -98,9 +99,11 @@ add_llvm_target(X86CodeGen ${sources}
CodeGenTypes
Core
GlobalISel
+ IRPrinter
Instrumentation
MC
ProfileData
+ Scalar
SelectionDAG
Support
Target
diff --git a/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp b/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..616f777833e565
--- /dev/null
+++ b/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
@@ -0,0 +1,56 @@
+//===-- X86CodeGenPassBuilder.cpp ---------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains X86 CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "X86TargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class X86CodeGenPassBuilder : public CodeGenPassBuilder<X86CodeGenPassBuilder> {
+public:
+ explicit X86CodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void X86CodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void X86CodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error X86CodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error X86TargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = X86CodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/X86/X86TargetMachine.h b/llvm/lib/Target/X86/X86TargetMachine.h
index 4836be4db0e8e8..df7f5e5ea47896 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.h
+++ b/llvm/lib/Target/X86/X86TargetMachine.h
@@ -61,6 +61,12 @@ class X86TargetMachine final : public LLVMTargetMachine {
bool isJIT() const { return IsJIT; }
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/XCore/CMakeLists.txt b/llvm/lib/Target/XCore/CMakeLists.txt
index 447f5c54528850..4bdca77b76f03f 100644
--- a/llvm/lib/Target/XCore/CMakeLists.txt
+++ b/llvm/lib/Target/XCore/CMakeLists.txt
@@ -14,6 +14,7 @@ add_public_tablegen_target(XCoreCommonTableGen)
add_llvm_target(XCoreCodeGen
XCoreAsmPrinter.cpp
+ XCoreCodeGenPassBuilder.cpp
XCoreFrameLowering.cpp
XCoreInstrInfo.cpp
XCoreISelDAGToDAG.cpp
@@ -34,7 +35,9 @@ add_llvm_target(XCoreCodeGen
CodeGen
CodeGenTypes
Core
+ IRPrinter
MC
+ Scalar
SelectionDAG
Support
Target
diff --git a/llvm/lib/Target/XCore/XCoreCodeGenPassBuilder.cpp b/llvm/lib/Target/XCore/XCoreCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..642ccfeae98890
--- /dev/null
+++ b/llvm/lib/Target/XCore/XCoreCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- XCoreCodeGenPassBuilder.cpp -------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains XCore CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "XCoreTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class XCoreCodeGenPassBuilder
+ : public CodeGenPassBuilder<XCoreCodeGenPassBuilder> {
+public:
+ explicit XCoreCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void XCoreCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void XCoreCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error XCoreCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error XCoreTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = XCoreCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.h b/llvm/lib/Target/XCore/XCoreTargetMachine.h
index 23276935713b6d..1c026cd0e7f9ae 100644
--- a/llvm/lib/Target/XCore/XCoreTargetMachine.h
+++ b/llvm/lib/Target/XCore/XCoreTargetMachine.h
@@ -52,6 +52,12 @@ class XCoreTargetMachine : public LLVMTargetMachine {
MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const override;
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/Xtensa/CMakeLists.txt b/llvm/lib/Target/Xtensa/CMakeLists.txt
index 7192f7392072b3..733dc99fcb14d9 100644
--- a/llvm/lib/Target/Xtensa/CMakeLists.txt
+++ b/llvm/lib/Target/Xtensa/CMakeLists.txt
@@ -13,15 +13,20 @@ tablegen(LLVM XtensaGenSubtargetInfo.inc -gen-subtarget)
add_public_tablegen_target(XtensaCommonTableGen)
add_llvm_target(XtensaCodeGen
+ XtensaCodeGenPassBuilder.cpp
XtensaTargetMachine.cpp
LINK_COMPONENTS
+ Analysis
AsmPrinter
CodeGen
Core
+ IRPrinter
MC
+ Scalar
Support
Target
+ TransformUtils
XtensaDesc
XtensaInfo
diff --git a/llvm/lib/Target/Xtensa/XtensaCodeGenPassBuilder.cpp b/llvm/lib/Target/Xtensa/XtensaCodeGenPassBuilder.cpp
new file mode 100644
index 00000000000000..58357d78b39a50
--- /dev/null
+++ b/llvm/lib/Target/Xtensa/XtensaCodeGenPassBuilder.cpp
@@ -0,0 +1,57 @@
+//===-- XtensaCodeGenPassBuilder.cpp ------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file contains Xtensa CodeGen pipeline builder.
+/// TODO: Port CodeGen passes to new pass manager.
+//===----------------------------------------------------------------------===//
+
+#include "XtensaTargetMachine.h"
+
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace {
+
+class XtensaCodeGenPassBuilder
+ : public CodeGenPassBuilder<XtensaCodeGenPassBuilder> {
+public:
+ explicit XtensaCodeGenPassBuilder(LLVMTargetMachine &TM,
+ CGPassBuilderOption Opts,
+ PassInstrumentationCallbacks *PIC)
+ : CodeGenPassBuilder(TM, Opts, PIC) {}
+ void addPreISel(AddIRPass &addPass) const;
+ void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const;
+ Error addInstSelector(AddMachinePass &) const;
+};
+
+void XtensaCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
+ // TODO: Add passes pre instruction selection.
+}
+
+void XtensaCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
+ CreateMCStreamer) const {
+ // TODO: Add AsmPrinter.
+}
+
+Error XtensaCodeGenPassBuilder::addInstSelector(AddMachinePass &) const {
+ // TODO: Add instruction selector.
+ return Error::success();
+}
+
+} // namespace
+
+Error XtensaTargetMachine::buildCodeGenPipeline(
+ ModulePassManager &MPM, MachineFunctionPassManager &MFPM,
+ MachineFunctionAnalysisManager &, raw_pwrite_stream &Out,
+ raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+ CGPassBuilderOption Opt, PassInstrumentationCallbacks *PIC) {
+ auto CGPB = XtensaCodeGenPassBuilder(*this, Opt, PIC);
+ return CGPB.buildPipeline(MPM, MFPM, Out, DwoOut, FileType);
+}
diff --git a/llvm/lib/Target/Xtensa/XtensaTargetMachine.h b/llvm/lib/Target/Xtensa/XtensaTargetMachine.h
index dd76f45b3bb717..81d36aa088398f 100644
--- a/llvm/lib/Target/Xtensa/XtensaTargetMachine.h
+++ b/llvm/lib/Target/Xtensa/XtensaTargetMachine.h
@@ -40,6 +40,12 @@ class XtensaTargetMachine : public LLVMTargetMachine {
TargetLoweringObjectFile *getObjFileLowering() const override {
return TLOF.get();
}
+
+ Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &,
+ MachineFunctionAnalysisManager &,
+ raw_pwrite_stream &, raw_pwrite_stream *,
+ CodeGenFileType, CGPassBuilderOption,
+ PassInstrumentationCallbacks *) override;
};
} // end namespace llvm
More information about the llvm-commits
mailing list