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
24inline namespace parallelism_v2 {
25
26// traits [simd.traits]
27template <class _Tp>
28inline constexpr bool is_abi_tag_v = false;
29
30template <class _Tp>
31struct is_abi_tag : bool_constant<is_abi_tag_v<_Tp>> {};
32
33template <class _Tp>
34inline constexpr bool is_simd_v = false;
35
36template <class _Tp>
37struct is_simd : bool_constant<is_simd_v<_Tp>> {};
38
39template <class _Tp>
40inline constexpr bool is_simd_mask_v = false;
41
42template <class _Tp>
43struct is_simd_mask : bool_constant<is_simd_mask_v<_Tp>> {};
44
45template <class _Tp>
46inline constexpr bool is_simd_flag_type_v = false;
47
48template <class _Tp>
49struct is_simd_flag_type : bool_constant<is_simd_flag_type_v<_Tp>> {};
50
51template <class _Tp, class _Abi = simd_abi::compatible<_Tp>, bool = (__is_vectorizable_v<_Tp> && is_abi_tag_v<_Abi>)>
52struct simd_size : integral_constant<size_t, _Abi::__simd_size> {};
53
54template <class _Tp, class _Abi>
55struct simd_size<_Tp, _Abi, false> {};
56
57template <class _Tp, class _Abi = simd_abi::compatible<_Tp>>
58inline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value;
59
60template <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>)>
63struct memory_alignment : integral_constant<size_t, std::__bit_ceil(sizeof(_Up) * _Tp::size())> {};
64
65template <class _Tp, class _Up>
66struct memory_alignment<_Tp, _Up, false> {};
67
68template <class _Tp, class _Up = typename _Tp::value_type>
69inline 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.

source code of libcxx/include/experimental/__simd/traits.h