MLIR  20.0.0git
RegionKindInterface.h
Go to the documentation of this file.
1 //===- RegionKindInterface.h - Region Kind Interfaces -----------*- C++ -*-===//
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 the definitions of the infer op interfaces defined in
10 // `RegionKindInterface.td`.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_IR_REGIONKINDINTERFACE_H_
15 #define MLIR_IR_REGIONKINDINTERFACE_H_
16 
17 #include "mlir/IR/OpDefinition.h"
18 
19 namespace mlir {
20 
21 /// The kinds of regions contained in an operation. SSACFG regions
22 /// require the SSA-Dominance property to hold. Graph regions do not
23 /// require SSA-Dominance. If a registered operation does not implement
24 /// RegionKindInterface, then any regions it contains are assumed to be
25 /// SSACFG regions.
26 enum class RegionKind {
27  SSACFG,
28  Graph,
29 };
30 
31 namespace OpTrait {
32 /// A trait that specifies that an operation only defines graph regions.
33 template <typename ConcreteType>
34 class HasOnlyGraphRegion : public TraitBase<ConcreteType, HasOnlyGraphRegion> {
35 public:
36  static RegionKind getRegionKind(unsigned index) { return RegionKind::Graph; }
37  static bool hasSSADominance(unsigned index) { return false; }
38 };
39 } // namespace OpTrait
40 
41 /// Return "true" if the given region may have SSA dominance. This function also
42 /// returns "true" in case the owner op is an unregistered op or an op that does
43 /// not implement the RegionKindInterface.
44 bool mayHaveSSADominance(Region &region);
45 
46 /// Return "true" if the given region may be a graph region without SSA
47 /// dominance. This function returns "true" in case the owner op is an
48 /// unregistered op. It returns "false" if it is a registered op that does not
49 /// implement the RegionKindInterface.
50 bool mayBeGraphRegion(Region &region);
51 
52 } // namespace mlir
53 
54 #include "mlir/IR/RegionKindInterface.h.inc"
55 
56 #endif // MLIR_IR_REGIONKINDINTERFACE_H_
A trait that specifies that an operation only defines graph regions.
static RegionKind getRegionKind(unsigned index)
static bool hasSSADominance(unsigned index)
Helper class for implementing traits.
Definition: OpDefinition.h:373
Include the generated interface declarations.
bool mayBeGraphRegion(Region &region)
Return "true" if the given region may be a graph region without SSA dominance.
bool mayHaveSSADominance(Region &region)
Return "true" if the given region may have SSA dominance.
RegionKind
The kinds of regions contained in an operation.