xref: /llvm-project/mlir/include/mlir/TableGen/SideEffects.h (revision 0c63122713c2d719789aef4bdfaf4e0b29c3b79e)
1 //===- SideEffects.h - Side Effects classes ---------------------*- C++ -*-===//
2 //
3 // Part of the MLIR 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 // Wrapper around side effect related classes defined in TableGen.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_TABLEGEN_SIDEEFFECTS_H_
14 #define MLIR_TABLEGEN_SIDEEFFECTS_H_
15 
16 #include "mlir/Support/LLVM.h"
17 #include "mlir/TableGen/Operator.h"
18 
19 namespace mlir {
20 namespace tblgen {
21 
22 // This class represents a specific instance of an effect that is being
23 // exhibited.
24 class SideEffect : public Operator::VariableDecorator {
25 public:
26   // Return the name of the C++ effect.
27   StringRef getName() const;
28 
29   // Return the name of the base C++ effect.
30   StringRef getBaseEffectName() const;
31 
32   // Return the name of the Interface that the effect belongs to.
33   std::string getInterfaceTrait() const;
34 
35   // Return the name of the resource class.
36   StringRef getResource() const;
37 
38   // Return the stage of the effect happen.
39   int64_t getStage() const;
40 
41   // Return if this side effect act on every single value of resource.
42   bool getEffectOnfullRegion() const;
43 
44   static bool classof(const Operator::VariableDecorator *var);
45 };
46 
47 // This class represents an instance of a side effect interface applied to an
48 // operation. This is a wrapper around an OpInterfaceTrait that also includes
49 // the effects that are applied.
50 class SideEffectTrait : public InterfaceTrait {
51 public:
52   // Return the effects that are attached to the side effect interface.
53   Operator::var_decorator_range getEffects() const;
54 
55   // Return the name of the base C++ effect.
56   StringRef getBaseEffectName() const;
57 
58   static bool classof(const Trait *t);
59 };
60 
61 } // namespace tblgen
62 } // namespace mlir
63 
64 #endif // MLIR_TABLEGEN_SIDEEFFECTS_H_
65