MLIR
20.0.0git
|
Base class for extensions of the Transform dialect that supports injecting operations into the Transform dialect at load time. More...
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
Public Member Functions | |
void | apply (MLIRContext *context, TransformDialect *transformDialect, ExtraDialects *...) const final |
Extension application hook. More... | |
Public Member Functions inherited from mlir::DialectExtension< DerivedTy, TransformDialect, ExtraDialects... > | |
virtual void | apply (MLIRContext *context, DialectsT *...dialects) const=0 |
Applies this extension to the given context and set of required dialects. More... | |
std::unique_ptr< DialectExtensionBase > | clone () const final |
Return a copy of this extension. More... | |
Public Member Functions inherited from mlir::DialectExtensionBase | |
virtual | ~DialectExtensionBase () |
ArrayRef< StringRef > | getRequiredDialects () const |
Return the dialects that our required by this extension to be loaded before applying. More... | |
Protected Types | |
using | Base = TransformDialectExtension< DerivedTy, ExtraDialects... > |
Protected Member Functions | |
TransformDialectExtension (bool buildOnly=false) | |
Extension constructor. More... | |
template<typename Func > | |
void | addCustomInitializationStep (Func &&func) |
Registers a custom initialization step to be performed when the extension is applied to the dialect while loading. More... | |
template<typename DataTy , typename Func > | |
void | addDialectDataInitializer (Func &&func) |
Registers the given function as one of the initializers for the dialect-owned data of the kind specified as template argument. More... | |
void | init () |
Hook for derived classes to inject constructor behavior. More... | |
template<typename... OpTys> | |
void | registerTransformOps () |
Injects the operations into the Transform dialect. More... | |
template<typename... TypeTys> | |
void | registerTypes () |
Injects the types into the Transform dialect. More... | |
template<typename DialectTy > | |
void | declareDependentDialect () |
Declares that this Transform dialect extension depends on the dialect provided as template parameter. More... | |
template<typename DialectTy > | |
void | declareGeneratedDialect () |
Declares that the transformations associated with the operations registered by this dialect extension may produce operations from the dialect provided as template parameter while processing payload IR that does not contain the operations from said dialect. More... | |
Protected Member Functions inherited from mlir::DialectExtension< DerivedTy, TransformDialect, ExtraDialects... > | |
void | apply (MLIRContext *context, MutableArrayRef< Dialect * > dialects) const final |
Override the base apply method to allow providing the exact dialect types. More... | |
DialectExtension () | |
Protected Member Functions inherited from mlir::DialectExtensionBase | |
DialectExtensionBase (ArrayRef< StringRef > dialectNames) | |
Initialize the extension with a set of required dialects. More... | |
Base class for extensions of the Transform dialect that supports injecting operations into the Transform dialect at load time.
Concrete extensions are expected to derive this class and register operations in the constructor. They can be registered with the DialectRegistry and automatically applied to the Transform dialect when it is loaded.
Derived classes are expected to define a void init()
function in which they can call various protected methods of the base class to register extension operations and declare their dependencies.
By default, the extension is configured both for construction of the Transform IR and for its application to some payload. If only the construction is desired, the extension can be switched to "build-only" mode that avoids loading the dialects that are only necessary for transforming the payload. To perform the switch, the extension must be wrapped into the BuildOnly
class template (see below) when it is registered, as in:
dialectRegistry.addExtension<BuildOnly<MyTransformDialectExt>>();
instead of:
dialectRegistry.addExtension<MyTransformDialectExt>();
Derived classes must reexport the constructor of this class or otherwise forward its boolean argument to support this behavior.
Definition at line 117 of file TransformDialect.h.
|
protected |
Definition at line 141 of file TransformDialect.h.
|
inlineexplicitprotected |
Extension constructor.
The argument indicates whether to skip generated dialects when applying the extension.
Definition at line 145 of file TransformDialect.h.
References mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::init().
|
inlineprotected |
Registers a custom initialization step to be performed when the extension is applied to the dialect while loading.
This is discouraged in favor of more specific calls declareGeneratedDialect
, addDialectDataInitializer
etc. Func
must be convertible to the void (MLIRContext *)
form. It will be called during the extension initialization and given the current MLIR context. This may be used to attach additional interfaces that cannot be attached elsewhere.
Definition at line 158 of file TransformDialect.h.
References mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::init().
|
inlineprotected |
Registers the given function as one of the initializers for the dialect-owned data of the kind specified as template argument.
The function must be convertible to the void (DataTy &)
form. It will be called during the extension initialization and will be given a mutable reference to DataTy
. The callback is expected to append data to the given storage, and is not allowed to remove or destructively mutate the existing data. The order in which callbacks from different extensions are executed is unspecified so the callbacks may not rely on data being already present. DataTy
must be a class deriving TransformDialectData
.
Definition at line 174 of file TransformDialect.h.
References mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::init().
|
inlinefinal |
Extension application hook.
Actually loads the dependent dialects and registers the additional operations. Not expected to be called directly.
Definition at line 125 of file TransformDialect.h.
References mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::init().
|
inlineprotected |
Declares that this Transform dialect extension depends on the dialect provided as template parameter.
When the Transform dialect is loaded, dependent dialects will be loaded as well. This is intended for dialects that contain attributes and types used in creation and canonicalization of the injected operations, similarly to how the dialect definition may list dependent dialects. This is not intended for dialects entities from which may be produced when applying the transformations specified by ops registered by this extension.
Definition at line 219 of file TransformDialect.h.
References mlir::MLIRContext::loadDialect().
|
inlineprotected |
Declares that the transformations associated with the operations registered by this dialect extension may produce operations from the dialect provided as template parameter while processing payload IR that does not contain the operations from said dialect.
This is similar to dependent dialects of a pass. These dialects will be loaded along with the transform dialect unless the extension is in the build-only mode.
Definition at line 231 of file TransformDialect.h.
References mlir::MLIRContext::loadDialect().
|
inlineprotected |
Hook for derived classes to inject constructor behavior.
Definition at line 186 of file TransformDialect.h.
Referenced by mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::addCustomInitializationStep(), mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::addDialectDataInitializer(), mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::apply(), and mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::TransformDialectExtension().
|
inlineprotected |
Injects the operations into the Transform dialect.
The operations must implement the TransformOpInterface and MemoryEffectsOpInterface, and the implementations must be already available when the operation is injected.
Definition at line 192 of file TransformDialect.h.
|
inlineprotected |
Injects the types into the Transform dialect.
The types must implement the TransformHandleTypeInterface and the implementation must be already available when the type is injected. Furthermore, the types must provide a getMnemonic
static method returning an object convertible to StringRef
that is unique across all injected types.
Definition at line 204 of file TransformDialect.h.