MLIR
18.0.0git
|
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/IR/Block.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Iterators.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "mlir/Rewrite/PatternApplicator.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/ScopedPrinter.h"
#include <optional>
Go to the source code of this file.
Classes | |
struct | mlir::detail::ConversionPatternRewriterImpl |
Namespaces | |
mlir | |
Include the generated interface declarations. | |
mlir::detail | |
Detect if any of the given parameter types has a sub-element handler. | |
Macros | |
#define | DEBUG_TYPE "dialect-conversion" |
Functions | |
template<typename... Args> | |
static void | logSuccess (llvm::ScopedPrinter &os, StringRef fmt, Args &&...args) |
A utility function to log a successful result for the given reason. More... | |
template<typename... Args> | |
static void | logFailure (llvm::ScopedPrinter &os, StringRef fmt, Args &&...args) |
A utility function to log a failure result for the given reason. More... | |
static Value | buildUnresolvedMaterialization (UnresolvedMaterialization::Kind kind, Block *insertBlock, Block::iterator insertPt, Location loc, ValueRange inputs, Type outputType, Type origOutputType, const TypeConverter *converter, SmallVectorImpl< UnresolvedMaterialization > &unresolvedMaterializations) |
Build an unresolved materialization operation given an output type and set of input operands. More... | |
static Value | buildUnresolvedArgumentMaterialization (PatternRewriter &rewriter, Location loc, ValueRange inputs, Type origOutputType, Type outputType, const TypeConverter *converter, SmallVectorImpl< UnresolvedMaterialization > &unresolvedMaterializations) |
static Value | buildUnresolvedTargetMaterialization (Location loc, Value input, Type outputType, const TypeConverter *converter, SmallVectorImpl< UnresolvedMaterialization > &unresolvedMaterializations) |
static void | detachNestedAndErase (Operation *op) |
Detach any operations nested in the given operation from their parent blocks, and erase the given operation. More... | |
static void | replaceMaterialization (ConversionPatternRewriterImpl &rewriterImpl, ResultRange matResults, ValueRange values, DenseMap< Value, SmallVector< Value >> &inverseMapping) |
Replace the results of a materialization operation with the given values. More... | |
static void | computeNecessaryMaterializations (DenseMap< Operation *, UnresolvedMaterialization * > &materializationOps, ConversionPatternRewriter &rewriter, ConversionPatternRewriterImpl &rewriterImpl, DenseMap< Value, SmallVector< Value >> &inverseMapping, SetVector< UnresolvedMaterialization * > &necessaryMaterializations) |
Compute all of the unresolved materializations that will persist beyond the conversion process, and require inserting a proper user materialization for. More... | |
static LogicalResult | legalizeUnresolvedMaterialization (UnresolvedMaterialization &mat, DenseMap< Operation *, UnresolvedMaterialization * > &materializationOps, ConversionPatternRewriter &rewriter, ConversionPatternRewriterImpl &rewriterImpl, DenseMap< Value, SmallVector< Value >> &inverseMapping) |
Legalize the given unresolved materialization. More... | |
static Operation * | findLiveUserOfReplaced (Value initialValue, ConversionPatternRewriterImpl &rewriterImpl, const DenseMap< Value, SmallVector< Value >> &inverseMapping) |
Finds a user of the given value, or of any other value that the given value replaced, that was not replaced in the conversion process. More... | |
static LogicalResult | convertFuncOpTypes (FunctionOpInterface funcOp, const TypeConverter &typeConverter, ConversionPatternRewriter &rewriter) |
static ConversionTarget::DynamicLegalityCallbackFn | composeLegalityCallbacks (ConversionTarget::DynamicLegalityCallbackFn oldCallback, ConversionTarget::DynamicLegalityCallbackFn newCallback) |
static FailureOr< SmallVector< Value > > | pdllConvertValues (ConversionPatternRewriter &rewriter, ValueRange values) |
Remap the given value using the rewriter and the type converter in the provided config. More... | |
#define DEBUG_TYPE "dialect-conversion" |
Definition at line 29 of file DialectConversion.cpp.
|
static |
Definition at line 393 of file DialectConversion.cpp.
References buildUnresolvedMaterialization(), mlir::OpBuilder::getInsertionBlock(), and mlir::OpBuilder::getInsertionPoint().
|
static |
Build an unresolved materialization operation given an output type and set of input operands.
Definition at line 375 of file DialectConversion.cpp.
Referenced by buildUnresolvedArgumentMaterialization(), and buildUnresolvedTargetMaterialization().
|
static |
Definition at line 402 of file DialectConversion.cpp.
References mlir::Block::begin(), buildUnresolvedMaterialization(), and mlir::Value::getParentBlock().
Referenced by mlir::detail::ConversionPatternRewriterImpl::remapValues().
|
static |
Definition at line 3237 of file DialectConversion.cpp.
Referenced by mlir::ConversionTarget::markOpRecursivelyLegal().
|
static |
Compute all of the unresolved materializations that will persist beyond the conversion process, and require inserting a proper user materialization for.
Definition at line 2552 of file DialectConversion.cpp.
References mlir::Value::getDefiningOp(), mlir::Value::getType(), mlir::Value::getUsers(), mlir::detail::ConversionPatternRewriterImpl::isOpIgnored(), mlir::detail::ConversionPatternRewriterImpl::mapping, mlir::detail::ConversionPatternRewriterImpl::unresolvedMaterializations, and mlir::Value::user_end().
|
static |
Definition at line 3097 of file DialectConversion.cpp.
References mlir::ConversionPatternRewriter::convertRegionTypes(), mlir::TypeConverter::convertSignatureArgs(), mlir::TypeConverter::convertTypes(), mlir::failed(), mlir::failure(), mlir::get(), mlir::Builder::getContext(), mlir::TypeConverter::SignatureConversion::getConvertedTypes(), mlir::success(), and mlir::RewriterBase::updateRootInPlace().
|
static |
Detach any operations nested in the given operation from their parent blocks, and erase the given operation.
This can be used when the nested operations are scheduled for erasure themselves, so deleting the regions of the given operation together with their content would result in double-free. This happens, for example, when rolling back op creation in the reverse order and if the nested ops were created before the parent op. This function does not need to collect nested ops recursively because it is expected to also be called for each nested op when it is about to be deleted.
Definition at line 1004 of file DialectConversion.cpp.
|
static |
Finds a user of the given value, or of any other value that the given value replaced, that was not replaced in the conversion process.
Definition at line 2829 of file DialectConversion.cpp.
References mlir::Value::getUsers(), and mlir::Value::user_end().
|
static |
Legalize the given unresolved materialization.
Returns success if the materialization was legalized, failure otherise.
Definition at line 2670 of file DialectConversion.cpp.
References mlir::Value::getType(), mlir::detail::ConversionPatternRewriterImpl::isOpIgnored(), and mlir::detail::ConversionPatternRewriterImpl::mapping.
|
static |
A utility function to log a failure result for the given reason.
Definition at line 46 of file DialectConversion.cpp.
|
static |
A utility function to log a successful result for the given reason.
Definition at line 33 of file DialectConversion.cpp.
|
static |
Remap the given value using the rewriter and the type converter in the provided config.
Definition at line 3334 of file DialectConversion.cpp.
References mlir::failed(), mlir::failure(), and mlir::ConversionPatternRewriter::getRemappedValues().
Referenced by mlir::registerConversionPDLFunctions().
|
static |
Replace the results of a materialization operation with the given values.
Definition at line 2526 of file DialectConversion.cpp.
References mlir::detail::ConversionPatternRewriterImpl::mapping, and mlir::ResultRange::replaceAllUsesWith().