|
MLIR 24.0.0git
|
#include "mlir/Dialect/LLVMIR/LLVMMemoryOps.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/LLVMDebugIntrinsicOps.h"#include "mlir/IR/Builders.h"#include "mlir/IR/DialectImplementation.h"#include "mlir/IR/Matchers.h"#include "mlir/IR/PatternMatch.h"#include "mlir/Interfaces/DataLayoutInterfaces.h"#include "mlir/Interfaces/MemorySlotInterfaces.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/TypeSwitch.h"#include "llvm/Support/DebugLog.h"#include <optional>#include "mlir/Dialect/LLVMIR/LLVMMemoryOps.cpp.inc"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "sroa" |
| #define | GET_OP_CLASSES |
Functions | |
| static void | destructureIndices (Type currType, ArrayRef< GEPArg > indices, SmallVectorImpl< int32_t > &rawConstantIndices, SmallVectorImpl< Value > &dynamicIndices) |
| Destructures the 'indices' parameter into 'rawConstantIndices' and 'dynamicIndices', encoding the former in the process. | |
| static LogicalResult | verifyStructIndices (Type baseGEPType, unsigned indexPos, GEPIndicesAdaptor< ValueRange > indices, function_ref< InFlightDiagnostic()> emitOpError) |
| For the given indices, check if they comply with baseGEPType, especially check against LLVMStructTypes nested within. | |
| static LogicalResult | verifyStructIndices (Type baseGEPType, GEPIndicesAdaptor< ValueRange > indices, function_ref< InFlightDiagnostic()> emitOpError) |
| Driver function around verifyStructIndices. | |
| template<typename OpTy> | |
| static LogicalResult | verifyAtomicMemOp (OpTy memOp, Type valueType, ArrayRef< AtomicOrdering > unsupportedOrderings) |
| Verifies the attributes and the type of atomic memory access operations. | |
| static bool | isSupportedTypeForConversion (Type type) |
| Checks if type can be used in any kind of conversion sequences. | |
| static bool | areConversionCompatible (const DataLayout &layout, Type targetType, Type srcType, bool narrowingConversion) |
| Checks that rhs can be converted to lhs by a sequence of casts and truncations. | |
| static bool | isBigEndian (const DataLayout &dataLayout) |
| Checks if dataLayout describes a little endian layout. | |
| static Value | castToSameSizedInt (OpBuilder &builder, Location loc, Value val, const DataLayout &dataLayout) |
| Converts a value to an integer type of the same size. | |
| static Value | castIntValueToSameSizedType (OpBuilder &builder, Location loc, Value val, Type targetType) |
| Converts a value with an integer type to targetType. | |
| static Value | castSameSizedTypes (OpBuilder &builder, Location loc, Value srcValue, Type targetType, const DataLayout &dataLayout) |
| Constructs operations that convert srcValue into a new value of type targetType. | |
| static Value | createExtractAndCast (OpBuilder &builder, Location loc, Value srcValue, Type targetType, const DataLayout &dataLayout) |
| Constructs operations that convert srcValue into a new value of type targetType. | |
| static Value | createInsertAndCast (OpBuilder &builder, Location loc, Value srcValue, Value reachingDef, const DataLayout &dataLayout) |
| Constructs operations that insert the bits of srcValue into the "beginning" of reachingDef (beginning is endianness dependent). | |
| static bool | isValidAccessType (const MemorySlot &slot, Type accessType, const DataLayout &dataLayout) |
| Checks if slot can be accessed through the provided access type. | |
| static Type | getTypeAtIndex (const DestructurableMemorySlot &slot, Attribute index) |
| Returns the subslot's type at the requested index. | |
| static bool | hasAllZeroIndices (LLVM::GEPOp gepOp) |
| static std::optional< uint64_t > | gepToByteOffset (const DataLayout &dataLayout, LLVM::GEPOp gep) |
| Returns the amount of bytes the provided GEP elements will offset the pointer by. | |
| static std::optional< SubslotAccessInfo > | getSubslotAccessInfo (const DestructurableMemorySlot &slot, const DataLayout &dataLayout, LLVM::GEPOp gep) |
| Computes subslot access information for an access into slot with the given offset. | |
| static LLVM::LLVMArrayType | getByteArrayType (MLIRContext *context, unsigned size) |
| Constructs a byte array type of the given size. | |
Variables | |
| static constexpr const char | kElemTypeAttrName [] = "elem_type" |
| #define DEBUG_TYPE "sroa" |
Definition at line 32 of file LLVMMemoryOps.cpp.
| #define GET_OP_CLASSES |
Definition at line 1389 of file LLVMMemoryOps.cpp.
|
static |
Checks that rhs can be converted to lhs by a sequence of casts and truncations.
Checks for narrowing or widening conversion compatibility depending on narrowingConversion.
Definition at line 771 of file LLVMMemoryOps.cpp.
References mlir::DataLayout::getTypeSize(), and isSupportedTypeForConversion().
Referenced by castSameSizedTypes(), createExtractAndCast(), and createInsertAndCast().
|
static |
Converts a value with an integer type to targetType.
Definition at line 820 of file LLVMMemoryOps.cpp.
References mlir::OpBuilder::createOrFold(), mlir::Value::getType(), and isSupportedTypeForConversion().
Referenced by castSameSizedTypes(), createExtractAndCast(), and createInsertAndCast().
|
static |
Constructs operations that convert srcValue into a new value of type targetType.
Assumes the types have the same bitsize.
Definition at line 835 of file LLVMMemoryOps.cpp.
References areConversionCompatible(), castIntValueToSameSizedType(), castToSameSizedInt(), mlir::OpBuilder::createOrFold(), mlir::Value::getType(), and replacement().
Referenced by createExtractAndCast(), and createInsertAndCast().
|
static |
Converts a value to an integer type of the same size.
Assumes that the type can be converted.
Definition at line 802 of file LLVMMemoryOps.cpp.
References mlir::OpBuilder::createOrFold(), mlir::Builder::getIntegerType(), mlir::Value::getType(), mlir::DataLayout::getTypeSizeInBits(), and isSupportedTypeForConversion().
Referenced by castSameSizedTypes(), createExtractAndCast(), and createInsertAndCast().
|
static |
Constructs operations that convert srcValue into a new value of type targetType.
Performs bit-level extraction if the source type is larger than the target type. Assumes that this conversion is possible.
Definition at line 864 of file LLVMMemoryOps.cpp.
References areConversionCompatible(), castIntValueToSameSizedType(), castSameSizedTypes(), castToSameSizedInt(), mlir::OpBuilder::createOrFold(), mlir::Builder::getIntegerAttr(), mlir::Builder::getIntegerType(), mlir::Value::getType(), mlir::DataLayout::getTypeSizeInBits(), isBigEndian(), and replacement().
|
static |
Constructs operations that insert the bits of srcValue into the "beginning" of reachingDef (beginning is endianness dependent).
Assumes that this conversion is possible.
Definition at line 905 of file LLVMMemoryOps.cpp.
References areConversionCompatible(), castIntValueToSameSizedType(), castSameSizedTypes(), castToSameSizedInt(), mlir::OpBuilder::createOrFold(), mlir::Builder::getIntegerAttr(), mlir::Value::getType(), mlir::DataLayout::getTypeSizeInBits(), and isBigEndian().
|
static |
Destructures the 'indices' parameter into 'rawConstantIndices' and 'dynamicIndices', encoding the former in the process.
In the process, dynamic indices which are used to index into a structure type are converted to constant indices when possible. To do this, the GEPs element type should be passed as first parameter.
Definition at line 159 of file LLVMMemoryOps.cpp.
References indices, mlir::LLVM::kGEPConstantBitWidth, mlir::m_ConstantInt(), and mlir::matchPattern().
|
static |
Returns the amount of bytes the provided GEP elements will offset the pointer by.
Returns nullopt if no constant offset could be computed.
Definition at line 1183 of file LLVMMemoryOps.cpp.
References mlir::DataLayout::getTypeSize(), and indices.
Referenced by getSubslotAccessInfo().
|
static |
Constructs a byte array type of the given size.
Definition at line 1296 of file LLVMMemoryOps.cpp.
|
static |
Computes subslot access information for an access into slot with the given offset.
Returns nullopt when the offset is out-of-bounds or when the access is into the padding of slot.
Definition at line 1244 of file LLVMMemoryOps.cpp.
References gepToByteOffset(), mlir::DataLayout::getTypeSize(), mlir::LLVM::kGEPConstantBitWidth, and mlir::MemorySlot::valueType.
|
static |
Returns the subslot's type at the requested index.
Definition at line 1057 of file LLVMMemoryOps.cpp.
References mlir::MemorySlot::valueType.
|
static |
Definition at line 1157 of file LLVMMemoryOps.cpp.
|
static |
Checks if dataLayout describes a little endian layout.
Definition at line 795 of file LLVMMemoryOps.cpp.
References mlir::DataLayout::getEndianness().
Referenced by createExtractAndCast(), and createInsertAndCast().
Checks if type can be used in any kind of conversion sequences.
Definition at line 753 of file LLVMMemoryOps.cpp.
Referenced by areConversionCompatible(), castIntValueToSameSizedType(), and castToSameSizedInt().
|
static |
Checks if slot can be accessed through the provided access type.
Definition at line 1036 of file LLVMMemoryOps.cpp.
References mlir::DataLayout::getTypeSize(), and mlir::MemorySlot::valueType.
|
static |
Verifies the attributes and the type of atomic memory access operations.
Definition at line 393 of file LLVMMemoryOps.cpp.
References mlir::DataLayout::closest(), mlir::LLVM::isTypeCompatibleWithAtomicOp(), and success().
|
static |
Driver function around verifyStructIndices.
Definition at line 314 of file LLVMMemoryOps.cpp.
References indices, and verifyStructIndices().
|
static |
For the given indices, check if they comply with baseGEPType, especially check against LLVMStructTypes nested within.
Definition at line 274 of file LLVMMemoryOps.cpp.
References indices, success(), and verifyStructIndices().
Referenced by verifyStructIndices(), and verifyStructIndices().
|
staticconstexpr |
Definition at line 41 of file LLVMMemoryOps.cpp.