diff options
Diffstat (limited to 'mlir')
-rw-r--r-- | mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h | 3 | ||||
-rw-r--r-- | mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h index 708a3fe0b23e..42d06f301ad5 100644 --- a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h +++ b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h @@ -52,6 +52,9 @@ using LoweringCallback = std::function<std::unique_ptr<llvm::Module>( /// typed ABI on top of GPU runtimes such as CUDA or ROCm (HIP). std::unique_ptr<OperationPass<ModuleOp>> createGpuToLLVMConversionPass(); +void populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter, + OwningRewritePatternList &patterns); + } // namespace mlir #endif // MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_ diff --git a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp index 60a47a9d7bef..67921aec9b47 100644 --- a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp @@ -798,3 +798,22 @@ std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> mlir::createGpuToLLVMConversionPass() { return std::make_unique<GpuToLLVMConversionPass>(); } + +void mlir::populateGpuToLLVMConversionPatterns( + LLVMTypeConverter &converter, OwningRewritePatternList &patterns) { + auto gpuBinaryAnnotation = gpu::getDefaultGpuBinaryAnnotation(); + converter.addConversion( + [context = &converter.getContext()](gpu::AsyncTokenType type) -> Type { + return LLVM::LLVMPointerType::get(IntegerType::get(context, 8)); + }); + patterns.add<ConvertAllocOpToGpuRuntimeCallPattern, + ConvertDeallocOpToGpuRuntimeCallPattern, + ConvertHostRegisterOpToGpuRuntimeCallPattern, + ConvertMemcpyOpToGpuRuntimeCallPattern, + ConvertWaitAsyncOpToGpuRuntimeCallPattern, + ConvertWaitOpToGpuRuntimeCallPattern, + ConvertAsyncYieldToGpuRuntimeCallPattern>(converter); + patterns.add<ConvertLaunchFuncOpToGpuRuntimeCallPattern>(converter, + gpuBinaryAnnotation); + patterns.add<EraseGpuModuleOpPattern>(&converter.getContext()); +} |