xref: /llvm-project/mlir/include/mlir/Dialect/Transform/PDLExtension/PDLExtensionOps.h (revision 5a9bdd85ee4d8527e2cedf44f3ce26ff414f9b6a)
1 //===- PDLExtensionOps.h - PDL extension for Transform dialect --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MLIR_DIALECT_TRANSFORM_PDLEXTENSION_PDLEXTENSIONOPS_H
10 #define MLIR_DIALECT_TRANSFORM_PDLEXTENSION_PDLEXTENSIONOPS_H
11 
12 #include "mlir/Bytecode/BytecodeOpInterface.h"
13 #include "mlir/Dialect/Transform/IR/TransformDialect.h"
14 #include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"
15 #include "mlir/IR/OpDefinition.h"
16 #include "mlir/IR/OpImplementation.h"
17 #include "mlir/IR/SymbolTable.h"
18 #include "mlir/Interfaces/SideEffectInterfaces.h"
19 
20 #define GET_OP_CLASSES
21 #include "mlir/Dialect/Transform/PDLExtension/PDLExtensionOps.h.inc"
22 
23 namespace mlir {
24 namespace transform {
25 /// PDL constraint callbacks that can be used by the PDL extension of the
26 /// Transform dialect. These are owned by the Transform dialect and can be
27 /// populated by extensions.
28 class PDLMatchHooks : public TransformDialectData<PDLMatchHooks> {
29 public:
PDLMatchHooks(MLIRContext * ctx)30   PDLMatchHooks(MLIRContext *ctx) : TransformDialectData(ctx) {}
31 
32   /// Takes ownership of the named PDL constraint function from the given
33   /// map and makes them available for use by the operations in the dialect.
34   void
35   mergeInPDLMatchHooks(llvm::StringMap<PDLConstraintFunction> &&constraintFns);
36 
37   /// Returns the named PDL constraint functions available in the dialect
38   /// as a map from their name to the function.
39   const llvm::StringMap<::mlir::PDLConstraintFunction> &
40   getPDLConstraintHooks() const;
41 
42 private:
43   /// A container for PDL constraint function that can be used by
44   /// operations in this dialect.
45   PDLPatternModule pdlMatchHooks;
46 };
47 } // namespace transform
48 } // namespace mlir
49 
50 MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::transform::PDLMatchHooks)
51 
52 #endif // MLIR_DIALECT_TRANSFORM_PDLEXTENSION_PDLEXTENSIONOPS_H
53