1 //===- Predicate.cpp - Pattern predicates ---------------------------------===//
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
7 //===----------------------------------------------------------------------===//
12 using namespace mlir::pdl_to_pdl_interp
;
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
18 Position::~Position() = default;
20 /// Returns the depth of the first ancestor operation position.
21 unsigned Position::getOperationDepth() const {
22 if (const auto *operationPos
= dyn_cast
<OperationPosition
>(this))
23 return operationPos
->getDepth();
24 return parent
? parent
->getOperationDepth() : 0;
27 //===----------------------------------------------------------------------===//
30 AttributePosition::AttributePosition(const KeyTy
&key
) : Base(key
) {
34 //===----------------------------------------------------------------------===//
37 OperandPosition::OperandPosition(const KeyTy
&key
) : Base(key
) {
41 //===----------------------------------------------------------------------===//
42 // OperandGroupPosition
44 OperandGroupPosition::OperandGroupPosition(const KeyTy
&key
) : Base(key
) {
45 parent
= std::get
<0>(key
);
48 //===----------------------------------------------------------------------===//
51 bool OperationPosition::isOperandDefiningOp() const {
52 return isa_and_nonnull
<OperandPosition
, OperandGroupPosition
>(parent
);