CIRCT 23.0.0git
Loading...
Searching...
No Matches
ProceduralRegionTrait.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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// This header file defines traits for (non-)procedural regions and operations.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef CIRCT_SUPPORT_PROCEDURALREGIONTRAIT_H
14#define CIRCT_SUPPORT_PROCEDURALREGIONTRAIT_H
15
16#include "circt/Support/LLVM.h"
17#include "mlir/IR/OpDefinition.h"
18#include "llvm/Support/LogicalResult.h"
19
20namespace circt {
21
22/// Returns `success` if the operation has no closer surrounding parent
23/// marked as procedural region than its closest parent marked as
24/// non-procedural region.
25/// Also returns `success` if no parent is marked as either procedural or
26/// non-procedural region.
27LogicalResult verifyNotInProceduralRegion(Operation *op);
28
29/// Returns `success` if the operation has no closer surrounding parent
30/// marked as non-procedural region than its closest parent marked as
31/// procedural region.
32/// Also returns `success` if no parent is marked as either procedural or
33/// non-procedural region.
34LogicalResult verifyNotInNonProceduralRegion(Operation *op);
35
36/// Returns true if `op` has a parent marked as a procedural region that is
37/// closer than any parent marked as a non-procedural region. Returns false
38/// otherwise, including when no parent is marked as either.
39bool isInProceduralRegion(Operation *op);
40
41/// Signals that an operation's regions are procedural.
42template <typename ConcreteType>
44 : public mlir::OpTrait::TraitBase<ConcreteType, ProceduralRegion> {
45 static LogicalResult verifyTrait(Operation *op) {
46 return mlir::OpTrait::impl::verifyNRegions(op, 1);
47 }
48};
49
50/// Signals that an operation's regions are non-procedural.
51template <typename ConcreteType>
53 : public mlir::OpTrait::TraitBase<ConcreteType, NonProceduralRegion> {
54 static LogicalResult verifyTrait(Operation *op) {
55 return mlir::OpTrait::impl::verifyNRegions(op, 1);
56 }
57};
58
59/// Signals that an operation must not be in a non-procedural region.
60template <typename ConcreteType>
62 : public mlir::OpTrait::TraitBase<ConcreteType, ProceduralOp> {
63public:
64 static LogicalResult verifyTrait(Operation *op) {
66 }
67};
68
69/// Signals that an operation must not be in a procedural region.
70template <typename ConcreteType>
72 : public mlir::OpTrait::TraitBase<ConcreteType, NonProceduralOp> {
73public:
74 static LogicalResult verifyTrait(Operation *op) {
76 }
77};
78
79} // namespace circt
80
81#endif // CIRCT_SUPPORT_PROCEDURALREGIONTRAIT_H
Signals that an operation must not be in a procedural region.
static LogicalResult verifyTrait(Operation *op)
Signals that an operation's regions are non-procedural.
static LogicalResult verifyTrait(Operation *op)
Signals that an operation must not be in a non-procedural region.
static LogicalResult verifyTrait(Operation *op)
Signals that an operation's regions are procedural.
static LogicalResult verifyTrait(Operation *op)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
LogicalResult verifyNotInNonProceduralRegion(Operation *op)
Returns success if the operation has no closer surrounding parent marked as non-procedural region tha...
LogicalResult verifyNotInProceduralRegion(Operation *op)
Returns success if the operation has no closer surrounding parent marked as procedural region than it...
bool isInProceduralRegion(Operation *op)
Returns true if op has a parent marked as a procedural region that is closer than any parent marked a...