MLIR  21.0.0git
Classes | Namespaces | Macros | Typedefs | 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/Dominance.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"
 

Typedefs

using ValueVector = SmallVector< Value, 1 >
 A vector of SSA values, optimized for the most common case of a single value. More...
 

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...
 
static OpBuilder::InsertPoint computeInsertPoint (ArrayRef< Value > vals)
 Helper function that computes an insertion point where the given values are defined and can be used without a dominance violation. More...
 
static LogicalResult legalizeUnresolvedMaterialization (RewriterBase &rewriter, UnresolvedMaterializationRewrite *rewrite)
 
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 31 of file DialectConversion.cpp.

Typedef Documentation

◆ ValueVector

using ValueVector = SmallVector<Value, 1>

A vector of SSA values, optimized for the most common case of a single value.

Definition at line 100 of file DialectConversion.cpp.

Function Documentation

◆ composeLegalityCallbacks()

◆ computeInsertPoint() [1/2]

static OpBuilder::InsertPoint computeInsertPoint ( ArrayRef< Value vals)
static

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

Definition at line 69 of file DialectConversion.cpp.

References computeInsertPoint(), mlir::DominanceInfo::dominates(), mlir::OpBuilder::InsertPoint::getBlock(), and mlir::OpBuilder::InsertPoint::getPoint().

◆ computeInsertPoint() [2/2]

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 59 of file DialectConversion.cpp.

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

Referenced by computeInsertPoint(), mlir::detail::ConversionPatternRewriterImpl::findOrBuildReplacementValue(), mlir::detail::ConversionPatternRewriterImpl::notifyOpReplaced(), 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 3397 of file DialectConversion.cpp.

References mlir::Operation::getParentOp(), mlir::Operation::getParentWithTrait(), mlir::Operation::hasTrait(), mlir::Operation::isAncestor(), and mlir::Operation::isProperAncestor().

Referenced by mlir::applyAnalysisConversion().

◆ legalizeUnresolvedMaterialization()

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

◆ 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 48 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 35 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 3299 of file DialectConversion.cpp.

References mlir::ConversionPatternRewriter::getRemappedValues().

Referenced by mlir::registerConversionPDLFunctions().