MLIR  19.0.0git
Public Types | Public Member Functions | List of all members
mlir::AttrTypeWalker Class Reference

AttrTypeWalker. More...

#include "mlir/IR/AttrTypeSubElements.h"

Public Types

template<typename T >
using WalkFn = std::function< WalkResult(T)>
 

Public Member Functions

template<WalkOrder Order, typename T >
WalkResult walk (T element)
 Walk the given attribute/type, and recursively walk any sub elements. More...
 
template<typename T >
WalkResult walk (T element)
 
void addWalk (WalkFn< Attribute > &&fn)
 Register a walk function for a given attribute or type. More...
 
void addWalk (WalkFn< Type > &&fn)
 
template<typename FnT , typename T = typename llvm::function_traits< std::decay_t<FnT>>::template arg_t<0>, typename BaseT = std::conditional_t<std::is_base_of_v<Attribute, T>, Attribute, Type>, typename ResultT = std::invoke_result_t<FnT, T>>
std::enable_if_t<!std::is_same_v< T, BaseT >||std::is_same_v< ResultT, void > > addWalk (FnT &&callback)
 Register a replacement function that doesn't match the default signature, either because it uses a derived parameter type, or it uses a simplified result type. More...
 

Detailed Description

AttrTypeWalker.

This class provides a utility for walking attributes/types, and their sub elements. Multiple walk functions may be registered.

Definition at line 33 of file AttrTypeSubElements.h.

Member Typedef Documentation

◆ WalkFn

template<typename T >
using mlir::AttrTypeWalker::WalkFn = std::function<WalkResult(T)>

Definition at line 54 of file AttrTypeSubElements.h.

Member Function Documentation

◆ addWalk() [1/3]

template<typename FnT , typename T = typename llvm::function_traits< std::decay_t<FnT>>::template arg_t<0>, typename BaseT = std::conditional_t<std::is_base_of_v<Attribute, T>, Attribute, Type>, typename ResultT = std::invoke_result_t<FnT, T>>
std::enable_if_t<!std::is_same_v<T, BaseT> || std::is_same_v<ResultT, void> > mlir::AttrTypeWalker::addWalk ( FnT &&  callback)
inline

Register a replacement function that doesn't match the default signature, either because it uses a derived parameter type, or it uses a simplified result type.

Definition at line 83 of file AttrTypeSubElements.h.

References addWalk(), and mlir::WalkResult::advance().

◆ addWalk() [2/3]

void mlir::AttrTypeWalker::addWalk ( WalkFn< Attribute > &&  fn)
inline

Register a walk function for a given attribute or type.

A walk function must be convertible to any of the following forms(where T is a class derived from Type or Attribute:

  • WalkResult(T)
    • Returns a walk result, which can be used to control the walk
  • void(T)
    • Returns void, i.e. the walk always continues.

Note: When walking, the mostly recently added walk functions will be invoked first.

Definition at line 68 of file AttrTypeSubElements.h.

Referenced by addWalk(), deepCloneAliasScopes(), mlir::Attribute::walk(), and mlir::Type::walk().

◆ addWalk() [3/3]

void mlir::AttrTypeWalker::addWalk ( WalkFn< Type > &&  fn)
inline

Definition at line 71 of file AttrTypeSubElements.h.

◆ walk() [1/2]

template<WalkOrder Order, typename T >
WalkResult mlir::AttrTypeWalker::walk ( element)
inline

Walk the given attribute/type, and recursively walk any sub elements.

Definition at line 41 of file AttrTypeSubElements.h.

Referenced by deepCloneAliasScopes(), mlir::Attribute::walk(), and mlir::Type::walk().

◆ walk() [2/2]

template<typename T >
WalkResult mlir::AttrTypeWalker::walk ( element)
inline

Definition at line 45 of file AttrTypeSubElements.h.


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