//===- MatchersInternal.h - Structural query framework ----------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Implements the base layer of the matcher framework. // // Matchers are methods that return a Matcher which provides a method // match(Operation *op) // // The matcher functions are defined in include/mlir/IR/Matchers.h. // This file contains the wrapper classes needed to construct matchers for // mlir-query. // //===----------------------------------------------------------------------===// #ifndef MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERSINTERNAL_H #define MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERSINTERNAL_H #include "mlir/IR/Matchers.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" namespace mlir::query::matcher { // Generic interface for matchers on an MLIR operation. class MatcherInterface : public llvm::ThreadSafeRefCountedBase<MatcherInterface> { … }; // MatcherFnImpl takes a matcher function object and implements // MatcherInterface. template <typename MatcherFn> class MatcherFnImpl : public MatcherInterface { … }; // Matcher wraps a MatcherInterface implementation and provides a match() // method that redirects calls to the underlying implementation. class DynMatcher { … }; } // namespace mlir::query::matcher #endif // MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERSINTERNAL_H