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 class Pass; 20 21 namespace gpu { 22 class GPUModuleOp; 23 class MMAMatrixType; 24 } // namespace gpu 25 26 #define GEN_PASS_DECL_CONVERTGPUOPSTONVVMOPS 27 #include "mlir/Conversion/Passes.h.inc" 28 29 LLVM::LLVMStructType convertMMAToLLVMType(gpu::MMAMatrixType type); 30 31 /// Configure target to convert from the GPU dialect to NVVM. 32 void configureGpuToNVVMConversionLegality(ConversionTarget &target); 33 34 /// Configure the LLVM type convert to convert types and address spaces from the 35 /// GPU dialect to NVVM. 36 void configureGpuToNVVMTypeConverter(LLVMTypeConverter &converter); 37 38 /// Collect a set of patterns to convert from the GPU dialect to NVVM. 39 void populateGpuToNVVMConversionPatterns(const LLVMTypeConverter &converter, 40 RewritePatternSet &patterns); 41 42 /// Populate GpuSubgroupReduce pattern to NVVM. It generates a specific nvvm 43 /// op that is not available on every GPU. 44 void populateGpuSubgroupReduceOpLoweringPattern( 45 const LLVMTypeConverter &converter, RewritePatternSet &patterns); 46 47 /// Collect a set of patterns to convert WMMA ops from GPU dialect to NVVM. 48 void populateGpuWMMAToNVVMConversionPatterns(const LLVMTypeConverter &converter, 49 RewritePatternSet &patterns); 50 } // namespace mlir 51 52 #endif // MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ 53