MLIR 24.0.0git
MemorySlotInterfacesImpl.cpp File Reference
#include "mlir/Dialect/MemRef/IR/MemorySlotInterfacesImpl.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 Attribute getAttributeIndexFromIndexOperands (MLIRContext *ctx, ValueRange indices, MemRefType memrefType)
 Returns the index of a memref in attribute form, given its indices.
static std::optional< int64_t > matchVScaleMultiple (Value size)
 Returns the scalable vector width a vscale-sized memref maps to: the factor C when size is a known multiple of vscale.

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 72 of file MemorySlotInterfacesImpl.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 94 of file MemorySlotInterfacesImpl.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 42 of file MemorySlotInterfacesImpl.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 56 of file MemorySlotInterfacesImpl.cpp.

References nextIndex().