MLIR  18.0.0git
Classes | Public Types | Public Member Functions | List of all members
mlir::LLVM::GEPIndicesAdaptor< DynamicRange > Class Template Reference

Class used for convenient access and iteration over GEP indices. More...

#include "mlir/Dialect/LLVMIR/LLVMDialect.h"

Classes

class  iterator
 

Public Types

using value_type = std::conditional_t< std::is_base_of< Attribute, llvm::detail::ValueOfRange< DynamicRange > >::value, Attribute, PointerUnion< IntegerAttr, llvm::detail::ValueOfRange< DynamicRange > >>
 Return type of 'operator[]' and the iterators 'operator*'. More...
 

Public Member Functions

 GEPIndicesAdaptor (DenseI32ArrayAttr rawConstantIndices, DynamicRange values)
 Constructs a GEPIndicesAdaptor with the raw constant indices of a GEPOp and the range that is indexed into for retrieving dynamic indices. More...
 
value_type operator[] (size_t index) const
 Returns the GEP index at the given position. More...
 
bool isDynamicIndex (size_t index) const
 Returns whether the GEP index at the given position is a dynamic index. More...
 
size_t size () const
 Returns the amount of indices of the GEPOp. More...
 
bool empty () const
 Returns true if this GEPOp does not have any indices. More...
 
iterator begin () const
 Returns the begin iterator, iterating over all GEP indices. More...
 
iterator end () const
 Returns the end iterator, iterating over all GEP indices. More...
 

Detailed Description

template<typename DynamicRange>
class mlir::LLVM::GEPIndicesAdaptor< DynamicRange >

Class used for convenient access and iteration over GEP indices.

This class is templated to support not only retrieving the dynamic operands of a GEP operation, but also as an adaptor during folding or conversion to LLVM IR.

GEP indices may either be constant indices or dynamic indices. The 'rawConstantIndices' is specially encoded by GEPOp and contains either the constant index or the information that an index is a dynamic index.

When an access to such an index is made it is done through the 'DynamicRange' of this class. This way it can be used as getter in GEPOp via 'GEPIndicesAdaptor<ValueRange>' or during folding via 'GEPIndicesAdaptor<ArrayRef<Attribute>>'.

Definition at line 115 of file LLVMDialect.h.

Member Typedef Documentation

◆ value_type

template<typename DynamicRange >
using mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::value_type = std::conditional_t< std::is_base_of<Attribute, llvm::detail::ValueOfRange<DynamicRange> >::value, Attribute, PointerUnion<IntegerAttr, llvm::detail::ValueOfRange<DynamicRange> >>

Return type of 'operator[]' and the iterators 'operator*'.

It is depended upon the value type of 'DynamicRange'. If 'DynamicRange' contains Attributes or subclasses thereof, then value_type is 'Attribute'. In all other cases it is a pointer union between the value type of 'DynamicRange' and IntegerAttr.

Definition at line 122 of file LLVMDialect.h.

Constructor & Destructor Documentation

◆ GEPIndicesAdaptor()

template<typename DynamicRange >
mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::GEPIndicesAdaptor ( DenseI32ArrayAttr  rawConstantIndices,
DynamicRange  values 
)
inline

Constructs a GEPIndicesAdaptor with the raw constant indices of a GEPOp and the range that is indexed into for retrieving dynamic indices.

Definition at line 130 of file LLVMDialect.h.

Member Function Documentation

◆ begin()

template<typename DynamicRange >
iterator mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::begin ( ) const
inline

Returns the begin iterator, iterating over all GEP indices.

Definition at line 192 of file LLVMDialect.h.

References mlir::detail::DenseArrayAttrImpl< T >::asArrayRef().

Referenced by mlir::LLVM::SplitGEP::matchAndRewrite(), and mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::operator[]().

◆ empty()

template<typename DynamicRange >
bool mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::empty ( ) const
inline

Returns true if this GEPOp does not have any indices.

Definition at line 152 of file LLVMDialect.h.

◆ end()

template<typename DynamicRange >
iterator mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::end ( ) const
inline

Returns the end iterator, iterating over all GEP indices.

Definition at line 198 of file LLVMDialect.h.

References mlir::detail::DenseArrayAttrImpl< T >::asArrayRef().

Referenced by mlir::LLVM::SplitGEP::matchAndRewrite().

◆ isDynamicIndex()

template<typename DynamicRange >
bool mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::isDynamicIndex ( size_t  index) const
inline

Returns whether the GEP index at the given position is a dynamic index.

Definition at line 144 of file LLVMDialect.h.

◆ operator[]()

template<typename DynamicRange >
value_type mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::operator[] ( size_t  index) const
inline

Returns the GEP index at the given position.

Note that this operation has a linear complexity in regards to the accessed position. To iterate over all indices, use the iterators.

This operation is invalid if the index is out of bounds.

Definition at line 138 of file LLVMDialect.h.

References mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::begin(), and mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::size().

◆ size()

template<typename DynamicRange >
size_t mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::size ( ) const
inline

Returns the amount of indices of the GEPOp.

Definition at line 149 of file LLVMDialect.h.

Referenced by mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::operator[](), and verifyStructIndices().


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