//===- GPUOpsLowering.h - GPU FuncOp / ReturnOp lowering -------*- C++ -*--===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUCOMMON_GPUOPSLOWERING_H_ #define MLIR_CONVERSION_GPUCOMMON_GPUOPSLOWERING_H_ #include "mlir/Conversion/LLVMCommon/Pattern.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" namespace mlir { struct GPUFuncOpLowering : ConvertOpToLLVMPattern { GPUFuncOpLowering(LLVMTypeConverter &converter, unsigned allocaAddrSpace, Identifier kernelAttributeName) : ConvertOpToLLVMPattern(converter), allocaAddrSpace(allocaAddrSpace), kernelAttributeName(kernelAttributeName) {} LogicalResult matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override; private: /// The address spcae to use for `alloca`s in private memory. unsigned allocaAddrSpace; /// The attribute name to use instead of `gpu.kernel`. Identifier kernelAttributeName; }; struct GPUReturnOpLowering : public ConvertOpToLLVMPattern { using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern; LogicalResult matchAndRewrite(gpu::ReturnOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { rewriter.replaceOpWithNewOp(op, operands); return success(); } }; } // namespace mlir #endif // MLIR_CONVERSION_GPUCOMMON_GPUOPSLOWERING_H_