|
MLIR 22.0.0git
|
The lowering of gpu.printf to a call to an external printf() function. More...
#include "Conversion/GPUCommon/GPUOpsLowering.h"
Public Member Functions | |
| GPUPrintfOpToLLVMCallLowering (const LLVMTypeConverter &converter, int addressSpace=0, LLVM::cconv::CConv callingConvention=LLVM::cconv::CConv::C, StringRef funcName="printf") | |
| LogicalResult | matchAndRewrite (gpu::PrintfOp gpuPrintfOp, gpu::PrintfOpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override |
| Public Member Functions inherited from mlir::ConvertOpToLLVMPattern< gpu::PrintfOp > | |
| ConvertOpToLLVMPattern (const LLVMTypeConverter &typeConverter, PatternBenefit benefit=1) | |
| LogicalResult | matchAndRewrite (Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const final |
| Wrappers around the RewritePattern methods that pass the derived op type. | |
| Public Member Functions inherited from mlir::ConvertToLLVMPattern | |
| ConvertToLLVMPattern (StringRef rootOpName, MLIRContext *context, const LLVMTypeConverter &typeConverter, PatternBenefit benefit=1) | |
Additional Inherited Members | |
| Public Types inherited from mlir::ConvertOpToLLVMPattern< gpu::PrintfOp > | |
| using | OpAdaptor |
| using | OneToNOpAdaptor |
| Protected Member Functions inherited from mlir::ConvertToLLVMPattern | |
| LLVM::LLVMDialect & | getDialect () const |
| Returns the LLVM dialect. | |
| const LLVMTypeConverter * | getTypeConverter () const |
| Type | getIndexType () const |
| Gets the MLIR type wrapping the LLVM integer type whose bit width is defined by the used type converter. | |
| Type | getIntPtrType (unsigned addressSpace=0) const |
| Gets the MLIR type wrapping the LLVM integer type whose bit width corresponds to that of a LLVM pointer type. | |
| Type | getVoidType () const |
| Gets the MLIR type wrapping the LLVM void type. | |
| Type | getVoidPtrType () const |
| Get the MLIR type wrapping the LLVM i8* type. | |
| Type | getPtrType (unsigned addressSpace=0) const |
| Get the MLIR type wrapping the LLVM ptr type. | |
| Value | getStridedElementPtr (ConversionPatternRewriter &rewriter, Location loc, MemRefType type, Value memRefDesc, ValueRange indices, LLVM::GEPNoWrapFlags noWrapFlags=LLVM::GEPNoWrapFlags::none) const |
| Convenience wrapper for the corresponding helper utility. | |
| bool | isConvertibleAndHasIdentityMaps (MemRefType type) const |
| Returns if the given memref type is convertible to LLVM and has an identity layout map. | |
| Type | getElementPtrType (MemRefType type) const |
| Returns the type of a pointer to an element of the memref. | |
| void | getMemRefDescriptorSizes (Location loc, MemRefType memRefType, ValueRange dynamicSizes, ConversionPatternRewriter &rewriter, SmallVectorImpl< Value > &sizes, SmallVectorImpl< Value > &strides, Value &size, bool sizeInBytes=true) const |
| Computes sizes, strides and buffer size of memRefType with identity layout. | |
| Value | getSizeInBytes (Location loc, Type type, ConversionPatternRewriter &rewriter) const |
| Computes the size of type in bytes. | |
| Value | getNumElements (Location loc, MemRefType memRefType, ValueRange dynamicSizes, ConversionPatternRewriter &rewriter) const |
| Computes total number of elements for the given MemRef and dynamicSizes. | |
| MemRefDescriptor | createMemRefDescriptor (Location loc, MemRefType memRefType, Value allocatedPtr, Value alignedPtr, ArrayRef< Value > sizes, ArrayRef< Value > strides, ConversionPatternRewriter &rewriter) const |
| Creates and populates a canonical memref descriptor struct. | |
| Value | copyUnrankedDescriptor (OpBuilder &builder, Location loc, UnrankedMemRefType memRefType, Value operand, bool toDynamic) const |
| Copies the given unranked memory descriptor to heap-allocated memory (if toDynamic is true) or to stack-allocated memory (otherwise) and returns the new descriptor. | |
| LogicalResult | copyUnrankedDescriptors (OpBuilder &builder, Location loc, TypeRange origTypes, SmallVectorImpl< Value > &operands, bool toDynamic) const |
| Copies the memory descriptor for any operands that were unranked descriptors originally to heap-allocated memory (if toDynamic is true) or to stack-allocated memory (otherwise). | |
| Static Protected Member Functions inherited from mlir::ConvertToLLVMPattern | |
| static Value | createIndexAttrConstant (OpBuilder &builder, Location loc, Type resultType, int64_t value) |
| Create a constant Op producing a value of resultType from an index-typed integer attribute. | |
The lowering of gpu.printf to a call to an external printf() function.
This pass will add a declaration of printf() to the GPUModule if needed and separate out the format strings into global constants. For some runtimes, such as OpenCL on AMD, this is sufficient setup, as the compiler will lower printf calls to appropriate device-side code. However not all backends use the same calling convention and function naming. For example, the LLVM SPIRV backend requires calling convention LLVM::cconv::CConv::SPIR_FUNC and function name needs to be mangled as "_Z6printfPU3AS2Kcz". Default callingConvention is LLVM::cconv::CConv::C and funcName is "printf" but they can be customized as needed.
Definition at line 154 of file GPUOpsLowering.h.
|
inline |
Definition at line 156 of file GPUOpsLowering.h.
References mlir::ConvertOpToLLVMPattern< gpu::PrintfOp >::ConvertOpToLLVMPattern().
|
override |
Definition at line 492 of file GPUOpsLowering.cpp.
References mlir::getOrCreateStringConstant(), mlir::getOrDefineFunction(), mlir::Operation::getParentWithTrait(), and success().