| 1 | //===--- MatchersInternal.cpp----------------------------------------------===// |
|---|---|
| 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 | #include "mlir/Query/Matcher/MatchersInternal.h" |
| 10 | #include "llvm/ADT/SetVector.h" |
| 11 | |
| 12 | namespace mlir::query::matcher { |
| 13 | |
| 14 | namespace internal { |
| 15 | |
| 16 | bool allOfVariadicOperator(Operation *op, SetVector<Operation *> *matchedOps, |
| 17 | ArrayRef<DynMatcher> innerMatchers) { |
| 18 | return llvm::all_of(Range&: innerMatchers, P: [&](const DynMatcher &matcher) { |
| 19 | if (matchedOps) |
| 20 | return matcher.match(op, matchedOps&: *matchedOps); |
| 21 | return matcher.match(op); |
| 22 | }); |
| 23 | } |
| 24 | bool anyOfVariadicOperator(Operation *op, SetVector<Operation *> *matchedOps, |
| 25 | ArrayRef<DynMatcher> innerMatchers) { |
| 26 | return llvm::any_of(Range&: innerMatchers, P: [&](const DynMatcher &matcher) { |
| 27 | if (matchedOps) |
| 28 | return matcher.match(op, matchedOps&: *matchedOps); |
| 29 | return matcher.match(op); |
| 30 | }); |
| 31 | } |
| 32 | } // namespace internal |
| 33 | } // namespace mlir::query::matcher |
| 34 |
