|
MLIR 23.0.0git
|
#include "mlir/Dialect/Affine/IR/AffineOps.h"#include "mlir/Dialect/Arith/IR/Arith.h"#include "mlir/Dialect/Arith/Transforms/NarrowTypeEmulationConverter.h"#include "mlir/Dialect/Arith/Transforms/Passes.h"#include "mlir/Dialect/Arith/Utils/Utils.h"#include "mlir/Dialect/MemRef/IR/MemRef.h"#include "mlir/Dialect/MemRef/Transforms/Transforms.h"#include "mlir/Dialect/MemRef/Utils/MemRefUtils.h"#include "mlir/Dialect/Vector/IR/VectorOps.h"#include "mlir/IR/Builders.h"#include "mlir/IR/BuiltinTypes.h"#include "mlir/IR/OpDefinition.h"#include "mlir/Transforms/DialectConversion.h"#include "llvm/Support/FormatVariadic.h"#include "llvm/Support/MathExtras.h"#include <cassert>#include <type_traits>Go to the source code of this file.
Functions | |
| static LogicalResult | convertCastingOp (ConversionPatternRewriter &rewriter, memref::ReinterpretCastOp::Adaptor adaptor, memref::ReinterpretCastOp op, MemRefType newTy, bool assumeAligned) |
| Converts a memref::ReinterpretCastOp to the converted type. | |
| static Value | getOffsetForBitwidth (Location loc, OpFoldResult srcIdx, int sourceBits, int targetBits, OpBuilder &builder) |
| When data is loaded/stored in targetBits granularity, but is used in sourceBits granularity (sourceBits < targetBits), the targetBits is treated as an array of elements of width sourceBits. | |
| static Value | getSubByteWriteMask (Location loc, OpFoldResult linearizedIndices, int64_t srcBits, int64_t dstBits, Value bitwidthOffset, OpBuilder &builder) |
| When writing a subbyte size, masked bitwise operations are used to only modify the relevant bits. | |
| static Value | getIndicesForLoadOrStore (OpBuilder &builder, Location loc, OpFoldResult linearizedIndex, int64_t srcBits, int64_t dstBits) |
| Returns the scaled linearized index based on the srcBits and dstBits sizes. | |
| static OpFoldResult | getLinearizedSrcIndices (OpBuilder &builder, Location loc, int64_t srcBits, const SmallVector< OpFoldResult > &indices, Value memref) |
| static SmallVector< int64_t > | getLinearizedShape (MemRefType ty, int srcBits, int dstBits) |
|
static |
Converts a memref::ReinterpretCastOp to the converted type.
The result memref is linearized to a rank-1 byte view (or rank-0 if the source is rank-0). When assumeAligned is true, dynamic offsets are accepted under the alignment contract that the caller guarantees the offset is a multiple of dstBits / srcBits; statically-provable misalignment is rejected. When assumeAligned is false, dynamic offsets are rejected outright since divisibility cannot be proven from the IR alone.
Definition at line 42 of file EmulateNarrowType.cpp.
References mlir::bindSymbols(), mlir::memref::Ceil, mlir::AffineExpr::floorDiv(), mlir::getConstantIntValue(), mlir::Type::getIntOrFloatBitWidth(), mlir::memref::getLinearizedMemRefOffsetAndSize(), mlir::memref::LinearizedMemRefInfo::intraDataOffset, mlir::memref::isStaticShapeAndContiguousRowMajor(), mlir::memref::LinearizedMemRefInfo::linearizedOffset, mlir::memref::LinearizedMemRefInfo::linearizedSize, mlir::affine::makeComposedFoldedAffineApply(), and success().
|
static |
Returns the scaled linearized index based on the srcBits and dstBits sizes.
The input linearizedIndex has the granularity of srcBits, and the returned index has the granularity of dstBits
Definition at line 172 of file EmulateNarrowType.cpp.
References mlir::bindSymbols(), mlir::AffineExpr::floorDiv(), mlir::Builder::getContext(), mlir::getValueOrCreateConstantIndexOp(), and mlir::affine::makeComposedFoldedAffineApply().
|
static |
Definition at line 746 of file EmulateNarrowType.cpp.
Referenced by mlir::memref::populateMemRefNarrowTypeEmulationConversions().
|
static |
Definition at line 184 of file EmulateNarrowType.cpp.
References mlir::memref::getLinearizedMemRefOffsetAndSize(), and indices.
|
static |
When data is loaded/stored in targetBits granularity, but is used in sourceBits granularity (sourceBits < targetBits), the targetBits is treated as an array of elements of width sourceBits.
Return the bit offset of the value at position srcIdx. For example, if sourceBits equals to 4 and targetBits equals to 8, the x-th element is located at (x % 2) * 4. Because there are two elements in one i8, and one element has 4 bits.
Definition at line 134 of file EmulateNarrowType.cpp.
References mlir::bindSymbols(), mlir::Builder::getContext(), mlir::Builder::getIntegerType(), mlir::getValueOrCreateConstantIndexOp(), and mlir::affine::makeComposedFoldedAffineApply().
|
static |
When writing a subbyte size, masked bitwise operations are used to only modify the relevant bits.
This function returns an and mask for clearing the destination bits in a subbyte write. E.g., when writing to the second i4 in an i32, 0xFFFFFF0F is created.
Definition at line 153 of file EmulateNarrowType.cpp.
References mlir::Builder::getIntegerAttr(), and mlir::Builder::getIntegerType().