13 #ifndef MLIR_TRANSFORMS_DIALECTCONVERSION_H_
14 #define MLIR_TRANSFORMS_DIALECTCONVERSION_H_
17 #include "llvm/ADT/MapVector.h"
18 #include "llvm/ADT/StringMap.h"
19 #include <type_traits>
26 class ConversionPatternRewriter;
44 : conversions(other.conversions),
45 argumentMaterializations(other.argumentMaterializations),
46 sourceMaterializations(other.sourceMaterializations),
47 targetMaterializations(other.targetMaterializations),
48 typeAttributeConversions(other.typeAttributeConversions) {}
50 conversions = other.conversions;
51 argumentMaterializations = other.argumentMaterializations;
52 sourceMaterializations = other.sourceMaterializations;
53 targetMaterializations = other.targetMaterializations;
54 typeAttributeConversions = other.typeAttributeConversions;
63 : remappedInputs(numOrigInputs) {}
77 return remappedInputs[input];
99 void remapInput(
unsigned origInputNo,
unsigned newInputNo,
100 unsigned newInputCount = 1);
129 llvm::PointerIntPair<Attribute, 2>
impl;
132 static constexpr
unsigned naTag = 0;
133 static constexpr
unsigned resultTag = 1;
134 static constexpr
unsigned abortTag = 2;
162 template <
typename FnT,
typename T =
typename llvm::function_traits<
163 std::decay_t<FnT>>::template arg_t<0>>
165 registerConversion(wrapCallback<T>(std::forward<FnT>(callback)));
182 template <
typename FnT,
typename T =
typename llvm::function_traits<
183 std::decay_t<FnT>>::template arg_t<1>>
185 argumentMaterializations.emplace_back(
186 wrapMaterialization<T>(std::forward<FnT>(callback)));
191 template <
typename FnT,
typename T =
typename llvm::function_traits<
192 std::decay_t<FnT>>::template arg_t<1>>
194 sourceMaterializations.emplace_back(
195 wrapMaterialization<T>(std::forward<FnT>(callback)));
199 template <
typename FnT,
typename T =
typename llvm::function_traits<
200 std::decay_t<FnT>>::template arg_t<1>>
202 targetMaterializations.emplace_back(
203 wrapMaterialization<T>(std::forward<FnT>(callback)));
226 typename llvm::function_traits<std::decay_t<FnT>>::template arg_t<0>,
228 typename llvm::function_traits<std::decay_t<FnT>>::template arg_t<1>>
230 registerTypeAttributeConversion(
231 wrapTypeAttributeConversion<T, A>(std::forward<FnT>(callback)));
248 return dyn_cast_or_null<TargetType>(
convertType(t));
262 template <
typename RangeT>
263 std::enable_if_t<!std::is_convertible<RangeT, Type>::value &&
264 !std::is_convertible<RangeT, Operation *>::value,
267 return llvm::all_of(range, [
this](
Type type) {
return isLegal(type); });
283 SignatureConversion &result)
const;
285 SignatureConversion &result,
286 unsigned origInputOffset = 0)
const;
300 return materializeConversion(argumentMaterializations, builder, loc,
305 return materializeConversion(sourceMaterializations, builder, loc,
310 return materializeConversion(targetMaterializations, builder, loc,
325 using ConversionCallbackFn = std::function<std::optional<LogicalResult>(
329 using MaterializationCallbackFn = std::function<std::optional<Value>(
333 using TypeAttributeConversionCallbackFn =
346 template <
typename T,
typename FnT>
347 std::enable_if_t<std::is_invocable_v<FnT, T>, ConversionCallbackFn>
348 wrapCallback(FnT &&callback)
const {
349 return wrapCallback<T>([callback = std::forward<FnT>(callback)](
351 if (std::optional<Type> resultOpt = callback(type)) {
352 bool wasSuccess =
static_cast<bool>(*resultOpt);
354 results.push_back(*resultOpt);
355 return std::optional<LogicalResult>(
success(wasSuccess));
357 return std::optional<LogicalResult>();
362 template <
typename T,
typename FnT>
363 std::enable_if_t<std::is_invocable_v<FnT, T, SmallVectorImpl<Type> &>,
364 ConversionCallbackFn>
365 wrapCallback(FnT &&callback)
const {
366 return [callback = std::forward<FnT>(callback)](
368 SmallVectorImpl<Type> &results) -> std::optional<LogicalResult> {
369 T derivedType = dyn_cast<T>(type);
372 return callback(derivedType, results);
377 void registerConversion(ConversionCallbackFn callback) {
378 conversions.emplace_back(std::move(callback));
379 cachedDirectConversions.clear();
380 cachedMultiConversions.clear();
386 template <
typename T,
typename FnT>
387 MaterializationCallbackFn wrapMaterialization(FnT &&callback)
const {
388 return [callback = std::forward<FnT>(callback)](
389 OpBuilder &builder,
Type resultType, ValueRange inputs,
390 Location loc) -> std::optional<Value> {
391 if (T derivedType = dyn_cast<T>(resultType))
392 return callback(builder, derivedType, inputs, loc);
401 template <
typename T,
typename A,
typename FnT>
402 TypeAttributeConversionCallbackFn
403 wrapTypeAttributeConversion(FnT &&callback)
const {
404 return [callback = std::forward<FnT>(callback)](
405 Type type, Attribute attr) -> AttributeConversionResult {
406 if (T derivedType = dyn_cast<T>(type)) {
407 if (A derivedAttr = dyn_cast_or_null<A>(attr))
408 return callback(derivedType, derivedAttr);
416 registerTypeAttributeConversion(TypeAttributeConversionCallbackFn callback) {
417 typeAttributeConversions.emplace_back(std::move(callback));
419 cachedDirectConversions.clear();
420 cachedMultiConversions.clear();
424 SmallVector<ConversionCallbackFn, 4> conversions;
427 SmallVector<MaterializationCallbackFn, 2> argumentMaterializations;
428 SmallVector<MaterializationCallbackFn, 2> sourceMaterializations;
429 SmallVector<MaterializationCallbackFn, 2> targetMaterializations;
432 SmallVector<TypeAttributeConversionCallbackFn, 2> typeAttributeConversions;
437 mutable DenseMap<Type, Type> cachedDirectConversions;
439 mutable DenseMap<Type, SmallVector<Type, 2>> cachedMultiConversions;
441 mutable llvm::sys::SmartRWMutex<true> cacheMutex;
460 llvm_unreachable(
"unimplemented rewrite");
469 rewrite(op, operands, rewriter);
481 template <
typename ConverterTy>
482 std::enable_if_t<std::is_base_of<TypeConverter, ConverterTy>::value,
491 using RewritePattern::RewritePattern;
494 template <
typename... Args>
510 template <
typename SourceOp>
525 return match(cast<SourceOp>(op));
529 auto sourceOp = cast<SourceOp>(op);
535 auto sourceOp = cast<SourceOp>(op);
542 llvm_unreachable(
"must override match or matchAndRewrite");
546 llvm_unreachable(
"must override matchAndRewrite or a rewrite method");
553 rewrite(op, adaptor, rewriter);
564 template <
typename SourceOp>
569 SourceOp::getInterfaceID(), benefit, context) {}
573 SourceOp::getInterfaceID(), benefit, context) {}
579 rewrite(cast<SourceOp>(op), operands, rewriter);
591 llvm_unreachable(
"must override matchAndRewrite or a rewrite method");
598 rewrite(op, operands, rewriter);
610 StringRef functionLikeOpName, RewritePatternSet &patterns,
611 const TypeConverter &converter);
613 template <
typename FuncOpT>
617 patterns, converter);
621 RewritePatternSet &patterns,
const TypeConverter &converter);
628 struct ConversionPatternRewriterImpl;
697 llvm::unique_function<
bool(
OpOperand &)
const> functor)
override;
722 ValueRange argValues = std::nullopt)
override;
766 std::unique_ptr<detail::ConversionPatternRewriterImpl>
impl;
802 std::function<std::optional<bool>(
Operation *)>;
813 template <
typename OpT>
822 template <
typename OpT>
826 template <
typename OpT,
typename OpT2,
typename... OpTs>
837 setLegalityCallback(op, callback);
839 template <
typename OpT>
844 template <
typename OpT,
typename OpT2,
typename... OpTs>
846 addDynamicallyLegalOp<OpT>(callback);
849 template <
typename OpT,
class Callable>
850 std::enable_if_t<!std::is_invocable_v<Callable, Operation *>>
852 addDynamicallyLegalOp<OpT>(
853 [=](
Operation *op) {
return callback(cast<OpT>(op)); });
861 template <
typename OpT>
865 template <
typename OpT,
typename OpT2,
typename... OpTs>
878 template <
typename OpT>
883 template <
typename OpT,
typename OpT2,
typename... OpTs>
885 markOpRecursivelyLegal<OpT>(callback);
888 template <
typename OpT,
class Callable>
889 std::enable_if_t<!std::is_invocable_v<Callable, Operation *>>
891 markOpRecursivelyLegal<OpT>(
892 [=](
Operation *op) {
return callback(cast<OpT>(op)); });
900 template <
typename... Names>
905 template <
typename... Args>
913 template <
typename... Names>
915 StringRef name, Names... names) {
918 setLegalityCallback(dialectNames, callback);
920 template <
typename... Args>
923 Args::getDialectNamespace()...);
930 setLegalityCallback(fn);
935 template <
typename... Names>
940 template <
typename... Args>
982 struct LegalizationInfo {
987 bool isRecursivelyLegal =
false;
994 std::optional<LegalizationInfo> getOpInfo(OperationName op)
const;
998 llvm::MapVector<OperationName, LegalizationInfo> legalOperations;
1002 DenseMap<OperationName, DynamicLegalityCallbackFn> opRecursiveLegalityFns;
1006 llvm::StringMap<LegalizationAction> legalDialects;
1009 llvm::StringMap<DynamicLegalityCallbackFn> dialectLegalityFns;
1067 const FrozenRewritePatternSet &patterns,
1068 DenseSet<Operation *> *unconvertedOps =
nullptr);
1071 const FrozenRewritePatternSet &patterns,
1072 DenseSet<Operation *> *unconvertedOps =
nullptr);
1079 const ConversionTarget &target,
1080 const FrozenRewritePatternSet &patterns);
1082 const FrozenRewritePatternSet &patterns);
1096 ArrayRef<Operation *> ops, ConversionTarget &target,
1097 const FrozenRewritePatternSet &patterns,
1098 DenseSet<Operation *> &convertedOps,
1099 function_ref<
void(Diagnostic &)> notifyCallback =
nullptr);
1101 Operation *op, ConversionTarget &target,
1102 const FrozenRewritePatternSet &patterns,
1103 DenseSet<Operation *> &convertedOps,
1104 function_ref<
void(Diagnostic &)> notifyCallback =
nullptr);
Attributes are known-constant values of operations.
This class represents an argument of a Block.
Block represents an ordered list of Operations.
OpListType::iterator iterator
This class implements a pattern rewriter for use with ConversionPatterns.
void replaceOp(Operation *op, ValueRange newValues) override
PatternRewriter hook for replacing an operation.
LogicalResult getRemappedValues(ValueRange keys, SmallVectorImpl< Value > &results)
Return the converted values that replace 'keys' with types defined by the type converter of the curre...
FailureOr< Block * > convertRegionTypes(Region *region, const TypeConverter &converter, TypeConverter::SignatureConversion *entryConversion=nullptr)
Convert the types of block arguments within the given region.
void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, ValueRange argValues=std::nullopt) override
PatternRewriter hook for inlining the ops of a block into another block.
LogicalResult notifyMatchFailure(Location loc, function_ref< void(Diagnostic &)> reasonCallback) override
PatternRewriter hook for notifying match failure reasons.
void inlineRegionBefore(Region ®ion, Region &parent, Region::iterator before) override
PatternRewriter hook for moving blocks out of a region.
void finalizeRootUpdate(Operation *op) override
PatternRewriter hook for updating the root operation in-place.
void eraseOp(Operation *op) override
PatternRewriter hook for erasing a dead operation.
void replaceOpWithIf(Operation *op, ValueRange newValues, bool *allUsesReplaced, llvm::unique_function< bool(OpOperand &) const > functor) override
PatternRewriter hook for replacing an operation when the given functor returns "true".
void notifyBlockCreated(Block *block) override
PatternRewriter hook creating a new block.
Block * splitBlock(Block *block, Block::iterator before) override
PatternRewriter hook for splitting a block into two parts.
detail::ConversionPatternRewriterImpl & getImpl()
Return a reference to the internal implementation.
ConversionPatternRewriter(MLIRContext *ctx)
void notifyOperationInserted(Operation *op) override
PatternRewriter hook for inserting a new operation.
void cancelRootUpdate(Operation *op) override
PatternRewriter hook for updating the root operation in-place.
void eraseBlock(Block *block) override
PatternRewriter hook for erase all operations in a block.
bool canRecoverFromRewriteFailure() const override
Indicate that the conversion rewriter can recover from rewrite failure.
Value getRemappedValue(Value key)
Return the converted value of 'key' with a type defined by the type converter of the currently execut...
Block * applySignatureConversion(Region *region, TypeConverter::SignatureConversion &conversion, const TypeConverter *converter=nullptr)
Apply a signature conversion to the entry block of the given region.
void replaceUsesOfBlockArgument(BlockArgument from, Value to)
Replace all the uses of the block argument from with value to.
void startRootUpdate(Operation *op) override
PatternRewriter hook for updating the root operation in-place.
LogicalResult convertNonEntryRegionTypes(Region *region, const TypeConverter &converter, ArrayRef< TypeConverter::SignatureConversion > blockConversions)
Convert the types of block arguments within the given region except for the entry region.
~ConversionPatternRewriter() override
void cloneRegionBefore(Region ®ion, Region &parent, Region::iterator before, IRMapping &mapping) override
PatternRewriter hook for cloning blocks of one region into another.
Base class for the conversion patterns.
const TypeConverter * typeConverter
An optional type converter for use by this pattern.
ConversionPattern(const TypeConverter &typeConverter, Args &&...args)
Construct a conversion pattern with the given converter, and forward the remaining arguments to Rewri...
virtual void rewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const
Hook for derived classes to implement rewriting.
const TypeConverter * getTypeConverter() const
Return the type converter held by this pattern, or nullptr if the pattern does not require type conve...
std::enable_if_t< std::is_base_of< TypeConverter, ConverterTy >::value, const ConverterTy * > getTypeConverter() const
virtual LogicalResult matchAndRewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const
Hook for derived classes to implement combined matching and rewriting.
This class describes a specific conversion target.
void setDialectAction(ArrayRef< StringRef > dialectNames, LegalizationAction action)
Register a legality action for the given dialects.
void setOpAction(LegalizationAction action)
void addLegalOp(OperationName op)
Register the given operations as legal.
void addDynamicallyLegalDialect(DynamicLegalityCallbackFn callback)
void setOpAction(OperationName op, LegalizationAction action)
Register a legality action for the given operation.
void addDynamicallyLegalDialect(const DynamicLegalityCallbackFn &callback, StringRef name, Names... names)
Register the operations of the given dialects as dynamically legal, i.e.
void addDynamicallyLegalOp(const DynamicLegalityCallbackFn &callback)
void addLegalDialect(StringRef name, Names... names)
Register the operations of the given dialects as legal.
std::optional< LegalOpDetails > isLegal(Operation *op) const
If the given operation instance is legal on this target, a structure containing legality information ...
std::enable_if_t<!std::is_invocable_v< Callable, Operation * > > markOpRecursivelyLegal(Callable &&callback)
void markUnknownOpDynamicallyLegal(const DynamicLegalityCallbackFn &fn)
Register unknown operations as dynamically legal.
std::optional< LegalizationAction > getOpAction(OperationName op) const
Get the legality action for the given operation.
void addDynamicallyLegalOp(OperationName op, const DynamicLegalityCallbackFn &callback)
Register the given operation as dynamically legal and set the dynamic legalization callback to the on...
void addIllegalDialect(StringRef name, Names... names)
Register the operations of the given dialects as illegal, i.e.
std::enable_if_t<!std::is_invocable_v< Callable, Operation * > > addDynamicallyLegalOp(Callable &&callback)
void addDynamicallyLegalOp(const DynamicLegalityCallbackFn &callback)
void markOpRecursivelyLegal(const DynamicLegalityCallbackFn &callback={})
void addIllegalOp(OperationName op)
Register the given operation as illegal, i.e.
LegalizationAction
This enumeration corresponds to the specific action to take when considering an operation legal for t...
@ Illegal
The target explicitly does not support this operation.
@ Dynamic
This operation has dynamic legalization constraints that must be checked by the target.
@ Legal
The target supports this operation.
ConversionTarget(MLIRContext &ctx)
void markOpRecursivelyLegal(OperationName name, const DynamicLegalityCallbackFn &callback)
Mark an operation, that must have either been set as Legal or DynamicallyLegal, as being recursively ...
void markOpRecursivelyLegal(const DynamicLegalityCallbackFn &callback={})
std::function< std::optional< bool >(Operation *)> DynamicLegalityCallbackFn
The signature of the callback used to determine if an operation is dynamically legal on the target.
bool isIllegal(Operation *op) const
Returns true is operation instance is illegal on this target.
virtual ~ConversionTarget()=default
This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine.
This class provides support for representing a failure result, or a valid value of type T.
This is a utility class for mapping one set of IR entities to another.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
This class helps build Operations.
void setListener(Listener *newListener)
Sets the listener of this builder to the one provided.
Listener * getListener() const
Returns the current listener of this builder, or nullptr if this builder doesn't have a listener.
OpConversionPattern is a wrapper around ConversionPattern that allows for matching and rewriting agai...
void rewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const final
Hook for derived classes to implement rewriting.
LogicalResult match(Operation *op) const final
Wrappers around the ConversionPattern methods that pass the derived op type.
typename SourceOp::Adaptor OpAdaptor
OpConversionPattern(MLIRContext *context, PatternBenefit benefit=1)
virtual LogicalResult match(SourceOp op) const
Rewrite and Match methods that operate on the SourceOp type.
OpConversionPattern(const TypeConverter &typeConverter, MLIRContext *context, PatternBenefit benefit=1)
virtual LogicalResult matchAndRewrite(SourceOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const
virtual void rewrite(SourceOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const
LogicalResult matchAndRewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const final
Hook for derived classes to implement combined matching and rewriting.
OpInterfaceConversionPattern is a wrapper around ConversionPattern that allows for matching and rewri...
void rewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const final
Wrappers around the ConversionPattern methods that pass the derived op type.
LogicalResult matchAndRewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const final
Hook for derived classes to implement combined matching and rewriting.
OpInterfaceConversionPattern(MLIRContext *context, PatternBenefit benefit=1)
OpInterfaceConversionPattern(const TypeConverter &typeConverter, MLIRContext *context, PatternBenefit benefit=1)
virtual void rewrite(SourceOp op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const
Rewrite and Match methods that operate on the SourceOp type.
virtual LogicalResult matchAndRewrite(SourceOp op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const
This class represents an operand of an operation.
Operation is the basic unit of execution within MLIR.
A PDL configuration that is used to supported dialect conversion functionality.
void notifyRewriteEnd(PatternRewriter &rewriter) final
void notifyRewriteBegin(PatternRewriter &rewriter) final
Hooks that are invoked at the beginning and end of a rewrite of a matched pattern.
const TypeConverter * getTypeConverter() const
Return the type converter used by this configuration, which may be nullptr if no type conversions are...
PDLConversionConfig(const TypeConverter *converter)
~PDLConversionConfig() final=default
This class provides a base class for users implementing a type of pattern configuration.
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
This class contains all of the data related to a pattern, but does not contain any methods or logic f...
This class contains a list of basic blocks and a link to the parent operation it is attached to.
BlockListType::iterator iterator
RewritePattern is the common base class for all DAG to DAG replacements.
virtual LogicalResult match(Operation *op) const
Attempt to match against code rooted at the specified operation, which is the same operation code as ...
virtual void rewrite(Operation *op, PatternRewriter &rewriter) const
Rewrite the IR rooted at the specified operation with the result of this pattern, generating any new ...
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the rewriter that the IR failed to be rewritten because of a match failure,...
virtual void cloneRegionBefore(Region ®ion, Region &parent, Region::iterator before, IRMapping &mapping)
Clone the blocks that belong to "region" before the given position in another region "parent".
virtual void inlineRegionBefore(Region ®ion, Region &parent, Region::iterator before)
Move the blocks that belong to "region" before the given position in another region "parent".
virtual void inlineBlockBefore(Block *source, Block *dest, Block::iterator before, ValueRange argValues=std::nullopt)
Inline the operations of block 'source' into block 'dest' before the given position.
The general result of a type attribute conversion callback, allowing for early termination.
Attribute getResult() const
constexpr AttributeConversionResult()
static AttributeConversionResult abort()
static AttributeConversionResult na()
AttributeConversionResult(Attribute attr)
static AttributeConversionResult result(Attribute attr)
This class provides all of the information necessary to convert a type signature.
void addInputs(unsigned origInputNo, ArrayRef< Type > types)
Remap an input of the original signature with a new set of types.
std::optional< InputMapping > getInputMapping(unsigned input) const
Get the input mapping for the given argument.
ArrayRef< Type > getConvertedTypes() const
Return the argument types for the new signature.
void remapInput(unsigned origInputNo, Value replacement)
Remap an input of the original signature to another replacement value.
SignatureConversion(unsigned numOrigInputs)
std::optional< Attribute > convertTypeAttribute(Type type, Attribute attr) const
Convert an attribute present attr from within the type type using the registered conversion functions...
void addConversion(FnT &&callback)
Register a conversion function.
bool isLegal(Type type) const
Return true if the given type is legal for this type converter, i.e.
void addArgumentMaterialization(FnT &&callback)
Register a materialization function, which must be convertible to the following form: std::optional<V...
Value materializeSourceConversion(OpBuilder &builder, Location loc, Type resultType, ValueRange inputs) const
Value materializeArgumentConversion(OpBuilder &builder, Location loc, Type resultType, ValueRange inputs) const
Materialize a conversion from a set of types into one result type by generating a cast sequence of so...
LogicalResult convertSignatureArgs(TypeRange types, SignatureConversion &result, unsigned origInputOffset=0) const
std::enable_if_t<!std::is_convertible< RangeT, Type >::value &&!std::is_convertible< RangeT, Operation * >::value, bool > isLegal(RangeT &&range) const
Return true if all of the given types are legal for this type converter.
TargetType convertType(Type t) const
Attempts a 1-1 type conversion, expecting the result type to be TargetType.
LogicalResult convertSignatureArg(unsigned inputNo, Type type, SignatureConversion &result) const
This method allows for converting a specific argument of a signature.
TypeConverter(const TypeConverter &other)
TypeConverter & operator=(const TypeConverter &other)
LogicalResult convertType(Type t, SmallVectorImpl< Type > &results) const
Convert the given type.
std::optional< SignatureConversion > convertBlockSignature(Block *block) const
This function converts the type signature of the given block, by invoking 'convertSignatureArg' for e...
void addSourceMaterialization(FnT &&callback)
This method registers a materialization that will be called when converting a legal type to an illega...
virtual ~TypeConverter()=default
void addTypeAttributeConversion(FnT &&callback)
Register a conversion function for attributes within types.
void addTargetMaterialization(FnT &&callback)
This method registers a materialization that will be called when converting type from an illegal,...
LogicalResult convertTypes(TypeRange types, SmallVectorImpl< Type > &results) const
Convert the given set of types, filling 'results' as necessary.
Value materializeTargetConversion(OpBuilder &builder, Location loc, Type resultType, ValueRange inputs) const
bool isSignatureLegal(FunctionType ty) const
Return true if the inputs and outputs of the given function type are legal.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
@ Type
An inlay hint that for a type annotation.
This header declares functions that assist transformations in the MemRef dialect.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
llvm::function_ref< Fn > function_ref
void populateFunctionOpInterfaceTypeConversionPattern(StringRef functionLikeOpName, RewritePatternSet &patterns, const TypeConverter &converter)
Add a pattern to the given pattern list to convert the signature of a FunctionOpInterface op with the...
void populateAnyFunctionOpInterfaceTypeConversionPattern(RewritePatternSet &patterns, const TypeConverter &converter)
LogicalResult applyPartialConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, DenseSet< Operation * > *unconvertedOps=nullptr)
Below we define several entry points for operation conversion.
LogicalResult applyFullConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns)
Apply a complete conversion on the given operations, and all nested operations.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
void registerConversionPDLFunctions(RewritePatternSet &patterns)
Register the dialect conversion PDL functions with the given pattern set.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
LogicalResult applyAnalysisConversion(ArrayRef< Operation * > ops, ConversionTarget &target, const FrozenRewritePatternSet &patterns, DenseSet< Operation * > &convertedOps, function_ref< void(Diagnostic &)> notifyCallback=nullptr)
Apply an analysis conversion on the given operations, and all nested operations.
A structure containing additional information describing a specific legal operation instance.
bool isRecursivelyLegal
A flag that indicates if this operation is 'recursively' legal.
This class represents an efficient way to signal success or failure.
This class acts as a special tag that makes the desire to match any operation that implements a given...