MLIR 24.0.0git
LLVMMemoryIntrinsicOps.cpp File Reference
#include "mlir/Dialect/LLVMIR/LLVMMemoryIntrinsicOps.h"
#include "IR/LLVMOps.h"
#include "mlir/Dialect/LLVMIR/LLVMArithOps.h"
#include "mlir/Dialect/LLVMIR/LLVMConstantOps.h"
#include "mlir/Dialect/LLVMIR/LLVMConversionOps.h"
#include "mlir/Dialect/LLVMIR/LLVMMemoryOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Interfaces/DataLayoutInterfaces.h"
#include "mlir/Interfaces/MemorySlotInterfaces.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include <optional>
#include "mlir/Dialect/LLVMIR/LLVMMemoryIntrinsicOps.cpp.inc"

Go to the source code of this file.

Macros

#define GET_OP_CLASSES

Functions

template<class MemIntr>
static bool definitelyWritesOnlyWithinSlot (MemIntr op, const MemorySlot &slot, const DataLayout &dataLayout)
 Returns whether one can be sure the memory intrinsic does not write outside of the bounds of the given slot, on a best-effort basis.
static bool areAllIndicesI32 (const DestructurableMemorySlot &slot)
 Checks whether all indices are i32.
template<class MemsetIntr>
static bool memsetCanRewire (MemsetIntr op, const DestructurableMemorySlot &slot, SmallPtrSetImpl< Attribute > &usedIndices, SmallVectorImpl< MemorySlot > &mustBeSafelyUsed, const DataLayout &dataLayout)
template<class MemsetIntr>
static Value memsetGetStored (MemsetIntr op, const MemorySlot &slot, OpBuilder &builder)
template<class MemsetIntr>
static bool memsetCanUsesBeRemoved (MemsetIntr op, const MemorySlot &slot, const SmallPtrSetImpl< OpOperand * > &blockingUses, SmallVectorImpl< OpOperand * > &newBlockingUses, const DataLayout &dataLayout)
template<class MemsetIntr>
static DeletionKind memsetRewire (MemsetIntr op, const DestructurableMemorySlot &slot, DenseMap< Attribute, MemorySlot > &subslots, OpBuilder &builder, const DataLayout &dataLayout)
template<class MemcpyLike>
static bool memcpyLoadsFrom (MemcpyLike op, const MemorySlot &slot)
template<class MemcpyLike>
static bool memcpyStoresTo (MemcpyLike op, const MemorySlot &slot)
template<class MemcpyLike>
static Value memcpyGetStored (MemcpyLike op, const MemorySlot &slot, OpBuilder &builder)
template<class MemcpyLike>
static bool memcpyCanUsesBeRemoved (MemcpyLike op, const MemorySlot &slot, const SmallPtrSetImpl< OpOperand * > &blockingUses, SmallVectorImpl< OpOperand * > &newBlockingUses, const DataLayout &dataLayout)
template<class MemcpyLike>
static DeletionKind memcpyRemoveBlockingUses (MemcpyLike op, const MemorySlot &slot, const SmallPtrSetImpl< OpOperand * > &blockingUses, OpBuilder &builder, Value reachingDefinition)
template<class MemcpyLike>
static LogicalResult memcpyEnsureOnlySafeAccesses (MemcpyLike op, const MemorySlot &slot, SmallVectorImpl< MemorySlot > &mustBeSafelyUsed)
template<class MemcpyLike>
static bool memcpyCanRewire (MemcpyLike op, const DestructurableMemorySlot &slot, SmallPtrSetImpl< Attribute > &usedIndices, SmallVectorImpl< MemorySlot > &mustBeSafelyUsed, const DataLayout &dataLayout)
template<class MemcpyLike>
static DeletionKind memcpyRewire (MemcpyLike op, const DestructurableMemorySlot &slot, DenseMap< Attribute, MemorySlot > &subslots, OpBuilder &builder, const DataLayout &dataLayout)
 Rewires a memcpy-like operation.

Macro Definition Documentation

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 786 of file LLVMMemoryIntrinsicOps.cpp.

Function Documentation

◆ areAllIndicesI32()

bool areAllIndicesI32 ( const DestructurableMemorySlot & slot)
static

Checks whether all indices are i32.

This is used to check GEPs can index into them.

Definition at line 208 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::Value::getContext(), mlir::MemorySlot::ptr, and mlir::DestructurableMemorySlot::subelementTypes.

Referenced by memcpyCanRewire(), and memsetCanRewire().

◆ definitelyWritesOnlyWithinSlot()

template<class MemIntr>
bool definitelyWritesOnlyWithinSlot ( MemIntr op,
const MemorySlot & slot,
const DataLayout & dataLayout )
static

Returns whether one can be sure the memory intrinsic does not write outside of the bounds of the given slot, on a best-effort basis.

Definition at line 196 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::Value::getType(), mlir::DataLayout::getTypeSize(), mlir::MemorySlot::ptr, and mlir::MemorySlot::valueType.

Referenced by memcpyEnsureOnlySafeAccesses(), and memsetCanRewire().

◆ memcpyCanRewire()

template<class MemcpyLike>
bool memcpyCanRewire ( MemcpyLike op,
const DestructurableMemorySlot & slot,
SmallPtrSetImpl< Attribute > & usedIndices,
SmallVectorImpl< MemorySlot > & mustBeSafelyUsed,
const DataLayout & dataLayout )
static

◆ memcpyCanUsesBeRemoved()

template<class MemcpyLike>
bool memcpyCanUsesBeRemoved ( MemcpyLike op,
const MemorySlot & slot,
const SmallPtrSetImpl< OpOperand * > & blockingUses,
SmallVectorImpl< OpOperand * > & newBlockingUses,
const DataLayout & dataLayout )
static

◆ memcpyEnsureOnlySafeAccesses()

template<class MemcpyLike>
LogicalResult memcpyEnsureOnlySafeAccesses ( MemcpyLike op,
const MemorySlot & slot,
SmallVectorImpl< MemorySlot > & mustBeSafelyUsed )
static

◆ memcpyGetStored()

template<class MemcpyLike>
Value memcpyGetStored ( MemcpyLike op,
const MemorySlot & slot,
OpBuilder & builder )
static

Definition at line 465 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::MemorySlot::valueType.

◆ memcpyLoadsFrom()

template<class MemcpyLike>
bool memcpyLoadsFrom ( MemcpyLike op,
const MemorySlot & slot )
static

Definition at line 455 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::MemorySlot::ptr.

◆ memcpyRemoveBlockingUses()

template<class MemcpyLike>
DeletionKind memcpyRemoveBlockingUses ( MemcpyLike op,
const MemorySlot & slot,
const SmallPtrSetImpl< OpOperand * > & blockingUses,
OpBuilder & builder,
Value reachingDefinition )
static

Definition at line 491 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::Delete.

◆ memcpyRewire()

template<class MemcpyLike>
DeletionKind memcpyRewire ( MemcpyLike op,
const DestructurableMemorySlot & slot,
DenseMap< Attribute, MemorySlot > & subslots,
OpBuilder & builder,
const DataLayout & dataLayout )
static

Rewires a memcpy-like operation.

Only copies to or from the full slot are supported.

Definition at line 565 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::Delete, mlir::MemorySlot::ptr, mlir::DestructurableMemorySlot::subelementTypes, and mlir::MemorySlot::valueType.

◆ memcpyStoresTo()

template<class MemcpyLike>
bool memcpyStoresTo ( MemcpyLike op,
const MemorySlot & slot )
static

Definition at line 460 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::MemorySlot::ptr.

◆ memsetCanRewire()

template<class MemsetIntr>
bool memsetCanRewire ( MemsetIntr op,
const DestructurableMemorySlot & slot,
SmallPtrSetImpl< Attribute > & usedIndices,
SmallVectorImpl< MemorySlot > & mustBeSafelyUsed,
const DataLayout & dataLayout )
static

◆ memsetCanUsesBeRemoved()

template<class MemsetIntr>
bool memsetCanUsesBeRemoved ( MemsetIntr op,
const MemorySlot & slot,
const SmallPtrSetImpl< OpOperand * > & blockingUses,
SmallVectorImpl< OpOperand * > & newBlockingUses,
const DataLayout & dataLayout )
static

◆ memsetGetStored()

template<class MemsetIntr>
Value memsetGetStored ( MemsetIntr op,
const MemorySlot & slot,
OpBuilder & builder )
static

Returns an integer value that is width bits wide representing the value assigned to the slot by memset.

Definition at line 243 of file LLVMMemoryIntrinsicOps.cpp.

References mlir::m_Constant(), mlir::matchPattern(), and mlir::MemorySlot::valueType.

◆ memsetRewire()

template<class MemsetIntr>
DeletionKind memsetRewire ( MemsetIntr op,
const DestructurableMemorySlot & slot,
DenseMap< Attribute, MemorySlot > & subslots,
OpBuilder & builder,
const DataLayout & dataLayout )
static