MLIR  19.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 779 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 806 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 783 of file DialectConversion.h.

Constructor & Destructor Documentation

◆ ConversionTarget()

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

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

References Dynamic, and setDialectAction().

Referenced by addDynamicallyLegalDialect(), and mlir::math::populateLegalizeToF32ConversionTarget().

◆ addDynamicallyLegalDialect() [2/2]

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

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

◆ addDynamicallyLegalOp() [2/4]

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

Definition at line 845 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 850 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 946 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 941 of file DialectConversion.h.

References Illegal, and setDialectAction().

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

◆ addIllegalOp() [1/3]

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

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

References addIllegalOp().

◆ addIllegalOp() [3/3]

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

◆ addLegalDialect() [1/2]

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

Definition at line 911 of file DialectConversion.h.

References Legal, and setDialectAction().

◆ addLegalDialect() [2/2]

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

◆ addLegalOp() [1/3]

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

Definition at line 828 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 832 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 3394 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 3435 of file DialectConversion.cpp.

◆ 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 3400 of file DialectConversion.cpp.

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

◆ markOpRecursivelyLegal() [2/4]

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

Definition at line 884 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 889 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 3478 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 934 of file DialectConversion.h.

Referenced by mlir::arith::populateEmulateUnsupportedFloatsLegality(), and mlir::vector::populateVectorLinearizeTypeConversionsAndLegality().

◆ setDialectAction()

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

Register a legality action for the given dialects.

Definition at line 3388 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 819 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 3383 of file DialectConversion.cpp.

Referenced by setOpAction().


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