Skip to content

Commit 7ac7d41

Browse files
authored
[NewPM][NVPTX] Add NVPTXPassRegistry.def NFCI (#86246)
Prepare for dag-isel migration.
1 parent 76fdb59 commit 7ac7d41

File tree

2 files changed

+42
-39
lines changed

2 files changed

+42
-39
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===- NVPTXPassRegistry.def - Registry of NVPTX 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+
// NVPTX backend.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
// NOTE: NO INCLUDE GUARD DESIRED!
15+
16+
#ifndef MODULE_PASS
17+
#define MODULE_PASS(NAME, CREATE_PASS)
18+
#endif
19+
MODULE_PASS("generic-to-nvvm", GenericToNVVMPass())
20+
MODULE_PASS("nvptx-lower-ctor-dtor", NVPTXCtorDtorLoweringPass())
21+
#undef MODULE_PASS
22+
23+
#ifndef FUNCTION_ANALYSIS
24+
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
25+
#endif
26+
27+
#ifndef FUNCTION_ALIAS_ANALYSIS
28+
#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
29+
FUNCTION_ANALYSIS(NAME, CREATE_PASS)
30+
#endif
31+
FUNCTION_ALIAS_ANALYSIS("nvptx-aa", NVPTXAA())
32+
#undef FUNCTION_ALIAS_ANALYSIS
33+
#undef FUNCTION_ANALYSIS
34+
35+
#ifndef FUNCTION_PASS
36+
#define FUNCTION_PASS(NAME, CREATE_PASS)
37+
#endif
38+
FUNCTION_PASS("nvvm-intr-range", NVVMIntrRangePass())
39+
FUNCTION_PASS("nvvm-reflect", NVVMReflectPass())
40+
#undef FUNCTION_PASS

llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -227,45 +227,8 @@ void NVPTXTargetMachine::registerDefaultAliasAnalyses(AAManager &AAM) {
227227

228228
void NVPTXTargetMachine::registerPassBuilderCallbacks(
229229
PassBuilder &PB, bool PopulateClassToPassNames) {
230-
PB.registerPipelineParsingCallback(
231-
[](StringRef PassName, FunctionPassManager &PM,
232-
ArrayRef<PassBuilder::PipelineElement>) {
233-
if (PassName == "nvvm-reflect") {
234-
PM.addPass(NVVMReflectPass());
235-
return true;
236-
}
237-
if (PassName == "nvvm-intr-range") {
238-
PM.addPass(NVVMIntrRangePass());
239-
return true;
240-
}
241-
return false;
242-
});
243-
244-
PB.registerAnalysisRegistrationCallback([](FunctionAnalysisManager &FAM) {
245-
FAM.registerPass([&] { return NVPTXAA(); });
246-
});
247-
248-
PB.registerParseAACallback([](StringRef AAName, AAManager &AAM) {
249-
if (AAName == "nvptx-aa") {
250-
AAM.registerFunctionAnalysis<NVPTXAA>();
251-
return true;
252-
}
253-
return false;
254-
});
255-
256-
PB.registerPipelineParsingCallback(
257-
[](StringRef PassName, ModulePassManager &PM,
258-
ArrayRef<PassBuilder::PipelineElement>) {
259-
if (PassName == "nvptx-lower-ctor-dtor") {
260-
PM.addPass(NVPTXCtorDtorLoweringPass());
261-
return true;
262-
}
263-
if (PassName == "generic-to-nvvm") {
264-
PM.addPass(GenericToNVVMPass());
265-
return true;
266-
}
267-
return false;
268-
});
230+
#define GET_PASS_REGISTRY "NVPTXPassRegistry.def"
231+
#include "llvm/Passes/TargetPassRegistry.inc"
269232

270233
PB.registerPipelineStartEPCallback(
271234
[this](ModulePassManager &PM, OptimizationLevel Level) {

0 commit comments

Comments
 (0)