146035553Spatrick// -*- C++ -*- 2*4bdff4beSrobert//===----------------------------------------------------------------------===// 346035553Spatrick// 446035553Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 546035553Spatrick// See https://llvm.org/LICENSE.txt for license information. 646035553Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 746035553Spatrick// 846035553Spatrick//===----------------------------------------------------------------------===// 9*4bdff4beSrobert 1046035553Spatrick#ifndef _LIBCPP_EXPERIMENTAL_SIMD 1146035553Spatrick#define _LIBCPP_EXPERIMENTAL_SIMD 1246035553Spatrick 1346035553Spatrick/* 1446035553Spatrick experimental/simd synopsis 1546035553Spatrick 1646035553Spatricknamespace std::experimental { 1746035553Spatrick 1846035553Spatrickinline namespace parallelism_v2 { 1946035553Spatrick 2046035553Spatricknamespace simd_abi { 2146035553Spatrick 2246035553Spatrickstruct scalar {}; 2346035553Spatricktemplate <int N> struct fixed_size {}; 2446035553Spatricktemplate <typename T> inline constexpr int max_fixed_size = implementation-defined; 2546035553Spatricktemplate <typename T> using compatible = implementation-defined; 2646035553Spatricktemplate <typename T> using native = implementation-defined; 2746035553Spatrick 2846035553Spatrick} // simd_abi 2946035553Spatrick 3046035553Spatrickstruct element_aligned_tag {}; 3146035553Spatrickstruct vector_aligned_tag {}; 3246035553Spatricktemplate <size_t> struct overaligned_tag {}; 3346035553Spatrickinline constexpr element_aligned_tag element_aligned{}; 3446035553Spatrickinline constexpr vector_aligned_tag vector_aligned{}; 3546035553Spatricktemplate <size_t N> inline constexpr overaligned_tag<N> overaligned{}; 3646035553Spatrick 3746035553Spatrick// traits [simd.traits] 3846035553Spatricktemplate <class T> struct is_abi_tag; 3946035553Spatricktemplate <class T> inline constexpr bool is_abi_tag_v = is_abi_tag<T>::value; 4046035553Spatrick 4146035553Spatricktemplate <class T> struct is_simd; 4246035553Spatricktemplate <class T> inline constexpr bool is_simd_v = is_simd<T>::value; 4346035553Spatrick 4446035553Spatricktemplate <class T> struct is_simd_mask; 4546035553Spatricktemplate <class T> inline constexpr bool is_simd_mask_v = is_simd_mask<T>::value; 4646035553Spatrick 4746035553Spatricktemplate <class T> struct is_simd_flag_type; 4846035553Spatricktemplate <class T> inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<T>::value; 4946035553Spatrick 5046035553Spatricktemplate <class T, size_t N> struct abi_for_size { using type = see below; }; 5146035553Spatricktemplate <class T, size_t N> using abi_for_size_t = typename abi_for_size<T, N>::type; 5246035553Spatrick 5346035553Spatricktemplate <class T, class Abi = simd_abi::compatible<T>> struct simd_size; 5446035553Spatricktemplate <class T, class Abi = simd_abi::compatible<T>> 5546035553Spatrickinline constexpr size_t simd_size_v = simd_size<T, Abi>::value; 5646035553Spatrick 5746035553Spatricktemplate <class T, class U = typename T::value_type> struct memory_alignment; 5846035553Spatricktemplate <class T, class U = typename T::value_type> 5946035553Spatrickinline constexpr size_t memory_alignment_v = memory_alignment<T, U>::value; 6046035553Spatrick 6146035553Spatrick// class template simd [simd.class] 6246035553Spatricktemplate <class T, class Abi = simd_abi::compatible<T>> class simd; 6346035553Spatricktemplate <class T> using native_simd = simd<T, simd_abi::native<T>>; 6446035553Spatricktemplate <class T, int N> using fixed_size_simd = simd<T, simd_abi::fixed_size<N>>; 6546035553Spatrick 6646035553Spatrick// class template simd_mask [simd.mask.class] 6746035553Spatricktemplate <class T, class Abi = simd_abi::compatible<T>> class simd_mask; 6846035553Spatricktemplate <class T> using native_simd_mask = simd_mask<T, simd_abi::native<T>>; 6946035553Spatricktemplate <class T, int N> using fixed_size_simd_mask = simd_mask<T, simd_abi::fixed_size<N>>; 7046035553Spatrick 7146035553Spatrick// casts [simd.casts] 7246035553Spatricktemplate <class T, class U, class Abi> see below simd_cast(const simd<U, Abi>&); 7346035553Spatricktemplate <class T, class U, class Abi> see below static_simd_cast(const simd<U, Abi>&); 7446035553Spatrick 7546035553Spatricktemplate <class T, class Abi> 7646035553Spatrickfixed_size_simd<T, simd_size_v<T, Abi>> to_fixed_size(const simd<T, Abi>&) noexcept; 7746035553Spatricktemplate <class T, class Abi> 7846035553Spatrickfixed_size_simd_mask<T, simd_size_v<T, Abi>> to_fixed_size(const simd_mask<T, Abi>&) noexcept; 7946035553Spatricktemplate <class T, size_t N> native_simd<T> to_native(const fixed_size_simd<T, N>&) noexcept; 8046035553Spatricktemplate <class T, size_t N> 8146035553Spatricknative_simd_mask<T> to_native(const fixed_size_simd_mask<T, N>> &) noexcept; 8246035553Spatricktemplate <class T, size_t N> simd<T> to_compatible(const fixed_size_simd<T, N>&) noexcept; 8346035553Spatricktemplate <class T, size_t N> simd_mask<T> to_compatible(const fixed_size_simd_mask<T, N>&) noexcept; 8446035553Spatrick 8546035553Spatricktemplate <size_t... Sizes, class T, class Abi> 8646035553Spatricktuple<simd<T, abi_for_size_t<Sizes>>...> split(const simd<T, Abi>&); 8746035553Spatricktemplate <size_t... Sizes, class T, class Abi> 8846035553Spatricktuple<simd_mask<T, abi_for_size_t<Sizes>>...> split(const simd_mask<T, Abi>&); 8946035553Spatricktemplate <class V, class Abi> 9046035553Spatrickarray<V, simd_size_v<typename V::value_type, Abi> / V::size()> split( 9146035553Spatrickconst simd<typename V::value_type, Abi>&); 9246035553Spatricktemplate <class V, class Abi> 9346035553Spatrickarray<V, simd_size_v<typename V::value_type, Abi> / V::size()> split( 9446035553Spatrickconst simd_mask<typename V::value_type, Abi>&); 9546035553Spatrick 9646035553Spatricktemplate <class T, class... Abis> 9746035553Spatricksimd<T, abi_for_size_t<T, (simd_size_v<T, Abis> + ...)>> concat(const simd<T, Abis>&...); 9846035553Spatricktemplate <class T, class... Abis> 9946035553Spatricksimd_mask<T, abi_for_size_t<T, (simd_size_v<T, Abis> + ...)>> concat(const simd_mask<T, Abis>&...); 10046035553Spatrick 10146035553Spatrick// reductions [simd.mask.reductions] 10246035553Spatricktemplate <class T, class Abi> bool all_of(const simd_mask<T, Abi>&) noexcept; 10346035553Spatricktemplate <class T, class Abi> bool any_of(const simd_mask<T, Abi>&) noexcept; 10446035553Spatricktemplate <class T, class Abi> bool none_of(const simd_mask<T, Abi>&) noexcept; 10546035553Spatricktemplate <class T, class Abi> bool some_of(const simd_mask<T, Abi>&) noexcept; 10646035553Spatricktemplate <class T, class Abi> int popcount(const simd_mask<T, Abi>&) noexcept; 10746035553Spatricktemplate <class T, class Abi> int find_first_set(const simd_mask<T, Abi>&); 10846035553Spatricktemplate <class T, class Abi> int find_last_set(const simd_mask<T, Abi>&); 10946035553Spatrick 11046035553Spatrickbool all_of(see below) noexcept; 11146035553Spatrickbool any_of(see below) noexcept; 11246035553Spatrickbool none_of(see below) noexcept; 11346035553Spatrickbool some_of(see below) noexcept; 11446035553Spatrickint popcount(see below) noexcept; 11546035553Spatrickint find_first_set(see below) noexcept; 11646035553Spatrickint find_last_set(see below) noexcept; 11746035553Spatrick 11846035553Spatrick// masked assignment [simd.whereexpr] 11946035553Spatricktemplate <class M, class T> class const_where_expression; 12046035553Spatricktemplate <class M, class T> class where_expression; 12146035553Spatrick 12246035553Spatrick// masked assignment [simd.mask.where] 12346035553Spatricktemplate <class T> struct nodeduce { using type = T; }; // exposition only 12446035553Spatrick 12546035553Spatricktemplate <class T> using nodeduce_t = typename nodeduce<T>::type; // exposition only 12646035553Spatrick 12746035553Spatricktemplate <class T, class Abi> 12846035553Spatrickwhere_expression<simd_mask<T, Abi>, simd<T, Abi>> 12946035553Spatrickwhere(const typename simd<T, Abi>::mask_type&, simd<T, Abi>&) noexcept; 13046035553Spatrick 13146035553Spatricktemplate <class T, class Abi> 13246035553Spatrickconst_where_expression<simd_mask<T, Abi>, const simd<T, Abi>> 13346035553Spatrickwhere(const typename simd<T, Abi>::mask_type&, const simd<T, Abi>&) noexcept; 13446035553Spatrick 13546035553Spatricktemplate <class T, class Abi> 13646035553Spatrickwhere_expression<simd_mask<T, Abi>, simd_mask<T, Abi>> 13746035553Spatrickwhere(const nodeduce_t<simd_mask<T, Abi>>&, simd_mask<T, Abi>&) noexcept; 13846035553Spatrick 13946035553Spatricktemplate <class T, class Abi> 14046035553Spatrickconst_where_expression<simd_mask<T, Abi>, const simd_mask<T, Abi>> 14146035553Spatrickwhere(const nodeduce_t<simd_mask<T, Abi>>&, const simd_mask<T, Abi>&) noexcept; 14246035553Spatrick 14346035553Spatricktemplate <class T> where_expression<bool, T> where(see below k, T& d) noexcept; 14446035553Spatrick 14546035553Spatricktemplate <class T> 14646035553Spatrickconst_where_expression<bool, const T> where(see below k, const T& d) noexcept; 14746035553Spatrick 14846035553Spatrick// reductions [simd.reductions] 14946035553Spatricktemplate <class T, class Abi, class BinaryOperation = std::plus<>> 15046035553SpatrickT reduce(const simd<T, Abi>&, BinaryOperation = BinaryOperation()); 15146035553Spatrick 15246035553Spatricktemplate <class M, class V, class BinaryOperation> 15346035553Spatricktypename V::value_type reduce(const const_where_expression<M, V>& x, 15446035553Spatricktypename V::value_type neutral_element, BinaryOperation binary_op); 15546035553Spatrick 15646035553Spatricktemplate <class M, class V> 15746035553Spatricktypename V::value_type reduce(const const_where_expression<M, V>& x, plus<> binary_op = plus<>()); 15846035553Spatrick 15946035553Spatricktemplate <class M, class V> 16046035553Spatricktypename V::value_type reduce(const const_where_expression<M, V>& x, multiplies<> binary_op); 16146035553Spatrick 16246035553Spatricktemplate <class M, class V> 16346035553Spatricktypename V::value_type reduce(const const_where_expression<M, V>& x, bit_and<> binary_op); 16446035553Spatrick 16546035553Spatricktemplate <class M, class V> 16646035553Spatricktypename V::value_type reduce(const const_where_expression<M, V>& x, bit_or<> binary_op); 16746035553Spatrick 16846035553Spatricktemplate <class M, class V> 16946035553Spatricktypename V::value_type reduce(const const_where_expression<M, V>& x, bit_xor<> binary_op); 17046035553Spatrick 17146035553Spatricktemplate <class T, class Abi> T hmin(const simd<T, Abi>&); 17246035553Spatricktemplate <class M, class V> T hmin(const const_where_expression<M, V>&); 17346035553Spatricktemplate <class T, class Abi> T hmax(const simd<T, Abi>&); 17446035553Spatricktemplate <class M, class V> T hmax(const const_where_expression<M, V>&); 17546035553Spatrick 17646035553Spatrick// algorithms [simd.alg] 17746035553Spatricktemplate <class T, class Abi> simd<T, Abi> min(const simd<T, Abi>&, const simd<T, Abi>&) noexcept; 17846035553Spatrick 17946035553Spatricktemplate <class T, class Abi> simd<T, Abi> max(const simd<T, Abi>&, const simd<T, Abi>&) noexcept; 18046035553Spatrick 18146035553Spatricktemplate <class T, class Abi> 18246035553Spatrickstd::pair<simd<T, Abi>, simd<T, Abi>> minmax(const simd<T, Abi>&, const simd<T, Abi>&) noexcept; 18346035553Spatrick 18446035553Spatricktemplate <class T, class Abi> 18546035553Spatricksimd<T, Abi> clamp(const simd<T, Abi>& v, const simd<T, Abi>& lo, const simd<T, Abi>& hi); 18646035553Spatrick 18746035553Spatrick// [simd.whereexpr] 18846035553Spatricktemplate <class M, class T> 18946035553Spatrickclass const_where_expression { 19046035553Spatrick const M& mask; // exposition only 19146035553Spatrick T& data; // exposition only 19246035553Spatrickpublic: 19346035553Spatrick const_where_expression(const const_where_expression&) = delete; 19446035553Spatrick const_where_expression& operator=(const const_where_expression&) = delete; 19546035553Spatrick remove_const_t<T> operator-() const &&; 19646035553Spatrick template <class U, class Flags> void copy_to(U* mem, Flags f) const &&; 19746035553Spatrick}; 19846035553Spatrick 19946035553Spatricktemplate <class M, class T> 20046035553Spatrickclass where_expression : public const_where_expression<M, T> { 20146035553Spatrickpublic: 20246035553Spatrick where_expression(const where_expression&) = delete; 20346035553Spatrick where_expression& operator=(const where_expression&) = delete; 20446035553Spatrick template <class U> void operator=(U&& x); 20546035553Spatrick template <class U> void operator+=(U&& x); 20646035553Spatrick template <class U> void operator-=(U&& x); 20746035553Spatrick template <class U> void operator*=(U&& x); 20846035553Spatrick template <class U> void operator/=(U&& x); 20946035553Spatrick template <class U> void operator%=(U&& x); 21046035553Spatrick template <class U> void operator&=(U&& x); 21146035553Spatrick template <class U> void operator|=(U&& x); 21246035553Spatrick template <class U> void operator^=(U&& x); 21346035553Spatrick template <class U> void operator<<=(U&& x); 21446035553Spatrick template <class U> void operator>>=(U&& x); 21546035553Spatrick void operator++(); 21646035553Spatrick void operator++(int); 21746035553Spatrick void operator--(); 21846035553Spatrick void operator--(int); 21946035553Spatrick template <class U, class Flags> void copy_from(const U* mem, Flags); 22046035553Spatrick}; 22146035553Spatrick 22246035553Spatrick// [simd.class] 22346035553Spatricktemplate <class T, class Abi> class simd { 22446035553Spatrickpublic: 22546035553Spatrick using value_type = T; 22646035553Spatrick using reference = see below; 22746035553Spatrick using mask_type = simd_mask<T, Abi>; 22846035553Spatrick 22946035553Spatrick using abi_type = Abi; 23046035553Spatrick static constexpr size_t size() noexcept; 23146035553Spatrick simd() = default; 23246035553Spatrick 23346035553Spatrick // implicit type conversion constructor 23446035553Spatrick template <class U> simd(const simd<U, simd_abi::fixed_size<size()>>&); 23546035553Spatrick 23646035553Spatrick // implicit broadcast constructor (see below for constraints) 23746035553Spatrick template <class U> simd(U&& value); 23846035553Spatrick 23946035553Spatrick // generator constructor (see below for constraints) 24046035553Spatrick template <class G> explicit simd(G&& gen); 24146035553Spatrick 24246035553Spatrick // load constructor 24346035553Spatrick template <class U, class Flags> simd(const U* mem, Flags f); 24446035553Spatrick 24546035553Spatrick // loads [simd.load] 24646035553Spatrick template <class U, class Flags> void copy_from(const U* mem, Flags f); 24746035553Spatrick 24846035553Spatrick // stores [simd.store] 24946035553Spatrick template <class U, class Flags> void copy_to(U* mem, Flags f) const; 25046035553Spatrick 25146035553Spatrick // scalar access [simd.subscr] 25246035553Spatrick reference operator[](size_t); 25346035553Spatrick value_type operator[](size_t) const; 25446035553Spatrick 25546035553Spatrick // unary operators [simd.unary] 25646035553Spatrick simd& operator++(); 25746035553Spatrick simd operator++(int); 25846035553Spatrick simd& operator--(); 25946035553Spatrick simd operator--(int); 26046035553Spatrick mask_type operator!() const; 26146035553Spatrick simd operator~() const; // see below 26246035553Spatrick simd operator+() const; 26346035553Spatrick simd operator-() const; 26446035553Spatrick 26546035553Spatrick // binary operators [simd.binary] 26646035553Spatrick friend simd operator+ (const simd&, const simd&); 26746035553Spatrick friend simd operator- (const simd&, const simd&); 26846035553Spatrick friend simd operator* (const simd&, const simd&); 26946035553Spatrick friend simd operator/ (const simd&, const simd&); 27046035553Spatrick friend simd operator% (const simd&, const simd&); 27146035553Spatrick friend simd operator& (const simd&, const simd&); 27246035553Spatrick friend simd operator| (const simd&, const simd&); 27346035553Spatrick friend simd operator^ (const simd&, const simd&); 27446035553Spatrick friend simd operator<<(const simd&, const simd&); 27546035553Spatrick friend simd operator>>(const simd&, const simd&); 27646035553Spatrick friend simd operator<<(const simd&, int); 27746035553Spatrick friend simd operator>>(const simd&, int); 27846035553Spatrick 27946035553Spatrick // compound assignment [simd.cassign] 28046035553Spatrick friend simd& operator+= (simd&, const simd&); 28146035553Spatrick friend simd& operator-= (simd&, const simd&); 28246035553Spatrick friend simd& operator*= (simd&, const simd&); 28346035553Spatrick friend simd& operator/= (simd&, const simd&); 28446035553Spatrick friend simd& operator%= (simd&, const simd&); 28546035553Spatrick 28646035553Spatrick friend simd& operator&= (simd&, const simd&); 28746035553Spatrick friend simd& operator|= (simd&, const simd&); 28846035553Spatrick friend simd& operator^= (simd&, const simd&); 28946035553Spatrick friend simd& operator<<=(simd&, const simd&); 29046035553Spatrick friend simd& operator>>=(simd&, const simd&); 29146035553Spatrick friend simd& operator<<=(simd&, int); 29246035553Spatrick friend simd& operator>>=(simd&, int); 29346035553Spatrick 29446035553Spatrick // compares [simd.comparison] 29546035553Spatrick friend mask_type operator==(const simd&, const simd&); 29646035553Spatrick friend mask_type operator!=(const simd&, const simd&); 29746035553Spatrick friend mask_type operator>=(const simd&, const simd&); 29846035553Spatrick friend mask_type operator<=(const simd&, const simd&); 29946035553Spatrick friend mask_type operator> (const simd&, const simd&); 30046035553Spatrick friend mask_type operator< (const simd&, const simd&); 30146035553Spatrick}; 30246035553Spatrick 30346035553Spatrick// [simd.math] 30446035553Spatricktemplate <class Abi> using scharv = simd<signed char, Abi>; // exposition only 30546035553Spatricktemplate <class Abi> using shortv = simd<short, Abi>; // exposition only 30646035553Spatricktemplate <class Abi> using intv = simd<int, Abi>; // exposition only 30746035553Spatricktemplate <class Abi> using longv = simd<long int, Abi>; // exposition only 30846035553Spatricktemplate <class Abi> using llongv = simd<long long int, Abi>; // exposition only 30946035553Spatricktemplate <class Abi> using floatv = simd<float, Abi>; // exposition only 31046035553Spatricktemplate <class Abi> using doublev = simd<double, Abi>; // exposition only 31146035553Spatricktemplate <class Abi> using ldoublev = simd<long double, Abi>; // exposition only 31246035553Spatricktemplate <class T, class V> using samesize = fixed_size_simd<T, V::size()>; // exposition only 31346035553Spatrick 31446035553Spatricktemplate <class Abi> floatv<Abi> acos(floatv<Abi> x); 31546035553Spatricktemplate <class Abi> doublev<Abi> acos(doublev<Abi> x); 31646035553Spatricktemplate <class Abi> ldoublev<Abi> acos(ldoublev<Abi> x); 31746035553Spatrick 31846035553Spatricktemplate <class Abi> floatv<Abi> asin(floatv<Abi> x); 31946035553Spatricktemplate <class Abi> doublev<Abi> asin(doublev<Abi> x); 32046035553Spatricktemplate <class Abi> ldoublev<Abi> asin(ldoublev<Abi> x); 32146035553Spatrick 32246035553Spatricktemplate <class Abi> floatv<Abi> atan(floatv<Abi> x); 32346035553Spatricktemplate <class Abi> doublev<Abi> atan(doublev<Abi> x); 32446035553Spatricktemplate <class Abi> ldoublev<Abi> atan(ldoublev<Abi> x); 32546035553Spatrick 32646035553Spatricktemplate <class Abi> floatv<Abi> atan2(floatv<Abi> y, floatv<Abi> x); 32746035553Spatricktemplate <class Abi> doublev<Abi> atan2(doublev<Abi> y, doublev<Abi> x); 32846035553Spatricktemplate <class Abi> ldoublev<Abi> atan2(ldoublev<Abi> y, ldoublev<Abi> x); 32946035553Spatrick 33046035553Spatricktemplate <class Abi> floatv<Abi> cos(floatv<Abi> x); 33146035553Spatricktemplate <class Abi> doublev<Abi> cos(doublev<Abi> x); 33246035553Spatricktemplate <class Abi> ldoublev<Abi> cos(ldoublev<Abi> x); 33346035553Spatrick 33446035553Spatricktemplate <class Abi> floatv<Abi> sin(floatv<Abi> x); 33546035553Spatricktemplate <class Abi> doublev<Abi> sin(doublev<Abi> x); 33646035553Spatricktemplate <class Abi> ldoublev<Abi> sin(ldoublev<Abi> x); 33746035553Spatrick 33846035553Spatricktemplate <class Abi> floatv<Abi> tan(floatv<Abi> x); 33946035553Spatricktemplate <class Abi> doublev<Abi> tan(doublev<Abi> x); 34046035553Spatricktemplate <class Abi> ldoublev<Abi> tan(ldoublev<Abi> x); 34146035553Spatrick 34246035553Spatricktemplate <class Abi> floatv<Abi> acosh(floatv<Abi> x); 34346035553Spatricktemplate <class Abi> doublev<Abi> acosh(doublev<Abi> x); 34446035553Spatricktemplate <class Abi> ldoublev<Abi> acosh(ldoublev<Abi> x); 34546035553Spatrick 34646035553Spatricktemplate <class Abi> floatv<Abi> asinh(floatv<Abi> x); 34746035553Spatricktemplate <class Abi> doublev<Abi> asinh(doublev<Abi> x); 34846035553Spatricktemplate <class Abi> ldoublev<Abi> asinh(ldoublev<Abi> x); 34946035553Spatrick 35046035553Spatricktemplate <class Abi> floatv<Abi> atanh(floatv<Abi> x); 35146035553Spatricktemplate <class Abi> doublev<Abi> atanh(doublev<Abi> x); 35246035553Spatricktemplate <class Abi> ldoublev<Abi> atanh(ldoublev<Abi> x); 35346035553Spatrick 35446035553Spatricktemplate <class Abi> floatv<Abi> cosh(floatv<Abi> x); 35546035553Spatricktemplate <class Abi> doublev<Abi> cosh(doublev<Abi> x); 35646035553Spatricktemplate <class Abi> ldoublev<Abi> cosh(ldoublev<Abi> x); 35746035553Spatrick 35846035553Spatricktemplate <class Abi> floatv<Abi> sinh(floatv<Abi> x); 35946035553Spatricktemplate <class Abi> doublev<Abi> sinh(doublev<Abi> x); 36046035553Spatricktemplate <class Abi> ldoublev<Abi> sinh(ldoublev<Abi> x); 36146035553Spatrick 36246035553Spatricktemplate <class Abi> floatv<Abi> tanh(floatv<Abi> x); 36346035553Spatricktemplate <class Abi> doublev<Abi> tanh(doublev<Abi> x); 36446035553Spatricktemplate <class Abi> ldoublev<Abi> tanh(ldoublev<Abi> x); 36546035553Spatrick 36646035553Spatricktemplate <class Abi> floatv<Abi> exp(floatv<Abi> x); 36746035553Spatricktemplate <class Abi> doublev<Abi> exp(doublev<Abi> x); 36846035553Spatricktemplate <class Abi> ldoublev<Abi> exp(ldoublev<Abi> x); 36946035553Spatrick 37046035553Spatricktemplate <class Abi> floatv<Abi> exp2(floatv<Abi> x); 37146035553Spatricktemplate <class Abi> doublev<Abi> exp2(doublev<Abi> x); 37246035553Spatricktemplate <class Abi> ldoublev<Abi> exp2(ldoublev<Abi> x); 37346035553Spatrick 37446035553Spatricktemplate <class Abi> floatv<Abi> expm1(floatv<Abi> x); 37546035553Spatricktemplate <class Abi> doublev<Abi> expm1(doublev<Abi> x); 37646035553Spatricktemplate <class Abi> ldoublev<Abi> expm1(ldoublev<Abi> x); 37746035553Spatrick 37846035553Spatricktemplate <class Abi> floatv<Abi> frexp(floatv<Abi> value, samesize<int, floatv<Abi>>* exp); 37946035553Spatricktemplate <class Abi> doublev<Abi> frexp(doublev<Abi> value, samesize<int, doublev<Abi>>* exp); 38046035553Spatricktemplate <class Abi> ldoublev<Abi> frexp(ldoublev<Abi> value, samesize<int, ldoublev<Abi>>* exp); 38146035553Spatrick 38246035553Spatricktemplate <class Abi> samesize<int, floatv<Abi>> ilogb(floatv<Abi> x); 38346035553Spatricktemplate <class Abi> samesize<int, doublev<Abi>> ilogb(doublev<Abi> x); 38446035553Spatricktemplate <class Abi> samesize<int, ldoublev<Abi>> ilogb(ldoublev<Abi> x); 38546035553Spatrick 38646035553Spatricktemplate <class Abi> floatv<Abi> ldexp(floatv<Abi> x, samesize<int, floatv<Abi>> exp); 38746035553Spatricktemplate <class Abi> doublev<Abi> ldexp(doublev<Abi> x, samesize<int, doublev<Abi>> exp); 38846035553Spatricktemplate <class Abi> ldoublev<Abi> ldexp(ldoublev<Abi> x, samesize<int, ldoublev<Abi>> exp); 38946035553Spatrick 39046035553Spatricktemplate <class Abi> floatv<Abi> log(floatv<Abi> x); 39146035553Spatricktemplate <class Abi> doublev<Abi> log(doublev<Abi> x); 39246035553Spatricktemplate <class Abi> ldoublev<Abi> log(ldoublev<Abi> x); 39346035553Spatrick 39446035553Spatricktemplate <class Abi> floatv<Abi> log10(floatv<Abi> x); 39546035553Spatricktemplate <class Abi> doublev<Abi> log10(doublev<Abi> x); 39646035553Spatricktemplate <class Abi> ldoublev<Abi> log10(ldoublev<Abi> x); 39746035553Spatrick 39846035553Spatricktemplate <class Abi> floatv<Abi> log1p(floatv<Abi> x); 39946035553Spatricktemplate <class Abi> doublev<Abi> log1p(doublev<Abi> x); 40046035553Spatricktemplate <class Abi> ldoublev<Abi> log1p(ldoublev<Abi> x); 40146035553Spatrick 40246035553Spatricktemplate <class Abi> floatv<Abi> log2(floatv<Abi> x); 40346035553Spatricktemplate <class Abi> doublev<Abi> log2(doublev<Abi> x); 40446035553Spatricktemplate <class Abi> ldoublev<Abi> log2(ldoublev<Abi> x); 40546035553Spatrick 40646035553Spatricktemplate <class Abi> floatv<Abi> logb(floatv<Abi> x); 40746035553Spatricktemplate <class Abi> doublev<Abi> logb(doublev<Abi> x); 40846035553Spatricktemplate <class Abi> ldoublev<Abi> logb(ldoublev<Abi> x); 40946035553Spatrick 41046035553Spatricktemplate <class Abi> floatv<Abi> modf(floatv<Abi> value, floatv<Abi>* iptr); 41146035553Spatricktemplate <class Abi> doublev<Abi> modf(doublev<Abi> value, doublev<Abi>* iptr); 41246035553Spatricktemplate <class Abi> ldoublev<Abi> modf(ldoublev<Abi> value, ldoublev<Abi>* iptr); 41346035553Spatrick 41446035553Spatricktemplate <class Abi> floatv<Abi> scalbn(floatv<Abi> x, samesize<int, floatv<Abi>> n); 41546035553Spatricktemplate <class Abi> doublev<Abi> scalbn(doublev<Abi> x, samesize<int, doublev<Abi>> n); 41646035553Spatricktemplate <class Abi> ldoublev<Abi> scalbn(ldoublev<Abi> x, samesize<int, ldoublev<Abi>> n); 41746035553Spatricktemplate <class Abi> floatv<Abi> scalbln(floatv<Abi> x, samesize<long int, floatv<Abi>> n); 41846035553Spatricktemplate <class Abi> doublev<Abi> scalbln(doublev<Abi> x, samesize<long int, doublev<Abi>> n); 41946035553Spatricktemplate <class Abi> ldoublev<Abi> scalbln(ldoublev<Abi> x, samesize<long int, ldoublev<Abi>> n); 42046035553Spatrick 42146035553Spatricktemplate <class Abi> floatv<Abi> cbrt(floatv<Abi> x); 42246035553Spatricktemplate <class Abi> doublev<Abi> cbrt(doublev<Abi> x); 42346035553Spatricktemplate <class Abi> ldoublev<Abi> cbrt(ldoublev<Abi> x); 42446035553Spatrick 42546035553Spatricktemplate <class Abi> scharv<Abi> abs(scharv<Abi> j); 42646035553Spatricktemplate <class Abi> shortv<Abi> abs(shortv<Abi> j); 42746035553Spatricktemplate <class Abi> intv<Abi> abs(intv<Abi> j); 42846035553Spatricktemplate <class Abi> longv<Abi> abs(longv<Abi> j); 42946035553Spatricktemplate <class Abi> llongv<Abi> abs(llongv<Abi> j); 43046035553Spatricktemplate <class Abi> floatv<Abi> abs(floatv<Abi> j); 43146035553Spatricktemplate <class Abi> doublev<Abi> abs(doublev<Abi> j); 43246035553Spatricktemplate <class Abi> ldoublev<Abi> abs(ldoublev<Abi> j); 43346035553Spatrick 43446035553Spatricktemplate <class Abi> floatv<Abi> hypot(floatv<Abi> x, floatv<Abi> y); 43546035553Spatricktemplate <class Abi> doublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y); 43646035553Spatricktemplate <class Abi> ldoublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y); 43746035553Spatricktemplate <class Abi> floatv<Abi> hypot(floatv<Abi> x, floatv<Abi> y, floatv<Abi> z); 43846035553Spatricktemplate <class Abi> doublev<Abi> hypot(doublev<Abi> x, doublev<Abi> y, doublev<Abi> z); 43946035553Spatricktemplate <class Abi> ldoublev<Abi> hypot(ldoublev<Abi> x, ldoublev<Abi> y, ldoublev<Abi> z); 44046035553Spatrick 44146035553Spatricktemplate <class Abi> floatv<Abi> pow(floatv<Abi> x, floatv<Abi> y); 44246035553Spatricktemplate <class Abi> doublev<Abi> pow(doublev<Abi> x, doublev<Abi> y); 44346035553Spatricktemplate <class Abi> ldoublev<Abi> pow(ldoublev<Abi> x, ldoublev<Abi> y); 44446035553Spatrick 44546035553Spatricktemplate <class Abi> floatv<Abi> sqrt(floatv<Abi> x); 44646035553Spatricktemplate <class Abi> doublev<Abi> sqrt(doublev<Abi> x); 44746035553Spatricktemplate <class Abi> ldoublev<Abi> sqrt(ldoublev<Abi> x); 44846035553Spatrick 44946035553Spatricktemplate <class Abi> floatv<Abi> erf(floatv<Abi> x); 45046035553Spatricktemplate <class Abi> doublev<Abi> erf(doublev<Abi> x); 45146035553Spatricktemplate <class Abi> ldoublev<Abi> erf(ldoublev<Abi> x); 45246035553Spatricktemplate <class Abi> floatv<Abi> erfc(floatv<Abi> x); 45346035553Spatricktemplate <class Abi> doublev<Abi> erfc(doublev<Abi> x); 45446035553Spatricktemplate <class Abi> ldoublev<Abi> erfc(ldoublev<Abi> x); 45546035553Spatrick 45646035553Spatricktemplate <class Abi> floatv<Abi> lgamma(floatv<Abi> x); 45746035553Spatricktemplate <class Abi> doublev<Abi> lgamma(doublev<Abi> x); 45846035553Spatricktemplate <class Abi> ldoublev<Abi> lgamma(ldoublev<Abi> x); 45946035553Spatrick 46046035553Spatricktemplate <class Abi> floatv<Abi> tgamma(floatv<Abi> x); 46146035553Spatricktemplate <class Abi> doublev<Abi> tgamma(doublev<Abi> x); 46246035553Spatricktemplate <class Abi> ldoublev<Abi> tgamma(ldoublev<Abi> x); 46346035553Spatrick 46446035553Spatricktemplate <class Abi> floatv<Abi> ceil(floatv<Abi> x); 46546035553Spatricktemplate <class Abi> doublev<Abi> ceil(doublev<Abi> x); 46646035553Spatricktemplate <class Abi> ldoublev<Abi> ceil(ldoublev<Abi> x); 46746035553Spatrick 46846035553Spatricktemplate <class Abi> floatv<Abi> floor(floatv<Abi> x); 46946035553Spatricktemplate <class Abi> doublev<Abi> floor(doublev<Abi> x); 47046035553Spatricktemplate <class Abi> ldoublev<Abi> floor(ldoublev<Abi> x); 47146035553Spatrick 47246035553Spatricktemplate <class Abi> floatv<Abi> nearbyint(floatv<Abi> x); 47346035553Spatricktemplate <class Abi> doublev<Abi> nearbyint(doublev<Abi> x); 47446035553Spatricktemplate <class Abi> ldoublev<Abi> nearbyint(ldoublev<Abi> x); 47546035553Spatrick 47646035553Spatricktemplate <class Abi> floatv<Abi> rint(floatv<Abi> x); 47746035553Spatricktemplate <class Abi> doublev<Abi> rint(doublev<Abi> x); 47846035553Spatricktemplate <class Abi> ldoublev<Abi> rint(ldoublev<Abi> x); 47946035553Spatrick 48046035553Spatricktemplate <class Abi> samesize<long int, floatv<Abi>> lrint(floatv<Abi> x); 48146035553Spatricktemplate <class Abi> samesize<long int, doublev<Abi>> lrint(doublev<Abi> x); 48246035553Spatricktemplate <class Abi> samesize<long int, ldoublev<Abi>> lrint(ldoublev<Abi> x); 48346035553Spatricktemplate <class Abi> samesize<long long int, floatv<Abi>> llrint(floatv<Abi> x); 48446035553Spatricktemplate <class Abi> samesize<long long int, doublev<Abi>> llrint(doublev<Abi> x); 48546035553Spatricktemplate <class Abi> samesize<long long int, ldoublev<Abi>> llrint(ldoublev<Abi> x); 48646035553Spatrick 48746035553Spatricktemplate <class Abi> floatv<Abi> round(floatv<Abi> x); 48846035553Spatricktemplate <class Abi> doublev<Abi> round(doublev<Abi> x); 48946035553Spatricktemplate <class Abi> ldoublev<Abi> round(ldoublev<Abi> x); 49046035553Spatricktemplate <class Abi> samesize<long int, floatv<Abi>> lround(floatv<Abi> x); 49146035553Spatricktemplate <class Abi> samesize<long int, doublev<Abi>> lround(doublev<Abi> x); 49246035553Spatricktemplate <class Abi> samesize<long int, ldoublev<Abi>> lround(ldoublev<Abi> x); 49346035553Spatricktemplate <class Abi> samesize<long long int, floatv<Abi>> llround(floatv<Abi> x); 49446035553Spatricktemplate <class Abi> samesize<long long int, doublev<Abi>> llround(doublev<Abi> x); 49546035553Spatricktemplate <class Abi> samesize<long long int, ldoublev<Abi>> llround(ldoublev<Abi> x); 49646035553Spatrick 49746035553Spatricktemplate <class Abi> floatv<Abi> trunc(floatv<Abi> x); 49846035553Spatricktemplate <class Abi> doublev<Abi> trunc(doublev<Abi> x); 49946035553Spatricktemplate <class Abi> ldoublev<Abi> trunc(ldoublev<Abi> x); 50046035553Spatrick 50146035553Spatricktemplate <class Abi> floatv<Abi> fmod(floatv<Abi> x, floatv<Abi> y); 50246035553Spatricktemplate <class Abi> doublev<Abi> fmod(doublev<Abi> x, doublev<Abi> y); 50346035553Spatricktemplate <class Abi> ldoublev<Abi> fmod(ldoublev<Abi> x, ldoublev<Abi> y); 50446035553Spatrick 50546035553Spatricktemplate <class Abi> floatv<Abi> remainder(floatv<Abi> x, floatv<Abi> y); 50646035553Spatricktemplate <class Abi> doublev<Abi> remainder(doublev<Abi> x, doublev<Abi> y); 50746035553Spatricktemplate <class Abi> ldoublev<Abi> remainder(ldoublev<Abi> x, ldoublev<Abi> y); 50846035553Spatrick 50946035553Spatricktemplate <class Abi> floatv<Abi> remquo(floatv<Abi> x, floatv<Abi> y, samesize<int, floatv<Abi>>* quo); 51046035553Spatricktemplate <class Abi> doublev<Abi> remquo(doublev<Abi> x, doublev<Abi> y, samesize<int, doublev<Abi>>* quo); 51146035553Spatricktemplate <class Abi> ldoublev<Abi> remquo(ldoublev<Abi> x, ldoublev<Abi> y, samesize<int, ldoublev<Abi>>* quo); 51246035553Spatrick 51346035553Spatricktemplate <class Abi> floatv<Abi> copysign(floatv<Abi> x, floatv<Abi> y); 51446035553Spatricktemplate <class Abi> doublev<Abi> copysign(doublev<Abi> x, doublev<Abi> y); 51546035553Spatricktemplate <class Abi> ldoublev<Abi> copysign(ldoublev<Abi> x, ldoublev<Abi> y); 51646035553Spatrick 51746035553Spatricktemplate <class Abi> doublev<Abi> nan(const char* tagp); 51846035553Spatricktemplate <class Abi> floatv<Abi> nanf(const char* tagp); 51946035553Spatricktemplate <class Abi> ldoublev<Abi> nanl(const char* tagp); 52046035553Spatrick 52146035553Spatricktemplate <class Abi> floatv<Abi> nextafter(floatv<Abi> x, floatv<Abi> y); 52246035553Spatricktemplate <class Abi> doublev<Abi> nextafter(doublev<Abi> x, doublev<Abi> y); 52346035553Spatricktemplate <class Abi> ldoublev<Abi> nextafter(ldoublev<Abi> x, ldoublev<Abi> y); 52446035553Spatrick 52546035553Spatricktemplate <class Abi> floatv<Abi> nexttoward(floatv<Abi> x, ldoublev<Abi> y); 52646035553Spatricktemplate <class Abi> doublev<Abi> nexttoward(doublev<Abi> x, ldoublev<Abi> y); 52746035553Spatricktemplate <class Abi> ldoublev<Abi> nexttoward(ldoublev<Abi> x, ldoublev<Abi> y); 52846035553Spatrick 52946035553Spatricktemplate <class Abi> floatv<Abi> fdim(floatv<Abi> x, floatv<Abi> y); 53046035553Spatricktemplate <class Abi> doublev<Abi> fdim(doublev<Abi> x, doublev<Abi> y); 53146035553Spatricktemplate <class Abi> ldoublev<Abi> fdim(ldoublev<Abi> x, ldoublev<Abi> y); 53246035553Spatrick 53346035553Spatricktemplate <class Abi> floatv<Abi> fmax(floatv<Abi> x, floatv<Abi> y); 53446035553Spatricktemplate <class Abi> doublev<Abi> fmax(doublev<Abi> x, doublev<Abi> y); 53546035553Spatricktemplate <class Abi> ldoublev<Abi> fmax(ldoublev<Abi> x, ldoublev<Abi> y); 53646035553Spatrick 53746035553Spatricktemplate <class Abi> floatv<Abi> fmin(floatv<Abi> x, floatv<Abi> y); 53846035553Spatricktemplate <class Abi> doublev<Abi> fmin(doublev<Abi> x, doublev<Abi> y); 53946035553Spatricktemplate <class Abi> ldoublev<Abi> fmin(ldoublev<Abi> x, ldoublev<Abi> y); 54046035553Spatrick 54146035553Spatricktemplate <class Abi> floatv<Abi> fma(floatv<Abi> x, floatv<Abi> y, floatv<Abi> z); 54246035553Spatricktemplate <class Abi> doublev<Abi> fma(doublev<Abi> x, doublev<Abi> y, doublev<Abi> z); 54346035553Spatricktemplate <class Abi> ldoublev<Abi> fma(ldoublev<Abi> x, ldoublev<Abi> y, ldoublev<Abi> z); 54446035553Spatrick 54546035553Spatricktemplate <class Abi> samesize<int, floatv<Abi>> fpclassify(floatv<Abi> x); 54646035553Spatricktemplate <class Abi> samesize<int, doublev<Abi>> fpclassify(doublev<Abi> x); 54746035553Spatricktemplate <class Abi> samesize<int, ldoublev<Abi>> fpclassify(ldoublev<Abi> x); 54846035553Spatrick 54946035553Spatricktemplate <class Abi> simd_mask<float, Abi> isfinite(floatv<Abi> x); 55046035553Spatricktemplate <class Abi> simd_mask<double, Abi> isfinite(doublev<Abi> x); 55146035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isfinite(ldoublev<Abi> x); 55246035553Spatrick 55346035553Spatricktemplate <class Abi> simd_mask<float, Abi> isinf(floatv<Abi> x); 55446035553Spatricktemplate <class Abi> simd_mask<double, Abi> isinf(doublev<Abi> x); 55546035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isinf(ldoublev<Abi> x); 55646035553Spatrick 55746035553Spatricktemplate <class Abi> simd_mask<float, Abi> isnan(floatv<Abi> x); 55846035553Spatricktemplate <class Abi> simd_mask<double, Abi> isnan(doublev<Abi> x); 55946035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isnan(ldoublev<Abi> x); 56046035553Spatrick 56146035553Spatricktemplate <class Abi> simd_mask<float, Abi> isnormal(floatv<Abi> x); 56246035553Spatricktemplate <class Abi> simd_mask<double, Abi> isnormal(doublev<Abi> x); 56346035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isnormal(ldoublev<Abi> x); 56446035553Spatrick 56546035553Spatricktemplate <class Abi> simd_mask<float, Abi> signbit(floatv<Abi> x); 56646035553Spatricktemplate <class Abi> simd_mask<double, Abi> signbit(doublev<Abi> x); 56746035553Spatricktemplate <class Abi> simd_mask<long double, Abi> signbit(ldoublev<Abi> x); 56846035553Spatrick 56946035553Spatricktemplate <class Abi> simd_mask<float, Abi> isgreater(floatv<Abi> x, floatv<Abi> y); 57046035553Spatricktemplate <class Abi> simd_mask<double, Abi> isgreater(doublev<Abi> x, doublev<Abi> y); 57146035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isgreater(ldoublev<Abi> x, ldoublev<Abi> y); 57246035553Spatrick 57346035553Spatricktemplate <class Abi> simd_mask<float, Abi> isgreaterequal(floatv<Abi> x, floatv<Abi> y); 57446035553Spatricktemplate <class Abi> simd_mask<double, Abi> isgreaterequal(doublev<Abi> x, doublev<Abi> y); 57546035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isgreaterequal(ldoublev<Abi> x, ldoublev<Abi> y); 57646035553Spatrick 57746035553Spatricktemplate <class Abi> simd_mask<float, Abi> isless(floatv<Abi> x, floatv<Abi> y); 57846035553Spatricktemplate <class Abi> simd_mask<double, Abi> isless(doublev<Abi> x, doublev<Abi> y); 57946035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isless(ldoublev<Abi> x, ldoublev<Abi> y); 58046035553Spatrick 58146035553Spatricktemplate <class Abi> simd_mask<float, Abi> islessequal(floatv<Abi> x, floatv<Abi> y); 58246035553Spatricktemplate <class Abi> simd_mask<double, Abi> islessequal(doublev<Abi> x, doublev<Abi> y); 58346035553Spatricktemplate <class Abi> simd_mask<long double, Abi> islessequal(ldoublev<Abi> x, ldoublev<Abi> y); 58446035553Spatrick 58546035553Spatricktemplate <class Abi> simd_mask<float, Abi> islessgreater(floatv<Abi> x, floatv<Abi> y); 58646035553Spatricktemplate <class Abi> simd_mask<double, Abi> islessgreater(doublev<Abi> x, doublev<Abi> y); 58746035553Spatricktemplate <class Abi> simd_mask<long double, Abi> islessgreater(ldoublev<Abi> x, ldoublev<Abi> y); 58846035553Spatrick 58946035553Spatricktemplate <class Abi> simd_mask<float, Abi> isunordered(floatv<Abi> x, floatv<Abi> y); 59046035553Spatricktemplate <class Abi> simd_mask<double, Abi> isunordered(doublev<Abi> x, doublev<Abi> y); 59146035553Spatricktemplate <class Abi> simd_mask<long double, Abi> isunordered(ldoublev<Abi> x, ldoublev<Abi> y); 59246035553Spatrick 59346035553Spatricktemplate <class V> struct simd_div_t { V quot, rem; }; 59446035553Spatricktemplate <class Abi> simd_div_t<scharv<Abi>> div(scharv<Abi> numer, scharv<Abi> denom); 59546035553Spatricktemplate <class Abi> simd_div_t<shortv<Abi>> div(shortv<Abi> numer, shortv<Abi> denom); 59646035553Spatricktemplate <class Abi> simd_div_t<intv<Abi>> div(intv<Abi> numer, intv<Abi> denom); 59746035553Spatricktemplate <class Abi> simd_div_t<longv<Abi>> div(longv<Abi> numer, longv<Abi> denom); 59846035553Spatricktemplate <class Abi> simd_div_t<llongv<Abi>> div(llongv<Abi> numer, llongv<Abi> denom); 59946035553Spatrick 60046035553Spatrick// [simd.mask.class] 60146035553Spatricktemplate <class T, class Abi> 60246035553Spatrickclass simd_mask { 60346035553Spatrickpublic: 60446035553Spatrick using value_type = bool; 60546035553Spatrick using reference = see below; 60646035553Spatrick using simd_type = simd<T, Abi>; 60746035553Spatrick using abi_type = Abi; 60846035553Spatrick static constexpr size_t size() noexcept; 60946035553Spatrick simd_mask() = default; 61046035553Spatrick 61146035553Spatrick // broadcast constructor 61246035553Spatrick explicit simd_mask(value_type) noexcept; 61346035553Spatrick 61446035553Spatrick // implicit type conversion constructor 61546035553Spatrick template <class U> simd_mask(const simd_mask<U, simd_abi::fixed_size<size()>>&) noexcept; 61646035553Spatrick 61746035553Spatrick // load constructor 61846035553Spatrick template <class Flags> simd_mask(const value_type* mem, Flags); 61946035553Spatrick 62046035553Spatrick // loads [simd.mask.copy] 62146035553Spatrick template <class Flags> void copy_from(const value_type* mem, Flags); 62246035553Spatrick template <class Flags> void copy_to(value_type* mem, Flags) const; 62346035553Spatrick 62446035553Spatrick // scalar access [simd.mask.subscr] 62546035553Spatrick reference operator[](size_t); 62646035553Spatrick value_type operator[](size_t) const; 62746035553Spatrick 62846035553Spatrick // unary operators [simd.mask.unary] 62946035553Spatrick simd_mask operator!() const noexcept; 63046035553Spatrick 63146035553Spatrick // simd_mask binary operators [simd.mask.binary] 63246035553Spatrick friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept; 63346035553Spatrick friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept; 63446035553Spatrick friend simd_mask operator& (const simd_mask&, const simd_mask&) noexcept; 63546035553Spatrick friend simd_mask operator| (const simd_mask&, const simd_mask&) noexcept; 63646035553Spatrick friend simd_mask operator^ (const simd_mask&, const simd_mask&) noexcept; 63746035553Spatrick 63846035553Spatrick // simd_mask compound assignment [simd.mask.cassign] 63946035553Spatrick friend simd_mask& operator&=(simd_mask&, const simd_mask&) noexcept; 64046035553Spatrick friend simd_mask& operator|=(simd_mask&, const simd_mask&) noexcept; 64146035553Spatrick friend simd_mask& operator^=(simd_mask&, const simd_mask&) noexcept; 64246035553Spatrick 64346035553Spatrick // simd_mask compares [simd.mask.comparison] 64446035553Spatrick friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept; 64546035553Spatrick friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept; 64646035553Spatrick}; 64746035553Spatrick 64846035553Spatrick} // parallelism_v2 64946035553Spatrick} // std::experimental 65046035553Spatrick 65146035553Spatrick*/ 65246035553Spatrick 653*4bdff4beSrobert#include <__assert> // all public C++ headers provide the assertion handler 654*4bdff4beSrobert#include <__functional/operations.h> 65546035553Spatrick#include <array> 65646035553Spatrick#include <cstddef> 657*4bdff4beSrobert#include <experimental/__config> 658*4bdff4beSrobert#include <tuple> 65946035553Spatrick 66046035553Spatrick#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 66146035553Spatrick# pragma GCC system_header 66246035553Spatrick#endif 66346035553Spatrick 66476d0caaeSpatrick_LIBCPP_PUSH_MACROS 66576d0caaeSpatrick#include <__undef_macros> 66676d0caaeSpatrick 66746035553Spatrick_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD 66846035553Spatrick 66946035553Spatrick#if _LIBCPP_STD_VER >= 17 67046035553Spatrick 67146035553Spatrickenum class _StorageKind { 67246035553Spatrick _Scalar, 67346035553Spatrick _Array, 67446035553Spatrick _VecExt, 67546035553Spatrick}; 67646035553Spatrick 67746035553Spatricktemplate <_StorageKind __kind, int _Np> 67846035553Spatrickstruct __simd_abi {}; 67946035553Spatrick 68046035553Spatricktemplate <class _Tp, class _Abi> 68146035553Spatrickclass __simd_storage {}; 68246035553Spatrick 68346035553Spatricktemplate <class _Tp, int __num_element> 68446035553Spatrickclass __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> { 68546035553Spatrick std::array<_Tp, __num_element> __storage_; 68646035553Spatrick 68746035553Spatrick template <class, class> 68846035553Spatrick friend struct simd; 68946035553Spatrick 69046035553Spatrick template <class, class> 69146035553Spatrick friend struct simd_mask; 69246035553Spatrick 69346035553Spatrickpublic: 694*4bdff4beSrobert _Tp __get(size_t __index) const noexcept { return __storage_[__index]; } 69546035553Spatrick void __set(size_t __index, _Tp __val) noexcept { 69646035553Spatrick __storage_[__index] = __val; 69746035553Spatrick } 69846035553Spatrick}; 69946035553Spatrick 70046035553Spatricktemplate <class _Tp> 70146035553Spatrickclass __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { 70246035553Spatrick _Tp __storage_; 70346035553Spatrick 70446035553Spatrick template <class, class> 70546035553Spatrick friend struct simd; 70646035553Spatrick 70746035553Spatrick template <class, class> 70846035553Spatrick friend struct simd_mask; 70946035553Spatrick 71046035553Spatrickpublic: 711*4bdff4beSrobert _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; } 71246035553Spatrick void __set(size_t __index, _Tp __val) noexcept { 71346035553Spatrick (&__storage_)[__index] = __val; 71446035553Spatrick } 71546035553Spatrick}; 71646035553Spatrick 71746035553Spatrick#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION 71846035553Spatrick 719*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI constexpr size_t __floor_pow_of_2(size_t __val) { 72046035553Spatrick return ((__val - 1) & __val) == 0 ? __val 72146035553Spatrick : __floor_pow_of_2((__val - 1) & __val); 72246035553Spatrick} 72346035553Spatrick 724*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI constexpr size_t __ceil_pow_of_2(size_t __val) { 72546035553Spatrick return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1; 72646035553Spatrick} 72746035553Spatrick 72846035553Spatricktemplate <class _Tp, size_t __bytes> 72946035553Spatrickstruct __vec_ext_traits { 73076d0caaeSpatrick#if !defined(_LIBCPP_COMPILER_CLANG_BASED) 73146035553Spatrick typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes)))); 73246035553Spatrick#endif 73346035553Spatrick}; 73446035553Spatrick 73576d0caaeSpatrick#if defined(_LIBCPP_COMPILER_CLANG_BASED) 73646035553Spatrick#define _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT) \ 73746035553Spatrick template <> \ 73846035553Spatrick struct __vec_ext_traits<_TYPE, sizeof(_TYPE) * _NUM_ELEMENT> { \ 73946035553Spatrick using type = \ 74046035553Spatrick _TYPE __attribute__((vector_size(sizeof(_TYPE) * _NUM_ELEMENT))); \ 74146035553Spatrick } 74246035553Spatrick 74346035553Spatrick#define _LIBCPP_SPECIALIZE_VEC_EXT_32(_TYPE) \ 74446035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 1); \ 74546035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 2); \ 74646035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 3); \ 74746035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 4); \ 74846035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 5); \ 74946035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 6); \ 75046035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 7); \ 75146035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 8); \ 75246035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 9); \ 75346035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 10); \ 75446035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 11); \ 75546035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 12); \ 75646035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 13); \ 75746035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 14); \ 75846035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 15); \ 75946035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 16); \ 76046035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 17); \ 76146035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 18); \ 76246035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 19); \ 76346035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 20); \ 76446035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 21); \ 76546035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 22); \ 76646035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 23); \ 76746035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 24); \ 76846035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 25); \ 76946035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 26); \ 77046035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 27); \ 77146035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 28); \ 77246035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 29); \ 77346035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 30); \ 77446035553Spatrick _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 31); \ 775*4bdff4beSrobert _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 32) 77646035553Spatrick 77746035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(char); 77846035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(char16_t); 77946035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(char32_t); 78046035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(wchar_t); 78146035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(signed char); 78246035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(signed short); 78346035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(signed int); 78446035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long); 78546035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(signed long long); 78646035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned char); 78746035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned short); 78846035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned int); 78946035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long); 79046035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(unsigned long long); 79146035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(float); 79246035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(double); 79346035553Spatrick_LIBCPP_SPECIALIZE_VEC_EXT_32(long double); 79446035553Spatrick 79546035553Spatrick#undef _LIBCPP_SPECIALIZE_VEC_EXT_32 79646035553Spatrick#undef _LIBCPP_SPECIALIZE_VEC_EXT 79746035553Spatrick#endif 79846035553Spatrick 79946035553Spatricktemplate <class _Tp, int __num_element> 80046035553Spatrickclass __simd_storage<_Tp, __simd_abi<_StorageKind::_VecExt, __num_element>> { 80146035553Spatrick using _StorageType = 80246035553Spatrick typename __vec_ext_traits<_Tp, sizeof(_Tp) * __num_element>::type; 80346035553Spatrick 80446035553Spatrick _StorageType __storage_; 80546035553Spatrick 80646035553Spatrick template <class, class> 80746035553Spatrick friend struct simd; 80846035553Spatrick 80946035553Spatrick template <class, class> 81046035553Spatrick friend struct simd_mask; 81146035553Spatrick 81246035553Spatrickpublic: 813*4bdff4beSrobert _Tp __get(size_t __index) const noexcept { return __storage_[__index]; } 81446035553Spatrick void __set(size_t __index, _Tp __val) noexcept { 81546035553Spatrick __storage_[__index] = __val; 81646035553Spatrick } 81746035553Spatrick}; 81846035553Spatrick 81946035553Spatrick#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION 82046035553Spatrick 82146035553Spatricktemplate <class _Vp, class _Tp, class _Abi> 82246035553Spatrickclass __simd_reference { 82346035553Spatrick static_assert(std::is_same<_Vp, _Tp>::value, ""); 82446035553Spatrick 82546035553Spatrick template <class, class> 82646035553Spatrick friend struct simd; 82746035553Spatrick 82846035553Spatrick template <class, class> 82946035553Spatrick friend struct simd_mask; 83046035553Spatrick 83146035553Spatrick __simd_storage<_Tp, _Abi>* __ptr_; 83246035553Spatrick size_t __index_; 83346035553Spatrick 83446035553Spatrick __simd_reference(__simd_storage<_Tp, _Abi>* __ptr, size_t __index) 83546035553Spatrick : __ptr_(__ptr), __index_(__index) {} 83646035553Spatrick 83746035553Spatrick __simd_reference(const __simd_reference&) = default; 83846035553Spatrick 83946035553Spatrickpublic: 84046035553Spatrick __simd_reference() = delete; 84146035553Spatrick __simd_reference& operator=(const __simd_reference&) = delete; 84246035553Spatrick 84346035553Spatrick operator _Vp() const { return __ptr_->__get(__index_); } 84446035553Spatrick 84546035553Spatrick __simd_reference operator=(_Vp __value) && { 84646035553Spatrick __ptr_->__set(__index_, __value); 84746035553Spatrick return *this; 84846035553Spatrick } 84946035553Spatrick 85046035553Spatrick __simd_reference operator++() && { 85146035553Spatrick return std::move(*this) = __ptr_->__get(__index_) + 1; 85246035553Spatrick } 85346035553Spatrick 85446035553Spatrick _Vp operator++(int) && { 85546035553Spatrick auto __val = __ptr_->__get(__index_); 85646035553Spatrick __ptr_->__set(__index_, __val + 1); 85746035553Spatrick return __val; 85846035553Spatrick } 85946035553Spatrick 86046035553Spatrick __simd_reference operator--() && { 86146035553Spatrick return std::move(*this) = __ptr_->__get(__index_) - 1; 86246035553Spatrick } 86346035553Spatrick 86446035553Spatrick _Vp operator--(int) && { 86546035553Spatrick auto __val = __ptr_->__get(__index_); 86646035553Spatrick __ptr_->__set(__index_, __val - 1); 86746035553Spatrick return __val; 86846035553Spatrick } 86946035553Spatrick 87046035553Spatrick __simd_reference operator+=(_Vp __value) && { 87146035553Spatrick return std::move(*this) = __ptr_->__get(__index_) + __value; 87246035553Spatrick } 87346035553Spatrick 87446035553Spatrick __simd_reference operator-=(_Vp __value) && { 87546035553Spatrick return std::move(*this) = __ptr_->__get(__index_) - __value; 87646035553Spatrick } 87746035553Spatrick 87846035553Spatrick __simd_reference operator*=(_Vp __value) && { 87946035553Spatrick return std::move(*this) = __ptr_->__get(__index_) * __value; 88046035553Spatrick } 88146035553Spatrick 88246035553Spatrick __simd_reference operator/=(_Vp __value) && { 88346035553Spatrick return std::move(*this) = __ptr_->__get(__index_) / __value; 88446035553Spatrick } 88546035553Spatrick 88646035553Spatrick __simd_reference operator%=(_Vp __value) && { 88746035553Spatrick return std::move(*this) = __ptr_->__get(__index_) % __value; 88846035553Spatrick } 88946035553Spatrick 89046035553Spatrick __simd_reference operator>>=(_Vp __value) && { 89146035553Spatrick return std::move(*this) = __ptr_->__get(__index_) >> __value; 89246035553Spatrick } 89346035553Spatrick 89446035553Spatrick __simd_reference operator<<=(_Vp __value) && { 89546035553Spatrick return std::move(*this) = __ptr_->__get(__index_) << __value; 89646035553Spatrick } 89746035553Spatrick 89846035553Spatrick __simd_reference operator&=(_Vp __value) && { 89946035553Spatrick return std::move(*this) = __ptr_->__get(__index_) & __value; 90046035553Spatrick } 90146035553Spatrick 90246035553Spatrick __simd_reference operator|=(_Vp __value) && { 90346035553Spatrick return std::move(*this) = __ptr_->__get(__index_) | __value; 90446035553Spatrick } 90546035553Spatrick 90646035553Spatrick __simd_reference operator^=(_Vp __value) && { 90746035553Spatrick return std::move(*this) = __ptr_->__get(__index_) ^ __value; 90846035553Spatrick } 90946035553Spatrick}; 91046035553Spatrick 91146035553Spatricktemplate <class _To, class _From> 912*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI constexpr decltype(_To{std::declval<_From>()}, true) 91346035553Spatrick__is_non_narrowing_convertible_impl(_From) { 91446035553Spatrick return true; 91546035553Spatrick} 91646035553Spatrick 91746035553Spatricktemplate <class _To> 918*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI constexpr bool __is_non_narrowing_convertible_impl(...) { 91946035553Spatrick return false; 92046035553Spatrick} 92146035553Spatrick 92246035553Spatricktemplate <class _From, class _To> 923*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI 92446035553Spatrickconstexpr typename std::enable_if<std::is_arithmetic<_To>::value && 92546035553Spatrick std::is_arithmetic<_From>::value, 92646035553Spatrick bool>::type 92746035553Spatrick__is_non_narrowing_arithmetic_convertible() { 928*4bdff4beSrobert return experimental::__is_non_narrowing_convertible_impl<_To>(_From{}); 92946035553Spatrick} 93046035553Spatrick 93146035553Spatricktemplate <class _From, class _To> 932*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI 93346035553Spatrickconstexpr typename std::enable_if<!(std::is_arithmetic<_To>::value && 93446035553Spatrick std::is_arithmetic<_From>::value), 93546035553Spatrick bool>::type 93646035553Spatrick__is_non_narrowing_arithmetic_convertible() { 93746035553Spatrick return false; 93846035553Spatrick} 93946035553Spatrick 94046035553Spatricktemplate <class _Tp> 941*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum() { 94246035553Spatrick return _Tp{}; 94346035553Spatrick} 94446035553Spatrick 94546035553Spatricktemplate <class _Tp, class _Up, class... _Args> 946*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) { 947*4bdff4beSrobert return static_cast<_Tp>(__first) + experimental::__variadic_sum<_Tp>(__rest...); 94846035553Spatrick} 94946035553Spatrick 95046035553Spatricktemplate <class _Tp> 95146035553Spatrickstruct __nodeduce { 95246035553Spatrick using type = _Tp; 95346035553Spatrick}; 95446035553Spatrick 95546035553Spatricktemplate <class _Tp> 956*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI constexpr bool __vectorizable() { 95746035553Spatrick return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value && 95846035553Spatrick !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value; 95946035553Spatrick} 96046035553Spatrick 96146035553Spatrick_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD 96246035553Spatrick_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI 96346035553Spatrick 96446035553Spatrickusing scalar = __simd_abi<_StorageKind::_Scalar, 1>; 96546035553Spatrick 96646035553Spatricktemplate <int _Np> 96746035553Spatrickusing fixed_size = __simd_abi<_StorageKind::_Array, _Np>; 96846035553Spatrick 96946035553Spatricktemplate <class _Tp> 970*4bdff4beSrobertinline constexpr size_t max_fixed_size = 32; 97146035553Spatrick 97246035553Spatricktemplate <class _Tp> 97346035553Spatrickusing compatible = fixed_size<16 / sizeof(_Tp)>; 97446035553Spatrick 97546035553Spatrick#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION 97646035553Spatricktemplate <class _Tp> 97746035553Spatrickusing native = __simd_abi<_StorageKind::_VecExt, 97846035553Spatrick _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>; 97946035553Spatrick#else 98046035553Spatricktemplate <class _Tp> 98146035553Spatrickusing native = 98246035553Spatrick fixed_size<_Tp, _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>; 98346035553Spatrick#endif // _LIBCPP_HAS_NO_VECTOR_EXTENSION 98446035553Spatrick 98546035553Spatrick_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI 98646035553Spatrick_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD 98746035553Spatrick 98846035553Spatricktemplate <class _Tp, class _Abi = simd_abi::compatible<_Tp>> 98946035553Spatrickclass simd; 99046035553Spatricktemplate <class _Tp, class _Abi = simd_abi::compatible<_Tp>> 99146035553Spatrickclass simd_mask; 99246035553Spatrick 99346035553Spatrickstruct element_aligned_tag {}; 99446035553Spatrickstruct vector_aligned_tag {}; 99546035553Spatricktemplate <size_t> 99646035553Spatrickstruct overaligned_tag {}; 997*4bdff4beSrobertinline constexpr element_aligned_tag element_aligned{}; 998*4bdff4beSrobertinline constexpr vector_aligned_tag vector_aligned{}; 99946035553Spatricktemplate <size_t _Np> 1000*4bdff4beSrobertinline constexpr overaligned_tag<_Np> overaligned{}; 100146035553Spatrick 100246035553Spatrick// traits [simd.traits] 100346035553Spatricktemplate <class _Tp> 100446035553Spatrickstruct is_abi_tag : std::integral_constant<bool, false> {}; 100546035553Spatrick 100646035553Spatricktemplate <_StorageKind __kind, int _Np> 100746035553Spatrickstruct is_abi_tag<__simd_abi<__kind, _Np>> 100846035553Spatrick : std::integral_constant<bool, true> {}; 100946035553Spatrick 101046035553Spatricktemplate <class _Tp> 101146035553Spatrickstruct is_simd : std::integral_constant<bool, false> {}; 101246035553Spatrick 101346035553Spatricktemplate <class _Tp, class _Abi> 101446035553Spatrickstruct is_simd<simd<_Tp, _Abi>> : std::integral_constant<bool, true> {}; 101546035553Spatrick 101646035553Spatricktemplate <class _Tp> 101746035553Spatrickstruct is_simd_mask : std::integral_constant<bool, false> {}; 101846035553Spatrick 101946035553Spatricktemplate <class _Tp, class _Abi> 102046035553Spatrickstruct is_simd_mask<simd_mask<_Tp, _Abi>> : std::integral_constant<bool, true> { 102146035553Spatrick}; 102246035553Spatrick 102346035553Spatricktemplate <class _Tp> 102446035553Spatrickstruct is_simd_flag_type : std::integral_constant<bool, false> {}; 102546035553Spatrick 102646035553Spatricktemplate <> 102746035553Spatrickstruct is_simd_flag_type<element_aligned_tag> 102846035553Spatrick : std::integral_constant<bool, true> {}; 102946035553Spatrick 103046035553Spatricktemplate <> 103146035553Spatrickstruct is_simd_flag_type<vector_aligned_tag> 103246035553Spatrick : std::integral_constant<bool, true> {}; 103346035553Spatrick 103446035553Spatricktemplate <size_t _Align> 103546035553Spatrickstruct is_simd_flag_type<overaligned_tag<_Align>> 103646035553Spatrick : std::integral_constant<bool, true> {}; 103746035553Spatrick 103846035553Spatricktemplate <class _Tp> 1039*4bdff4beSrobertinline constexpr bool is_abi_tag_v = is_abi_tag<_Tp>::value; 104046035553Spatricktemplate <class _Tp> 1041*4bdff4beSrobertinline constexpr bool is_simd_v = is_simd<_Tp>::value; 104246035553Spatricktemplate <class _Tp> 1043*4bdff4beSrobertinline constexpr bool is_simd_mask_v = is_simd_mask<_Tp>::value; 104446035553Spatricktemplate <class _Tp> 1045*4bdff4beSrobertinline constexpr bool is_simd_flag_type_v = is_simd_flag_type<_Tp>::value; 104646035553Spatricktemplate <class _Tp, size_t _Np> 104746035553Spatrickstruct abi_for_size { 104846035553Spatrick using type = simd_abi::fixed_size<_Np>; 104946035553Spatrick}; 105046035553Spatricktemplate <class _Tp, size_t _Np> 105146035553Spatrickusing abi_for_size_t = typename abi_for_size<_Tp, _Np>::type; 105246035553Spatrick 105346035553Spatricktemplate <class _Tp, class _Abi = simd_abi::compatible<_Tp>> 105446035553Spatrickstruct simd_size; 105546035553Spatrick 105646035553Spatricktemplate <class _Tp, _StorageKind __kind, int _Np> 105746035553Spatrickstruct simd_size<_Tp, __simd_abi<__kind, _Np>> 105846035553Spatrick : std::integral_constant<size_t, _Np> { 105946035553Spatrick static_assert( 106046035553Spatrick std::is_arithmetic<_Tp>::value && 1061*4bdff4beSrobert !std::is_same<__remove_const_t<_Tp>, bool>::value, 106246035553Spatrick "Element type should be vectorizable"); 106346035553Spatrick}; 106446035553Spatrick 106546035553Spatrick// TODO: implement it. 106646035553Spatricktemplate <class _Tp, class _Up = typename _Tp::value_type> 106746035553Spatrickstruct memory_alignment; 106846035553Spatrick 106946035553Spatricktemplate <class _Tp, class _Abi = simd_abi::compatible<_Tp>> 1070*4bdff4beSrobertinline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value; 107146035553Spatrick 107246035553Spatricktemplate <class _Tp, class _Up = typename _Tp::value_type> 1073*4bdff4beSrobertinline constexpr size_t memory_alignment_v = memory_alignment<_Tp, _Up>::value; 107446035553Spatrick 107546035553Spatrick// class template simd [simd.class] 107646035553Spatricktemplate <class _Tp> 107746035553Spatrickusing native_simd = simd<_Tp, simd_abi::native<_Tp>>; 107846035553Spatricktemplate <class _Tp, int _Np> 107946035553Spatrickusing fixed_size_simd = simd<_Tp, simd_abi::fixed_size<_Np>>; 108046035553Spatrick 108146035553Spatrick// class template simd_mask [simd.mask.class] 108246035553Spatricktemplate <class _Tp> 108346035553Spatrickusing native_simd_mask = simd_mask<_Tp, simd_abi::native<_Tp>>; 108446035553Spatrick 108546035553Spatricktemplate <class _Tp, int _Np> 108646035553Spatrickusing fixed_size_simd_mask = simd_mask<_Tp, simd_abi::fixed_size<_Np>>; 108746035553Spatrick 108846035553Spatrick// casts [simd.casts] 108946035553Spatricktemplate <class _Tp> 109046035553Spatrickstruct __static_simd_cast_traits { 109146035553Spatrick template <class _Up, class _Abi> 109246035553Spatrick static simd<_Tp, _Abi> __apply(const simd<_Up, _Abi>& __v); 109346035553Spatrick}; 109446035553Spatrick 109546035553Spatricktemplate <class _Tp, class _NewAbi> 109646035553Spatrickstruct __static_simd_cast_traits<simd<_Tp, _NewAbi>> { 109746035553Spatrick template <class _Up, class _Abi> 109846035553Spatrick static typename std::enable_if<simd<_Up, _Abi>::size() == 109946035553Spatrick simd<_Tp, _NewAbi>::size(), 110046035553Spatrick simd<_Tp, _NewAbi>>::type 110146035553Spatrick __apply(const simd<_Up, _Abi>& __v); 110246035553Spatrick}; 110346035553Spatrick 110446035553Spatricktemplate <class _Tp> 110546035553Spatrickstruct __simd_cast_traits { 110646035553Spatrick template <class _Up, class _Abi> 110746035553Spatrick static typename std::enable_if< 110846035553Spatrick __is_non_narrowing_arithmetic_convertible<_Up, _Tp>(), 110946035553Spatrick simd<_Tp, _Abi>>::type 111046035553Spatrick __apply(const simd<_Up, _Abi>& __v); 111146035553Spatrick}; 111246035553Spatrick 111346035553Spatricktemplate <class _Tp, class _NewAbi> 111446035553Spatrickstruct __simd_cast_traits<simd<_Tp, _NewAbi>> { 111546035553Spatrick template <class _Up, class _Abi> 111646035553Spatrick static typename std::enable_if< 111746035553Spatrick __is_non_narrowing_arithmetic_convertible<_Up, _Tp>() && 111846035553Spatrick simd<_Up, _Abi>::size() == simd<_Tp, _NewAbi>::size(), 111946035553Spatrick simd<_Tp, _NewAbi>>::type 112046035553Spatrick __apply(const simd<_Up, _Abi>& __v); 112146035553Spatrick}; 112246035553Spatrick 112346035553Spatricktemplate <class _Tp, class _Up, class _Abi> 1124*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI auto simd_cast(const simd<_Up, _Abi>& __v) 112546035553Spatrick -> decltype(__simd_cast_traits<_Tp>::__apply(__v)) { 112646035553Spatrick return __simd_cast_traits<_Tp>::__apply(__v); 112746035553Spatrick} 112846035553Spatrick 112946035553Spatricktemplate <class _Tp, class _Up, class _Abi> 1130*4bdff4beSrobert_LIBCPP_HIDE_FROM_ABI auto static_simd_cast(const simd<_Up, _Abi>& __v) 113146035553Spatrick -> decltype(__static_simd_cast_traits<_Tp>::__apply(__v)) { 113246035553Spatrick return __static_simd_cast_traits<_Tp>::__apply(__v); 113346035553Spatrick} 113446035553Spatrick 113546035553Spatricktemplate <class _Tp, class _Abi> 113646035553Spatrickfixed_size_simd<_Tp, simd_size<_Tp, _Abi>::value> 113746035553Spatrickto_fixed_size(const simd<_Tp, _Abi>&) noexcept; 113846035553Spatrick 113946035553Spatricktemplate <class _Tp, class _Abi> 114046035553Spatrickfixed_size_simd_mask<_Tp, simd_size<_Tp, _Abi>::value> 114146035553Spatrickto_fixed_size(const simd_mask<_Tp, _Abi>&) noexcept; 114246035553Spatrick 114346035553Spatricktemplate <class _Tp, size_t _Np> 114446035553Spatricknative_simd<_Tp> to_native(const fixed_size_simd<_Tp, _Np>&) noexcept; 114546035553Spatrick 114646035553Spatricktemplate <class _Tp, size_t _Np> 114746035553Spatricknative_simd_mask<_Tp> to_native(const fixed_size_simd_mask<_Tp, _Np>&) noexcept; 114846035553Spatrick 114946035553Spatricktemplate <class _Tp, size_t _Np> 115046035553Spatricksimd<_Tp> to_compatible(const fixed_size_simd<_Tp, _Np>&) noexcept; 115146035553Spatrick 115246035553Spatricktemplate <class _Tp, size_t _Np> 115346035553Spatricksimd_mask<_Tp> to_compatible(const fixed_size_simd_mask<_Tp, _Np>&) noexcept; 115446035553Spatrick 115546035553Spatricktemplate <size_t... __sizes, class _Tp, class _Abi> 115646035553Spatricktuple<simd<_Tp, abi_for_size_t<_Tp, __sizes>>...> split(const simd<_Tp, _Abi>&); 115746035553Spatrick 115846035553Spatricktemplate <size_t... __sizes, class _Tp, class _Abi> 115946035553Spatricktuple<simd_mask<_Tp, abi_for_size_t<_Tp, __sizes>>...> 116046035553Spatricksplit(const simd_mask<_Tp, _Abi>&); 116146035553Spatrick 116246035553Spatricktemplate <class _SimdType, class _Abi> 116346035553Spatrickarray<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value / 116446035553Spatrick _SimdType::size()> 116546035553Spatricksplit(const simd<typename _SimdType::value_type, _Abi>&); 116646035553Spatrick 116746035553Spatricktemplate <class _SimdType, class _Abi> 116846035553Spatrickarray<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value / 116946035553Spatrick _SimdType::size()> 117046035553Spatricksplit(const simd_mask<typename _SimdType::value_type, _Abi>&); 117146035553Spatrick 117246035553Spatricktemplate <class _Tp, class... _Abis> 1173*4bdff4beSrobertsimd<_Tp, abi_for_size_t<_Tp, experimental::__variadic_sum(simd_size<_Tp, _Abis>::value...)>> 117446035553Spatrickconcat(const simd<_Tp, _Abis>&...); 117546035553Spatrick 117646035553Spatricktemplate <class _Tp, class... _Abis> 117746035553Spatricksimd_mask<_Tp, 1178*4bdff4beSrobert abi_for_size_t<_Tp, experimental::__variadic_sum(simd_size<_Tp, _Abis>::value...)>> 117946035553Spatrickconcat(const simd_mask<_Tp, _Abis>&...); 118046035553Spatrick 118146035553Spatrick// reductions [simd.mask.reductions] 118246035553Spatricktemplate <class _Tp, class _Abi> 118346035553Spatrickbool all_of(const simd_mask<_Tp, _Abi>&) noexcept; 118446035553Spatricktemplate <class _Tp, class _Abi> 118546035553Spatrickbool any_of(const simd_mask<_Tp, _Abi>&) noexcept; 118646035553Spatricktemplate <class _Tp, class _Abi> 118746035553Spatrickbool none_of(const simd_mask<_Tp, _Abi>&) noexcept; 118846035553Spatricktemplate <class _Tp, class _Abi> 118946035553Spatrickbool some_of(const simd_mask<_Tp, _Abi>&) noexcept; 119046035553Spatricktemplate <class _Tp, class _Abi> 119146035553Spatrickint popcount(const simd_mask<_Tp, _Abi>&) noexcept; 119246035553Spatricktemplate <class _Tp, class _Abi> 119346035553Spatrickint find_first_set(const simd_mask<_Tp, _Abi>&); 119446035553Spatricktemplate <class _Tp, class _Abi> 119546035553Spatrickint find_last_set(const simd_mask<_Tp, _Abi>&); 119646035553Spatrickbool all_of(bool) noexcept; 119746035553Spatrickbool any_of(bool) noexcept; 119846035553Spatrickbool none_of(bool) noexcept; 119946035553Spatrickbool some_of(bool) noexcept; 120046035553Spatrickint popcount(bool) noexcept; 120146035553Spatrickint find_first_set(bool) noexcept; 120246035553Spatrickint find_last_set(bool) noexcept; 120346035553Spatrick 120446035553Spatrick// masked assignment [simd.whereexpr] 120546035553Spatricktemplate <class _MaskType, class _Tp> 120646035553Spatrickclass const_where_expression; 120746035553Spatricktemplate <class _MaskType, class _Tp> 120846035553Spatrickclass where_expression; 120946035553Spatrick 121046035553Spatrick// masked assignment [simd.mask.where] 121146035553Spatricktemplate <class _Tp, class _Abi> 121246035553Spatrickwhere_expression<simd_mask<_Tp, _Abi>, simd<_Tp, _Abi>> 121346035553Spatrickwhere(const typename simd<_Tp, _Abi>::mask_type&, simd<_Tp, _Abi>&) noexcept; 121446035553Spatrick 121546035553Spatricktemplate <class _Tp, class _Abi> 121646035553Spatrickconst_where_expression<simd_mask<_Tp, _Abi>, const simd<_Tp, _Abi>> 121746035553Spatrickwhere(const typename simd<_Tp, _Abi>::mask_type&, 121846035553Spatrick const simd<_Tp, _Abi>&) noexcept; 121946035553Spatrick 122046035553Spatricktemplate <class _Tp, class _Abi> 122146035553Spatrickwhere_expression<simd_mask<_Tp, _Abi>, simd_mask<_Tp, _Abi>> 122246035553Spatrickwhere(const typename __nodeduce<simd_mask<_Tp, _Abi>>::type&, 122346035553Spatrick simd_mask<_Tp, _Abi>&) noexcept; 122446035553Spatrick 122546035553Spatricktemplate <class _Tp, class _Abi> 122646035553Spatrickconst_where_expression<simd_mask<_Tp, _Abi>, const simd_mask<_Tp, _Abi>> 122746035553Spatrickwhere(const typename __nodeduce<simd_mask<_Tp, _Abi>>::type&, 122846035553Spatrick const simd_mask<_Tp, _Abi>&) noexcept; 122946035553Spatrick 123046035553Spatricktemplate <class _Tp> 123146035553Spatrickwhere_expression<bool, _Tp> where(bool, _Tp&) noexcept; 123246035553Spatrick 123346035553Spatricktemplate <class _Tp> 123446035553Spatrickconst_where_expression<bool, const _Tp> where(bool, const _Tp&) noexcept; 123546035553Spatrick 123646035553Spatrick// reductions [simd.reductions] 123746035553Spatricktemplate <class _Tp, class _Abi, class _BinaryOp = std::plus<_Tp>> 123846035553Spatrick_Tp reduce(const simd<_Tp, _Abi>&, _BinaryOp = _BinaryOp()); 123946035553Spatrick 124046035553Spatricktemplate <class _MaskType, class _SimdType, class _BinaryOp> 124146035553Spatricktypename _SimdType::value_type 124246035553Spatrickreduce(const const_where_expression<_MaskType, _SimdType>&, 1243*4bdff4beSrobert typename _SimdType::value_type __neutral_element, _BinaryOp); 124446035553Spatrick 124546035553Spatricktemplate <class _MaskType, class _SimdType> 124646035553Spatricktypename _SimdType::value_type 124746035553Spatrickreduce(const const_where_expression<_MaskType, _SimdType>&, 1248*4bdff4beSrobert plus<typename _SimdType::value_type> = {}); 124946035553Spatrick 125046035553Spatricktemplate <class _MaskType, class _SimdType> 125146035553Spatricktypename _SimdType::value_type 125246035553Spatrickreduce(const const_where_expression<_MaskType, _SimdType>&, 1253*4bdff4beSrobert multiplies<typename _SimdType::value_type>); 125446035553Spatrick 125546035553Spatricktemplate <class _MaskType, class _SimdType> 125646035553Spatricktypename _SimdType::value_type 125746035553Spatrickreduce(const const_where_expression<_MaskType, _SimdType>&, 1258*4bdff4beSrobert bit_and<typename _SimdType::value_type>); 125946035553Spatrick 126046035553Spatricktemplate <class _MaskType, class _SimdType> 126146035553Spatricktypename _SimdType::value_type 126246035553Spatrickreduce(const const_where_expression<_MaskType, _SimdType>&, 1263*4bdff4beSrobert bit_or<typename _SimdType::value_type>); 126446035553Spatrick 126546035553Spatricktemplate <class _MaskType, class _SimdType> 126646035553Spatricktypename _SimdType::value_type 126746035553Spatrickreduce(const const_where_expression<_MaskType, _SimdType>&, 1268*4bdff4beSrobert bit_xor<typename _SimdType::value_type>); 126946035553Spatrick 127046035553Spatricktemplate <class _Tp, class _Abi> 127146035553Spatrick_Tp hmin(const simd<_Tp, _Abi>&); 127246035553Spatricktemplate <class _MaskType, class _SimdType> 127346035553Spatricktypename _SimdType::value_type 127446035553Spatrickhmin(const const_where_expression<_MaskType, _SimdType>&); 127546035553Spatricktemplate <class _Tp, class _Abi> 127646035553Spatrick_Tp hmax(const simd<_Tp, _Abi>&); 127746035553Spatricktemplate <class _MaskType, class _SimdType> 127846035553Spatricktypename _SimdType::value_type 127946035553Spatrickhmax(const const_where_expression<_MaskType, _SimdType>&); 128046035553Spatrick 128146035553Spatrick// algorithms [simd.alg] 128246035553Spatricktemplate <class _Tp, class _Abi> 128346035553Spatricksimd<_Tp, _Abi> min(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept; 128446035553Spatrick 128546035553Spatricktemplate <class _Tp, class _Abi> 128646035553Spatricksimd<_Tp, _Abi> max(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept; 128746035553Spatrick 128846035553Spatricktemplate <class _Tp, class _Abi> 128946035553Spatrickstd::pair<simd<_Tp, _Abi>, simd<_Tp, _Abi>> 129046035553Spatrickminmax(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&) noexcept; 129146035553Spatrick 129246035553Spatricktemplate <class _Tp, class _Abi> 129346035553Spatricksimd<_Tp, _Abi> clamp(const simd<_Tp, _Abi>&, const simd<_Tp, _Abi>&, 129446035553Spatrick const simd<_Tp, _Abi>&); 129546035553Spatrick 129646035553Spatrick// [simd.whereexpr] 129746035553Spatrick// TODO implement where expressions. 129846035553Spatricktemplate <class _MaskType, class _Tp> 129946035553Spatrickclass const_where_expression { 130046035553Spatrickpublic: 130146035553Spatrick const_where_expression(const const_where_expression&) = delete; 130246035553Spatrick const_where_expression& operator=(const const_where_expression&) = delete; 1303*4bdff4beSrobert __remove_const_t<_Tp> operator-() const&&; 130446035553Spatrick template <class _Up, class _Flags> 130546035553Spatrick void copy_to(_Up*, _Flags) const&&; 130646035553Spatrick}; 130746035553Spatrick 130846035553Spatricktemplate <class _MaskType, class _Tp> 130946035553Spatrickclass where_expression : public const_where_expression<_MaskType, _Tp> { 131046035553Spatrickpublic: 131146035553Spatrick where_expression(const where_expression&) = delete; 131246035553Spatrick where_expression& operator=(const where_expression&) = delete; 131346035553Spatrick template <class _Up> 131446035553Spatrick void operator=(_Up&&); 131546035553Spatrick template <class _Up> 131646035553Spatrick void operator+=(_Up&&); 131746035553Spatrick template <class _Up> 131846035553Spatrick void operator-=(_Up&&); 131946035553Spatrick template <class _Up> 132046035553Spatrick void operator*=(_Up&&); 132146035553Spatrick template <class _Up> 132246035553Spatrick void operator/=(_Up&&); 132346035553Spatrick template <class _Up> 132446035553Spatrick void operator%=(_Up&&); 132546035553Spatrick template <class _Up> 132646035553Spatrick void operator&=(_Up&&); 132746035553Spatrick template <class _Up> 132846035553Spatrick void operator|=(_Up&&); 132946035553Spatrick template <class _Up> 133046035553Spatrick void operator^=(_Up&&); 133146035553Spatrick template <class _Up> 133246035553Spatrick void operator<<=(_Up&&); 133346035553Spatrick template <class _Up> 133446035553Spatrick void operator>>=(_Up&&); 133546035553Spatrick void operator++(); 133646035553Spatrick void operator++(int); 133746035553Spatrick void operator--(); 133846035553Spatrick void operator--(int); 133946035553Spatrick template <class _Up, class _Flags> 134046035553Spatrick void copy_from(const _Up*, _Flags); 134146035553Spatrick}; 134246035553Spatrick 134346035553Spatrick// [simd.class] 134446035553Spatrick// TODO: implement simd 134546035553Spatricktemplate <class _Tp, class _Abi> 134646035553Spatrickclass simd { 134746035553Spatrickpublic: 134846035553Spatrick using value_type = _Tp; 134946035553Spatrick using reference = __simd_reference<_Tp, _Tp, _Abi>; 135046035553Spatrick using mask_type = simd_mask<_Tp, _Abi>; 135146035553Spatrick using abi_type = _Abi; 135246035553Spatrick 135346035553Spatrick simd() = default; 135446035553Spatrick simd(const simd&) = default; 135546035553Spatrick simd& operator=(const simd&) = default; 135646035553Spatrick 135746035553Spatrick static constexpr size_t size() noexcept { 135846035553Spatrick return simd_size<_Tp, _Abi>::value; 135946035553Spatrick } 136046035553Spatrick 136146035553Spatrickprivate: 136246035553Spatrick __simd_storage<_Tp, _Abi> __s_; 136346035553Spatrick 136446035553Spatrick template <class _Up> 136546035553Spatrick static constexpr bool __can_broadcast() { 136646035553Spatrick return (std::is_arithmetic<_Up>::value && 136746035553Spatrick __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()) || 136846035553Spatrick (!std::is_arithmetic<_Up>::value && 136946035553Spatrick std::is_convertible<_Up, _Tp>::value) || 1370*4bdff4beSrobert std::is_same<__remove_const_t<_Up>, int>::value || 1371*4bdff4beSrobert (std::is_same<__remove_const_t<_Up>, 137246035553Spatrick unsigned int>::value && 137346035553Spatrick std::is_unsigned<_Tp>::value); 137446035553Spatrick } 137546035553Spatrick 137646035553Spatrick template <class _Generator, size_t... __indicies> 137746035553Spatrick static constexpr decltype( 137846035553Spatrick std::forward_as_tuple(std::declval<_Generator>()( 137946035553Spatrick std::integral_constant<size_t, __indicies>())...), 138046035553Spatrick bool()) 138146035553Spatrick __can_generate(std::index_sequence<__indicies...>) { 1382*4bdff4beSrobert return !experimental::__variadic_sum<bool>( 138346035553Spatrick !__can_broadcast<decltype(std::declval<_Generator>()( 138446035553Spatrick std::integral_constant<size_t, __indicies>()))>()...); 138546035553Spatrick } 138646035553Spatrick 138746035553Spatrick template <class _Generator> 138846035553Spatrick static bool __can_generate(...) { 138946035553Spatrick return false; 139046035553Spatrick } 139146035553Spatrick 139246035553Spatrick template <class _Generator, size_t... __indicies> 139346035553Spatrick void __generator_init(_Generator&& __g, std::index_sequence<__indicies...>) { 139446035553Spatrick int __not_used[]{((*this)[__indicies] = 139546035553Spatrick __g(std::integral_constant<size_t, __indicies>()), 139646035553Spatrick 0)...}; 139746035553Spatrick (void)__not_used; 139846035553Spatrick } 139946035553Spatrick 140046035553Spatrickpublic: 140146035553Spatrick // implicit type conversion constructor 140246035553Spatrick template <class _Up, 140346035553Spatrick class = typename std::enable_if< 140446035553Spatrick std::is_same<_Abi, simd_abi::fixed_size<size()>>::value && 140546035553Spatrick __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()>::type> 140646035553Spatrick simd(const simd<_Up, simd_abi::fixed_size<size()>>& __v) { 140746035553Spatrick for (size_t __i = 0; __i < size(); __i++) { 140846035553Spatrick (*this)[__i] = static_cast<_Tp>(__v[__i]); 140946035553Spatrick } 141046035553Spatrick } 141146035553Spatrick 141246035553Spatrick // implicit broadcast constructor 141346035553Spatrick template <class _Up, 141446035553Spatrick class = typename std::enable_if<__can_broadcast<_Up>()>::type> 141546035553Spatrick simd(_Up&& __rv) { 141646035553Spatrick auto __v = static_cast<_Tp>(__rv); 141746035553Spatrick for (size_t __i = 0; __i < size(); __i++) { 141846035553Spatrick (*this)[__i] = __v; 141946035553Spatrick } 142046035553Spatrick } 142146035553Spatrick 142246035553Spatrick // generator constructor 142346035553Spatrick template <class _Generator, 142446035553Spatrick int = typename std::enable_if< 142546035553Spatrick __can_generate<_Generator>(std::make_index_sequence<size()>()), 142646035553Spatrick int>::type()> 142746035553Spatrick explicit simd(_Generator&& __g) { 142846035553Spatrick __generator_init(std::forward<_Generator>(__g), 142946035553Spatrick std::make_index_sequence<size()>()); 143046035553Spatrick } 143146035553Spatrick 143246035553Spatrick // load constructor 143346035553Spatrick template < 143446035553Spatrick class _Up, class _Flags, 143546035553Spatrick class = typename std::enable_if<__vectorizable<_Up>()>::type, 143646035553Spatrick class = typename std::enable_if<is_simd_flag_type<_Flags>::value>::type> 143746035553Spatrick simd(const _Up* __buffer, _Flags) { 143846035553Spatrick // TODO: optimize for overaligned flags 143946035553Spatrick for (size_t __i = 0; __i < size(); __i++) { 144046035553Spatrick (*this)[__i] = static_cast<_Tp>(__buffer[__i]); 144146035553Spatrick } 144246035553Spatrick } 144346035553Spatrick 144446035553Spatrick // loads [simd.load] 144546035553Spatrick template <class _Up, class _Flags> 144646035553Spatrick typename std::enable_if<__vectorizable<_Up>() && 144746035553Spatrick is_simd_flag_type<_Flags>::value>::type 144846035553Spatrick copy_from(const _Up* __buffer, _Flags) { 144946035553Spatrick *this = simd(__buffer, _Flags()); 145046035553Spatrick } 145146035553Spatrick 145246035553Spatrick // stores [simd.store] 145346035553Spatrick template <class _Up, class _Flags> 145446035553Spatrick typename std::enable_if<__vectorizable<_Up>() && 145546035553Spatrick is_simd_flag_type<_Flags>::value>::type 145646035553Spatrick copy_to(_Up* __buffer, _Flags) const { 145746035553Spatrick // TODO: optimize for overaligned flags 145846035553Spatrick for (size_t __i = 0; __i < size(); __i++) { 145946035553Spatrick __buffer[__i] = static_cast<_Up>((*this)[__i]); 146046035553Spatrick } 146146035553Spatrick } 146246035553Spatrick 146346035553Spatrick // scalar access [simd.subscr] 146446035553Spatrick reference operator[](size_t __i) { return reference(&__s_, __i); } 146546035553Spatrick 146646035553Spatrick value_type operator[](size_t __i) const { return __s_.__get(__i); } 146746035553Spatrick 146846035553Spatrick // unary operators [simd.unary] 146946035553Spatrick simd& operator++(); 147046035553Spatrick simd operator++(int); 147146035553Spatrick simd& operator--(); 147246035553Spatrick simd operator--(int); 147346035553Spatrick mask_type operator!() const; 147446035553Spatrick simd operator~() const; 147546035553Spatrick simd operator+() const; 147646035553Spatrick simd operator-() const; 147746035553Spatrick 1478*4bdff4beSrobert#if 0 147946035553Spatrick // binary operators [simd.binary] 148046035553Spatrick friend simd operator+(const simd&, const simd&); 148146035553Spatrick friend simd operator-(const simd&, const simd&); 148246035553Spatrick friend simd operator*(const simd&, const simd&); 148346035553Spatrick friend simd operator/(const simd&, const simd&); 148446035553Spatrick friend simd operator%(const simd&, const simd&); 148546035553Spatrick friend simd operator&(const simd&, const simd&); 148646035553Spatrick friend simd operator|(const simd&, const simd&); 148746035553Spatrick friend simd operator^(const simd&, const simd&); 148846035553Spatrick friend simd operator<<(const simd&, const simd&); 148946035553Spatrick friend simd operator>>(const simd&, const simd&); 149046035553Spatrick friend simd operator<<(const simd&, int); 149146035553Spatrick friend simd operator>>(const simd&, int); 149246035553Spatrick 149346035553Spatrick // compound assignment [simd.cassign] 149446035553Spatrick friend simd& operator+=(simd&, const simd&); 149546035553Spatrick friend simd& operator-=(simd&, const simd&); 149646035553Spatrick friend simd& operator*=(simd&, const simd&); 149746035553Spatrick friend simd& operator/=(simd&, const simd&); 149846035553Spatrick friend simd& operator%=(simd&, const simd&); 149946035553Spatrick 150046035553Spatrick friend simd& operator&=(simd&, const simd&); 150146035553Spatrick friend simd& operator|=(simd&, const simd&); 150246035553Spatrick friend simd& operator^=(simd&, const simd&); 150346035553Spatrick friend simd& operator<<=(simd&, const simd&); 150446035553Spatrick friend simd& operator>>=(simd&, const simd&); 150546035553Spatrick friend simd& operator<<=(simd&, int); 150646035553Spatrick friend simd& operator>>=(simd&, int); 150746035553Spatrick 150846035553Spatrick // compares [simd.comparison] 150946035553Spatrick friend mask_type operator==(const simd&, const simd&); 151046035553Spatrick friend mask_type operator!=(const simd&, const simd&); 151146035553Spatrick friend mask_type operator>=(const simd&, const simd&); 151246035553Spatrick friend mask_type operator<=(const simd&, const simd&); 151346035553Spatrick friend mask_type operator>(const simd&, const simd&); 151446035553Spatrick friend mask_type operator<(const simd&, const simd&); 1515*4bdff4beSrobert#endif 151646035553Spatrick}; 151746035553Spatrick 151846035553Spatrick// [simd.mask.class] 151946035553Spatricktemplate <class _Tp, class _Abi> 152046035553Spatrick// TODO: implement simd_mask 152146035553Spatrickclass simd_mask { 152246035553Spatrickpublic: 152346035553Spatrick using value_type = bool; 152446035553Spatrick // TODO: this is strawman implementation. Turn it into a proxy type. 152546035553Spatrick using reference = bool&; 152646035553Spatrick using simd_type = simd<_Tp, _Abi>; 152746035553Spatrick using abi_type = _Abi; 152846035553Spatrick static constexpr size_t size() noexcept; 152946035553Spatrick simd_mask() = default; 153046035553Spatrick 153146035553Spatrick // broadcast constructor 153246035553Spatrick explicit simd_mask(value_type) noexcept; 153346035553Spatrick 153446035553Spatrick // implicit type conversion constructor 153546035553Spatrick template <class _Up> 153646035553Spatrick simd_mask(const simd_mask<_Up, simd_abi::fixed_size<size()>>&) noexcept; 153746035553Spatrick 153846035553Spatrick // load constructor 153946035553Spatrick template <class _Flags> 154046035553Spatrick simd_mask(const value_type*, _Flags); 154146035553Spatrick 154246035553Spatrick // loads [simd.mask.copy] 154346035553Spatrick template <class _Flags> 154446035553Spatrick void copy_from(const value_type*, _Flags); 154546035553Spatrick template <class _Flags> 154646035553Spatrick void copy_to(value_type*, _Flags) const; 154746035553Spatrick 154846035553Spatrick // scalar access [simd.mask.subscr] 154946035553Spatrick reference operator[](size_t); 155046035553Spatrick value_type operator[](size_t) const; 155146035553Spatrick 155246035553Spatrick // unary operators [simd.mask.unary] 155346035553Spatrick simd_mask operator!() const noexcept; 155446035553Spatrick 1555*4bdff4beSrobert#if 0 155646035553Spatrick // simd_mask binary operators [simd.mask.binary] 155746035553Spatrick friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept; 155846035553Spatrick friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept; 155946035553Spatrick friend simd_mask operator&(const simd_mask&, const simd_mask&)noexcept; 156046035553Spatrick friend simd_mask operator|(const simd_mask&, const simd_mask&) noexcept; 156146035553Spatrick friend simd_mask operator^(const simd_mask&, const simd_mask&) noexcept; 156246035553Spatrick 156346035553Spatrick // simd_mask compound assignment [simd.mask.cassign] 156446035553Spatrick friend simd_mask& operator&=(simd_mask&, const simd_mask&) noexcept; 156546035553Spatrick friend simd_mask& operator|=(simd_mask&, const simd_mask&) noexcept; 156646035553Spatrick friend simd_mask& operator^=(simd_mask&, const simd_mask&) noexcept; 156746035553Spatrick 156846035553Spatrick // simd_mask compares [simd.mask.comparison] 156946035553Spatrick friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept; 157046035553Spatrick friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept; 1571*4bdff4beSrobert#endif 157246035553Spatrick}; 157346035553Spatrick 157446035553Spatrick#endif // _LIBCPP_STD_VER >= 17 157546035553Spatrick 157646035553Spatrick_LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD 157746035553Spatrick 157876d0caaeSpatrick_LIBCPP_POP_MACROS 157976d0caaeSpatrick 1580*4bdff4beSrobert#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 1581*4bdff4beSrobert# include <algorithm> 1582*4bdff4beSrobert# include <functional> 1583*4bdff4beSrobert#endif 1584*4bdff4beSrobert 158546035553Spatrick#endif /* _LIBCPP_EXPERIMENTAL_SIMD */ 1586