14 #ifndef MLIR_INTERFACES_SIDEEFFECTINTERFACES_H 15 #define MLIR_INTERFACES_SIDEEFFECTINTERFACES_H 20 namespace SideEffects {
29 template <
typename DerivedEffect,
typename BaseEffect = Effect>
38 static bool classof(const ::mlir::SideEffects::Effect *effect) {
43 static DerivedEffect *
get() {
44 return BaseEffect::template get<DerivedEffect>();
46 using BaseEffect::get;
56 template <
typename DerivedEffect>
57 static DerivedEffect *
get() {
59 "expected DerivedEffect to inherit from Effect");
61 static DerivedEffect instance;
84 template <
typename DerivedResource,
typename BaseResource = Resource>
90 static DerivedResource *
get() {
91 static DerivedResource instance;
111 virtual StringRef getName() = 0;
123 StringRef
getName() final {
return "<Default>"; }
130 StringRef
getName() final {
return "AutomaticAllocationScope"; }
138 template <
typename EffectT>
142 : effect(effect), resource(resource) {}
145 : effect(effect), resource(resource), value(value) {}
148 : effect(effect), resource(resource), value(symbol) {}
151 : effect(effect), resource(resource), parameters(parameters) {}
154 : effect(effect), resource(resource), value(value),
155 parameters(parameters) {}
158 : effect(effect), resource(resource), value(symbol),
159 parameters(parameters) {}
171 return value ? value.
dyn_cast<SymbolRefAttr>() : SymbolRefAttr();
206 template <
typename ConcreteType>
208 :
public TraitBase<ConcreteType, HasRecursiveSideEffects> {};
215 namespace MemoryEffects {
221 template <
typename DerivedEffect>
256 template <
typename EffectTy>
275 #include "mlir/Interfaces/SideEffectInterfaces.h.inc" 277 #endif // MLIR_INTERFACES_SIDEEFFECTINTERFACES_H Include the generated interface declarations.
bool wouldOpBeTriviallyDead(Operation *op)
Return true if the given operation would be dead if unused, and has no side effects on memory that wo...
bool isOpTriviallyDead(Operation *op)
Return true if the given operation is unused, and has no side effects on memory that prevent erasing...
Operation is a basic unit of execution within MLIR.
EffectT * getEffect() const
Return the effect being applied.
EffectInstance(EffectT *effect, SymbolRefAttr symbol, Attribute parameters, Resource *resource=DefaultResource::get())
Value getValue() const
Return the value the effect is applied on, or nullptr if there isn't a known value being affected...
This trait indicates that the side effects of an operation includes the effects of operations nested ...
static constexpr const bool value
This class provides an efficient unique identifier for a specific C++ type.
static DefaultResource * get()
Returns a unique instance for the given effect class.
This class represents a specific resource that an effect applies to.
An automatic allocation-scope resource that is valid in the context of a parent AutomaticAllocationSc...
EffectInstance(EffectT *effect, Value value, Attribute parameters, Resource *resource=DefaultResource::get())
EffectInstance(EffectT *effect, Resource *resource=DefaultResource::get())
EffectInstance(EffectT *effect, Attribute parameters, Resource *resource=DefaultResource::get())
The following effect indicates that the operation writes to some resource.
static bool classof(const ::mlir::SideEffects::Effect *effect)
'classof' used to support llvm style cast functionality.
SymbolRefAttr getSymbolRef() const
Return the symbol reference the effect is applied on, or nullptr if there isn't a known smbol being a...
The following effect indicates that the operation reads from some resource.
Attributes are known-constant values of operations.
bool hasSingleEffect(Operation *op, Value value=nullptr)
Returns true if op has only an effect of type EffectTy (and of no other type) on value.
A conservative default resource kind.
This base class is used for derived effects that are non-parametric.
This class represents a specific instance of an effect.
This class represents the base class used for memory effects.
static bool classof(const Resource *resource)
'classof' used to support llvm style cast functionality.
static TypeID getResourceID()
Return the unique identifier for the base resource class.
TypeID getResourceID() const
Return the unique identifier for the base resource class.
StringRef getName() final
Return a string name of the resource.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
StringRef getName() final
Return a string name of the resource.
Attribute getParameters() const
Return the parameters of the effect, if any.
Resource * getResource() const
Return the resource that the effect applies to.
Helper class for implementing traits.
EffectInstance(EffectT *effect, SymbolRefAttr symbol, Resource *resource=DefaultResource::get())
This class represents a base class for a specific effect type.
The following effect indicates that the operation frees some resource that has been allocated...
EffectInstance(EffectT *effect, Value value, Resource *resource=DefaultResource::get())
TypeID getEffectID() const
Return the unique identifier for the base effects class.
static TypeID getEffectID()
Return the unique identifier for the base effects class.
The following effect indicates that the operation allocates from some resource.
This base class is used for derived effects that are non-parametric.