MLIR 22.0.0git
Predicate.cpp
Go to the documentation of this file.
1//===- Predicate.cpp - Pattern predicates ---------------------------------===//
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 "Predicate.h"
10
11using namespace mlir;
12using namespace mlir::pdl_to_pdl_interp;
13
14//===----------------------------------------------------------------------===//
15// Positions
16//===----------------------------------------------------------------------===//
17
18Position::~Position() = default;
19
20/// Returns the depth of the first ancestor operation position.
22 if (const auto *operationPos = dyn_cast<OperationPosition>(this))
23 return operationPos->getDepth();
24 return parent ? parent->getOperationDepth() : 0;
25}
26
27//===----------------------------------------------------------------------===//
28// AttributePosition
29//===----------------------------------------------------------------------===//
30
34
35//===----------------------------------------------------------------------===//
36// OperandPosition
37//===----------------------------------------------------------------------===//
38
42
43//===----------------------------------------------------------------------===//
44// OperandGroupPosition
45//===----------------------------------------------------------------------===//
46
50
51//===----------------------------------------------------------------------===//
52// OperationPosition
53//===----------------------------------------------------------------------===//
54
56 return isa_and_nonnull<OperandPosition, OperandGroupPosition>(parent);
57}
unsigned getOperationDepth() const
Returns the depth of the first ancestor operation position.
Definition Predicate.cpp:21
Position * parent
Link to the parent position.
Definition Predicate.h:160
PredicateBase< AttributePosition, Position, std::pair< OperationPosition *, StringAttr >, Kind > Base
Definition Predicate.h:87
Include the generated interface declarations.
bool isOperandDefiningOp() const
Returns if this operation represents an operand defining op.
Definition Predicate.cpp:55