1 //===- GPUToNVVMPass.h - Convert GPU kernel to NVVM 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_GPUTONVVM_GPUTONVVMPASS_H_ 9 #define MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ 10 11 #include "mlir/Conversion/LLVMCommon/LoweringOptions.h" 12 #include "mlir/Dialect/LLVMIR/LLVMTypes.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 class MMAMatrixType; 26 } // namespace gpu 27 28 LLVM::LLVMStructType convertMMAToLLVMType(gpu::MMAMatrixType type); 29 30 /// Configure target to convert from the GPU dialect to NVVM. 31 void configureGpuToNVVMConversionLegality(ConversionTarget &target); 32 33 /// Collect a set of patterns to convert from the GPU dialect to NVVM. 34 void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter, 35 RewritePatternSet &patterns); 36 37 /// Collect a set of patterns to convert WMMA ops from GPU dialect to NVVM. 38 void populateGpuWMMAToNVVMConversionPatterns(LLVMTypeConverter &converter, 39 RewritePatternSet &patterns); 40 41 /// Creates a pass that lowers GPU dialect operations to NVVM counterparts. The 42 /// index bitwidth used for the lowering of the device side index computations 43 /// is configurable. 44 std::unique_ptr<OperationPass<gpu::GPUModuleOp>> createLowerGpuOpsToNVVMOpsPass( 45 unsigned indexBitwidth = kDeriveIndexBitwidthFromDataLayout); 46 47 } // namespace mlir 48 49 #endif // MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ 50