Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions llvm/lib/Target/DirectX/DirectXPassRegistry.def
Original file line number Diff line number Diff line change
@@ -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
20 changes: 2 additions & 18 deletions llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down