X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Famd%2Fcompiler%2Faco_util.h;h=b04eaba55a11f50c1f21fc507ee9d7701bdecefc;hb=ddffcf362770940cfc6300ff4d90c0443937ccbb;hp=ec77ba5571658e806878819dbf26a7f9ffc75ee2;hpb=93c8ebfa780ebd1495095e794731881aef29e7d3;p=mesa.git diff --git a/src/amd/compiler/aco_util.h b/src/amd/compiler/aco_util.h index ec77ba55716..b04eaba55a1 100644 --- a/src/amd/compiler/aco_util.h +++ b/src/amd/compiler/aco_util.h @@ -47,8 +47,8 @@ public: using const_iterator = const_pointer; using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - using size_type = std::size_t; - using difference_type = std::ptrdiff_t; + using size_type = uint16_t; + using difference_type = ptrdiff_t; /*! \brief Compiler generated default constructor */ @@ -58,49 +58,49 @@ public: * \param[in] data Pointer to the underlying data array * \param[in] length The size of the span */ - constexpr span(pointer data, const size_type length) - : data{ data } , length{ length } {} + constexpr span(uint16_t offset, const size_type length) + : offset{ offset } , length{ length } {} /*! \brief Returns an iterator to the begin of the span * \return data */ constexpr iterator begin() noexcept { - return data; + return (pointer)((uintptr_t)this + offset); } /*! \brief Returns a const_iterator to the begin of the span * \return data */ constexpr const_iterator begin() const noexcept { - return data; + return (const_pointer)((uintptr_t)this + offset); } /*! \brief Returns an iterator to the end of the span * \return data + length */ constexpr iterator end() noexcept { - return std::next(data, length); + return std::next(begin(), length); } /*! \brief Returns a const_iterator to the end of the span * \return data + length */ constexpr const_iterator end() const noexcept { - return std::next(data, length); + return std::next(begin(), length); } /*! \brief Returns a const_iterator to the begin of the span * \return data */ constexpr const_iterator cbegin() const noexcept { - return data; + return begin(); } /*! \brief Returns a const_iterator to the end of the span * \return data + length */ constexpr const_iterator cend() const noexcept { - return std::next(data, length); + return std::next(begin(), length); } /*! \brief Returns a reverse_iterator to the end of the span @@ -151,7 +151,7 @@ public: */ constexpr reference operator[](const size_type index) noexcept { assert(length > index); - return *(std::next(data, index)); + return *(std::next(begin(), index)); } /*! \brief Unchecked const access operator @@ -160,7 +160,7 @@ public: */ constexpr const_reference operator[](const size_type index) const noexcept { assert(length > index); - return *(std::next(data, index)); + return *(std::next(begin(), index)); } /*! \brief Returns a reference to the last element of the span @@ -168,7 +168,7 @@ public: */ constexpr reference back() noexcept { assert(length > 0); - return *(std::next(data, length - 1)); + return *(std::next(begin(), length - 1)); } /*! \brief Returns a const_reference to the last element of the span @@ -176,7 +176,7 @@ public: */ constexpr const_reference back() const noexcept { assert(length > 0); - return *(std::next(data, length - 1)); + return *(std::next(begin(), length - 1)); } /*! \brief Returns a reference to the first element of the span @@ -219,15 +219,15 @@ public: /*! \brief Clears the span */ constexpr void clear() noexcept { - data = nullptr; + offset = 0; length = 0; } private: - pointer data{ nullptr }; //!> Pointer to the underlying data array + uint16_t offset{ 0 }; //!> Byte offset from span to data size_type length{ 0 }; //!> Size of the span }; } // namespace aco -#endif // ACO_UTIL_H \ No newline at end of file +#endif // ACO_UTIL_H