MLIR  19.0.0git
Functions
MemRefMemorySlot.cpp File Reference
#include "mlir/Dialect/MemRef/IR/MemRefMemorySlot.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/Value.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/MemorySlotInterfaces.h"
#include "mlir/Support/LogicalResult.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. More...
 
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. More...
 
static bool isSupportedElementType (Type type)
 
static Attribute getAttributeIndexFromIndexOperands (MLIRContext *ctx, ValueRange indices, MemRefType memrefType)
 Returns the index of a memref in attribute form, given its indices. More...
 

Function Documentation

◆ getAttributeIndexFromIndexOperands()

static 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 193 of file MemRefMemorySlot.cpp.

References mlir::get(), and mlir::matchPattern().

◆ isSupportedElementType()

static bool isSupportedElementType ( Type  type)
static

Definition at line 67 of file MemRefMemorySlot.cpp.

References mlir::Type::getContext(), and mlir::Builder::getZeroAttr().

◆ nextIndex()

static 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 mlir::failure(), and mlir::success().

Referenced by walkIndicesAsAttr().

◆ walkIndicesAsAttr()

template<typename CallableT >
static 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 mlir::get(), nextIndex(), and mlir::succeeded().