MLIR 22.0.0git
mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait > Class Template Reference

This class represents an abstract interface. More...

#include "mlir/Support/InterfaceSupport.h"

Inheritance diagram for mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >:

Classes

struct  Trait
 This is a special trait that registers a given interface with an object. More...

Public Types

using Concept = typename Traits::Concept
template<typename T>
using Model = typename Traits::template Model<T>
template<typename T>
using FallbackModel = typename Traits::template FallbackModel<T>
using InterfaceBase
template<typename T, typename U>
using ExternalModel = typename Traits::template ExternalModel<T, U>
using ValueType = ValueT

Public Member Functions

 Interface (ValueT t=ValueT())
 Construct an interface from an instance of the value type.
 Interface (std::nullptr_t)
template<typename T, std::enable_if_t< std::is_base_of< Trait< T >, T >::value > * = nullptr>
 Interface (T t)
 Construct an interface instance from a type that implements this interface's trait.
 Interface (ValueT t, const Concept *conceptImpl)
 Constructor for a known concept.
 Interface (ValueT t, std::nullptr_t)
 Constructor for DenseMapInfo's empty key and tombstone key.

Static Public Member Functions

static bool classof (ValueT t)
 Support 'classof' by checking if the given object defines the concrete interface.
static TypeID getInterfaceID ()
 Define an accessor for the ID of this interface.

Protected Member Functions

const ConceptgetImpl () const
 Get the raw concept in the correct derived concept type.
ConceptgetImpl ()

Detailed Description

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
class mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >

This class represents an abstract interface.

An interface is a simplified mechanism for attaching concept based polymorphism to a class hierarchy. An interface is comprised of two components:

  • The derived interface class: This is what users interact with, and invoke methods on.
  • An interface Trait class: This is the class that is attached to the object implementing the interface. It is the mechanism with which models are specialized.

Derived interfaces types must provide the following template types:

  • ConcreteType: The CRTP derived type.
  • ValueT: The opaque type the derived interface operates on. For example Operation* for operation interfaces, or Attribute for attribute interfaces.
  • Traits: A class that contains definitions for a 'Concept' and a 'Model' class. The 'Concept' class defines an abstract virtual interface, where as the 'Model' class implements this interface for a specific derived T type. Both of these classes must not contain non-static data. A simple example is shown below:
struct ExampleInterfaceTraits {
struct Concept {
virtual unsigned getNumInputs(T t) const = 0;
};
template <typename DerivedT> class Model {
unsigned getNumInputs(T t) const final {
return cast<DerivedT>(t).getNumInputs();
}
};
};
typename Traits::Concept Concept
  • BaseType: A desired base type for the interface. This is a class that provides specific functionality for the ValueT value. For instance the specific Op that will wrap the Operation* for an OpInterface.
  • BaseTrait: The base type for the interface trait. This is the base class to use for the interface trait that will be attached to each instance of ValueT that implements this interface.

Definition at line 71 of file InterfaceSupport.h.

Member Typedef Documentation

◆ Concept

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
using mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::Concept = typename Traits::Concept

Definition at line 73 of file InterfaceSupport.h.

◆ ExternalModel

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
template<typename T, typename U>
using mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::ExternalModel = typename Traits::template ExternalModel<T, U>

Definition at line 81 of file InterfaceSupport.h.

◆ FallbackModel

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
template<typename T>
using mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::FallbackModel = typename Traits::template FallbackModel<T>

Definition at line 77 of file InterfaceSupport.h.

◆ InterfaceBase

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
using mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::InterfaceBase
Initial value:
Interface(ValueT t=ValueT())
Construct an interface from an instance of the value type.

Definition at line 78 of file InterfaceSupport.h.

◆ Model

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
template<typename T>
using mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::Model = typename Traits::template Model<T>

Definition at line 75 of file InterfaceSupport.h.

◆ ValueType

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
using mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::ValueType = ValueT

Definition at line 82 of file InterfaceSupport.h.

Constructor & Destructor Documentation

◆ Interface() [1/5]

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::Interface ( ValueT t = ValueT())
inlineexplicit

Construct an interface from an instance of the value type.

Definition at line 94 of file InterfaceSupport.h.

◆ Interface() [2/5]

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::Interface ( std::nullptr_t )
inline

Definition at line 100 of file InterfaceSupport.h.

◆ Interface() [3/5]

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
template<typename T, std::enable_if_t< std::is_base_of< Trait< T >, T >::value > * = nullptr>
mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::Interface ( T t)
inline

Construct an interface instance from a type that implements this interface's trait.

Definition at line 106 of file InterfaceSupport.h.

◆ Interface() [4/5]

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::Interface ( ValueT t,
const Concept * conceptImpl )
inline

Constructor for a known concept.

Definition at line 114 of file InterfaceSupport.h.

◆ Interface() [5/5]

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::Interface ( ValueT t,
std::nullptr_t  )
inline

Constructor for DenseMapInfo's empty key and tombstone key.

Definition at line 120 of file InterfaceSupport.h.

Member Function Documentation

◆ classof()

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
bool mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::classof ( ValueT t)
inlinestatic

Support 'classof' by checking if the given object defines the concrete interface.

Definition at line 124 of file InterfaceSupport.h.

◆ getImpl() [1/2]

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
Concept * mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::getImpl ( )
inlineprotected

Definition at line 132 of file InterfaceSupport.h.

◆ getImpl() [2/2]

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
const Concept * mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::getImpl ( ) const
inlineprotected

Get the raw concept in the correct derived concept type.

Definition at line 131 of file InterfaceSupport.h.

◆ getInterfaceID()

template<typename ConcreteType, typename ValueT, typename Traits, typename BaseType, template< typename, template< typename > class > class BaseTrait>
TypeID mlir::detail::Interface< ConcreteType, ValueT, Traits, BaseType, BaseTrait >::getInterfaceID ( )
inlinestatic

Define an accessor for the ID of this interface.

Definition at line 127 of file InterfaceSupport.h.


The documentation for this class was generated from the following file: