MLIR  19.0.0git
Static Public Member Functions | List of all members
llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::Attribute, std::remove_const_t< From > >||std::is_base_of_v< mlir::Attribute, From > > > Struct Template Reference

Add support for llvm style casts. More...

#include "mlir/IR/Attributes.h"

+ Inheritance diagram for llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::Attribute, std::remove_const_t< From > >||std::is_base_of_v< mlir::Attribute, From > > >:

Static Public Member Functions

static bool isPossible (mlir::Attribute ty)
 Arguments are taken as mlir::Attribute here and not as From, because when casting from an intermediate type of the hierarchy to one of its children, the val.getTypeID() inside T::classof will use the static getTypeID of the parent instead of the non-static Type::getTypeID that returns the dynamic ID. More...
 
static To doCast (mlir::Attribute attr)
 

Detailed Description

template<typename To, typename From>
struct llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::Attribute, std::remove_const_t< From > >||std::is_base_of_v< mlir::Attribute, From > > >

Add support for llvm style casts.

We provide a cast between To and From if From is mlir::Attribute or derives from it.

Definition at line 399 of file Attributes.h.

Member Function Documentation

◆ doCast()

template<typename To , typename From >
static To llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::Attribute, std::remove_const_t< From > >||std::is_base_of_v< mlir::Attribute, From > > >::doCast ( mlir::Attribute  attr)
inlinestatic

Definition at line 421 of file Attributes.h.

References mlir::Attribute::getImpl().

◆ isPossible()

template<typename To , typename From >
static bool llvm::CastInfo< To, From, std::enable_if_t< std::is_same_v< mlir::Attribute, std::remove_const_t< From > >||std::is_base_of_v< mlir::Attribute, From > > >::isPossible ( mlir::Attribute  ty)
inlinestatic

Arguments are taken as mlir::Attribute here and not as From, because when casting from an intermediate type of the hierarchy to one of its children, the val.getTypeID() inside T::classof will use the static getTypeID of the parent instead of the non-static Type::getTypeID that returns the dynamic ID.

This means that T::classof would end up comparing the static TypeID of the children to the static TypeID of its parent, making it impossible to downcast from the parent to the child.

Return a constant true instead of a dynamic true when casting to self or up the hierarchy.

Definition at line 412 of file Attributes.h.


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