MLIR
20.0.0git
|
This class describes a specific conversion target. More...
#include "mlir/Transforms/DialectConversion.h"
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< LegalizationAction > | getOpAction (OperationName op) const |
Get the legality action for the given operation. More... | |
std::optional< LegalOpDetails > | isLegal (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... | |
This class describes a specific conversion target.
Definition at line 944 of file DialectConversion.h.
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 971 of file DialectConversion.h.
|
strong |
This enumeration corresponds to the specific action to take when considering an operation legal for this conversion target.
Definition at line 948 of file DialectConversion.h.
|
inline |
Definition at line 974 of file DialectConversion.h.
|
virtualdefault |
|
inline |
Register the operations of the given dialects as dynamically legal, i.e.
requiring custom handling by the callback.
Definition at line 1084 of file DialectConversion.h.
References Dynamic, and setDialectAction().
Referenced by addDynamicallyLegalDialect(), and mlir::arith::populateEmulateUnsupportedFloatsLegality().
|
inline |
Definition at line 1091 of file DialectConversion.h.
References addDynamicallyLegalDialect().
|
inline |
Definition at line 1021 of file DialectConversion.h.
|
inline |
Definition at line 1010 of file DialectConversion.h.
References addDynamicallyLegalOp().
|
inline |
Definition at line 1015 of file DialectConversion.h.
References addDynamicallyLegalOp().
|
inline |
Register the given operation as dynamically legal and set the dynamic legalization callback to the one provided.
Definition at line 1004 of file DialectConversion.h.
References Dynamic, and setOpAction().
Referenced by addDynamicallyLegalOp(), mlir::configureGpuToROCDLConversionLegality(), mlir::configureOpenMPToLLVMConversionLegality(), mlir::configureParallelLoopToGPULegality(), mlir::amdgpu::populateAmdgpuEmulateAtomicsPatterns(), mlir::populateAsyncFuncToAsyncRuntimeConversionPatterns(), mlir::populateAsyncStructuralTypeConversionsAndLegality(), mlir::arith::populateEmulateUnsupportedFloatsLegality(), and mlir::scf::populateSCFStructuralTypeConversionTarget().
|
inline |
Definition at line 1111 of file DialectConversion.h.
References Illegal, and setDialectAction().
|
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 1106 of file DialectConversion.h.
References Illegal, and setDialectAction().
Referenced by mlir::configureArmSMEToLLVMConversionLegality(), mlir::configureGpuToNVVMConversionLegality(), and mlir::configureGpuToROCDLConversionLegality().
|
inline |
Definition at line 1032 of file DialectConversion.h.
Referenced by addIllegalOp().
|
inline |
Definition at line 1036 of file DialectConversion.h.
References addIllegalOp().
|
inline |
Register the given operation as illegal, i.e.
this operation is known to not be supported by this target.
Definition at line 1028 of file DialectConversion.h.
References Illegal, and setOpAction().
Referenced by mlir::configureAMXLegalizeForExportTarget(), mlir::configureArmSVELegalizeForExportTarget(), mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), mlir::configureX86VectorLegalizeForExportTarget(), and mlir::amdgpu::populateAmdgpuEmulateAtomicsPatterns().
|
inline |
Definition at line 1076 of file DialectConversion.h.
References Legal, and setDialectAction().
|
inline |
Register the operations of the given dialects as legal.
Definition at line 1071 of file DialectConversion.h.
References Legal, and setDialectAction().
Referenced by mlir::configureArmSMEToLLVMConversionLegality(), mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), and mlir::configureParallelLoopToGPULegality().
|
inline |
Definition at line 993 of file DialectConversion.h.
Referenced by addLegalOp().
|
inline |
Definition at line 997 of file DialectConversion.h.
References addLegalOp().
|
inline |
Register the given operations as legal.
Definition at line 989 of file DialectConversion.h.
References Legal, and setOpAction().
Referenced by mlir::configureAMXLegalizeForExportTarget(), mlir::configureArmSMEToLLVMConversionLegality(), mlir::configureArmSVELegalizeForExportTarget(), mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), mlir::configureX86VectorLegalizeForExportTarget(), mlir::arith::populateEmulateUnsupportedFloatsLegality(), and mlir::math::populateExtendToSupportedTypesConversionTarget().
auto ConversionTarget::getOpAction | ( | OperationName | op | ) | const |
Get the legality action for the given operation.
Definition at line 3167 of file DialectConversion.cpp.
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 3208 of file DialectConversion.cpp.
References mlir::Operation::getName().
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 3173 of file DialectConversion.cpp.
References mlir::Operation::getName(), and mlir::ConversionTarget::LegalOpDetails::isRecursivelyLegal.
Referenced by mlir::OperationConverter::convertOperations().
|
inline |
Definition at line 1060 of file DialectConversion.h.
|
inline |
Definition at line 1049 of file DialectConversion.h.
|
inline |
Definition at line 1054 of file DialectConversion.h.
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 3251 of file DialectConversion.cpp.
References composeLegalityCallbacks().
|
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 1099 of file DialectConversion.h.
Referenced by mlir::arith::populateEmulateUnsupportedFloatsLegality(), mlir::math::populateExtendToSupportedTypesConversionTarget(), and mlir::vector::populateVectorLinearizeTypeConversionsAndLegality().
void ConversionTarget::setDialectAction | ( | ArrayRef< StringRef > | dialectNames, |
LegalizationAction | action | ||
) |
Register a legality action for the given dialects.
Definition at line 3161 of file DialectConversion.cpp.
Referenced by addDynamicallyLegalDialect(), addIllegalDialect(), and addLegalDialect().
|
inline |
Definition at line 984 of file DialectConversion.h.
References setOpAction().
void ConversionTarget::setOpAction | ( | OperationName | op, |
LegalizationAction | action | ||
) |
Register a legality action for the given operation.
Definition at line 3156 of file DialectConversion.cpp.
Referenced by addDynamicallyLegalOp(), addIllegalOp(), addLegalOp(), and setOpAction().