xref: /llvm-project/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.h (revision 91856b34e3eddf157ab4c6ea623483b49d149e62)
1 //===- LinalgMatchOps.h - Linalg transform matcher ops ----------*- 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_LINALG_TRANSFORMOPS_LINALGMATCHOPS_H
10 #define MLIR_DIALECT_LINALG_TRANSFORMOPS_LINALGMATCHOPS_H
11 
12 #include "mlir/Dialect/Linalg/IR/Linalg.h"
13 #include "mlir/Dialect/Transform/IR/TransformAttrs.h"
14 #include "mlir/Dialect/Transform/Interfaces/MatchInterfaces.h"
15 
16 namespace mlir {
17 namespace transform {
18 
19 namespace detail {
20 LogicalResult verifyStructuredOpPredicateOpTrait(Operation *op,
21                                                  Value structuredOpHandle);
22 } // namespace detail
23 
24 template <typename OpTy>
25 class StructuredOpPredicateOpTrait
26     : public OpTrait::TraitBase<OpTy, StructuredOpPredicateOpTrait> {
27 public:
verifyTrait(Operation * op)28   static LogicalResult verifyTrait(Operation *op) {
29     static_assert(
30         OpTy::template hasTrait<SingleOpMatcherOpTrait>(),
31         "StructuredOpPredicateOpTrait requires SingleOpMatcherOpTrait");
32 
33     return detail::verifyStructuredOpPredicateOpTrait(
34         op, cast<OpTy>(op).getOperandHandle());
35   }
36 };
37 
38 } // namespace transform
39 } // namespace mlir
40 
41 //===----------------------------------------------------------------------===//
42 // Linalg Matcher Operations
43 //===----------------------------------------------------------------------===//
44 
45 #define GET_OP_CLASSES
46 #include "mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.h.inc"
47 
48 #endif // MLIR_DIALECT_LINALG_TRANSFORMOPS_LINALGMATCHOPS_H
49