14#ifndef MLIR_DIALECT_LLVMIR_LLVMMEMORYOPS_H_
15#define MLIR_DIALECT_LLVMIR_LLVMMEMORYOPS_H_
19#include "llvm/ADT/PointerEmbeddedInt.h"
23template <
typename Values>
30 llvm::PointerEmbeddedInt<int32_t, kGEPConstantBitWidth>;
41 GEPArg(int32_t integer) : BaseT(integer) {}
46 using BaseT::operator=;
52#include "mlir/Dialect/LLVMIR/LLVMMemoryOps.h.inc"
69template <
typename DynamicRange>
79 llvm::detail::ValueOfRange<DynamicRange>>::value,
86 : rawConstantIndices(rawConstantIndices), values(std::move(values)) {}
94 assert(
index <
size() &&
"index out of bounds");
100 return rawConstantIndices[
index] == GEPOp::kDynamicIndex;
104 size_t size()
const {
return rawConstantIndices.size(); }
107 bool empty()
const {
return rawConstantIndices.empty(); }
110 :
public llvm::iterator_facade_base<iterator, std::forward_iterator_tag,
111 value_type, std::ptrdiff_t,
112 value_type *, value_type> {
116 llvm::detail::IterOfRange<const DynamicRange> valuesIter)
117 : base(base), rawConstantIter(rawConstantIter), valuesIter(valuesIter) {
121 if (*rawConstantIter == GEPOp::kDynamicIndex)
124 return IntegerAttr::get(base->rawConstantIndices.getElementType(),
129 if (*rawConstantIter == GEPOp::kDynamicIndex)
136 return base == rhs.base && rawConstantIter == rhs.rawConstantIter &&
137 valuesIter == rhs.valuesIter;
143 llvm::detail::IterOfRange<const DynamicRange> valuesIter;
148 return iterator(
this, rawConstantIndices.asArrayRef().begin(),
154 return iterator(
this, rawConstantIndices.asArrayRef().end(), values.end());
166template <
typename To>
168 :
public CastInfo<To, mlir::LLVM::GEPArg::PointerUnion> {};
170template <
typename To>
172 :
public CastInfo<To, const mlir::LLVM::GEPArg::PointerUnion> {};
Attributes are known-constant values of operations.
GEPArg(int32_t integer)
Constructs a GEPArg with a constant index.
GEPArg(Value value)
Constructs a GEPArg with a dynamic index.
iterator(const GEPIndicesAdaptor *base, ArrayRef< int32_t >::iterator rawConstantIter, llvm::detail::IterOfRange< const DynamicRange > valuesIter)
bool operator==(const iterator &rhs) const
value_type operator*() const
Class used for convenient access and iteration over GEP indices.
iterator begin() const
Returns the begin iterator, iterating over all GEP indices.
std::conditional_t< std::is_base_of< Attribute, llvm::detail::ValueOfRange< DynamicRange > >::value, Attribute, PointerUnion< IntegerAttr, llvm::detail::ValueOfRange< DynamicRange > > > value_type
Return type of 'operator[]' and the iterators 'operator*'.
iterator end() const
Returns the end iterator, iterating over all GEP indices.
bool isDynamicIndex(size_t index) const
Returns whether the GEP index at the given position is a dynamic index.
size_t size() const
Returns the amount of indices of the GEPOp.
bool empty() const
Returns true if this GEPOp does not have any indices.
value_type operator[](size_t index) const
Returns the GEP index at the given position.
GEPIndicesAdaptor(DenseI32ArrayAttr rawConstantIndices, DynamicRange values)
Constructs a GEPIndicesAdaptor with the raw constant indices of a GEPOp and the range that is indexed...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
The OpAsmOpInterface, see OpAsmInterface.td for more details.
llvm::PointerEmbeddedInt< int32_t, kGEPConstantBitWidth > GEPConstantIndex
Wrapper around a int32_t for use in a PointerUnion.
constexpr int kGEPConstantBitWidth
Bit-width of a 'GEPConstantIndex' within GEPArg.
Include the generated interface declarations.
detail::DenseArrayAttrImpl< int32_t > DenseI32ArrayAttr