MLIR
20.0.0git
|
#include "mlir/Transforms/OneToNTypeConversion.h"
#include "mlir/Interfaces/FunctionInterfaces.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< Value > | buildUnrealizedForwardCasts (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< Value > | buildUnrealizedBackwardsCasts (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, TypeConverter &typeConverter, const FrozenRewritePatternSet &patterns) |
Applies the given set of patterns recursively on the given op and adds user materializations where necessary. More... | |
void | mlir::populateOneToNFunctionOpInterfaceTypeConversionPattern (StringRef functionLikeOpName, const TypeConverter &converter, RewritePatternSet &patterns) |
Add a pattern to the given pattern list to convert the signature of a FunctionOpInterface op with the given type converter. 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... | |
|
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 169 of file OneToNTypeConversion.cpp.
References buildUnrealizedCast(), mlir::detail::enumerate(), mlir::OneToNTypeMapping::getConvertedTypes(), mlir::OneToNTypeMapping::getOriginalTypes(), mlir::ValueRange::getTypes(), and isIdentityConversion().
Referenced by mlir::OneToNPatternRewriter::replaceOp().
|
static |
Builds an UnrealizedConversionCastOp
from the given inputs to the given result types.
Returns the result values of the cast.
Definition at line 101 of file OneToNTypeConversion.cpp.
References castKindAttrName, mlir::OpBuilder::create(), mlir::get(), getCastKindName(), mlir::Builder::getContext(), and mlir::Builder::getUnknownLoc().
Referenced by buildUnrealizedBackwardsCasts(), and buildUnrealizedForwardCasts().
|
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 132 of file OneToNTypeConversion.cpp.
References buildUnrealizedCast(), mlir::detail::enumerate(), mlir::OneToNTypeMapping::getConvertedTypes(), and isIdentityConversion().
Referenced by mlir::OneToNConversionPattern::matchAndRewrite().
StringRef getCastKindName | ( | CastKind | kind | ) |
Mapping of enum values to string values.
Definition at line 86 of file OneToNTypeConversion.cpp.
Referenced by mlir::applyPartialOneToNConversion(), and buildUnrealizedCast().
Definition at line 49 of file OneToNTypeConversion.cpp.
Referenced by buildUnrealizedBackwardsCasts(), buildUnrealizedForwardCasts(), and mlir::OneToNTypeMapping::hasNonIdentityConversion().
|
static |
Attribute name that is used to annotate inserted unrealized casts with their kind (source, argument, or target).
Definition at line 96 of file OneToNTypeConversion.cpp.
Referenced by mlir::applyPartialOneToNConversion(), and buildUnrealizedCast().