9 #ifndef MLIR_DIALECT_TRANSFORM_IR_TRANSFORMDIALECT_H 10 #define MLIR_DIALECT_TRANSFORM_IR_TRANSFORMDIALECT_H 16 #include "llvm/ADT/StringMap.h" 25 template <
typename OpTy>
34 "non-terminator ops injected into the transform dialect must " 35 "implement TransformOpInterface");
37 "ops injected into the transform dialect must implement " 38 "MemoryEffectsOpInterface");
45 #include "mlir/Dialect/Transform/IR/TransformDialect.h.inc" 75 template <
typename DerivedTy,
typename... ExtraDialects>
78 using Initializer = std::function<void(TransformDialect *)>;
79 using DialectLoader = std::function<void(MLIRContext *)>;
85 ExtraDialects *...)
const final {
86 for (
const DialectLoader &loader : dialectLoaders)
92 for (
const DialectLoader &loader : generatedDialectLoaders)
95 for (
const Initializer &init : opInitializers)
96 init(transformDialect);
97 transformDialect->mergeInPDLMatchHooks(std::move(pdlMatchConstraintFns));
106 : buildOnly(buildOnly) {
107 static_cast<DerivedTy *
>(
this)->init();
116 template <
typename... OpTys>
118 opInitializers.push_back([](TransformDialect *transformDialect) {
119 transformDialect->addOperationsChecked<OpTys...>();
131 template <
typename DialectTy>
133 dialectLoaders.push_back(
143 template <
typename DialectTy>
145 generatedDialectLoaders.push_back(
153 pdlMatchConstraintFns.try_emplace(name,
154 std::forward<PDLConstraintFunction>(fn));
156 template <
typename Constra
intFnTy>
158 pdlMatchConstraintFns.try_emplace(
160 std::forward<ConstraintFnTy>(fn)));
179 mutable llvm::StringMap<PDLConstraintFunction> pdlMatchConstraintFns;
187 template <
typename DerivedTy>
196 #include "mlir/Dialect/Transform/IR/TransformDialectEnums.h.inc" 198 #endif // MLIR_DIALECT_TRANSFORM_IR_TRANSFORMDIALECT_H Include the generated interface declarations.
bool hasTrait() const
Returns true if the operation has a particular trait.
TransformDialectExtension(bool buildOnly=false)
Extension constructor.
void declareGeneratedDialect()
Declares that the transformations associated with the operations registered by this dialect extension...
bool hasInterface() const
Returns true if this operation has the given interface registered to it.
void loadDialect()
Load a dialect in the context.
This class provides the API for ops that are known to be terminators.
std::function< LogicalResult(PatternRewriter &, ArrayRef< PDLValue >)> PDLConstraintFunction
A generic PDL pattern constraint function.
void init()
Hook for derived classes to inject constructor behavior.
This class represents a dialect extension anchored on the given set of dialects.
static Optional< RegisteredOperationName > lookup(StringRef name, MLIRContext *ctx)
Lookup the registered operation information for the given operation.
void registerPDLMatchConstraintFn(StringRef name, ConstraintFnTy &&fn)
void registerTransformOps()
Injects the operations into the Transform dialect.
MLIRContext is the top-level object for a collection of MLIR operations.
Base class for extensions of the Transform dialect that supports injecting operations into the Transf...
This is a "type erased" representation of a registered operation.
void declareDependentDialect()
Declares that this Transform dialect extension depends on the dialect provided as template parameter...
void apply(MLIRContext *context, TransformDialect *transformDialect, ExtraDialects *...) const final
Extension application hook.
void registerPDLMatchConstraintFn(StringRef name, PDLConstraintFunction &&fn)
Injects the named constraint to make it available for use with the PDLMatchOp in the transform dialec...
std::enable_if_t< std::is_convertible< ConstraintFnT, PDLConstraintFunction >::value, PDLConstraintFunction > buildConstraintFn(ConstraintFnT &&constraintFn)
Build a constraint function from the given function ConstraintFnT.