MLIR  20.0.0git
Public Member Functions | Protected Types | Protected Member Functions | List of all members
mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects > Class Template Reference

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"

+ Inheritance diagram for mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >:

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< DialectExtensionBaseclone () 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...
 

Detailed Description

template<typename DerivedTy, typename... ExtraDialects>
class mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >

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.

Member Typedef Documentation

◆ Base

template<typename DerivedTy , typename... ExtraDialects>
using mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::Base = TransformDialectExtension<DerivedTy, ExtraDialects...>
protected

Definition at line 141 of file TransformDialect.h.

Constructor & Destructor Documentation

◆ TransformDialectExtension()

template<typename DerivedTy , typename... ExtraDialects>
mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::TransformDialectExtension ( bool  buildOnly = false)
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().

Member Function Documentation

◆ addCustomInitializationStep()

template<typename DerivedTy , typename... ExtraDialects>
template<typename Func >
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::addCustomInitializationStep ( Func &&  func)
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().

◆ addDialectDataInitializer()

template<typename DerivedTy , typename... ExtraDialects>
template<typename DataTy , typename Func >
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::addDialectDataInitializer ( Func &&  func)
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().

◆ apply()

template<typename DerivedTy , typename... ExtraDialects>
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::apply ( MLIRContext context,
TransformDialect *  transformDialect,
ExtraDialects *  ... 
) const
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().

◆ declareDependentDialect()

template<typename DerivedTy , typename... ExtraDialects>
template<typename DialectTy >
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::declareDependentDialect ( )
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().

◆ declareGeneratedDialect()

template<typename DerivedTy , typename... ExtraDialects>
template<typename DialectTy >
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::declareGeneratedDialect ( )
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().

◆ init()

template<typename DerivedTy , typename... ExtraDialects>
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::init ( )
inlineprotected

◆ registerTransformOps()

template<typename DerivedTy , typename... ExtraDialects>
template<typename... OpTys>
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::registerTransformOps ( )
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.

◆ registerTypes()

template<typename DerivedTy , typename... ExtraDialects>
template<typename... TypeTys>
void mlir::transform::TransformDialectExtension< DerivedTy, ExtraDialects >::registerTypes ( )
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.


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