MLIR  16.0.0git
Classes | Public Types | Public Member Functions | List of all members
mlir::ConversionTarget Class Reference

This class describes a specific conversion target. More...

#include "mlir/Transforms/DialectConversion.h"

+ Inheritance diagram for mlir::ConversionTarget:

Classes

struct  LegalOpDetails
 A structure containing additional information describing a specific legal operation instance. More...
 

Public Types

enum  LegalizationAction { LegalizationAction::Legal, LegalizationAction::Dynamic, LegalizationAction::Illegal }
 This enumeration corresponds to the specific action to take when considering an operation legal for this conversion target. More...
 
using DynamicLegalityCallbackFn = std::function< Optional< bool >(Operation *)>
 The signature of the callback used to determine if an operation is dynamically legal on the target. More...
 

Public Member Functions

 ConversionTarget (MLIRContext &ctx)
 
virtual ~ConversionTarget ()=default
 
void setOpAction (OperationName op, LegalizationAction action)
 Register a legality action for the given operation. More...
 
template<typename OpT >
void setOpAction (LegalizationAction action)
 
void addLegalOp (OperationName op)
 Register the given operations as legal. More...
 
template<typename OpT >
void addLegalOp ()
 
template<typename OpT , typename OpT2 , typename... OpTs>
void addLegalOp ()
 
void addDynamicallyLegalOp (OperationName op, const DynamicLegalityCallbackFn &callback)
 Register the given operation as dynamically legal and set the dynamic legalization callback to the one provided. More...
 
template<typename OpT >
void addDynamicallyLegalOp (const DynamicLegalityCallbackFn &callback)
 
template<typename OpT , typename OpT2 , typename... OpTs>
void addDynamicallyLegalOp (const DynamicLegalityCallbackFn &callback)
 
template<typename OpT , class Callable >
std::enable_if_t<!std::is_invocable_v< Callable, Operation * > > addDynamicallyLegalOp (Callable &&callback)
 
void addIllegalOp (OperationName op)
 Register the given operation as illegal, i.e. More...
 
template<typename OpT >
void addIllegalOp ()
 
template<typename OpT , typename OpT2 , typename... OpTs>
void addIllegalOp ()
 
void markOpRecursivelyLegal (OperationName name, const DynamicLegalityCallbackFn &callback)
 Mark an operation, that must have either been set as Legal or DynamicallyLegal, as being recursively legal. More...
 
template<typename OpT >
void markOpRecursivelyLegal (const DynamicLegalityCallbackFn &callback={})
 
template<typename OpT , typename OpT2 , typename... OpTs>
void markOpRecursivelyLegal (const DynamicLegalityCallbackFn &callback={})
 
template<typename OpT , class Callable >
std::enable_if_t<!std::is_invocable_v< Callable, Operation * > > markOpRecursivelyLegal (Callable &&callback)
 
void setDialectAction (ArrayRef< StringRef > dialectNames, LegalizationAction action)
 Register a legality action for the given dialects. More...
 
template<typename... Names>
void addLegalDialect (StringRef name, Names... names)
 Register the operations of the given dialects as legal. More...
 
template<typename... Args>
void addLegalDialect ()
 
template<typename... Names>
void addDynamicallyLegalDialect (const DynamicLegalityCallbackFn &callback, StringRef name, Names... names)
 Register the operations of the given dialects as dynamically legal, i.e. More...
 
template<typename... Args>
void addDynamicallyLegalDialect (DynamicLegalityCallbackFn callback)
 
void markUnknownOpDynamicallyLegal (const DynamicLegalityCallbackFn &fn)
 Register unknown operations as dynamically legal. More...
 
template<typename... Names>
void addIllegalDialect (StringRef name, Names... names)
 Register the operations of the given dialects as illegal, i.e. More...
 
template<typename... Args>
void addIllegalDialect ()
 
Optional< LegalizationActiongetOpAction (OperationName op) const
 Get the legality action for the given operation. More...
 
Optional< LegalOpDetailsisLegal (Operation *op) const
 If the given operation instance is legal on this target, a structure containing legality information is returned. More...
 
bool isIllegal (Operation *op) const
 Returns true is operation instance is illegal on this target. More...
 

Detailed Description

This class describes a specific conversion target.

Definition at line 649 of file DialectConversion.h.

Member Typedef Documentation

◆ DynamicLegalityCallbackFn

The signature of the callback used to determine if an operation is dynamically legal on the target.

Definition at line 676 of file DialectConversion.h.

Member Enumeration Documentation

◆ LegalizationAction

This enumeration corresponds to the specific action to take when considering an operation legal for this conversion target.

Enumerator
Legal 

The target supports this operation.

Dynamic 

This operation has dynamic legalization constraints that must be checked by the target.

Illegal 

The target explicitly does not support this operation.

Definition at line 653 of file DialectConversion.h.

Constructor & Destructor Documentation

◆ ConversionTarget()

mlir::ConversionTarget::ConversionTarget ( MLIRContext ctx)
inline

Definition at line 678 of file DialectConversion.h.

◆ ~ConversionTarget()

virtual mlir::ConversionTarget::~ConversionTarget ( )
virtualdefault

Member Function Documentation

◆ addDynamicallyLegalDialect() [1/2]

template<typename... Names>
void mlir::ConversionTarget::addDynamicallyLegalDialect ( const DynamicLegalityCallbackFn callback,
StringRef  name,
Names...  names 
)
inline

Register the operations of the given dialects as dynamically legal, i.e.

requiring custom handling by the callback.

Definition at line 788 of file DialectConversion.h.

Referenced by constructResultVector().

◆ addDynamicallyLegalDialect() [2/2]

template<typename... Args>
void mlir::ConversionTarget::addDynamicallyLegalDialect ( DynamicLegalityCallbackFn  callback)
inline

Definition at line 795 of file DialectConversion.h.

◆ addDynamicallyLegalOp() [1/4]

void mlir::ConversionTarget::addDynamicallyLegalOp ( OperationName  op,
const DynamicLegalityCallbackFn callback 
)
inline

◆ addDynamicallyLegalOp() [2/4]

template<typename OpT >
void mlir::ConversionTarget::addDynamicallyLegalOp ( const DynamicLegalityCallbackFn callback)
inline

Definition at line 714 of file DialectConversion.h.

◆ addDynamicallyLegalOp() [3/4]

template<typename OpT , typename OpT2 , typename... OpTs>
void mlir::ConversionTarget::addDynamicallyLegalOp ( const DynamicLegalityCallbackFn callback)
inline

Definition at line 719 of file DialectConversion.h.

◆ addDynamicallyLegalOp() [4/4]

template<typename OpT , class Callable >
std::enable_if_t<!std::is_invocable_v<Callable, Operation *> > mlir::ConversionTarget::addDynamicallyLegalOp ( Callable &&  callback)
inline

Definition at line 725 of file DialectConversion.h.

◆ addIllegalDialect() [1/2]

template<typename... Names>
void mlir::ConversionTarget::addIllegalDialect ( StringRef  name,
Names...  names 
)
inline

Register the operations of the given dialects as illegal, i.e.

operations of this dialect are not supported by the target.

Definition at line 810 of file DialectConversion.h.

Referenced by mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), mfmaOpToIntrinsic(), mlir::populateBufferizationToMemRefConversionPatterns(), mlir::populateComplexToLLVMConversionPatterns(), and mlir::populateMathToLibmConversionPatterns().

◆ addIllegalDialect() [2/2]

template<typename... Args>
void mlir::ConversionTarget::addIllegalDialect ( )
inline

◆ addIllegalOp() [1/3]

void mlir::ConversionTarget::addIllegalOp ( OperationName  op)
inline

◆ addIllegalOp() [2/3]

template<typename OpT >
void mlir::ConversionTarget::addIllegalOp ( )
inline

Definition at line 736 of file DialectConversion.h.

◆ addIllegalOp() [3/3]

template<typename OpT , typename OpT2 , typename... OpTs>
void mlir::ConversionTarget::addIllegalOp ( )
inline

Definition at line 740 of file DialectConversion.h.

◆ addLegalDialect() [1/2]

template<typename... Names>
void mlir::ConversionTarget::addLegalDialect ( StringRef  name,
Names...  names 
)
inline

◆ addLegalDialect() [2/2]

template<typename... Args>
void mlir::ConversionTarget::addLegalDialect ( )
inline

Definition at line 780 of file DialectConversion.h.

◆ addLegalOp() [1/3]

void mlir::ConversionTarget::addLegalOp ( OperationName  op)
inline

◆ addLegalOp() [2/3]

template<typename OpT >
void mlir::ConversionTarget::addLegalOp ( )
inline

Definition at line 697 of file DialectConversion.h.

◆ addLegalOp() [3/3]

template<typename OpT , typename OpT2 , typename... OpTs>
void mlir::ConversionTarget::addLegalOp ( )
inline

Definition at line 701 of file DialectConversion.h.

◆ getOpAction()

auto ConversionTarget::getOpAction ( OperationName  op) const

Get the legality action for the given operation.

Definition at line 3117 of file DialectConversion.cpp.

◆ isIllegal()

bool ConversionTarget::isIllegal ( Operation op) const

Returns true is operation instance is illegal on this target.

Returns false if operation is legal, operation legality wasn't registered by user or dynamic legality callbacks returned None.

Definition at line 3158 of file DialectConversion.cpp.

References mlir::Operation::getName().

◆ isLegal()

auto ConversionTarget::isLegal ( Operation op) const

If the given operation instance is legal on this target, a structure containing legality information is returned.

If the operation is not legal, None is returned. Also returns None is operation legality wasn't registered by user or dynamic legality callbacks returned None.

Note: Legality is actually a 4-state: Legal(recursive=true), Legal(recursive=false), Illegal or Unknown, where Unknown is treated either as Legal or Illegal depending on context.

Definition at line 3123 of file DialectConversion.cpp.

References mlir::Operation::getName(), and mlir::ConversionTarget::LegalOpDetails::isRecursivelyLegal.

◆ markOpRecursivelyLegal() [1/4]

void ConversionTarget::markOpRecursivelyLegal ( OperationName  name,
const DynamicLegalityCallbackFn callback 
)

Mark an operation, that must have either been set as Legal or DynamicallyLegal, as being recursively legal.

This means that in addition to the operation itself, all of the operations nested within are also considered legal. An optional dynamic legality callback may be provided to mark subsets of legal instances as recursively legal.

Definition at line 3201 of file DialectConversion.cpp.

References composeLegalityCallbacks(), and mlir::OperationName::getDialectNamespace().

◆ markOpRecursivelyLegal() [2/4]

template<typename OpT >
void mlir::ConversionTarget::markOpRecursivelyLegal ( const DynamicLegalityCallbackFn callback = {})
inline

Definition at line 753 of file DialectConversion.h.

◆ markOpRecursivelyLegal() [3/4]

template<typename OpT , typename OpT2 , typename... OpTs>
void mlir::ConversionTarget::markOpRecursivelyLegal ( const DynamicLegalityCallbackFn callback = {})
inline

Definition at line 758 of file DialectConversion.h.

◆ markOpRecursivelyLegal() [4/4]

template<typename OpT , class Callable >
std::enable_if_t<!std::is_invocable_v<Callable, Operation *> > mlir::ConversionTarget::markOpRecursivelyLegal ( Callable &&  callback)
inline

Definition at line 764 of file DialectConversion.h.

◆ markUnknownOpDynamicallyLegal()

void mlir::ConversionTarget::markUnknownOpDynamicallyLegal ( const DynamicLegalityCallbackFn fn)
inline

Register unknown operations as dynamically legal.

For operations(and dialects) that do not have a set legalization action, treat them as dynamically legal and invoke the given callback.

Definition at line 803 of file DialectConversion.h.

Referenced by mlir::linalg::populateElementwiseToLinalgConversionPatterns(), mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns(), mlir::populateSCFToControlFlowConversionPatterns(), and sourceMaterializationCallback().

◆ setDialectAction()

void ConversionTarget::setDialectAction ( ArrayRef< StringRef >  dialectNames,
LegalizationAction  action 
)

Register a legality action for the given dialects.

Definition at line 3111 of file DialectConversion.cpp.

◆ setOpAction() [1/2]

void ConversionTarget::setOpAction ( OperationName  op,
LegalizationAction  action 
)

Register a legality action for the given operation.

Definition at line 3106 of file DialectConversion.cpp.

◆ setOpAction() [2/2]

template<typename OpT >
void mlir::ConversionTarget::setOpAction ( LegalizationAction  action)
inline

Definition at line 688 of file DialectConversion.h.


The documentation for this class was generated from the following files: