Skip to content

Commit e93be8d

Browse files
committed
Factor integer traits
1 parent f13baeb commit e93be8d

14 files changed

Lines changed: 1240 additions & 1258 deletions

docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ INPUT = ../include/xsimd/types/xsimd_api.hpp \
88
../include/xsimd/memory/xsimd_alignment.hpp \
99
../include/xsimd/memory/xsimd_aligned_allocator.hpp \
1010
../include/xsimd/types/xsimd_common_arch.hpp \
11-
../include/xsimd/types/xsimd_traits.hpp \
11+
../include/xsimd/types/simd_traits.hpp \
1212
../include/xsimd/types/xsimd_vsx_register.hpp \
1313
../include/xsimd/types/xsimd_avx2_register.hpp \
1414
../include/xsimd/types/xsimd_avx512bw_register.hpp \

include/xsimd/arch/common/xsimd_common_cast.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
#ifndef XSIMD_COMMON_CAST_HPP
1313
#define XSIMD_COMMON_CAST_HPP
1414

15-
#include "../../types/xsimd_traits.hpp"
15+
#include <array>
16+
17+
#include "../../config/xsimd_macros.hpp"
18+
#include "../../type_traits.hpp"
1619

1720
namespace xsimd
1821
{

include/xsimd/arch/utils/shifts.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
#define XSIMD_UTILS_SHIFTS_HPP
1515

1616
#include "../../config/xsimd_macros.hpp"
17+
#include "../../types/simd_traits.hpp"
1718
#include "../../types/xsimd_batch.hpp"
1819
#include "../../types/xsimd_batch_constant.hpp"
19-
#include "../../types/xsimd_traits.hpp"
2020

2121
namespace xsimd
2222
{

include/xsimd/arch/xsimd_neon.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <tuple>
2020
#include <type_traits>
2121

22+
#include "../type_traits.hpp"
2223
#include "../types/xsimd_neon_register.hpp"
2324
#include "../types/xsimd_utils.hpp"
2425
#include "./common/xsimd_common_bit.hpp"

include/xsimd/arch/xsimd_rvv.hpp

Lines changed: 30 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <type_traits>
1515

1616
#include "../config/xsimd_macros.hpp"
17+
#include "../type_traits.hpp"
1718
#include "../types/xsimd_batch_constant.hpp"
1819
#include "../types/xsimd_rvv_register.hpp"
1920
#include "./xsimd_constants.hpp"
@@ -86,32 +87,32 @@
8687
// for the function signature argument(s) to XSIMD_RVV_OVERLOAD. That signature can
8788
// also reference the template argument T, because it's a text substitution
8889
// into the template.
89-
#define XSIMD_RVV_WRAPPER_HEAD(NAME, SIGNATURE, ...) \
90-
namespace NAME##_cruft \
91-
{ \
92-
template <class T> \
93-
struct ctx \
94-
{ \
95-
static constexpr size_t width = XSIMD_RVV_BITS; \
96-
static constexpr size_t vl = width / (sizeof(T) * 8); \
97-
using vec = rvv_reg_t<T, width>; \
98-
using uvec = rvv_reg_t<as_unsigned_relaxed_t<T>, width>; \
99-
using svec = rvv_reg_t<as_signed_relaxed_t<T>, width>; \
100-
using fvec = rvv_reg_t<as_float_relaxed_t<T>, width>; \
101-
using bvec = rvv_bool_t<T, width>; \
102-
using scalar_vec = rvv_reg_t<T, types::detail::rvv_width_m1>; \
103-
using wide_vec = rvv_reg_t<T, width * 2>; \
104-
using narrow_vec = rvv_reg_t<T, width / 2>; \
105-
using type = SIGNATURE; \
106-
}; \
107-
template <class T> \
108-
using sig_t = typename ctx<T>::type; \
109-
template <class K, class T> \
110-
struct impl \
111-
{ \
112-
void operator()() const noexcept {}; \
113-
}; \
114-
template <class K> \
90+
#define XSIMD_RVV_WRAPPER_HEAD(NAME, SIGNATURE, ...) \
91+
namespace NAME##_cruft \
92+
{ \
93+
template <class T> \
94+
struct ctx \
95+
{ \
96+
static constexpr size_t width = XSIMD_RVV_BITS; \
97+
static constexpr size_t vl = width / (sizeof(T) * 8); \
98+
using vec = rvv_reg_t<T, width>; \
99+
using uvec = rvv_reg_t<xsimd::sized_uint_t<sizeof(T)>, width>; \
100+
using svec = rvv_reg_t<xsimd::sized_int_t<sizeof(T)>, width>; \
101+
using fvec = rvv_reg_t<as_float_relaxed_t<T>, width>; \
102+
using bvec = rvv_bool_t<T, width>; \
103+
using scalar_vec = rvv_reg_t<T, types::detail::rvv_width_m1>; \
104+
using wide_vec = rvv_reg_t<T, width * 2>; \
105+
using narrow_vec = rvv_reg_t<T, width / 2>; \
106+
using type = SIGNATURE; \
107+
}; \
108+
template <class T> \
109+
using sig_t = typename ctx<T>::type; \
110+
template <class K, class T> \
111+
struct impl \
112+
{ \
113+
void operator()() const noexcept {}; \
114+
}; \
115+
template <class K> \
115116
using impl_t = impl<K, sig_t<K>>;
116117

117118
#define XSIMD_RVV_WRAPPER_HEAD_NOVL(...) XSIMD_RVV_WRAPPER_HEAD(__VA_ARGS__)
@@ -294,57 +295,12 @@ namespace xsimd
294295
template <class T, size_t Width = XSIMD_RVV_BITS>
295296
using rvv_bool_t = types::detail::rvv_bool_t<T, Width>;
296297

297-
template <size_t>
298-
struct as_signed_relaxed;
299-
template <>
300-
struct as_signed_relaxed<1>
301-
{
302-
using type = int8_t;
303-
};
304-
template <>
305-
struct as_signed_relaxed<2>
306-
{
307-
using type = int16_t;
308-
};
309-
template <>
310-
struct as_signed_relaxed<4>
311-
{
312-
using type = int32_t;
313-
};
314-
template <>
315-
struct as_signed_relaxed<8>
316-
{
317-
using type = int64_t;
318-
};
319-
template <class T>
320-
using as_signed_relaxed_t = typename as_signed_relaxed<sizeof(T)>::type;
321-
template <size_t>
322-
struct as_unsigned_relaxed;
323-
template <>
324-
struct as_unsigned_relaxed<1>
298+
template <std::size_t S>
299+
struct as_float_relaxed
325300
{
326-
using type = uint8_t;
301+
using type = xsimd::sized_fp_t<S>;
327302
};
328303
template <>
329-
struct as_unsigned_relaxed<2>
330-
{
331-
using type = uint16_t;
332-
};
333-
template <>
334-
struct as_unsigned_relaxed<4>
335-
{
336-
using type = uint32_t;
337-
};
338-
template <>
339-
struct as_unsigned_relaxed<8>
340-
{
341-
using type = uint64_t;
342-
};
343-
template <class T>
344-
using as_unsigned_relaxed_t = typename as_unsigned_relaxed<sizeof(T)>::type;
345-
template <size_t>
346-
struct as_float_relaxed;
347-
template <>
348304
struct as_float_relaxed<1>
349305
{
350306
using type = int8_t;
@@ -354,16 +310,6 @@ namespace xsimd
354310
{
355311
using type = int16_t;
356312
};
357-
template <>
358-
struct as_float_relaxed<4>
359-
{
360-
using type = float;
361-
};
362-
template <>
363-
struct as_float_relaxed<8>
364-
{
365-
using type = double;
366-
};
367313
template <class T>
368314
using as_float_relaxed_t = typename as_float_relaxed<sizeof(T)>::type;
369315

0 commit comments

Comments
 (0)