Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | // -*- C++ -*- |
|---|---|
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H |
| 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H |
| 12 | |
| 13 | #include <__bit/bit_ceil.h> |
| 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> |
| 16 | #include <__type_traits/integral_constant.h> |
| 17 | #include <__type_traits/is_same.h> |
| 18 | #include <experimental/__simd/declaration.h> |
| 19 | #include <experimental/__simd/utility.h> |
| 20 | |
| 21 | #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) |
| 22 | |
| 23 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL |
| 24 | inline namespace parallelism_v2 { |
| 25 | |
| 26 | // traits [simd.traits] |
| 27 | template <class _Tp> |
| 28 | inline constexpr bool is_abi_tag_v = false; |
| 29 | |
| 30 | template <class _Tp> |
| 31 | struct is_abi_tag : bool_constant<is_abi_tag_v<_Tp>> {}; |
| 32 | |
| 33 | template <class _Tp> |
| 34 | inline constexpr bool is_simd_v = false; |
| 35 | |
| 36 | template <class _Tp> |
| 37 | struct is_simd : bool_constant<is_simd_v<_Tp>> {}; |
| 38 | |
| 39 | template <class _Tp> |
| 40 | inline constexpr bool is_simd_mask_v = false; |
| 41 | |
| 42 | template <class _Tp> |
| 43 | struct is_simd_mask : bool_constant<is_simd_mask_v<_Tp>> {}; |
| 44 | |
| 45 | template <class _Tp> |
| 46 | inline constexpr bool is_simd_flag_type_v = false; |
| 47 | |
| 48 | template <class _Tp> |
| 49 | struct is_simd_flag_type : bool_constant<is_simd_flag_type_v<_Tp>> {}; |
| 50 | |
| 51 | template <class _Tp, class _Abi = simd_abi::compatible<_Tp>, bool = (__is_vectorizable_v<_Tp> && is_abi_tag_v<_Abi>)> |
| 52 | struct simd_size : integral_constant<size_t, _Abi::__simd_size> {}; |
| 53 | |
| 54 | template <class _Tp, class _Abi> |
| 55 | struct simd_size<_Tp, _Abi, false> {}; |
| 56 | |
| 57 | template <class _Tp, class _Abi = simd_abi::compatible<_Tp>> |
| 58 | inline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value; |
| 59 | |
| 60 | template <class _Tp, |
| 61 | class _Up = typename _Tp::value_type, |
| 62 | bool = (is_simd_v<_Tp> && __is_vectorizable_v<_Up>) || (is_simd_mask_v<_Tp> && is_same_v<_Up, bool>)> |
| 63 | struct memory_alignment : integral_constant<size_t, std::__bit_ceil(sizeof(_Up) * _Tp::size())> {}; |
| 64 | |
| 65 | template <class _Tp, class _Up> |
| 66 | struct memory_alignment<_Tp, _Up, false> {}; |
| 67 | |
| 68 | template <class _Tp, class _Up = typename _Tp::value_type> |
| 69 | inline constexpr size_t memory_alignment_v = memory_alignment<_Tp, _Up>::value; |
| 70 | |
| 71 | } // namespace parallelism_v2 |
| 72 | _LIBCPP_END_NAMESPACE_EXPERIMENTAL |
| 73 | |
| 74 | #endif // _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) |
| 75 | #endif // _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H |
| 76 |
Warning: This file is not a C or C++ file. It does not have highlighting.
