Skip to content

Commit 76fdb59

Browse files
authored
[NewPM][DirectX] Add DirectXPassRegistry.def NFCI (#86242)
Prepare migration for dag-isel
1 parent 84e20cb commit 76fdb59

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===- DirectXPassRegistry.def - Registry of DirectX passes -----*- C++--*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file is used as the registry of passes that are part of the
10+
// DirectX backend.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
// NOTE: NO INCLUDE GUARD DESIRED!
15+
16+
#ifndef MODULE_ANALYSIS
17+
#define MODULE_ANALYSIS(NAME, CREATE_PASS)
18+
#endif
19+
MODULE_ANALYSIS("dx-shader-flags", dxil::ShaderFlagsAnalysis())
20+
MODULE_ANALYSIS("dxil-resource", DXILResourceAnalysis())
21+
#undef MODULE_ANALYSIS
22+
23+
#ifndef MODULE_PASS
24+
#define MODULE_PASS(NAME, CREATE_PASS)
25+
#endif
26+
// TODO: rename to print<foo> after NPM switch
27+
MODULE_PASS("print-dx-shader-flags", DXILResourcePrinterPass(dbgs()))
28+
MODULE_PASS("print-dxil-resource", DXILResourcePrinterPass(dbgs()))
29+
#undef MODULE_PASS

llvm/lib/Target/DirectX/DirectXTargetMachine.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,8 @@ DirectXTargetMachine::~DirectXTargetMachine() {}
104104

105105
void DirectXTargetMachine::registerPassBuilderCallbacks(
106106
PassBuilder &PB, bool PopulateClassToPassNames) {
107-
PB.registerPipelineParsingCallback(
108-
[](StringRef PassName, ModulePassManager &PM,
109-
ArrayRef<PassBuilder::PipelineElement>) {
110-
if (PassName == "print-dxil-resource") {
111-
PM.addPass(DXILResourcePrinterPass(dbgs()));
112-
return true;
113-
}
114-
if (PassName == "print-dx-shader-flags") {
115-
PM.addPass(dxil::ShaderFlagsAnalysisPrinter(dbgs()));
116-
return true;
117-
}
118-
return false;
119-
});
120-
121-
PB.registerAnalysisRegistrationCallback([](ModuleAnalysisManager &MAM) {
122-
MAM.registerPass([&] { return DXILResourceAnalysis(); });
123-
MAM.registerPass([&] { return dxil::ShaderFlagsAnalysis(); });
124-
});
107+
#define GET_PASS_REGISTRY "DirectXPassRegistry.def"
108+
#include "llvm/Passes/TargetPassRegistry.inc"
125109
}
126110

127111
bool DirectXTargetMachine::addPassesToEmitFile(

0 commit comments

Comments
 (0)