4#ifndef ARGON_PLATFORM_MVE
6#define ace [[gnu::always_inline]] constexpr
8#define ace [[gnu::always_inline]] inline
10template <
typename ScalarType>
18template <
typename ScalarType>
19 requires std::same_as<ScalarType, double> || std::same_as<ScalarType, uint64_t> || std::same_as<ScalarType, int64_t>
24 using vector_type = neon::Vec64_t<ScalarType>;
27 static_assert(neon::is_doubleword_v<vector_type>);
29 static constexpr size_t bytes = 8;
30 static constexpr size_t lanes = bytes /
sizeof(ScalarType);
43 requires(!std::is_same_v<typename T::scalar_type, vector_type>)
48 template <
size_t LaneIndex>
51 template <
typename... ArgTypes>
52 requires(
sizeof...(ArgTypes) > 1)
55 ace ArgonHalf(argon::Vector<vector_type> vec) : T{std::move(vec)} {};
56 ace ArgonHalf(
const ArgonHalf&) =
default;
57 ace ArgonHalf(ArgonHalf&&) =
default;
58 ace ArgonHalf& operator=(
const ArgonHalf&) =
default;
59 ace ArgonHalf& operator=(ArgonHalf&&) =
default;
67 template <
typename NewScalarType>
69 return neon::reinterpret<neon::Vec64_t<NewScalarType>>(this->vec_);
80 return neon::table_extension1(this->vec_, b, idx);
85 template <
size_t NumTables>
92 template <
size_t NumTables>
94 static_assert(NumTables > 1 && NumTables < 5,
"Table Extension can only be performed with 1, 2, 3, or 4 tables");
96 using multivec_type = neon::MultiVector_t<vector_type, NumTables>;
98 multivec_type multivector = *(multivec_type*)b;
100 if constexpr (NumTables == 2) {
101 return neon::table_extension2(this->vec_, multivector, idx);
102 }
else if constexpr (NumTables == 3) {
103 return neon::table_extension3(this->vec_, multivector, idx);
104 }
else if constexpr (NumTables == 4) {
105 return neon::table_extension4(this->vec_, multivector, idx);
111 template <
typename U>
113#ifndef __ARM_FEATURE_MVE
115 if constexpr (std::is_same_v<ScalarType, float> && std::is_same_v<U, int32_t>) {
116 return argon::helpers::convert_to_int32(this->vec_);
117 }
else if constexpr (std::is_same_v<ScalarType, float> && std::is_same_v<U, uint32_t>) {
118 return argon::helpers::convert_to_uint32(this->vec_);
121 return neon::convert<typename neon::Vec64<U>::type>(this->vec_);
127 template <
typename U,
int fracbits>
128 requires(std::is_same_v<U, uint32_t> || std::is_same_v<U, int32_t> || std::is_same_v<U, float>)
130 if constexpr (std::is_same_v<U, float>) {
131 return neon::convert_n<fracbits>(this->vec_);
132 }
else if constexpr (std::is_unsigned_v<U>) {
133 return argon::helpers::convert_n_to_uint32<fracbits>(this->vec_);
134 }
else if constexpr (std::is_signed_v<U>) {
135 return argon::helpers::convert_n_to_int32<fracbits>(this->vec_);
152template <argon::helpers::has_larger ScalarType>
154 using T = argon::Vector<neon::Vec64_t<ScalarType>>;
156 using argon_next_larger = Argon<next_larger>;
159 using vector_type = neon::Vec64_t<ScalarType>;
160 using lane_type =
const argon::Lane<vector_type>;
162 static_assert(neon::is_doubleword_v<vector_type>);
164 static constexpr size_t bytes = 8;
165 static constexpr size_t lanes = bytes /
sizeof(ScalarType);
179 template <
size_t LaneIndex>
182 template <
typename... ArgTypes>
183 requires(
sizeof...(ArgTypes) > 1)
192 template <
typename NewScalarType>
194 return neon::reinterpret<neon::Vec64_t<NewScalarType>>(this->vec_);
204 ace argon_next_larger
MultiplyLong(ScalarType b)
const {
return neon::multiply_long(this->vec_, b); }
208 return neon::multiply_long_lane(this->vec_, b.
vec(), b.
lane());
213 return neon::multiply_add_long(this->vec_, b);
217 ace argon_next_larger
MultiplyAddLong(ScalarType b)
const {
return neon::multiply_add_long(this->vec_, b); }
221 return neon::multiply_add_long_lane(this->vec_, b.
vec(), b.
lane());
226 requires(std::is_same_v<vector_type, int16x4_t> || std::is_same_v<vector_type, int32x2_t>)
228 return neon::multiply_double_saturate_long(this->vec_, b);
233 requires(std::is_same_v<vector_type, int16x4_t> || std::is_same_v<vector_type, int32x2_t>)
235 return neon::multiply_double_saturate_long(this->vec_, b);
240 requires(std::is_same_v<vector_type, int16x4_t> || std::is_same_v<vector_type, int32x2_t>)
242 return neon::multiply_double_saturate_long_lane(this->vec_, b.vec(), b.lane());
247 requires(std::is_same_v<vector_type, int16x4_t> || std::is_same_v<vector_type, int32x2_t>)
249 return neon::multiply_double_add_saturate_long(this->vec_, b);
254 requires(std::is_same_v<vector_type, int16x4_t> || std::is_same_v<vector_type, int32x2_t>)
256 return neon::multiply_double_add_saturate_long(this->vec_, b);
261 requires(std::is_same_v<vector_type, int16x4_t> || std::is_same_v<vector_type, int32x2_t>)
263 return neon::multiply_double_add_saturate_long_lane(this->vec_, b.vec(), b.lane());
271 return neon::subtract_absolute_long(this->vec_, b);
283 template <
typename SmallerType>
286 static_assert(std::is_same_v<SmallerType, argon::helpers::NextSmaller_t<ScalarType>>,
287 "PairwiseAddLong(b) requires b to be an ArgonHalf of the next-smaller element type");
288 return this->
Add(b.PairwiseAddLong());
292 ace argon_next_larger
Widen()
const {
return neon::move_long(this->vec_); }
298 return neon::shift_left_long<n>(this->vec_);
309 return neon::table_extension1(this->vec_, b, idx);
314 template <
size_t NumTables>
321 template <
size_t NumTables>
323 static_assert(NumTables > 1 && NumTables < 5,
"Table Extension can only be performed with 1, 2, 3, or 4 tables");
325 using multivec_type = neon::MultiVector_t<vector_type, NumTables>;
327 multivec_type multivector = *(multivec_type*)b;
329 if constexpr (NumTables == 2) {
330 return neon::table_extension2(this->vec_, multivector, idx);
331 }
else if constexpr (NumTables == 3) {
332 return neon::table_extension3(this->vec_, multivector, idx);
333 }
else if constexpr (NumTables == 4) {
334 return neon::table_extension4(this->vec_, multivector, idx);
340 template <
typename U>
342#ifndef __ARM_FEATURE_MVE
344 if constexpr (std::is_same_v<ScalarType, float> && std::is_same_v<U, int32_t>) {
345 return argon::helpers::convert_to_int32(this->vec_);
346 }
else if constexpr (std::is_same_v<ScalarType, float> && std::is_same_v<U, uint32_t>) {
347 return argon::helpers::convert_to_uint32(this->vec_);
350 return neon::convert<typename neon::Vec64<U>::type>(this->vec_);
356 template <
typename U,
int fracbits>
357 requires(std::is_same_v<U, uint32_t> || std::is_same_v<U, int32_t> || std::is_same_v<U, float>)
359 if constexpr (std::is_same_v<U, float>) {
360 return neon::convert_n<fracbits>(this->vec_);
361 }
else if constexpr (std::is_unsigned_v<U>) {
362 return argon::helpers::convert_n_to_uint32<fracbits>(this->vec_);
363 }
else if constexpr (std::is_signed_v<U>) {
364 return argon::helpers::convert_n_to_int32<fracbits>(this->vec_);
375template <
class... ArgTypes>
376 requires(
sizeof...(ArgTypes) > 1)
380 requires std::is_scalar_v<V>
386 requires std::is_scalar_v<V>
392 requires std::is_scalar_v<V>
394 return b.Multiply(a);
398 requires std::is_scalar_v<V>
408template <
size_t Index,
typename T>
410 static_assert(Index < ArgonHalf<T>::lanes);
ace ArgonHalf< ScalarType > TableLookup(ArgonHalf< ScalarType > idx)
Look up each index lane in idx from this vector acting as a one-register table.
Definition argon_half.hpp:74
ace argon_next_larger MultiplyDoubleSaturateLong(ArgonHalf< ScalarType > b) const
Multiply, double, and saturate long: saturate(2 * this * b) widened (vector × vector).
Definition argon_half.hpp:225
ace ArgonHalf< next_larger > PairwiseAddLong() const
Pairwise add adjacent lanes and widen: produces lanes/2 wider-type results.
Definition argon_half.hpp:277
ace argon_next_larger MultiplyLong(ScalarType b) const
Multiply this by a scalar, widening each product (vector × scalar).
Definition argon_half.hpp:204
ace ArgonHalf< ScalarType > PairwiseAddLong(ArgonHalf< SmallerType > b) const
Pairwise add adjacent lanes of the next-smaller-type vector b and accumulate into this.
Definition argon_half.hpp:285
ace argon_next_larger MultiplyAddLong(ScalarType b) const
Multiply-accumulate long (vector × scalar).
Definition argon_half.hpp:217
ace ArgonHalf(ArgTypes... args)
Construct from one value per lane, each converted to the lane type.
Definition argon_half.hpp:53
ace argon_next_larger Widen() const
Zero-extend (widen) each lane to the next-larger element type.
Definition argon_half.hpp:292
ace argon_next_larger MultiplyLong(ArgonHalf< ScalarType > b) const
Multiply this and b, widening each product to the next-larger element type (vector × vector).
Definition argon_half.hpp:201
static ace ArgonHalf< ScalarType > Create(uint64_t a)
Create a new ArgonHalf from a raw 64-bit value.
Definition argon_half.hpp:63
ace ArgonHalf(typename T::scalar_type scalar)
Duplicate a scalar across every lane.
Definition argon_half.hpp:42
ace argon_next_larger MultiplyDoubleSaturateLong(lane_type b) const
Multiply, double, and saturate long (vector × lane).
Definition argon_half.hpp:239
ace argon_next_larger MultiplyDoubleAddSaturateLong(lane_type b) const
Multiply, double, add, and saturate long (vector × lane).
Definition argon_half.hpp:260
ace ArgonHalf< ScalarType > TableExtension(ArgonHalf< ScalarType > b, ArgonHalf< ScalarType > idx)
Extend a previous table-lookup result using this vector as an additional table (1 extension register)...
Definition argon_half.hpp:79
ace argon_next_larger SubtractAbsoluteLong(ArgonHalf< ScalarType > b) const
Absolute difference and widen: |this - b| widened to the next-larger element type.
Definition argon_half.hpp:270
ace argon_next_larger SubtractLong(ArgonHalf< ScalarType > b) const
Subtract b from this, widening each result to the next-larger element type.
Definition argon_half.hpp:267
ace argon_next_larger AddLong(ArgonHalf< ScalarType > b) const
Add this and b, widening each lane to the next-larger element type.
Definition argon_half.hpp:198
ace ArgonHalf< ScalarType > TableExtension(std::array< ArgonHalf< ScalarType >, NumTables > b, ArgonHalf< ScalarType > idx)
Multi-register table extension lookup (2–4 registers) supplied as std::array.
Definition argon_half.hpp:86
ace argon_next_larger MultiplyAddLong(ArgonHalf< ScalarType > b) const
Multiply this and b, widen each product, and prepare for long accumulation (vector × vector).
Definition argon_half.hpp:212
ace ArgonHalf(argon::Lane< vector_type > lane)
Duplicate the lane lane refers to across every lane.
Definition argon_half.hpp:46
ace ArgonHalf(vector_type vector)
Construct from the underlying intrinsic vector.
Definition argon_half.hpp:38
ace ArgonHalf(argon::ConstLane< LaneIndex, vector_type > lane)
Duplicate lane LaneIndex of lane's vector across every lane.
Definition argon_half.hpp:49
constexpr ArgonHalf()=default
Leave the lanes uninitialised; value-initialisation (ArgonHalf<T>{}) zeroes them.
ace argon_next_larger MultiplyDoubleAddSaturateLong(ScalarType b) const
Multiply, double, add, and saturate long (vector × scalar).
Definition argon_half.hpp:253
ace ArgonHalf(typename T::scalar_type scalar)
Duplicate a scalar across every lane.
Definition argon_half.hpp:175
ace ArgonHalf< ScalarType > TableExtension(vector_type *b, ArgonHalf< ScalarType > idx)
Multi-register table extension lookup (2–4 registers) from a raw pointer.
Definition argon_half.hpp:93
ace ArgonHalf< NewScalarType > As() const
reinterpret an ArgonHalf to a different type
Definition argon_half.hpp:68
ace argon_next_larger MultiplyDoubleSaturateLong(ScalarType b) const
Multiply, double, and saturate long (vector × scalar).
Definition argon_half.hpp:232
ace ArgonHalf< U > ConvertTo()
Convert each lane to a different element type.
Definition argon_half.hpp:112
ace Argon< ScalarType > CombineWith(ArgonHalf< ScalarType > high) const
Combine this (low) half with high to form a 128-bit Argon<ScalarType> vector.
Definition argon_half.hpp:140
ace argon_next_larger ShiftLeftLong()
Shift each lane left by n bits, widening the result to the next-larger element type.
Definition argon_half.hpp:297
ace argon_next_larger MultiplyLong(lane_type b) const
Multiply this by a lane value, widening each product (vector × lane).
Definition argon_half.hpp:207
ace ArgonHalf< U > ConvertTo()
Convert each lane to a different type using a fixed-point fractional bit count.
Definition argon_half.hpp:129
ace argon_next_larger MultiplyDoubleAddSaturateLong(ArgonHalf< ScalarType > b) const
Multiply, double, add, and saturate long: saturate(acc + 2 * this * b) widened (vector × vector).
Definition argon_half.hpp:246
ace ArgonHalf< ScalarType > Reverse() const
Reverse the order of all elements within this 64-bit vector.
Definition argon_half.hpp:143
ace argon_next_larger MultiplyAddLong(lane_type b) const
Multiply-accumulate long (vector × lane).
Definition argon_half.hpp:220
Definition argon_half.hpp:11
Definition argon_full.hpp:44
Represents a single lane of a SIMD vector with the lane index known at compile time.
Definition lane.hpp:35
Represents a single lane of a SIMD vector with a runtime-determined index.
Definition lane.hpp:107
ace int lane()
On ARM32, return the local lane index within the 64-bit half-register returned by vec().
Definition lane.hpp:153
ace neon::Vec64_t< scalar_type > vec()
On ARM32, return the 64-bit half-register that contains this lane.
Definition lane.hpp:141
Represents a SIMD vector with various operations.
Definition vector.hpp:53
simd::Scalar_t< neon::Vec64_t< ScalarType > > scalar_type
Definition vector.hpp:58
ace argon_type Add(argon_type b) const
Definition vector.hpp:387
constexpr bool has_smaller_v
Helper template to determine if a type has a smaller corresponding type.
Definition helpers.hpp:18
NextLarger< T >::type NextLarger_t
Helper alias to get the next larger type for a given type.
Definition helpers.hpp:75
Lane deconstruction feature.
Definition argon_full.hpp:1547