1 /*************************************************************************** 2 * Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and * 3 * Martin Renou * 4 * Copyright (c) QuantStack * 5 * Copyright (c) Serge Guelton * 6 * * 7 * Distributed under the terms of the BSD 3-Clause License. * 8 * * 9 * The full license is in the file LICENSE, distributed with this software. * 10 ****************************************************************************/ 11 12 #ifndef XSIMD_REGISTER_HPP 13 #define XSIMD_REGISTER_HPP 14 15 #include <type_traits> 16 17 namespace xsimd 18 { 19 namespace types 20 { 21 22 template<class T, class Arch> 23 struct simd_register; 24 25 template <class T, class A> 26 struct has_simd_register : std::false_type 27 { 28 }; 29 30 #define XSIMD_DECLARE_SIMD_REGISTER(SCALAR_TYPE, ISA, VECTOR_TYPE) \ 31 template<> \ 32 struct simd_register<SCALAR_TYPE, ISA>\ 33 {\ 34 using register_type = VECTOR_TYPE;\ 35 register_type data;\ 36 operator register_type() const { return data; }\ 37 };\ 38 template <>\ 39 struct has_simd_register<SCALAR_TYPE, ISA> : std::true_type\ 40 {} 41 42 #define XSIMD_DECLARE_SIMD_REGISTER_ALIAS(ISA, ISA_BASE)\ 43 template<class T> \ 44 struct simd_register<T, ISA> : simd_register<T, ISA_BASE>\ 45 {\ 46 using register_type = typename simd_register<T, ISA_BASE>::register_type;\ 47 simd_register(register_type reg) : simd_register<T, ISA_BASE>{reg} {}\ 48 simd_register() = default;\ 49 };\ 50 template<class T>\ 51 struct has_simd_register<T, ISA> : has_simd_register<T, ISA_BASE>\ 52 {} 53 54 template <class T, class Arch> 55 struct get_bool_simd_register 56 { 57 using type = simd_register<T, Arch>; 58 }; 59 60 template <class T, class Arch> 61 using get_bool_simd_register_t = typename get_bool_simd_register<T, Arch>::type; 62 } 63 64 namespace kernel 65 { 66 // TODO: rename this, as it might conflict with C++20 keyword. 67 // We should use add_const and add_reference to build A const& 68 template<class A> 69 using requires_arch = A const&; 70 template<class T> 71 struct convert {}; 72 } 73 } 74 75 #endif 76