My Project
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
mlir::ConversionTarget Class Reference

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

#include <DialectConversion.h>

Classes

struct  LegalOpDetails
 

Public Types

enum  LegalizationAction { LegalizationAction::Legal, LegalizationAction::Dynamic, LegalizationAction::Illegal }
 
using DynamicLegalityCallbackFn = std::function< bool(Operation *)>
 

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)
 
template<typename OpT >
void addLegalOp ()
 Register the given operations as legal. More...
 
template<typename OpT , typename OpT2 , typename... OpTs>
void addLegalOp ()
 
template<typename OpT >
void addDynamicallyLegalOp ()
 
template<typename OpT , typename OpT2 , typename... OpTs>
void addDynamicallyLegalOp ()
 
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<!is_invocable< Callable, Operation * >::value >::type addDynamicallyLegalOp (Callable &&callback)
 
template<typename OpT >
void addIllegalOp ()
 
template<typename OpT , typename OpT2 , typename... OpTs>
void addIllegalOp ()
 
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<!is_invocable< Callable, Operation * >::value >::type 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 (StringRef name, Names... names)
 
template<typename... Args>
void addDynamicallyLegalDialect (Optional< DynamicLegalityCallbackFn > callback=llvm::None)
 
template<typename... Names>
void addIllegalDialect (StringRef name, Names... names)
 
template<typename... Args>
void addIllegalDialect ()
 
Optional< LegalizationActiongetOpAction (OperationName op) const
 Get the legality action for the given operation. More...
 
Optional< LegalOpDetailsisLegal (Operation *op) const
 

Protected Member Functions

virtual bool isDynamicallyLegal (Operation *op) const
 

Detailed Description

This class describes a specific conversion target.

Member Typedef Documentation

◆ DynamicLegalityCallbackFn

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

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.

Constructor & Destructor Documentation

◆ ConversionTarget()

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

◆ ~ConversionTarget()

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

Member Function Documentation

◆ addDynamicallyLegalDialect() [1/2]

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

Register the operations of the given dialects as dynamically legal, i.e. requiring custom handling by the target via 'isDynamicallyLegal'.

◆ addDynamicallyLegalDialect() [2/2]

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

◆ addDynamicallyLegalOp() [1/5]

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

Register the given operation as dynamically legal, i.e. requiring custom handling by the target via 'isDynamicallyLegal'.

◆ addDynamicallyLegalOp() [2/5]

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

◆ addDynamicallyLegalOp() [3/5]

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

Register the given operation as dynamically legal and set the dynamic legalization callback to the one provided.

◆ addDynamicallyLegalOp() [4/5]

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

◆ addDynamicallyLegalOp() [5/5]

template<typename OpT , class Callable >
std::enable_if<!is_invocable<Callable, Operation *>::value>::type mlir::ConversionTarget::addDynamicallyLegalOp ( Callable &&  callback)
inline

◆ 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.

◆ addIllegalDialect() [2/2]

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

◆ addIllegalOp() [1/2]

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

Register the given operation as illegal, i.e. this operation is known to not be supported by this target.

◆ addIllegalOp() [2/2]

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

◆ addLegalDialect() [1/2]

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

Register the operations of the given dialects as legal.

◆ addLegalDialect() [2/2]

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

◆ addLegalOp() [1/2]

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

Register the given operations as legal.

◆ addLegalOp() [2/2]

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

◆ getOpAction()

auto ConversionTarget::getOpAction ( OperationName  op) const

Get the legality action for the given operation.

◆ isDynamicallyLegal()

virtual bool mlir::ConversionTarget::isDynamicallyLegal ( Operation op) const
inlineprotectedvirtual

Runs a custom legalization query for the given operation. This should return true if the given operation is legal, otherwise false.

◆ 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.

◆ markOpRecursivelyLegal() [1/3]

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

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.

◆ markOpRecursivelyLegal() [2/3]

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

◆ markOpRecursivelyLegal() [3/3]

template<typename OpT , class Callable >
std::enable_if<!is_invocable<Callable, Operation *>::value>::type mlir::ConversionTarget::markOpRecursivelyLegal ( Callable &&  callback)
inline

◆ setDialectAction()

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

Register a legality action for the given dialects.

◆ setOpAction() [1/2]

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

Register a legality action for the given operation.

◆ setOpAction() [2/2]

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

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