MLIR: lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp File Reference (original) (raw)

Go to the source code of this file.

Namespaces
Functions
static Value getOffsetForBitwidth (Location loc, Value srcIdx, int sourceBits, int targetBits, OpBuilder &builder)
Returns the offset of the value in targetBits representation. More...
static Value adjustAccessChainForBitwidth (const SPIRVTypeConverter &typeConverter, spirv::AccessChainOp op, int sourceBits, int targetBits, OpBuilder &builder)
Returns an adjusted spirv::AccessChainOp. More...
static Value castBoolToIntN (Location loc, Value srcBool, Type dstType, OpBuilder &builder)
Casts the given srcBool into an integer of dstType. More...
static Value shiftValue (Location loc, Value value, Value offset, Value mask, OpBuilder &builder)
Returns the targetBits-bit value shifted by the given offset, and cast to the type destination type, and masked. More...
static bool isAllocationSupported (Operation *allocOp, MemRefType type)
Returns true if the allocations of memref type generated from allocOp can be lowered to SPIR-V. More...
static std::optional< spirv::Scope > getAtomicOpScope (MemRefType type)
Returns the scope to use for atomic operations use for emulating store operations of unsupported integer bitwidths, based on the memref type. More...
static Value castIntNToBool (Location loc, Value srcInt, OpBuilder &builder)
Casts the given srcInt into a boolean value. More...
static FailureOr< MemoryRequirements > calculateMemoryRequirements (Value accessedPtr, bool isNontemporal)
Given an accessed SPIR-V pointer, calculates its alignment requirements, if any. More...
template
static FailureOr< MemoryRequirements > calculateMemoryRequirements (Value accessedPtr, LoadOrStoreOp loadOrStoreOp)
Given an accessed SPIR-V pointer and the original memref load/store memAccess op, calculates the alignment requirements, if any. More...
void mlir::populateMemRefToSPIRVPatterns (const SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns)
Appends to a pattern list additional patterns for translating MemRef ops to SPIR-V ops. More...

ATOMIC_CASE

| #define ATOMIC_CASE | ( | | kind, | | -------------------- | - | | ---------------------------------------------------------------- | | | spirvOp | | | | | ) | | | |

Value:

rewriter.replaceOpWithNewOpspirv::spirvOp( \

atomicOp, resultType, ptr, *scope, \

spirv::MemorySemantics::AcquireRelease, adaptor.getValue()); \

break

union mlir::linalg::@1203::ArityGroupAndKind::Kind kind

DEBUG_TYPE

#define DEBUG_TYPE "memref-to-spirv-pattern"

adjustAccessChainForBitwidth()

static Value adjustAccessChainForBitwidth ( const SPIRVTypeConverter & typeConverter, spirv::AccessChainOp op, int sourceBits, int targetBits, OpBuilder & builder ) static

calculateMemoryRequirements() [1/2]

calculateMemoryRequirements() [2/2]

template

static FailureOr<MemoryRequirements> calculateMemoryRequirements ( Value accessedPtr, LoadOrStoreOp loadOrStoreOp ) static

castBoolToIntN()

castIntNToBool()

getAtomicOpScope()

static std::optionalspirv::Scope getAtomicOpScope ( MemRefType type) static

Returns the scope to use for atomic operations use for emulating store operations of unsupported integer bitwidths, based on the memref type.

Returns std::nullopt on failure.

Definition at line 150 of file MemRefToSPIRV.cpp.

getOffsetForBitwidth()

Returns the offset of the value in targetBits representation.

srcIdx is an index into a 1-D array with each element having sourceBits. It's assumed to be non-negative.

When accessing an element in the array treating as having elements of targetBits, multiple values are loaded in the same time. The method returns the offset where the srcIdx locates in the value. For example, if sourceBits equals to 8 and targetBits equals to 32, the x-th element is located at (x % 4) * 8. Because there are four elements in one i32, and one element has 8 bits.

Definition at line 47 of file MemRefToSPIRV.cpp.

References mlir::OpBuilder::createOrFold(), mlir::Builder::getIntegerAttr(), and mlir::Value::getType().

isAllocationSupported()

static bool isAllocationSupported ( Operation * allocOp, MemRefType type ) static

shiftValue()