25 #ifndef ARM_COMPUTE_WRAPPER_SHR_H
26 #define ARM_COMPUTE_WRAPPER_SHR_H
29 #include <type_traits>
35 #define VQRSHRN_IMPL(half_vtype, vtype, prefix, postfix) \
37 inline half_vtype vqrshrn(const vtype &a) \
39 return prefix##_##postfix(a, b); \
51 #define VQRSHRN_SCALAR_IMPL(half_vtype, vtype, prefix, postfix) \
53 inline half_vtype vqrshrn(const vtype &a) \
55 return prefix##_##postfix(a, b); \
58 VQRSHRN_SCALAR_IMPL(int8_t, int16_t, vqrshrnh_n, s16)
59 VQRSHRN_SCALAR_IMPL(uint8_t, uint16_t, vqrshrnh_n, u16)
60 VQRSHRN_SCALAR_IMPL(int16_t, int32_t, vqrshrns_n, s32)
61 VQRSHRN_SCALAR_IMPL(uint16_t, uint32_t, vqrshrns_n, u32)
62 VQRSHRN_SCALAR_IMPL(int32_t, int64_t, vqrshrnd_n, s64)
63 VQRSHRN_SCALAR_IMPL(uint32_t, uint64_t, vqrshrnd_n, u64)
65 #undef VQRSHRN_SCALAR_IMPL
71 #define VQRSHRN_EX_IMPL(half_vtype, vtype, prefix_signed, prefix_unsigned, postfix) \
72 template <int b, typename T> \
73 inline typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value, half_vtype>::type \
74 vqrshrn_ex(const vtype &a) \
76 return prefix_signed##_##postfix(a, b); \
79 template <int b, typename T> \
80 inline typename std::enable_if<std::is_integral<T>::value && !std::is_signed<T>::value, u##half_vtype>::type \
81 vqrshrn_ex(const vtype &a) \
83 return prefix_unsigned##_##postfix(a, b); \
88 #undef VQRSHRN_EX_IMPL
90 #define VSHR_IMPL(vtype, prefix, postfix) \
92 inline vtype vshr_n(const vtype &a) \
94 return prefix##_##postfix(a, b); \
100 #define VSHRQ_IMPL(vtype, prefix, postfix) \
102 inline vtype vshrq_n(const vtype &a) \
104 return prefix##_##postfix(a, b); \
111 #define VSHRQ_SCALAR_IMPL(vtype, prefix, postfix) \
113 inline vtype vshrq_n(const vtype &a) \
115 return prefix##_##postfix(a, b); \
117 VSHRQ_SCALAR_IMPL(uint32_t, vshrd_n, u64)
118 VSHRQ_SCALAR_IMPL(int32_t, vshrd_n, s64)
120 #undef VSHRQ_SCALAR_IMPL
121 #endif // __aarch64__
124 #define VQRSHRN_EX_SCALAR_IMPL(half_vtype, vtype, prefix_signed, prefix_unsigned, postfix) \
125 template <int b, typename T> \
126 inline typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value, half_vtype>::type \
127 vqrshrn_ex(const vtype &a) \
129 return prefix_signed##_##postfix(a, b); \
132 template <int b, typename T> \
133 inline typename std::enable_if<std::is_integral<T>::value && !std::is_signed<T>::value, u##half_vtype>::type \
134 vqrshrn_ex(const vtype &a) \
136 return prefix_unsigned##_##postfix(a, b); \
139 VQRSHRN_EX_SCALAR_IMPL(int8_t, int16_t, vqrshrnh_n, vqrshrunh_n, s16)
140 VQRSHRN_EX_SCALAR_IMPL(int16_t, int32_t, vqrshrns_n, vqrshruns_n, s32)
141 VQRSHRN_EX_SCALAR_IMPL(int32_t, int64_t, vqrshrnd_n, vqrshrund_n, s64)
143 #undef VQRSHRN_EX_IMPL
144 #endif // __aarch64__