MLIR
19.0.0git
|
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Config/mlir-config.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 |
struct | mlir::detail::ConversionPatternRewriterImpl::SingleEraseRewriter |
A rewriter that keeps track of erased ops and blocks. More... | |
struct | mlir::OperationConverter |
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... | |
template<typename RewriteTy , typename R > | |
static bool | hasRewrite (R &&rewrites, Operation *op) |
Return "true" if there is an operation rewrite that matches the specified rewrite type and operation among the given rewrites. More... | |
template<typename RewriteTy , typename R > | |
static RewriteTy * | findSingleRewrite (R &&rewrites, Block *block) |
Find the single rewrite object of the specified type and block among the given rewrites. 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 *, UnresolvedMaterializationRewrite * > &materializationOps, ConversionPatternRewriter &rewriter, ConversionPatternRewriterImpl &rewriterImpl, DenseMap< Value, SmallVector< Value >> &inverseMapping, SetVector< UnresolvedMaterializationRewrite * > &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 (UnresolvedMaterializationRewrite &mat, DenseMap< Operation *, UnresolvedMaterializationRewrite * > &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 30 of file DialectConversion.cpp.
|
static |
Definition at line 3451 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 2742 of file DialectConversion.cpp.
References mlir::Value::getDefiningOp(), mlir::Value::getType(), mlir::Value::getUsers(), mlir::detail::ConversionPatternRewriterImpl::isOpIgnored(), mlir::detail::ConversionPatternRewriterImpl::mapping, rewrite(), mlir::detail::ConversionPatternRewriterImpl::rewrites, and mlir::Value::user_end().
|
static |
Definition at line 3290 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::RewriterBase::modifyOpInPlace(), and mlir::success().
|
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 3022 of file DialectConversion.cpp.
References mlir::Value::getUsers(), and mlir::Value::user_end().
|
static |
Find the single rewrite object of the specified type and block among the given rewrites.
In debug mode, asserts that there is mo more than one such object. Return "nullptr" if no object was found.
Definition at line 770 of file DialectConversion.cpp.
References rewrite().
|
static |
Return "true" if there is an operation rewrite that matches the specified rewrite type and operation among the given rewrites.
Definition at line 759 of file DialectConversion.cpp.
|
static |
Legalize the given unresolved materialization.
Returns success if the materialization was legalized, failure otherise.
Definition at line 2864 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 47 of file DialectConversion.cpp.
|
static |
A utility function to log a successful result for the given reason.
Definition at line 34 of file DialectConversion.cpp.
|
static |
Remap the given value using the rewriter and the type converter in the provided config.
Definition at line 3549 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 2716 of file DialectConversion.cpp.
References mlir::detail::ConversionPatternRewriterImpl::mapping, and mlir::ResultRange::replaceAllUsesWith().