MLIR
19.0.0git
|
#include "mlir/Dialect/LLVMIR/Transforms/TypeConsistency.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc"
Go to the source code of this file.
Namespaces | |
mlir | |
Include the generated interface declarations. | |
mlir::LLVM | |
Macros | |
#define | GEN_PASS_DEF_LLVMTYPECONSISTENCY |
Functions | |
static Type | isElementTypeInconsistent (Value addr, Type expectedType) |
Checks that a pointer value has a pointee type hint consistent with the expected type. More... | |
static std::optional< uint64_t > | gepToByteOffset (DataLayout &layout, GEPOp gep) |
Returns the amount of bytes the provided GEP elements will offset the pointer by. More... | |
static LogicalResult | findIndicesForOffset (DataLayout &layout, Type base, uint64_t offset, SmallVectorImpl< GEPArg > &equivalentIndicesOut) |
Fills in equivalentIndicesOut with GEP indices that would be equivalent to offsetting a pointer by offset bytes, assuming the GEP has base as base type. More... | |
static FailureOr< Type > | getRequiredConsistentGEPType (GEPOp gep) |
Returns the consistent type for the GEP if the GEP is not type-consistent. More... | |
static FailureOr< DestructurableTypeRange > | getWrittenToFields (const DataLayout &dataLayout, DestructurableTypeInterface destructurableType, unsigned storeSize, unsigned storeOffset) |
Returns the list of elements of destructurableType that are written to by a store operation writing storeSize bytes at storeOffset . More... | |
static void | splitVectorStore (const DataLayout &dataLayout, Location loc, RewriterBase &rewriter, Value address, TypedValue< VectorType > value, unsigned storeOffset) |
Splits a store of the vector value into address at storeOffset into multiple stores of each element with the goal of each generated store becoming type-consistent through subsequent pattern applications. More... | |
static void | splitIntegerStore (const DataLayout &dataLayout, Location loc, RewriterBase &rewriter, Value address, Value value, unsigned storeSize, unsigned storeOffset, DestructurableTypeRange writtenToFields) |
Splits a store of the integer value into address at storeOffset into multiple stores to each 'writtenToFields', making each store operation type-consistent. More... | |
#define GEN_PASS_DEF_LLVMTYPECONSISTENCY |
Definition at line 15 of file TypeConsistency.cpp.
|
static |
Fills in equivalentIndicesOut
with GEP indices that would be equivalent to offsetting a pointer by offset
bytes, assuming the GEP has base
as base type.
Definition at line 104 of file TypeConsistency.cpp.
References mlir::failure(), mlir::LLVM::LLVMStructType::getBody(), mlir::DataLayout::getTypeSize(), mlir::LLVM::LLVMStructType::isPacked(), max(), and mlir::success().
Referenced by mlir::LLVM::CanonicalizeAlignedGep::matchAndRewrite().
|
static |
Returns the amount of bytes the provided GEP elements will offset the pointer by.
Returns nullopt if the offset could not be computed.
Definition at line 51 of file TypeConsistency.cpp.
References mlir::LLVM::LLVMStructType::getBody(), mlir::DataLayout::getTypeABIAlignment(), mlir::DataLayout::getTypeSize(), and mlir::LLVM::LLVMStructType::isPacked().
Referenced by mlir::LLVM::CanonicalizeAlignedGep::matchAndRewrite(), and mlir::LLVM::SplitStores::matchAndRewrite().
Returns the consistent type for the GEP if the GEP is not type-consistent.
Returns failure if the GEP is already consistent.
Definition at line 199 of file TypeConsistency.cpp.
References mlir::failure(), and isElementTypeInconsistent().
Referenced by mlir::LLVM::CanonicalizeAlignedGep::matchAndRewrite(), mlir::LLVM::SplitGEP::matchAndRewrite(), and mlir::LLVM::SplitStores::matchAndRewrite().
|
static |
Returns the list of elements of destructurableType
that are written to by a store operation writing storeSize
bytes at storeOffset
.
storeOffset
is required to cleanly point to an immediate element within the type. If the write operation were to write to any padding, write beyond the aggregate or partially write to a non-aggregate, failure is returned.
Definition at line 299 of file TypeConsistency.cpp.
References mlir::failed(), mlir::failure(), mlir::DataLayout::getTypeABIAlignment(), and mlir::DataLayout::getTypeSize().
Referenced by mlir::LLVM::SplitStores::matchAndRewrite().
Checks that a pointer value has a pointee type hint consistent with the expected type.
Returns the type it actually hints to if it differs, or nullptr if the type is consistent or impossible to analyze.
Definition at line 30 of file TypeConsistency.cpp.
References mlir::Value::getDefiningOp().
Referenced by getRequiredConsistentGEPType(), and mlir::LLVM::SplitStores::matchAndRewrite().
|
static |
Splits a store of the integer value
into address
at storeOffset
into multiple stores to each 'writtenToFields', making each store operation type-consistent.
Definition at line 396 of file TypeConsistency.cpp.
References mlir::OpBuilder::create(), mlir::Builder::getI8Type(), mlir::Builder::getIntegerAttr(), mlir::Builder::getIntegerType(), mlir::Value::getType(), mlir::DataLayout::getTypeSize(), and min().
Referenced by mlir::LLVM::SplitStores::matchAndRewrite().
|
static |
Splits a store of the vector value
into address
at storeOffset
into multiple stores of each element with the goal of each generated store becoming type-consistent through subsequent pattern applications.
Definition at line 369 of file TypeConsistency.cpp.
References mlir::OpBuilder::create(), mlir::Builder::getI32IntegerAttr(), mlir::Builder::getI8Type(), mlir::Value::getType(), and mlir::DataLayout::getTypeSize().
Referenced by mlir::LLVM::SplitStores::matchAndRewrite().