8#ifndef MLIR_CONVERSION_GPUCOMMON_GPUOPSLOWERING_H_
9#define MLIR_CONVERSION_GPUCOMMON_GPUOPSLOWERING_H_
29 LLVM::LLVMFunctionType type);
35 StringRef namePrefix, StringRef str,
36 uint64_t alignment = 0,
37 unsigned addrSpace = 0);
51 unsigned alignmentBit = 0,
54 alignmentBit(alignmentBit) {}
58 ConversionPatternRewriter &rewriter)
const override;
62 unsigned alignmentBit;
96 allocaAddrSpace(
options.allocaAddrSpace),
97 workgroupAddrSpace(
options.workgroupAddrSpace),
98 kernelAttributeName(
options.kernelAttributeName),
99 kernelBlockSizeAttributeName(
options.kernelBlockSizeAttributeName),
100 kernelClusterSizeAttributeName(
options.kernelClusterSizeAttributeName),
101 kernelCallingConvention(
options.kernelCallingConvention),
102 nonKernelCallingConvention(
options.nonKernelCallingConvention),
103 encodeWorkgroupAttributionsAsArguments(
104 options.encodeWorkgroupAttributionsAsArguments) {}
108 ConversionPatternRewriter &rewriter)
const override;
112 FailureOr<LoweredLLVMFuncAttrs>
118 unsigned allocaAddrSpace;
120 unsigned workgroupAddrSpace;
124 StringAttr kernelAttributeName;
127 StringAttr kernelBlockSizeAttributeName;
130 StringAttr kernelClusterSizeAttributeName;
133 LLVM::CConv kernelCallingConvention;
135 LLVM::CConv nonKernelCallingConvention;
139 bool encodeWorkgroupAttributionsAsArguments;
151 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
152 ConversionPatternRewriter &rewriter)
const override;
172 LLVM::cconv::CConv callingConvention = LLVM::cconv::CConv::C,
173 StringRef funcName =
"printf")
175 addressSpace(addressSpace), callingConvention(callingConvention),
176 funcName(funcName) {}
179 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
180 ConversionPatternRewriter &rewriter)
const override;
184 LLVM::cconv::CConv callingConvention;
194 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
195 ConversionPatternRewriter &rewriter)
const override;
203 ConversionPatternRewriter &rewriter)
const override;
209 ConversionPatternRewriter &rewriter,
214template <
typename SourceOp>
221 ConversionPatternRewriter &rewriter)
const override {
223 *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
FailureOr< LoweredLLVMFuncAttrs > buildLoweredGPULLVMFuncAttrs(gpu::GPUFuncOp gpuFuncOp, Type llvmFuncType, OpBuilder &rewriter) const
Lower discardable attrs like func lowering, then set llvm.func properties and append GPU / target-spe...
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.