MLIR  17.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 class  LegalizationAction { Legal , Dynamic , Illegal }
 This enumeration corresponds to the specific action to take when considering an operation legal for this conversion target. More...
 
using DynamicLegalityCallbackFn = std::function< std::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 ()
 
std::optional< LegalizationActiongetOpAction (OperationName op) const
 Get the legality action for the given operation. More...
 
std::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 657 of file DialectConversion.h.

Member Typedef Documentation

◆ DynamicLegalityCallbackFn

using mlir::ConversionTarget::DynamicLegalityCallbackFn = std::function<std::optional<bool>(Operation *)>

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

Definition at line 684 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 661 of file DialectConversion.h.

Constructor & Destructor Documentation

◆ ConversionTarget()

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

Definition at line 687 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 797 of file DialectConversion.h.

References Dynamic, and setDialectAction().

Referenced by addDynamicallyLegalDialect().

◆ addDynamicallyLegalDialect() [2/2]

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

Definition at line 804 of file DialectConversion.h.

References addDynamicallyLegalDialect().

◆ addDynamicallyLegalOp() [1/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 734 of file DialectConversion.h.

◆ addDynamicallyLegalOp() [2/4]

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

Definition at line 723 of file DialectConversion.h.

References addDynamicallyLegalOp().

◆ addDynamicallyLegalOp() [3/4]

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

Definition at line 728 of file DialectConversion.h.

References addDynamicallyLegalOp().

◆ addDynamicallyLegalOp() [4/4]

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

◆ addIllegalDialect() [1/2]

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

Definition at line 824 of file DialectConversion.h.

References Illegal, and setDialectAction().

◆ addIllegalDialect() [2/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 819 of file DialectConversion.h.

References Illegal, and setDialectAction().

Referenced by mlir::configureGpuToNVVMConversionLegality(), and mlir::configureGpuToROCDLConversionLegality().

◆ addIllegalOp() [1/3]

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

Definition at line 745 of file DialectConversion.h.

Referenced by addIllegalOp().

◆ addIllegalOp() [2/3]

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

Definition at line 749 of file DialectConversion.h.

References addIllegalOp().

◆ addIllegalOp() [3/3]

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

Register the given operation as illegal, i.e.

this operation is known to not be supported by this target.

Definition at line 741 of file DialectConversion.h.

References Illegal, and setOpAction().

Referenced by mlir::configureAMXLegalizeForExportTarget(), mlir::configureArmSVELegalizeForExportTarget(), mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), and mlir::configureX86VectorLegalizeForExportTarget().

◆ addLegalDialect() [1/2]

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

Definition at line 789 of file DialectConversion.h.

References Legal, and setDialectAction().

◆ addLegalDialect() [2/2]

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

Register the operations of the given dialects as legal.

Definition at line 784 of file DialectConversion.h.

References Legal, and setDialectAction().

Referenced by mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), and mlir::configureParallelLoopToGPULegality().

◆ addLegalOp() [1/3]

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

Definition at line 706 of file DialectConversion.h.

Referenced by addLegalOp().

◆ addLegalOp() [2/3]

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

Definition at line 710 of file DialectConversion.h.

References addLegalOp().

◆ addLegalOp() [3/3]

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

◆ getOpAction()

auto ConversionTarget::getOpAction ( OperationName  op) const

Get the legality action for the given operation.

Definition at line 3141 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 3182 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, std::nullopt is returned. Also returns std::nullopt if 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 3147 of file DialectConversion.cpp.

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

◆ markOpRecursivelyLegal() [1/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 773 of file DialectConversion.h.

◆ markOpRecursivelyLegal() [2/4]

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

Definition at line 762 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 767 of file DialectConversion.h.

◆ markOpRecursivelyLegal() [4/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 3225 of file DialectConversion.cpp.

References composeLegalityCallbacks().

◆ 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 812 of file DialectConversion.h.

Referenced by mlir::gpu::populateLowerMemorySpaceOpLegality().

◆ setDialectAction()

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

Register a legality action for the given dialects.

Definition at line 3135 of file DialectConversion.cpp.

Referenced by addDynamicallyLegalDialect(), addIllegalDialect(), and addLegalDialect().

◆ setOpAction() [1/2]

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

Definition at line 697 of file DialectConversion.h.

References setOpAction().

◆ setOpAction() [2/2]

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

Register a legality action for the given operation.

Definition at line 3130 of file DialectConversion.cpp.

Referenced by addDynamicallyLegalOp(), addIllegalOp(), addLegalOp(), and setOpAction().


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