Skip to content

Commit 6a9f6de

Browse files
committed
[libc++][NFC] Refactor <experimental/simd> a bit to simplify dependencies
1 parent 2fe94ce commit 6a9f6de

File tree

12 files changed

+66
-123
lines changed

12 files changed

+66
-123
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,10 +914,8 @@ set(files
914914
expected
915915
experimental/__config
916916
experimental/__memory
917-
experimental/__simd/abi_tag.h
918917
experimental/__simd/aligned_tag.h
919918
experimental/__simd/declaration.h
920-
experimental/__simd/internal_declaration.h
921919
experimental/__simd/reference.h
922920
experimental/__simd/scalar.h
923921
experimental/__simd/simd.h

libcxx/include/experimental/__simd/abi_tag.h

Lines changed: 0 additions & 55 deletions
This file was deleted.

libcxx/include/experimental/__simd/aligned_tag.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
#ifndef _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H
1111
#define _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H
1212

13-
#include <__bit/bit_ceil.h>
1413
#include <__memory/assume_aligned.h>
1514
#include <cstddef>
1615
#include <experimental/__config>
16+
#include <experimental/__simd/traits.h>
1717

1818
#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
1919

@@ -30,16 +30,22 @@ struct element_aligned_tag {
3030
}
3131
};
3232

33+
template <>
34+
inline constexpr bool is_simd_flag_type_v<element_aligned_tag> = true;
35+
3336
struct vector_aligned_tag {
3437
template <class _Tp, class _Up = typename _Tp::value_type>
35-
static constexpr size_t __alignment = std::__bit_ceil(sizeof(_Up) * _Tp::size());
38+
static constexpr size_t __alignment = memory_alignment_v<_Tp, _Up>;
3639

3740
template <class _Tp, class _Up>
3841
static _LIBCPP_HIDE_FROM_ABI constexpr _Up* __apply(_Up* __ptr) {
3942
return std::__assume_aligned<__alignment<_Tp, _Up>, _Up>(__ptr);
4043
}
4144
};
4245

46+
template <>
47+
inline constexpr bool is_simd_flag_type_v<vector_aligned_tag> = true;
48+
4349
template <size_t _Np>
4450
struct overaligned_tag {
4551
template <class _Tp, class _Up = typename _Tp::value_type>
@@ -51,6 +57,9 @@ struct overaligned_tag {
5157
}
5258
};
5359

60+
template <size_t _Np>
61+
inline constexpr bool is_simd_flag_type_v<overaligned_tag<_Np>> = true;
62+
5463
inline constexpr element_aligned_tag element_aligned{};
5564

5665
inline constexpr vector_aligned_tag vector_aligned{};

libcxx/include/experimental/__simd/declaration.h

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,63 @@
1010
#ifndef _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H
1111
#define _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H
1212

13+
#include <cstddef>
1314
#include <experimental/__config>
14-
#include <experimental/__simd/abi_tag.h>
1515

1616
#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
1717

1818
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
1919
inline namespace parallelism_v2 {
20+
namespace simd_abi {
21+
template <int>
22+
struct __vec_ext;
23+
struct __scalar;
24+
25+
using scalar = __scalar;
26+
27+
// TODO: make this platform dependent
28+
template <int _Np>
29+
using fixed_size = __vec_ext<_Np>;
30+
31+
template <class _Tp>
32+
inline constexpr int max_fixed_size = 32;
33+
34+
// TODO: make this platform dependent
35+
template <class _Tp>
36+
using compatible = __vec_ext<16 / sizeof(_Tp)>;
37+
38+
// TODO: make this platform dependent
39+
template <class _Tp>
40+
using native = __vec_ext<_LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
41+
42+
// TODO: make this platform dependent
43+
template <class _Tp, size_t _Np, class... _Abis>
44+
struct deduce {
45+
using type = fixed_size<_Np>;
46+
};
47+
48+
// TODO: make this platform dependent
49+
template <class _Tp, size_t _Np, class... _Abis>
50+
using deduce_t = typename deduce<_Tp, _Np, _Abis...>::type;
51+
52+
} // namespace simd_abi
53+
54+
template <class _Tp, class _Abi>
55+
struct __simd_storage;
56+
57+
template <class _Tp, class _Abi>
58+
struct __mask_storage;
59+
60+
template <class _Tp, class _Abi>
61+
struct __simd_operations;
62+
63+
template <class _Tp, class _Abi>
64+
struct __mask_operations;
65+
66+
struct element_aligned_tag;
67+
struct vector_aligned_tag;
68+
template <size_t>
69+
struct overaligned_tag;
2070

2171
template <class _Tp, class _Abi = simd_abi::compatible<_Tp>>
2272
class simd;

libcxx/include/experimental/__simd/internal_declaration.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

libcxx/include/experimental/__simd/scalar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <cstddef>
1414
#include <experimental/__config>
15-
#include <experimental/__simd/internal_declaration.h>
15+
#include <experimental/__simd/declaration.h>
1616
#include <experimental/__simd/traits.h>
1717

1818
#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)

libcxx/include/experimental/__simd/simd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
#include <__utility/forward.h>
1616
#include <cstddef>
1717
#include <experimental/__config>
18-
#include <experimental/__simd/abi_tag.h>
1918
#include <experimental/__simd/declaration.h>
20-
#include <experimental/__simd/internal_declaration.h>
2119
#include <experimental/__simd/reference.h>
2220
#include <experimental/__simd/traits.h>
2321
#include <experimental/__simd/utility.h>

libcxx/include/experimental/__simd/simd_mask.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
#include <__type_traits/is_same.h>
1414
#include <cstddef>
1515
#include <experimental/__config>
16-
#include <experimental/__simd/abi_tag.h>
1716
#include <experimental/__simd/declaration.h>
18-
#include <experimental/__simd/internal_declaration.h>
1917
#include <experimental/__simd/reference.h>
2018
#include <experimental/__simd/traits.h>
2119

libcxx/include/experimental/__simd/traits.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
#ifndef _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H
1111
#define _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H
1212

13+
#include <__bit/bit_ceil.h>
1314
#include <__type_traits/integral_constant.h>
1415
#include <__type_traits/is_same.h>
1516
#include <cstddef>
1617
#include <experimental/__config>
17-
#include <experimental/__simd/abi_tag.h>
18-
#include <experimental/__simd/aligned_tag.h>
1918
#include <experimental/__simd/declaration.h>
20-
#include <experimental/__simd/internal_declaration.h>
2119
#include <experimental/__simd/utility.h>
2220

2321
#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
@@ -47,15 +45,6 @@ struct is_simd_mask : bool_constant<is_simd_mask_v<_Tp>> {};
4745
template <class _Tp>
4846
inline constexpr bool is_simd_flag_type_v = false;
4947

50-
template <>
51-
inline constexpr bool is_simd_flag_type_v<element_aligned_tag> = true;
52-
53-
template <>
54-
inline constexpr bool is_simd_flag_type_v<vector_aligned_tag> = true;
55-
56-
template <size_t _Np>
57-
inline constexpr bool is_simd_flag_type_v<overaligned_tag<_Np>> = true;
58-
5948
template <class _Tp>
6049
struct is_simd_flag_type : bool_constant<is_simd_flag_type_v<_Tp>> {};
6150

@@ -71,7 +60,7 @@ inline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value;
7160
template <class _Tp,
7261
class _Up = typename _Tp::value_type,
7362
bool = (is_simd_v<_Tp> && __is_vectorizable_v<_Up>) || (is_simd_mask_v<_Tp> && is_same_v<_Up, bool>)>
74-
struct memory_alignment : integral_constant<size_t, vector_aligned_tag::__alignment<_Tp, _Up>> {};
63+
struct memory_alignment : integral_constant<size_t, std::__bit_ceil(sizeof(_Up) * _Tp::size())> {};
7564

7665
template <class _Tp, class _Up>
7766
struct memory_alignment<_Tp, _Up, false> {};

libcxx/include/experimental/__simd/vec_ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <__utility/integer_sequence.h>
1616
#include <cstddef>
1717
#include <experimental/__config>
18-
#include <experimental/__simd/internal_declaration.h>
18+
#include <experimental/__simd/declaration.h>
1919
#include <experimental/__simd/traits.h>
2020
#include <experimental/__simd/utility.h>
2121

libcxx/include/experimental/simd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ inline namespace parallelism_v2 {
7878
#endif
7979

8080
#include <experimental/__config>
81-
#include <experimental/__simd/abi_tag.h>
8281
#include <experimental/__simd/aligned_tag.h>
8382
#include <experimental/__simd/declaration.h>
8483
#include <experimental/__simd/scalar.h>

libcxx/include/module.modulemap.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,8 @@ module std_experimental [system] {
530530
export *
531531
}
532532
module simd {
533-
module abi_tag { private header "experimental/__simd/abi_tag.h" }
534533
module aligned_tag { private header "experimental/__simd/aligned_tag.h" }
535534
module declaration { private header "experimental/__simd/declaration.h" }
536-
module internal_declaration { private header "experimental/__simd/internal_declaration.h" }
537535
module reference { private header "experimental/__simd/reference.h" }
538536
module scalar { private header "experimental/__simd/scalar.h" }
539537
module simd { private header "experimental/__simd/simd.h" }

0 commit comments

Comments
 (0)