MLIR  19.0.0git
Namespaces | Functions | Variables
OneToNTypeConversion.cpp File Reference
#include "mlir/Transforms/OneToNTypeConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/SmallSet.h"
#include <unordered_map>

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Functions

static bool isIdentityConversion (Type originalType, TypeRange convertedTypes)
 
StringRef getCastKindName (CastKind kind)
 Mapping of enum values to string values. More...
 
static ValueRange buildUnrealizedCast (OpBuilder &builder, TypeRange resultTypes, ValueRange inputs, CastKind kind)
 Builds an UnrealizedConversionCastOp from the given inputs to the given result types. More...
 
static SmallVector< ValuebuildUnrealizedForwardCasts (ValueRange originalValues, OneToNTypeMapping &conversion, RewriterBase &rewriter, CastKind kind)
 Builds one UnrealizedConversionCastOp for each of the given original values using the respective target types given in the provided conversion mapping and returns the results of these casts. More...
 
static SmallVector< ValuebuildUnrealizedBackwardsCasts (ValueRange convertedValues, const OneToNTypeMapping &typeConversion, RewriterBase &rewriter)
 Builds one UnrealizedConversionCastOp for each sequence of the given original values to one value of the type they originated from, i.e., a "reverse" conversion from N converted values back to one value of the original type, using the given (forward) type conversion. More...
 
LogicalResult mlir::applyPartialOneToNConversion (Operation *op, OneToNTypeConverter &typeConverter, const FrozenRewritePatternSet &patterns)
 Applies the given set of patterns recursively on the given op and adds user materializations where necessary. More...
 

Variables

static const char *const castKindAttrName
 Attribute name that is used to annotate inserted unrealized casts with their kind (source, argument, or target). More...
 

Function Documentation

◆ buildUnrealizedBackwardsCasts()

static SmallVector<Value> buildUnrealizedBackwardsCasts ( ValueRange  convertedValues,
const OneToNTypeMapping typeConversion,
RewriterBase rewriter 
)
static

Builds one UnrealizedConversionCastOp for each sequence of the given original values to one value of the type they originated from, i.e., a "reverse" conversion from N converted values back to one value of the original type, using the given (forward) type conversion.

If a given value was mapped to a value of the same type (i.e., the conversion in the mapping is an identity conversion), then the "converted" value is returned without cast. Note that these unrealized casts are different from source materializations in that they are always inserted, even if they immediately fold away, such that patterns always see valid intermediate IR, whereas materializations are only used in the places where the unrealized casts don't fold away.

Definition at line 182 of file OneToNTypeConversion.cpp.

References buildUnrealizedCast(), mlir::detail::enumerate(), mlir::OneToNTypeMapping::getConvertedTypes(), mlir::OneToNTypeMapping::getOriginalTypes(), mlir::ValueRange::getTypes(), and isIdentityConversion().

◆ buildUnrealizedCast()

static ValueRange buildUnrealizedCast ( OpBuilder builder,
TypeRange  resultTypes,
ValueRange  inputs,
CastKind  kind 
)
static

Builds an UnrealizedConversionCastOp from the given inputs to the given result types.

Returns the result values of the cast.

Definition at line 114 of file OneToNTypeConversion.cpp.

Referenced by mlir::OneToNPatternRewriter::applySignatureConversion(), and buildUnrealizedBackwardsCasts().

◆ buildUnrealizedForwardCasts()

static SmallVector<Value> buildUnrealizedForwardCasts ( ValueRange  originalValues,
OneToNTypeMapping conversion,
RewriterBase rewriter,
CastKind  kind 
)
static

Builds one UnrealizedConversionCastOp for each of the given original values using the respective target types given in the provided conversion mapping and returns the results of these casts.

If the conversion mapping of a value maps a type to itself (i.e., is an identity conversion), then no cast is inserted and the original value is returned instead. Note that these unrealized casts are different from target materializations in that they are always inserted, even if they immediately fold away, such that patterns always see valid intermediate IR, whereas materializations are only used in the places where the unrealized casts don't fold away.

Definition at line 145 of file OneToNTypeConversion.cpp.

◆ getCastKindName()

StringRef getCastKindName ( CastKind  kind)

Mapping of enum values to string values.

Definition at line 99 of file OneToNTypeConversion.cpp.

◆ isIdentityConversion()

static bool isIdentityConversion ( Type  originalType,
TypeRange  convertedTypes 
)
static

Variable Documentation

◆ castKindAttrName

const char* const castKindAttrName
static
Initial value:
=
"__one-to-n-type-conversion_cast-kind__"

Attribute name that is used to annotate inserted unrealized casts with their kind (source, argument, or target).

Definition at line 109 of file OneToNTypeConversion.cpp.