blob: edbb3b24931f5a891de8cfb437fd70779eef85ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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_ALIGNED_TAG_H
#define _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H
#include <__memory/assume_aligned.h>
#include <cstddef>
#include <experimental/__config>
#include <experimental/__simd/traits.h>
#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
inline namespace parallelism_v2 {
// memory alignment
struct element_aligned_tag {
template <class _Tp, class _Up = typename _Tp::value_type>
static constexpr size_t __alignment = alignof(_Up);
template <class _Tp, class _Up>
static _LIBCPP_HIDE_FROM_ABI constexpr _Up* __apply(_Up* __ptr) {
return __ptr;
}
};
template <>
inline constexpr bool is_simd_flag_type_v<element_aligned_tag> = true;
struct vector_aligned_tag {
template <class _Tp, class _Up = typename _Tp::value_type>
static constexpr size_t __alignment = memory_alignment_v<_Tp, _Up>;
template <class _Tp, class _Up>
static _LIBCPP_HIDE_FROM_ABI constexpr _Up* __apply(_Up* __ptr) {
return std::__assume_aligned<__alignment<_Tp, _Up>, _Up>(__ptr);
}
};
template <>
inline constexpr bool is_simd_flag_type_v<vector_aligned_tag> = true;
template <size_t _Np>
struct overaligned_tag {
template <class _Tp, class _Up = typename _Tp::value_type>
static constexpr size_t __alignment = _Np;
template <class _Tp, class _Up>
static _LIBCPP_HIDE_FROM_ABI constexpr _Up* __apply(_Up* __ptr) {
return std::__assume_aligned<__alignment<_Tp, _Up>, _Up>(__ptr);
}
};
template <size_t _Np>
inline constexpr bool is_simd_flag_type_v<overaligned_tag<_Np>> = true;
inline constexpr element_aligned_tag element_aligned{};
inline constexpr vector_aligned_tag vector_aligned{};
template <size_t _Np>
inline constexpr overaligned_tag<_Np> overaligned{};
} // namespace parallelism_v2
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
#endif // _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
#endif // _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H
|