[llvm] 76fdb59 - [NewPM][DirectX] Add DirectXPassRegistry.def NFCI (#86242)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 19:37:56 PDT 2024
Author: paperchalice
Date: 2024-03-23T10:37:53+08:00
New Revision: 76fdb5902fbadbc08c6742156071431d8ad801ea
URL: https://github.com/llvm/llvm-project/commit/76fdb5902fbadbc08c6742156071431d8ad801ea
DIFF: https://github.com/llvm/llvm-project/commit/76fdb5902fbadbc08c6742156071431d8ad801ea.diff
LOG: [NewPM][DirectX] Add DirectXPassRegistry.def NFCI (#86242)
Prepare migration for dag-isel
Added:
llvm/lib/Target/DirectX/DirectXPassRegistry.def
Modified:
llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/DirectX/DirectXPassRegistry.def b/llvm/lib/Target/DirectX/DirectXPassRegistry.def
new file mode 100644
index 00000000000000..bbf0c254bb697f
--- /dev/null
+++ b/llvm/lib/Target/DirectX/DirectXPassRegistry.def
@@ -0,0 +1,29 @@
+//===- DirectXPassRegistry.def - Registry of DirectX passes -----*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is used as the registry of passes that are part of the
+// DirectX backend.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: NO INCLUDE GUARD DESIRED!
+
+#ifndef MODULE_ANALYSIS
+#define MODULE_ANALYSIS(NAME, CREATE_PASS)
+#endif
+MODULE_ANALYSIS("dx-shader-flags", dxil::ShaderFlagsAnalysis())
+MODULE_ANALYSIS("dxil-resource", DXILResourceAnalysis())
+#undef MODULE_ANALYSIS
+
+#ifndef MODULE_PASS
+#define MODULE_PASS(NAME, CREATE_PASS)
+#endif
+// TODO: rename to print<foo> after NPM switch
+MODULE_PASS("print-dx-shader-flags", DXILResourcePrinterPass(dbgs()))
+MODULE_PASS("print-dxil-resource", DXILResourcePrinterPass(dbgs()))
+#undef MODULE_PASS
diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
index 03c825b3977db3..bebca0675522f3 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -104,24 +104,8 @@ DirectXTargetMachine::~DirectXTargetMachine() {}
void DirectXTargetMachine::registerPassBuilderCallbacks(
PassBuilder &PB, bool PopulateClassToPassNames) {
- PB.registerPipelineParsingCallback(
- [](StringRef PassName, ModulePassManager &PM,
- ArrayRef<PassBuilder::PipelineElement>) {
- if (PassName == "print-dxil-resource") {
- PM.addPass(DXILResourcePrinterPass(dbgs()));
- return true;
- }
- if (PassName == "print-dx-shader-flags") {
- PM.addPass(dxil::ShaderFlagsAnalysisPrinter(dbgs()));
- return true;
- }
- return false;
- });
-
- PB.registerAnalysisRegistrationCallback([](ModuleAnalysisManager &MAM) {
- MAM.registerPass([&] { return DXILResourceAnalysis(); });
- MAM.registerPass([&] { return dxil::ShaderFlagsAnalysis(); });
- });
+#define GET_PASS_REGISTRY "DirectXPassRegistry.def"
+#include "llvm/Passes/TargetPassRegistry.inc"
}
bool DirectXTargetMachine::addPassesToEmitFile(
More information about the llvm-commits
mailing list