MLIR
15.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 | 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< !llvm::is_invocable< Callable, Operation * >::value >::type | 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< !llvm::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 (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< LegalizationAction > | getOpAction (OperationName op) const |
Get the legality action for the given operation. More... | |
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 648 of file DialectConversion.h.
using mlir::ConversionTarget::DynamicLegalityCallbackFn = std::function<Optional<bool>(Operation *)> |
The signature of the callback used to determine if an operation is dynamically legal on the target.
Definition at line 675 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 652 of file DialectConversion.h.
|
inline |
Definition at line 677 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 789 of file DialectConversion.h.
|
inline |
Definition at line 796 of file DialectConversion.h.
|
inline |
Register the given operation as dynamically legal and set the dynamic legalization callback to the one provided.
Definition at line 707 of file DialectConversion.h.
Referenced by mlir::configureOpenMPToLLVMConversionLegality(), mlir::configureParallelLoopToGPULegality(), mlir::populateAsyncStructuralTypeConversionsAndLegality(), mlir::populateOpenACCToLLVMConversionPatterns(), mlir::populateOpenACCToSCFConversionPatterns(), mlir::scf::populateSCFStructuralTypeConversionsAndLegality(), populateSPIRVLayoutInfoPatterns(), and sourceMaterializationCallback().
|
inline |
Definition at line 713 of file DialectConversion.h.
|
inline |
Definition at line 718 of file DialectConversion.h.
References value.
|
inline |
Definition at line 725 of file DialectConversion.h.
|
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 811 of file DialectConversion.h.
Referenced by mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), mlir::populateBufferizationToMemRefConversionPatterns(), mlir::populateComplexToLLVMConversionPatterns(), and mlir::populateMathToLibmConversionPatterns().
|
inline |
Definition at line 816 of file DialectConversion.h.
References mlir::applyAnalysisConversion(), mlir::applyFullConversion(), mlir::applyPartialConversion(), and mlir::TypeConverter::isLegal().
|
inline |
Register the given operation as illegal, i.e.
this operation is known to not be supported by this target.
Definition at line 732 of file DialectConversion.h.
Referenced by mlir::configureAMXLegalizeForExportTarget(), mlir::configureArmSVELegalizeForExportTarget(), mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), mlir::configureX86VectorLegalizeForExportTarget(), getSrcVectorElementType(), mlir::populateComplexToLibmConversionPatterns(), and mlir::populateSCFToControlFlowConversionPatterns().
|
inline |
Definition at line 736 of file DialectConversion.h.
|
inline |
Definition at line 740 of file DialectConversion.h.
|
inline |
Register the operations of the given dialects as legal.
Definition at line 776 of file DialectConversion.h.
Referenced by mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), mlir::configureParallelLoopToGPULegality(), createI32Constant(), encodeKernelName(), mlir::populateAffineToVectorConversionPatterns(), mlir::populateBufferizationToMemRefConversionPatterns(), mlir::populateComplexToLibmConversionPatterns(), mlir::populateComplexToStandardConversionPatterns(), mlir::linalg::populateLinalgToStandardConversionPatterns(), mlir::populateMathToLibmConversionPatterns(), mlir::populateOpenACCToLLVMConversionPatterns(), mlir::populateOpenACCToSCFConversionPatterns(), populateSPIRVLayoutInfoPatterns(), mlir::populateVectorToROCDLConversionPatterns(), and unpackOperandVector().
|
inline |
Definition at line 781 of file DialectConversion.h.
|
inline |
Register the given operations as legal.
Definition at line 692 of file DialectConversion.h.
Referenced by mlir::configureAMXLegalizeForExportTarget(), mlir::configureArmSVELegalizeForExportTarget(), mlir::configureGpuToNVVMConversionLegality(), mlir::configureGpuToROCDLConversionLegality(), mlir::configureX86VectorLegalizeForExportTarget(), getSrcVectorElementType(), mlir::populateBufferizationToMemRefConversionPatterns(), mlir::bufferization::populateBufferizeMaterializationLegality(), mlir::populateComplexToStandardConversionPatterns(), mlir::populateLinalgToLLVMConversionPatterns(), mlir::linalg::populateLinalgToStandardConversionPatterns(), mlir::populateMemRefToLLVMConversionPatterns(), mlir::populateOpenACCToLLVMConversionPatterns(), mlir::populateOpenMPToLLVMConversionPatterns(), and populateSPIRVLayoutInfoPatterns().
|
inline |
Definition at line 696 of file DialectConversion.h.
|
inline |
Definition at line 700 of file DialectConversion.h.
auto ConversionTarget::getOpAction | ( | OperationName | op | ) | const |
Get the legality action for the given operation.
Definition at line 3121 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 3162 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, 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 3127 of file DialectConversion.cpp.
References mlir::Operation::getName(), and mlir::ConversionTarget::LegalOpDetails::isRecursivelyLegal.
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 3205 of file DialectConversion.cpp.
References composeLegalityCallbacks(), and mlir::OperationName::getDialectNamespace().
|
inline |
Definition at line 753 of file DialectConversion.h.
|
inline |
Definition at line 758 of file DialectConversion.h.
References value.
|
inline |
Definition at line 765 of file DialectConversion.h.
|
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 804 of file DialectConversion.h.
Referenced by mlir::linalg::populateElementwiseToLinalgConversionPatterns(), mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns(), mlir::populateSCFToControlFlowConversionPatterns(), and sourceMaterializationCallback().
void ConversionTarget::setDialectAction | ( | ArrayRef< StringRef > | dialectNames, |
LegalizationAction | action | ||
) |
Register a legality action for the given dialects.
Definition at line 3115 of file DialectConversion.cpp.
void ConversionTarget::setOpAction | ( | OperationName | op, |
LegalizationAction | action | ||
) |
Register a legality action for the given operation.
Definition at line 3110 of file DialectConversion.cpp.
|
inline |
Definition at line 687 of file DialectConversion.h.