MLIR 24.0.0git
MemRefMemorySlot.cpp File Reference
#include "mlir/Dialect/MemRef/IR/MemRefMemorySlot.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/UB/IR/UBOps.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/Value.h"
#include "mlir/Interfaces/MemorySlotInterfaces.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/ErrorHandling.h"

Go to the source code of this file.

Functions

static LogicalResult nextIndex (ArrayRef< int64_t > shape, MutableArrayRef< int64_t > index)
 Walks over the indices of the elements of a tensor of a given shape by updating index in place to the next index.
template<typename CallableT>
static void walkIndicesAsAttr (MLIRContext *ctx, ArrayRef< int64_t > shape, CallableT &&walker)
 Calls walker for each index within a tensor of a given shape, providing the index as an array attribute of the coordinates.
static std::optional< int64_tmatchVScaleMultiple (Value size)
 Returns the scalable vector width a vscale-sized memref maps to: the factor C when size is a known multiple of vscale.
static Attribute getAttributeIndexFromIndexOperands (MLIRContext *ctx, ValueRange indices, MemRefType memrefType)
 Returns the index of a memref in attribute form, given its indices.

Function Documentation

◆ getAttributeIndexFromIndexOperands()

Attribute getAttributeIndexFromIndexOperands ( MLIRContext * ctx,
ValueRange indices,
MemRefType memrefType )
static

Returns the index of a memref in attribute form, given its indices.

Returns a null pointer if whether the indices form a valid index for the provided MemRefType cannot be computed. The indices must come from a valid memref StoreOp or LoadOp.

Definition at line 243 of file MemRefMemorySlot.cpp.

References indices, mlir::m_Constant(), and mlir::matchPattern().

◆ matchVScaleMultiple()

std::optional< int64_t > matchVScaleMultiple ( Value size)
static

Returns the scalable vector width a vscale-sized memref maps to: the factor C when size is a known multiple of vscale.

Definition at line 69 of file MemRefMemorySlot.cpp.

References mlir::getConstantIntValue(), mlir::Value::getDefiningOp(), mlir::Operation::getName(), mlir::OperationName::getStringRef(), and mul.

◆ nextIndex()

LogicalResult nextIndex ( ArrayRef< int64_t > shape,
MutableArrayRef< int64_t > index )
static

Walks over the indices of the elements of a tensor of a given shape by updating index in place to the next index.

This returns failure if the provided index was the last index.

Definition at line 37 of file MemRefMemorySlot.cpp.

References success().

Referenced by walkIndicesAsAttr().

◆ walkIndicesAsAttr()

template<typename CallableT>
void walkIndicesAsAttr ( MLIRContext * ctx,
ArrayRef< int64_t > shape,
CallableT && walker )
static

Calls walker for each index within a tensor of a given shape, providing the index as an array attribute of the coordinates.

Definition at line 51 of file MemRefMemorySlot.cpp.

References nextIndex().