8#ifndef MLIR_CONVERSION_GPUCOMMON_GPUOPSLOWERING_H_
9#define MLIR_CONVERSION_GPUCOMMON_GPUOPSLOWERING_H_
28 LLVM::LLVMFunctionType type);
34 StringRef namePrefix, StringRef str,
35 uint64_t alignment = 0,
36 unsigned addrSpace = 0);
50 unsigned alignmentBit = 0,
53 alignmentBit(alignmentBit) {}
57 ConversionPatternRewriter &rewriter)
const override;
61 unsigned alignmentBit;
95 allocaAddrSpace(
options.allocaAddrSpace),
96 workgroupAddrSpace(
options.workgroupAddrSpace),
97 kernelAttributeName(
options.kernelAttributeName),
98 kernelBlockSizeAttributeName(
options.kernelBlockSizeAttributeName),
99 kernelClusterSizeAttributeName(
options.kernelClusterSizeAttributeName),
100 kernelCallingConvention(
options.kernelCallingConvention),
101 nonKernelCallingConvention(
options.nonKernelCallingConvention),
102 encodeWorkgroupAttributionsAsArguments(
103 options.encodeWorkgroupAttributionsAsArguments) {}
107 ConversionPatternRewriter &rewriter)
const override;
111 unsigned allocaAddrSpace;
113 unsigned workgroupAddrSpace;
117 StringAttr kernelAttributeName;
120 StringAttr kernelBlockSizeAttributeName;
123 StringAttr kernelClusterSizeAttributeName;
126 LLVM::CConv kernelCallingConvention;
128 LLVM::CConv nonKernelCallingConvention;
132 bool encodeWorkgroupAttributionsAsArguments;
144 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
145 ConversionPatternRewriter &rewriter)
const override;
165 LLVM::cconv::CConv callingConvention = LLVM::cconv::CConv::C,
166 StringRef funcName =
"printf")
168 addressSpace(addressSpace), callingConvention(callingConvention),
169 funcName(funcName) {}
172 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
173 ConversionPatternRewriter &rewriter)
const override;
177 LLVM::cconv::CConv callingConvention;
187 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
188 ConversionPatternRewriter &rewriter)
const override;
196 ConversionPatternRewriter &rewriter)
const override;
202 ConversionPatternRewriter &rewriter,
207template <
typename SourceOp>
214 ConversionPatternRewriter &rewriter)
const override {
216 *this->getTypeConverter());
static llvm::ManagedStatic< PassManagerOptions > options
ConvertOpToLLVMPattern(const LLVMTypeConverter &typeConverter, PatternBenefit benefit=1)
typename gpu::DynamicSharedMemoryOp::Adaptor OpAdaptor
Conversion from types to the LLVM IR dialect.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
LogicalResult scalarizeVectorOp(Operation *op, ValueRange operands, ConversionPatternRewriter &rewriter, const LLVMTypeConverter &converter)
Unrolls op to array/vector elements.
Include the generated interface declarations.
LLVM::LLVMFuncOp getOrDefineFunction(Operation *moduleOp, Location loc, OpBuilder &b, StringRef name, LLVM::LLVMFunctionType type)
Note that these functions don't take a SymbolTable because GPU module lowerings can have name collisi...
LLVM::GlobalOp getOrCreateStringConstant(OpBuilder &b, Location loc, Operation *moduleOp, Type llvmI8, StringRef namePrefix, StringRef str, uint64_t alignment=0, unsigned addrSpace=0)
Create a global that contains the given string.
LogicalResult matchAndRewrite(gpu::DynamicSharedMemoryOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override
GPUDynamicSharedMemoryOpLowering(const LLVMTypeConverter &converter, unsigned alignmentBit=0, PatternBenefit benefit=1)
unsigned allocaAddrSpace
The address space to use for allocas in private memory.
LLVM::CConv nonKernelCallingConvention
The calling convention to use for non-kernel functions.
StringAttr kernelBlockSizeAttributeName
The attribute name to to set block size.
LLVM::CConv kernelCallingConvention
The calling convention to use for kernel functions.
unsigned workgroupAddrSpace
The address space to use declaring workgroup memory.
bool encodeWorkgroupAttributionsAsArguments
Whether to encode workgroup attributions as additional arguments instead of a global variable.
StringAttr kernelClusterSizeAttributeName
The attribute name to to set cluster size.
StringAttr kernelAttributeName
The attribute name to use instead of gpu.kernel.
LogicalResult matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override
GPUFuncOpLowering(const LLVMTypeConverter &converter, const GPUFuncOpLoweringOptions &options, PatternBenefit benefit=1)
The lowering of gpu.printf to a call to HIP hostcalls.
LogicalResult matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override
LogicalResult matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override
GPUPrintfOpToLLVMCallLowering(const LLVMTypeConverter &converter, int addressSpace=0, LLVM::cconv::CConv callingConvention=LLVM::cconv::CConv::C, StringRef funcName="printf")
Lowering of gpu.printf to a vprintf standard library.
LogicalResult matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override
LogicalResult matchAndRewrite(gpu::ReturnOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override
Unrolls SourceOp to array/vector elements.
LogicalResult matchAndRewrite(SourceOp op, typename SourceOp::Adaptor adaptor, ConversionPatternRewriter &rewriter) const override
Methods that operate on the SourceOp type.