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;
92 allocaAddrSpace(
options.allocaAddrSpace),
93 workgroupAddrSpace(
options.workgroupAddrSpace),
94 kernelAttributeName(
options.kernelAttributeName),
95 kernelBlockSizeAttributeName(
options.kernelBlockSizeAttributeName),
96 kernelCallingConvention(
options.kernelCallingConvention),
97 nonKernelCallingConvention(
options.nonKernelCallingConvention),
98 encodeWorkgroupAttributionsAsArguments(
99 options.encodeWorkgroupAttributionsAsArguments) {}
103 ConversionPatternRewriter &rewriter)
const override;
107 unsigned allocaAddrSpace;
109 unsigned workgroupAddrSpace;
113 StringAttr kernelAttributeName;
116 StringAttr kernelBlockSizeAttributeName;
119 LLVM::CConv kernelCallingConvention;
121 LLVM::CConv nonKernelCallingConvention;
125 bool encodeWorkgroupAttributionsAsArguments;
137 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
138 ConversionPatternRewriter &rewriter)
const override;
158 LLVM::cconv::CConv callingConvention = LLVM::cconv::CConv::C,
159 StringRef funcName =
"printf")
161 addressSpace(addressSpace), callingConvention(callingConvention),
162 funcName(funcName) {}
165 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
166 ConversionPatternRewriter &rewriter)
const override;
170 LLVM::cconv::CConv callingConvention;
180 matchAndRewrite(gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor,
181 ConversionPatternRewriter &rewriter)
const override;
189 ConversionPatternRewriter &rewriter)
const override;
195 ConversionPatternRewriter &rewriter,
200template <
typename SourceOp>
207 ConversionPatternRewriter &rewriter)
const override {
209 *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 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.