1 //===- GPUToROCDLPass.h - Convert GPU kernel to ROCDL dialect ---*- 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 #ifndef MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_ 9 #define MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_ 10 11 #include "mlir/Conversion/GPUToROCDL/Runtimes.h" 12 #include "mlir/Conversion/LLVMCommon/LoweringOptions.h" 13 #include <memory> 14 15 namespace mlir { 16 class LLVMTypeConverter; 17 class ConversionTarget; 18 class RewritePatternSet; 19 20 template <typename OpT> 21 class OperationPass; 22 23 namespace gpu { 24 class GPUModuleOp; 25 } // namespace gpu 26 27 #define GEN_PASS_DECL_CONVERTGPUOPSTOROCDLOPS 28 #include "mlir/Conversion/Passes.h.inc" 29 30 /// Collect a set of patterns to convert from the GPU dialect to ROCDL. 31 /// If `runtime` is Unknown, gpu.printf will not be lowered 32 /// The resulting pattern set should be run over a gpu.module op 33 void populateGpuToROCDLConversionPatterns(const LLVMTypeConverter &converter, 34 RewritePatternSet &patterns, 35 gpu::amd::Runtime runtime); 36 37 /// Configure target to convert from the GPU dialect to ROCDL. 38 void configureGpuToROCDLConversionLegality(ConversionTarget &target); 39 40 /// Creates a pass that lowers GPU dialect operations to ROCDL counterparts. The 41 /// index bitwidth used for the lowering of the device side index computations 42 /// is configurable. 43 std::unique_ptr<OperationPass<gpu::GPUModuleOp>> 44 createLowerGpuOpsToROCDLOpsPass( 45 const std::string &chipset = "gfx900", 46 unsigned indexBitwidth = kDeriveIndexBitwidthFromDataLayout, 47 bool useBarePtrCallConv = false, 48 gpu::amd::Runtime runtime = gpu::amd::Runtime::Unknown); 49 50 } // namespace mlir 51 52 #endif // MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_ 53