Skip to content

Commit 4fb3b44

Browse files
committed
[mlir] Add existing callback functions to GpuModuleToBinary pass
1 parent 79f59af commit 4fb3b44

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

mlir/include/mlir/Dialect/GPU/Transforms/Passes.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,19 @@ def GpuModuleToBinaryPass
9595
Option<"cmdOptions", "opts", "std::string", [{""}],
9696
"Command line options to pass to the tools.">,
9797
Option<"compilationTarget", "format", "std::string", [{"fatbin"}],
98-
"The target representation of the compilation process.">
98+
"The target representation of the compilation process.">,
99+
Option<"initialLlvmIRCallback", "initialLlvmIRCallback",
100+
"llvm::function_ref<void(llvm::Module &)>", "nullptr",
101+
"Callback invoked with the initial LLVM IR for the device module.">,
102+
Option<"linkedLlvmIRCallback", "linkedLlvmIRCallback",
103+
"llvm::function_ref<void(llvm::Module &)>", "nullptr",
104+
"Callback invoked with LLVM IR for the device module after linking the device libraries.">,
105+
Option<"optimizedLlvmIRCallback", "optimizedLlvmIRCallback",
106+
"llvm::function_ref<void(llvm::Module &)>", "nullptr",
107+
"Callback invoked with LLVM IR for the device module after LLVM optimizations but before codegen.">,
108+
Option<"isaCallback", "isaCallback",
109+
"llvm::function_ref<void(llvm::StringRef)>", "nullptr",
110+
"Callback invoked with the target ISA for the device, for example PTX assembly.">
99111
];
100112
}
101113

mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ void GpuModuleToBinaryPass::runOnOperation() {
6969
return &parentTable.value();
7070
};
7171

72-
TargetOptions targetOptions(toolkitPath, linkFiles, cmdOptions, *targetFormat,
73-
lazyTableBuilder);
72+
TargetOptions targetOptions(
73+
toolkitPath, linkFiles, cmdOptions, *targetFormat, lazyTableBuilder,
74+
initialLlvmIRCallback.getValue(), linkedLlvmIRCallback.getValue(),
75+
optimizedLlvmIRCallback.getValue(), isaCallback.getValue());
7476
if (failed(transformGpuModulesToBinaries(
7577
getOperation(), OffloadingLLVMTranslationAttrInterface(nullptr),
7678
targetOptions)))

0 commit comments

Comments
 (0)