9 #ifndef MLIR_IR_DIALECTINTERFACE_H 10 #define MLIR_IR_DIALECTINTERFACE_H 13 #include "llvm/ADT/DenseSet.h" 14 #include "llvm/ADT/STLExtras.h" 27 template <
typename ConcreteType,
typename BaseT>
47 template <
typename ConcreteType>
58 : dialect(dialect), interfaceID(id) {}
77 struct InterfaceKeyInfo :
public DenseMapInfo<const DialectInterface *> {
86 if (rhs == getEmptyKey() || rhs == getTombstoneKey())
94 using InterfaceVectorT = std::vector<const DialectInterface *>;
107 auto it = interfaces.find_as(dialect);
108 return it == interfaces.end() ? nullptr : *it;
113 template <
typename InterfaceT>
115 :
public llvm::mapped_iterator_base<iterator<InterfaceT>,
116 InterfaceVectorT::const_iterator,
117 const InterfaceT &> {
118 using llvm::mapped_iterator_base<iterator<InterfaceT>,
119 InterfaceVectorT::const_iterator,
120 const InterfaceT &>::mapped_iterator_base;
124 return *
static_cast<const InterfaceT *
>(interface);
142 InterfaceVectorT orderedInterfaces;
148 template <
typename InterfaceType>
156 : detail::DialectInterfaceCollectionBase(
161 template <
typename Object>
163 return static_cast<const InterfaceType *
>(
An iterator class that iterates the held interface objects of the given derived interface type...
Include the generated interface declarations.
TypeID getID() const
Return the derived interface id.
Operation is a basic unit of execution within MLIR.
The base class used for all derived interface types.
iterator< InterfaceT > interface_end() const
Dialect * getDialect() const
Return the dialect that this interface represents.
A collection of dialect interfaces within a context, for a given concrete interface type...
const InterfaceT & mapElement(const DialectInterface *interface) const
Map the element to the iterator result type.
const InterfaceType * getInterfaceFor(Object *obj) const
Get the interface for a given object, or null if one is not registered.
This class provides an efficient unique identifier for a specific C++ type.
const DialectInterface * getInterfaceFor(Dialect *dialect) const
Get the interface for the given dialect.
static TypeID getInterfaceID()
Get a unique id for the derived interface type.
DialectInterface(Dialect *dialect, TypeID id)
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
DialectInterfaceBase(Dialect *dialect)
This class is the base class for a collection of instances for a specific interface kind...
iterator< InterfaceT > interface_begin() const
Iterator access to the held interfaces.
DialectInterfaceCollection(MLIRContext *ctx)
Collect the registered dialect interfaces within the provided context.
MLIRContext is the top-level object for a collection of MLIR operations.
const DialectInterface * getInterfaceFor(Operation *op) const
Get the interface for the dialect of given operation, or null if one is not registered.
llvm::hash_code hash_value(const StructType::MemberDecorationInfo &memberDecorationInfo)
This class represents an interface overridden for a single dialect.