MLIR  20.0.0git
Classes | Namespaces | Macros | Functions
DialectConversion.cpp File Reference
#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
 AttrTypeReplacer.
 

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 OpBuilder::InsertPoint computeInsertPoint (Value value)
 Helper function that computes an insertion point where the given value is defined and can be used without a dominance violation. 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...
 
static LogicalResult legalizeUnresolvedMaterialization (RewriterBase &rewriter, UnresolvedMaterializationRewrite *rewrite)
 
static OperationfindLiveUserOfReplaced (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 std::pair< ValueRange, const TypeConverter * > getReplacedValues (IRRewrite *rewrite)
 Helper function that returns the replaced values and the type converter if the given rewrite object is an "operation replacement" or a "block type conversion" (which corresponds to a "block replacement"). 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...
 
static OperationfindCommonAncestor (ArrayRef< Operation * > ops)
 Find a common IsolatedFromAbove ancestor of the given ops. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "dialect-conversion"

Definition at line 30 of file DialectConversion.cpp.

Function Documentation

◆ composeLegalityCallbacks()

◆ computeInsertPoint()

static OpBuilder::InsertPoint computeInsertPoint ( Value  value)
static

Helper function that computes an insertion point where the given value is defined and can be used without a dominance violation.

Definition at line 58 of file DialectConversion.cpp.

References mlir::Block::begin(), and mlir::Value::getParentBlock().

Referenced by mlir::detail::ConversionPatternRewriterImpl::applySignatureConversion(), and mlir::detail::ConversionPatternRewriterImpl::remapValues().

◆ convertFuncOpTypes()

static LogicalResult convertFuncOpTypes ( FunctionOpInterface  funcOp,
const TypeConverter typeConverter,
ConversionPatternRewriter rewriter 
)
static

◆ findCommonAncestor()

static Operation* findCommonAncestor ( ArrayRef< Operation * >  ops)
static

Find a common IsolatedFromAbove ancestor of the given ops.

If at least one op is a top-level module op (which is expected to be isolated from above), return that op.

Definition at line 3291 of file DialectConversion.cpp.

Referenced by mlir::applyAnalysisConversion().

◆ findLiveUserOfReplaced()

static Operation* findLiveUserOfReplaced ( Value  initialValue,
ConversionPatternRewriterImpl rewriterImpl,
const DenseMap< Value, SmallVector< Value >> &  inverseMapping 
)
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 2538 of file DialectConversion.cpp.

References mlir::Value::getUsers(), and mlir::Value::user_end().

◆ getReplacedValues()

static std::pair<ValueRange, const TypeConverter *> getReplacedValues ( IRRewrite *  rewrite)
static

Helper function that returns the replaced values and the type converter if the given rewrite object is an "operation replacement" or a "block type conversion" (which corresponds to a "block replacement").

Otherwise, return an empty ValueRange and a null type converter pointer.

Definition at line 2564 of file DialectConversion.cpp.

References rewrite().

◆ hasRewrite()

template<typename RewriteTy , typename R >
static bool hasRewrite ( R &&  rewrites,
Operation op 
)
static

Return "true" if there is an operation rewrite that matches the specified rewrite type and operation among the given rewrites.

Definition at line 729 of file DialectConversion.cpp.

◆ legalizeUnresolvedMaterialization()

static LogicalResult legalizeUnresolvedMaterialization ( RewriterBase rewriter,
UnresolvedMaterializationRewrite *  rewrite 
)
static

Definition at line 2420 of file DialectConversion.cpp.

◆ logFailure()

template<typename... Args>
static void logFailure ( llvm::ScopedPrinter &  os,
StringRef  fmt,
Args &&...  args 
)
static

A utility function to log a failure result for the given reason.

Definition at line 47 of file DialectConversion.cpp.

◆ logSuccess()

template<typename... Args>
static void logSuccess ( llvm::ScopedPrinter &  os,
StringRef  fmt,
Args &&...  args 
)
static

A utility function to log a successful result for the given reason.

Definition at line 34 of file DialectConversion.cpp.

◆ pdllConvertValues()

static FailureOr<SmallVector<Value> > pdllConvertValues ( ConversionPatternRewriter rewriter,
ValueRange  values 
)
static

Remap the given value using the rewriter and the type converter in the provided config.

Definition at line 3193 of file DialectConversion.cpp.

References mlir::ConversionPatternRewriter::getRemappedValues().

Referenced by mlir::registerConversionPDLFunctions().