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   static bool classof(const Operator::VariableDecorator *var);
39 };
40 
41 // This class represents an instance of a side effect interface applied to an
42 // operation. This is a wrapper around an OpInterfaceTrait that also includes
43 // the effects that are applied.
44 class SideEffectTrait : public InterfaceOpTrait {
45 public:
46   // Return the effects that are attached to the side effect interface.
47   Operator::var_decorator_range getEffects() const;
48 
49   // Return the name of the base C++ effect.
50   StringRef getBaseEffectName() const;
51 
52   static bool classof(const OpTrait *t);
53 };
54 
55 } // end namespace tblgen
56 } // end namespace mlir
57 
58 #endif // MLIR_TABLEGEN_SIDEEFFECTS_H_
59