aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/experimental/simd
diff options
context:
space:
mode:
authordanlark <danlark@yandex-team.ru>2022-02-10 16:46:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:08 +0300
commit3426a9bc7f169ae9da54cef557ad2a33f6e8eee0 (patch)
tree26154e1e9990f1bb4525d3e3fb5b6dac2c2c1da2 /contrib/libs/cxxsupp/libcxx/include/experimental/simd
parentcb68f224c46a8ee52ac3fdd2a32534b8bb8dc134 (diff)
downloadydb-3426a9bc7f169ae9da54cef557ad2a33f6e8eee0.tar.gz
Restoring authorship annotation for <danlark@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/experimental/simd')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/experimental/simd670
1 files changed, 335 insertions, 335 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/simd b/contrib/libs/cxxsupp/libcxx/include/experimental/simd
index 59a7139585..211d26da5b 100644
--- a/contrib/libs/cxxsupp/libcxx/include/experimental/simd
+++ b/contrib/libs/cxxsupp/libcxx/include/experimental/simd
@@ -1,9 +1,9 @@
// -*- C++ -*-
//===------------------------------- simd ---------------------------------===//
//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_SIMD
@@ -650,7 +650,7 @@ public:
*/
#include <experimental/__config>
-#include <algorithm>
+#include <algorithm>
#include <array>
#include <cstddef>
#include <functional>
@@ -664,248 +664,248 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
-#if _LIBCPP_STD_VER >= 17
-
+#if _LIBCPP_STD_VER >= 17
+
enum class _StorageKind {
_Scalar,
_Array,
- _VecExt,
+ _VecExt,
};
template <_StorageKind __kind, int _Np>
struct __simd_abi {};
template <class _Tp, class _Abi>
-class __simd_storage {};
+class __simd_storage {};
template <class _Tp, int __num_element>
-class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> {
- std::array<_Tp, __num_element> __storage_;
-
- template <class, class>
- friend struct simd;
-
- template <class, class>
- friend struct simd_mask;
-
-public:
- _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
- void __set(size_t __index, _Tp __val) noexcept {
- __storage_[__index] = __val;
- }
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> {
+ std::array<_Tp, __num_element> __storage_;
+
+ template <class, class>
+ friend struct simd;
+
+ template <class, class>
+ friend struct simd_mask;
+
+public:
+ _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
+ void __set(size_t __index, _Tp __val) noexcept {
+ __storage_[__index] = __val;
+ }
};
template <class _Tp>
-class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> {
- _Tp __storage_;
-
- template <class, class>
- friend struct simd;
-
- template <class, class>
- friend struct simd_mask;
-
-public:
- _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; };
- void __set(size_t __index, _Tp __val) noexcept {
- (&__storage_)[__index] = __val;
- }
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> {
+ _Tp __storage_;
+
+ template <class, class>
+ friend struct simd;
+
+ template <class, class>
+ friend struct simd_mask;
+
+public:
+ _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; };
+ void __set(size_t __index, _Tp __val) noexcept {
+ (&__storage_)[__index] = __val;
+ }
};
-#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
-
-constexpr size_t __floor_pow_of_2(size_t __val) {
- return ((__val - 1) & __val) == 0 ? __val
- : __floor_pow_of_2((__val - 1) & __val);
-}
-
-constexpr size_t __ceil_pow_of_2(size_t __val) {
- return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;
-}
-
-template <class _Tp, size_t __bytes>
-struct __vec_ext_traits {
+#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
+constexpr size_t __floor_pow_of_2(size_t __val) {
+ return ((__val - 1) & __val) == 0 ? __val
+ : __floor_pow_of_2((__val - 1) & __val);
+}
+
+constexpr size_t __ceil_pow_of_2(size_t __val) {
+ return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;
+}
+
+template <class _Tp, size_t __bytes>
+struct __vec_ext_traits {
#if !defined(_LIBCPP_COMPILER_CLANG_BASED)
- typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes))));
-#endif
-};
-
+ typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes))));
+#endif
+};
+
#if defined(_LIBCPP_COMPILER_CLANG_BASED)
-#define _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT) \
- template <> \
- struct __vec_ext_traits<_TYPE, sizeof(_TYPE) * _NUM_ELEMENT> { \
- using type = \
- _TYPE __attribute__((vector_size(sizeof(_TYPE) * _NUM_ELEMENT))); \
- }
-
-#define _LIBCPP_SPECIALIZE_VEC_EXT_32(_TYPE) \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 1); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 2); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 3); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 4); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 5); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 6); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 7); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 8); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 9); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 10); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 11); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 12); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 13); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 14); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 15); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 16); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 17); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 18); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 19); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 20); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 21); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 22); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 23); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 24); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 25); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 26); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 27); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 28); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 29); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 30); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 31); \
- _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 32);
-
-_LIBCPP_SPECIALIZE_VEC_EXT_32(char);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(char16_t);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(char32_t);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(wchar_t);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(signed char);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(signed short);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(signed int);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long long);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned char);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned short);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned int);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long long);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(float);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(double);
-_LIBCPP_SPECIALIZE_VEC_EXT_32(long double);
-
-#undef _LIBCPP_SPECIALIZE_VEC_EXT_32
-#undef _LIBCPP_SPECIALIZE_VEC_EXT
-#endif
-
-template <class _Tp, int __num_element>
-class __simd_storage<_Tp, __simd_abi<_StorageKind::_VecExt, __num_element>> {
- using _StorageType =
- typename __vec_ext_traits<_Tp, sizeof(_Tp) * __num_element>::type;
-
- _StorageType __storage_;
-
- template <class, class>
- friend struct simd;
-
- template <class, class>
- friend struct simd_mask;
-
-public:
- _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
- void __set(size_t __index, _Tp __val) noexcept {
- __storage_[__index] = __val;
- }
-};
-
-#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION
-
-template <class _Vp, class _Tp, class _Abi>
-class __simd_reference {
- static_assert(std::is_same<_Vp, _Tp>::value, "");
-
- template <class, class>
- friend struct simd;
-
- template <class, class>
- friend struct simd_mask;
-
- __simd_storage<_Tp, _Abi>* __ptr_;
- size_t __index_;
-
- __simd_reference(__simd_storage<_Tp, _Abi>* __ptr, size_t __index)
- : __ptr_(__ptr), __index_(__index) {}
-
- __simd_reference(const __simd_reference&) = default;
-
-public:
- __simd_reference() = delete;
- __simd_reference& operator=(const __simd_reference&) = delete;
-
- operator _Vp() const { return __ptr_->__get(__index_); }
-
- __simd_reference operator=(_Vp __value) && {
- __ptr_->__set(__index_, __value);
- return *this;
- }
-
- __simd_reference operator++() && {
- return std::move(*this) = __ptr_->__get(__index_) + 1;
- }
-
- _Vp operator++(int) && {
- auto __val = __ptr_->__get(__index_);
- __ptr_->__set(__index_, __val + 1);
- return __val;
- }
-
- __simd_reference operator--() && {
- return std::move(*this) = __ptr_->__get(__index_) - 1;
- }
-
- _Vp operator--(int) && {
- auto __val = __ptr_->__get(__index_);
- __ptr_->__set(__index_, __val - 1);
- return __val;
- }
-
- __simd_reference operator+=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) + __value;
- }
-
- __simd_reference operator-=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) - __value;
- }
-
- __simd_reference operator*=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) * __value;
- }
-
- __simd_reference operator/=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) / __value;
- }
-
- __simd_reference operator%=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) % __value;
- }
-
- __simd_reference operator>>=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) >> __value;
- }
-
- __simd_reference operator<<=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) << __value;
- }
-
- __simd_reference operator&=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) & __value;
- }
-
- __simd_reference operator|=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) | __value;
- }
-
- __simd_reference operator^=(_Vp __value) && {
- return std::move(*this) = __ptr_->__get(__index_) ^ __value;
- }
-};
-
+#define _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT) \
+ template <> \
+ struct __vec_ext_traits<_TYPE, sizeof(_TYPE) * _NUM_ELEMENT> { \
+ using type = \
+ _TYPE __attribute__((vector_size(sizeof(_TYPE) * _NUM_ELEMENT))); \
+ }
+
+#define _LIBCPP_SPECIALIZE_VEC_EXT_32(_TYPE) \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 1); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 2); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 3); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 4); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 5); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 6); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 7); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 8); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 9); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 10); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 11); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 12); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 13); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 14); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 15); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 16); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 17); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 18); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 19); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 20); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 21); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 22); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 23); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 24); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 25); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 26); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 27); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 28); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 29); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 30); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 31); \
+ _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 32);
+
+_LIBCPP_SPECIALIZE_VEC_EXT_32(char);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(char16_t);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(char32_t);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(wchar_t);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed char);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed short);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed int);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned char);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned short);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned int);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long long);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(float);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(double);
+_LIBCPP_SPECIALIZE_VEC_EXT_32(long double);
+
+#undef _LIBCPP_SPECIALIZE_VEC_EXT_32
+#undef _LIBCPP_SPECIALIZE_VEC_EXT
+#endif
+
+template <class _Tp, int __num_element>
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_VecExt, __num_element>> {
+ using _StorageType =
+ typename __vec_ext_traits<_Tp, sizeof(_Tp) * __num_element>::type;
+
+ _StorageType __storage_;
+
+ template <class, class>
+ friend struct simd;
+
+ template <class, class>
+ friend struct simd_mask;
+
+public:
+ _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
+ void __set(size_t __index, _Tp __val) noexcept {
+ __storage_[__index] = __val;
+ }
+};
+
+#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
+template <class _Vp, class _Tp, class _Abi>
+class __simd_reference {
+ static_assert(std::is_same<_Vp, _Tp>::value, "");
+
+ template <class, class>
+ friend struct simd;
+
+ template <class, class>
+ friend struct simd_mask;
+
+ __simd_storage<_Tp, _Abi>* __ptr_;
+ size_t __index_;
+
+ __simd_reference(__simd_storage<_Tp, _Abi>* __ptr, size_t __index)
+ : __ptr_(__ptr), __index_(__index) {}
+
+ __simd_reference(const __simd_reference&) = default;
+
+public:
+ __simd_reference() = delete;
+ __simd_reference& operator=(const __simd_reference&) = delete;
+
+ operator _Vp() const { return __ptr_->__get(__index_); }
+
+ __simd_reference operator=(_Vp __value) && {
+ __ptr_->__set(__index_, __value);
+ return *this;
+ }
+
+ __simd_reference operator++() && {
+ return std::move(*this) = __ptr_->__get(__index_) + 1;
+ }
+
+ _Vp operator++(int) && {
+ auto __val = __ptr_->__get(__index_);
+ __ptr_->__set(__index_, __val + 1);
+ return __val;
+ }
+
+ __simd_reference operator--() && {
+ return std::move(*this) = __ptr_->__get(__index_) - 1;
+ }
+
+ _Vp operator--(int) && {
+ auto __val = __ptr_->__get(__index_);
+ __ptr_->__set(__index_, __val - 1);
+ return __val;
+ }
+
+ __simd_reference operator+=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) + __value;
+ }
+
+ __simd_reference operator-=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) - __value;
+ }
+
+ __simd_reference operator*=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) * __value;
+ }
+
+ __simd_reference operator/=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) / __value;
+ }
+
+ __simd_reference operator%=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) % __value;
+ }
+
+ __simd_reference operator>>=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) >> __value;
+ }
+
+ __simd_reference operator<<=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) << __value;
+ }
+
+ __simd_reference operator&=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) & __value;
+ }
+
+ __simd_reference operator|=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) | __value;
+ }
+
+ __simd_reference operator^=(_Vp __value) && {
+ return std::move(*this) = __ptr_->__get(__index_) ^ __value;
+ }
+};
+
template <class _To, class _From>
constexpr decltype(_To{std::declval<_From>()}, true)
__is_non_narrowing_convertible_impl(_From) {
@@ -943,17 +943,17 @@ constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {
return static_cast<_Tp>(__first) + __variadic_sum<_Tp>(__rest...);
}
-template <class _Tp>
-struct __nodeduce {
- using type = _Tp;
-};
-
-template <class _Tp>
-constexpr bool __vectorizable() {
- return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value &&
- !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value;
-}
-
+template <class _Tp>
+struct __nodeduce {
+ using type = _Tp;
+};
+
+template <class _Tp>
+constexpr bool __vectorizable() {
+ return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value &&
+ !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value;
+}
+
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI
@@ -964,19 +964,19 @@ using fixed_size = __simd_abi<_StorageKind::_Array, _Np>;
template <class _Tp>
inline constexpr size_t max_fixed_size = 32;
-
+
template <class _Tp>
using compatible = fixed_size<16 / sizeof(_Tp)>;
-
-#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
-template <class _Tp>
-using native = __simd_abi<_StorageKind::_VecExt,
- _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
-#else
+
+#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
template <class _Tp>
-using native =
- fixed_size<_Tp, _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
-#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION
+using native = __simd_abi<_StorageKind::_VecExt,
+ _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
+#else
+template <class _Tp>
+using native =
+ fixed_size<_Tp, _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
+#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
@@ -1058,7 +1058,7 @@ struct simd_size<_Tp, __simd_abi<__kind, _Np>>
"Element type should be vectorizable");
};
-// TODO: implement it.
+// TODO: implement it.
template <class _Tp, class _Up = typename _Tp::value_type>
struct memory_alignment;
@@ -1340,23 +1340,23 @@ public:
// TODO: implement simd
template <class _Tp, class _Abi>
class simd {
-public:
- using value_type = _Tp;
- using reference = __simd_reference<_Tp, _Tp, _Abi>;
- using mask_type = simd_mask<_Tp, _Abi>;
- using abi_type = _Abi;
-
- simd() = default;
- simd(const simd&) = default;
- simd& operator=(const simd&) = default;
-
- static constexpr size_t size() noexcept {
- return simd_size<_Tp, _Abi>::value;
- }
-
+public:
+ using value_type = _Tp;
+ using reference = __simd_reference<_Tp, _Tp, _Abi>;
+ using mask_type = simd_mask<_Tp, _Abi>;
+ using abi_type = _Abi;
+
+ simd() = default;
+ simd(const simd&) = default;
+ simd& operator=(const simd&) = default;
+
+ static constexpr size_t size() noexcept {
+ return simd_size<_Tp, _Abi>::value;
+ }
+
private:
- __simd_storage<_Tp, _Abi> __s_;
-
+ __simd_storage<_Tp, _Abi> __s_;
+
template <class _Up>
static constexpr bool __can_broadcast() {
return (std::is_arithmetic<_Up>::value &&
@@ -1369,98 +1369,98 @@ private:
std::is_unsigned<_Tp>::value);
}
- template <class _Generator, size_t... __indicies>
- static constexpr decltype(
- std::forward_as_tuple(std::declval<_Generator>()(
- std::integral_constant<size_t, __indicies>())...),
- bool())
- __can_generate(std::index_sequence<__indicies...>) {
- return !__variadic_sum<bool>(
- !__can_broadcast<decltype(std::declval<_Generator>()(
- std::integral_constant<size_t, __indicies>()))>()...);
+ template <class _Generator, size_t... __indicies>
+ static constexpr decltype(
+ std::forward_as_tuple(std::declval<_Generator>()(
+ std::integral_constant<size_t, __indicies>())...),
+ bool())
+ __can_generate(std::index_sequence<__indicies...>) {
+ return !__variadic_sum<bool>(
+ !__can_broadcast<decltype(std::declval<_Generator>()(
+ std::integral_constant<size_t, __indicies>()))>()...);
+ }
+
+ template <class _Generator>
+ static bool __can_generate(...) {
+ return false;
+ }
+
+ template <class _Generator, size_t... __indicies>
+ void __generator_init(_Generator&& __g, std::index_sequence<__indicies...>) {
+ int __not_used[]{((*this)[__indicies] =
+ __g(std::integral_constant<size_t, __indicies>()),
+ 0)...};
+ (void)__not_used;
}
- template <class _Generator>
- static bool __can_generate(...) {
- return false;
- }
-
- template <class _Generator, size_t... __indicies>
- void __generator_init(_Generator&& __g, std::index_sequence<__indicies...>) {
- int __not_used[]{((*this)[__indicies] =
- __g(std::integral_constant<size_t, __indicies>()),
- 0)...};
- (void)__not_used;
- }
-
-public:
+public:
// implicit type conversion constructor
template <class _Up,
class = typename std::enable_if<
std::is_same<_Abi, simd_abi::fixed_size<size()>>::value &&
__is_non_narrowing_arithmetic_convertible<_Up, _Tp>()>::type>
- simd(const simd<_Up, simd_abi::fixed_size<size()>>& __v) {
- for (size_t __i = 0; __i < size(); __i++) {
- (*this)[__i] = static_cast<_Tp>(__v[__i]);
- }
- }
+ simd(const simd<_Up, simd_abi::fixed_size<size()>>& __v) {
+ for (size_t __i = 0; __i < size(); __i++) {
+ (*this)[__i] = static_cast<_Tp>(__v[__i]);
+ }
+ }
// implicit broadcast constructor
template <class _Up,
class = typename std::enable_if<__can_broadcast<_Up>()>::type>
- simd(_Up&& __rv) {
- auto __v = static_cast<_Tp>(__rv);
- for (size_t __i = 0; __i < size(); __i++) {
- (*this)[__i] = __v;
- }
- }
+ simd(_Up&& __rv) {
+ auto __v = static_cast<_Tp>(__rv);
+ for (size_t __i = 0; __i < size(); __i++) {
+ (*this)[__i] = __v;
+ }
+ }
// generator constructor
template <class _Generator,
- int = typename std::enable_if<
- __can_generate<_Generator>(std::make_index_sequence<size()>()),
- int>::type()>
- explicit simd(_Generator&& __g) {
- __generator_init(std::forward<_Generator>(__g),
- std::make_index_sequence<size()>());
- }
+ int = typename std::enable_if<
+ __can_generate<_Generator>(std::make_index_sequence<size()>()),
+ int>::type()>
+ explicit simd(_Generator&& __g) {
+ __generator_init(std::forward<_Generator>(__g),
+ std::make_index_sequence<size()>());
+ }
// load constructor
- template <
- class _Up, class _Flags,
- class = typename std::enable_if<__vectorizable<_Up>()>::type,
- class = typename std::enable_if<is_simd_flag_type<_Flags>::value>::type>
- simd(const _Up* __buffer, _Flags) {
- // TODO: optimize for overaligned flags
- for (size_t __i = 0; __i < size(); __i++) {
- (*this)[__i] = static_cast<_Tp>(__buffer[__i]);
- }
- }
+ template <
+ class _Up, class _Flags,
+ class = typename std::enable_if<__vectorizable<_Up>()>::type,
+ class = typename std::enable_if<is_simd_flag_type<_Flags>::value>::type>
+ simd(const _Up* __buffer, _Flags) {
+ // TODO: optimize for overaligned flags
+ for (size_t __i = 0; __i < size(); __i++) {
+ (*this)[__i] = static_cast<_Tp>(__buffer[__i]);
+ }
+ }
// loads [simd.load]
template <class _Up, class _Flags>
- typename std::enable_if<__vectorizable<_Up>() &&
- is_simd_flag_type<_Flags>::value>::type
- copy_from(const _Up* __buffer, _Flags) {
- *this = simd(__buffer, _Flags());
- }
+ typename std::enable_if<__vectorizable<_Up>() &&
+ is_simd_flag_type<_Flags>::value>::type
+ copy_from(const _Up* __buffer, _Flags) {
+ *this = simd(__buffer, _Flags());
+ }
// stores [simd.store]
template <class _Up, class _Flags>
- typename std::enable_if<__vectorizable<_Up>() &&
- is_simd_flag_type<_Flags>::value>::type
- copy_to(_Up* __buffer, _Flags) const {
- // TODO: optimize for overaligned flags
- for (size_t __i = 0; __i < size(); __i++) {
- __buffer[__i] = static_cast<_Up>((*this)[__i]);
- }
- }
+ typename std::enable_if<__vectorizable<_Up>() &&
+ is_simd_flag_type<_Flags>::value>::type
+ copy_to(_Up* __buffer, _Flags) const {
+ // TODO: optimize for overaligned flags
+ for (size_t __i = 0; __i < size(); __i++) {
+ __buffer[__i] = static_cast<_Up>((*this)[__i]);
+ }
+ }
// scalar access [simd.subscr]
- reference operator[](size_t __i) { return reference(&__s_, __i); }
-
- value_type operator[](size_t __i) const { return __s_.__get(__i); }
+ reference operator[](size_t __i) { return reference(&__s_, __i); }
+ value_type operator[](size_t __i) const { return __s_.__get(__i); }
+
// unary operators [simd.unary]
simd& operator++();
simd operator++(int);
@@ -1563,8 +1563,8 @@ public:
friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept;
};
-#endif // _LIBCPP_STD_VER >= 17
-
+#endif // _LIBCPP_STD_VER >= 17
+
_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
_LIBCPP_POP_MACROS