xref: /llvm-project/mlir/include/mlir/IR/RegionKindInterface.td (revision 697a5036cd9bdf9d12978e082e38ac75f0eb108e)
1//===- RegionKindInterface.td - Region kind interfaces -----*- tablegen -*-===//
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 file contains a set of interfaces to query the properties of regions
10// in an operation.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_IR_REGIONKINDINTERFACE
15#define MLIR_IR_REGIONKINDINTERFACE
16
17include "mlir/IR/OpBase.td"
18
19// OpInterface to query the properties of regions in an operation
20def RegionKindInterface : OpInterface<"RegionKindInterface"> {
21  let description = [{
22    Interface for operations to describe the abstract semantics of
23    their regions. Currently, two kinds of regions are
24    supported. RegionKind::Graph represents a graph region without
25    control flow semantics. RegionKind::SSACFG represents an
26    [SSA-style control flow](../LangRef.md/#modeling-control-flow) region
27    with basic blocks, sequential semantics, and reachability.
28  }];
29  let cppNamespace = "::mlir";
30
31  let methods = [
32    StaticInterfaceMethod<
33      /*desc=*/[{
34        Return the kind of the region with the given index inside this operation.
35      }],
36      /*retTy=*/"::mlir::RegionKind",
37      /*methodName=*/"getRegionKind",
38      /*args=*/(ins "unsigned":$index)
39    >,
40    StaticInterfaceMethod<
41      /*desc=*/"Return true if the kind of the given region requires the "
42               "SSA-Dominance property",
43      /*retTy=*/"bool",
44      /*methodName=*/"hasSSADominance",
45      /*args=*/(ins "unsigned":$index),
46      /*methodBody=*/[{
47        return getRegionKind(index) == ::mlir::RegionKind::SSACFG;
48      }]
49    >,
50  ];
51}
52
53def HasOnlyGraphRegion : NativeOpTrait<"HasOnlyGraphRegion">;
54
55// Op's regions that don't need a terminator: requires some other traits
56// so it defines a list that must be concatenated.
57def GraphRegionNoTerminator : TraitList<[
58    NoTerminator,
59    SingleBlock,
60    RegionKindInterface,
61    HasOnlyGraphRegion
62  ]>;
63
64#endif // MLIR_IR_REGIONKINDINTERFACE
65