File indexing completed on 2026-05-03 08:13:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03_EXPERIMENTAL___SIMD_SCALAR_H
0011 #define _LIBCPP___CXX03_EXPERIMENTAL___SIMD_SCALAR_H
0012
0013 #include <__cxx03/__assert>
0014 #include <__cxx03/cstddef>
0015 #include <__cxx03/experimental/__config>
0016 #include <__cxx03/experimental/__simd/declaration.h>
0017 #include <__cxx03/experimental/__simd/traits.h>
0018
0019 #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
0020
0021 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
0022 inline namespace parallelism_v2 {
0023 namespace simd_abi {
0024 struct __scalar {
0025 static constexpr size_t __simd_size = 1;
0026 };
0027 }
0028
0029 template <>
0030 inline constexpr bool is_abi_tag_v<simd_abi::__scalar> = true;
0031
0032 template <class _Tp>
0033 struct __simd_storage<_Tp, simd_abi::__scalar> {
0034 _Tp __data;
0035
0036 _LIBCPP_HIDE_FROM_ABI _Tp __get([[maybe_unused]] size_t __idx) const noexcept {
0037 _LIBCPP_ASSERT_UNCATEGORIZED(__idx == 0, "Index is out of bounds");
0038 return __data;
0039 }
0040 _LIBCPP_HIDE_FROM_ABI void __set([[maybe_unused]] size_t __idx, _Tp __v) noexcept {
0041 _LIBCPP_ASSERT_UNCATEGORIZED(__idx == 0, "Index is out of bounds");
0042 __data = __v;
0043 }
0044 };
0045
0046 template <class _Tp>
0047 struct __mask_storage<_Tp, simd_abi::__scalar> : __simd_storage<bool, simd_abi::__scalar> {};
0048
0049 template <class _Tp>
0050 struct __simd_operations<_Tp, simd_abi::__scalar> {
0051 using _SimdStorage = __simd_storage<_Tp, simd_abi::__scalar>;
0052 using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>;
0053
0054 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept { return {__v}; }
0055
0056 template <class _Generator>
0057 static _LIBCPP_HIDE_FROM_ABI _SimdStorage __generate(_Generator&& __g) noexcept {
0058 return {__g(std::integral_constant<size_t, 0>())};
0059 }
0060
0061 template <class _Up>
0062 static _LIBCPP_HIDE_FROM_ABI void __load(_SimdStorage& __s, const _Up* __mem) noexcept {
0063 __s.__data = static_cast<_Tp>(__mem[0]);
0064 }
0065
0066 template <class _Up>
0067 static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept {
0068 *__mem = static_cast<_Up>(__s.__data);
0069 }
0070 };
0071
0072 template <class _Tp>
0073 struct __mask_operations<_Tp, simd_abi::__scalar> {
0074 using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>;
0075
0076 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { return {__v}; }
0077
0078 static _LIBCPP_HIDE_FROM_ABI void __load(_MaskStorage& __s, const bool* __mem) noexcept { __s.__data = __mem[0]; }
0079
0080 static _LIBCPP_HIDE_FROM_ABI void __store(_MaskStorage __s, bool* __mem) noexcept { __mem[0] = __s.__data; }
0081 };
0082
0083 }
0084 _LIBCPP_END_NAMESPACE_EXPERIMENTAL
0085
0086 #endif
0087 #endif