|
native 0.0.1
Vectors, masks and wide register packs for C++26
|
One complete WebAssembly SIMD128 register with semantic element lanes. More...
#include <polyfill_body.h>
Public Types | |
| using | native_type = std::array<typename chunk_type::native_type,register_count> |
| Native register representations in logical lane order. | |
Public Member Functions | |
| constexpr | simd () noexcept=default |
| Default initialization leaves storage unspecified; braces zero it. | |
| constexpr | simd (T value) noexcept |
| Copy each lane's representation; unused physical bytes are zero. | |
| constexpr | simd (std::array< T, N > const &values) noexcept |
| Copy the array elements in lane order. | |
|
template<class... U> requires (sizeof...(U)==N && (std::same_as<U,T> && ...)) | |
| constexpr | simd (U... values) noexcept |
| Construct exactly N lanes from values of the element type. | |
| constexpr native_type | to_native () const noexcept |
| Bridge to the implementation register without numerical conversion. | |
| constexpr native_type | to_native () const noexcept |
| Bridge to the implementation register without numerical conversion. | |
| constexpr native_type | to_native () const noexcept |
| Bridge to the implementation register without numerical conversion. | |
| template<std::size_t Alignment = 1> | |
| constexpr void | store_memory (T *p) const noexcept |
| Write exactly N objects; Alignment is a caller promise. | |
| constexpr void | store (T *p) const noexcept |
| Write exactly N elements in lane order. | |
| constexpr void | storeu (T *p) const noexcept |
| Synonym for store; register alignment is unnecessary. | |
| constexpr void | store_partial (T *p, std::size_t n) const noexcept |
| Write the first n <= N elements; a null pointer is valid for n == 0. | |
| constexpr bits_type | bits () const noexcept |
| Return each lane as its unchanged unsigned representation. | |
| constexpr bits_type | to_bits () const noexcept |
| Synonym for bits; no floating-point conversion occurs. | |
| constexpr void | store_bits (word_type *p) const noexcept |
| Write N unsigned lane representations without numerical conversion. | |
| constexpr | simd () noexcept=default |
| Initialize the stored representations to zero. | |
| constexpr | simd (T value) noexcept |
| Broadcast an element to all logical lanes. | |
|
template<simd_integer_element U> requires (simd_integer_element<T>) | |
| constexpr | simd (U value) noexcept |
| Reduce an integral scalar to the lane width and broadcast it. | |
| constexpr | simd (std::array< T, N > const &values) noexcept |
| Copy logical lanes in array order. | |
|
template<class... U> requires (sizeof...(U)==N && (std::convertible_to<U,T> && ...) && (!simd_integer_element<T> || (simd_integer_element<U> && ...))) | |
| constexpr | simd (U... values) noexcept |
| Construct logical lanes in argument order. | |
| constexpr | simd (native_type value) noexcept |
| Adopt the underlying register array without numerical conversion. | |
| constexpr | operator native_type () const noexcept |
| Project the underlying register array for native interoperability. | |
| constexpr native_type | to_native () const noexcept |
| Return the underlying register representations in logical order. | |
| constexpr void | store (T *p) const noexcept |
| Write all logical lanes to an unaligned element pointer. | |
| constexpr void | storeu (T *p) const noexcept |
| Write all logical lanes without an alignment promise. | |
| template<std::size_t Alignment = 1> | |
| constexpr void | store_memory (T *p) const noexcept |
| Store logical lanes; Alignment is the caller's byte-alignment promise. | |
| constexpr void | store_partial (T *p, std::size_t count) const noexcept |
| Write exactly count lanes. Zero count permits null and touches nothing. | |
| constexpr bits_type | bits () const noexcept |
| Return exact unsigned lane representations without normalization. | |
| constexpr bits_type | to_bits () const noexcept |
| Return exact unsigned lane representations. | |
| constexpr void | store_bits (word_type *p) const noexcept |
| Write exact lane representations as unsigned words. | |
| constexpr void | store_bits_partial (word_type *p, std::size_t count) const noexcept |
| Store count exact lane words; zero permits null and touches nothing. | |
| constexpr std::uint64_t | to_bitset () const noexcept |
| Return logical mask lanes, excluding tail padding. | |
|
template<std::size_t I> requires (I<N) | |
| constexpr T | get () const noexcept |
| Read one logical lane selected at compile time. | |
|
template<std::size_t I> requires (I<N) | |
| constexpr simd | set (T value) const noexcept |
| Replace one logical lane, retaining every other lane's representation. | |
|
template<std::size_t I> requires (I<N) | |
| constexpr simd | replace (T value) const noexcept |
| Synonym for replacing one compile-time-selected logical lane. | |
|
template<std::size_t K> requires (simd_integer_element<T> && ((NATIVE_HOST_WASM!=0) || requires(chunk_type x) { x.template right<K>(); })) | |
| constexpr simd | right () const noexcept |
| Shift every integral lane right by the immediate count. | |
|
template<std::size_t K> requires (simd_integer_element<T> && ((NATIVE_HOST_WASM!=0) || requires(chunk_type x) { x.template left<K>(); })) | |
| constexpr simd | left () const noexcept |
| Shift every integral lane left by the immediate count. | |
|
template<class C> requires requires(simd value,C count) { { value<<count } -> std::same_as<simd>; } | |
| constexpr simd & | operator<<= (C count) noexcept |
| Apply the corresponding supported shift in place. | |
|
template<class C> requires requires(simd value,C count) { { value>>count } -> std::same_as<simd>; } | |
| constexpr simd & | operator>>= (C count) noexcept |
| Apply the corresponding supported shift in place. | |
| constexpr | simd () noexcept=default |
| Initialize every lane to zero. | |
| constexpr | simd (T x) noexcept |
| Broadcast a floating element value to every lane. | |
|
template<simd_integer_element U> requires simd_integer_element<T> | |
| constexpr | simd (U input) noexcept |
| Broadcast an integer, retaining its low lane-width bits in every lane. | |
| constexpr | simd (std::array< T, N > const &a) noexcept |
| Copy the array in lane order. | |
|
template<class... U> requires (sizeof...(U) == N && ((std::same_as<U, T> && ...) || (simd_integer_element<T> && (simd_integer_element<U> && ...)))) | |
| constexpr | simd (U... x) noexcept |
| Construct N lanes; integer arguments retain their low lane-width bits. | |
| constexpr native_type | to_native () const noexcept |
| Return the implementation register without changing its bits. | |
| constexpr void | store (T *p) const noexcept |
| Store exactly 16 unaligned bytes in lane order. | |
| template<std::size_t Align> | |
| constexpr void | store_memory (T *p) const noexcept |
| Store all lanes; Align is the caller-provided pointer alignment. | |
| constexpr void | store_partial (T *p, std::size_t n) const noexcept |
| Write only the first n lanes; require n <= N. Null is valid when n is zero. | |
| constexpr void | store_bits (word_type *p) const noexcept |
| Store lane representations as corresponding unsigned words. | |
| constexpr bits_type | bits () const noexcept |
| Reinterpret each lane as an unsigned word of the same width. | |
|
template<std::size_t I> requires (I < N) | |
| constexpr T | get () const noexcept |
| Extract the compile-time-selected lane as its scalar element type. | |
|
template<std::size_t I> requires (I < N) | |
| constexpr simd | replace (T x) const noexcept |
| Replace one compile-time-selected lane and preserve every other lane. | |
| constexpr simd & | operator+= (simd b) noexcept |
| Apply the corresponding lane operation and update this value. | |
| constexpr simd & | operator-= (simd b) noexcept |
| Apply the corresponding lane operation and update this value. | |
| constexpr simd & | operator*= (simd b) noexcept |
| Apply the corresponding lane operation and update this value. | |
| constexpr simd & | operator/= (simd b) noexcept |
| Apply the corresponding lane operation and update this value. | |
| constexpr simd & | operator&= (simd b) noexcept |
| Apply the corresponding lane operation and update this value. | |
| constexpr simd & | operator|= (simd b) noexcept |
| Apply the corresponding lane operation and update this value. | |
| constexpr simd & | operator^= (simd b) noexcept |
| Apply the corresponding lane operation and update this value. | |
| constexpr simd | left (unsigned count) const noexcept |
| WebAssembly shifts reduce the count modulo the lane width. | |
|
template<std::size_t K> requires simd_integer_element<T> | |
| constexpr simd | left () const noexcept |
| Shift lanes left by K modulo the lane width. | |
| constexpr simd | right (unsigned count) const noexcept |
| WebAssembly shifts reduce the count modulo the lane width. | |
|
template<std::size_t K> requires simd_integer_element<T> | |
| constexpr simd | right () const noexcept |
| Shift lanes right by K modulo the lane width. | |
Static Public Member Functions | |
| static constexpr simd | from_native (native_type value) noexcept |
| Adopt register bits unchanged; unused physical bytes are unspecified. | |
| static constexpr simd | unsafe_from_native (native_type value) noexcept |
| Synonym for from_native; these storage-only shapes do not normalize padding. | |
| static constexpr simd | from_native (native_type value) noexcept |
| Adopt register bits unchanged; unused physical bytes are unspecified. | |
| static constexpr simd | unsafe_from_native (native_type value) noexcept |
| Synonym for from_native; these storage-only shapes do not normalize padding. | |
| static constexpr simd | from_native (native_type value) noexcept |
| Adopt register bits unchanged; unused physical bytes are unspecified. | |
| static constexpr simd | unsafe_from_native (native_type value) noexcept |
| Synonym for from_native; these storage-only shapes do not normalize padding. | |
| template<std::size_t Alignment = 1> | |
| static constexpr simd | load_memory (T const *p) noexcept |
| Read exactly N objects, without requiring register-width alignment. | |
| static constexpr simd | load (T const *p) noexcept |
| Read exactly N elements with their natural alignment. | |
| static constexpr simd | loadu (T const *p) noexcept |
| Synonym for load; register alignment is unnecessary. | |
| static constexpr simd | load_partial (T const *p, std::size_t n, T fill=T{}) noexcept |
| Read n <= N elements and fill the remainder; a null pointer is valid for n == 0. | |
| static constexpr simd | from_bits (bits_type words) noexcept |
| Interpret unsigned words as lane representations without conversion. | |
| static constexpr simd | load_bits (word_type const *p) noexcept |
| Read N unsigned lane representations without numerical conversion. | |
| static constexpr simd | from_native (native_type value) noexcept |
| static constexpr simd | unsafe_from_native (native_type value) noexcept |
| Adopt canonical representations; callers supply canonical mask/Boolean lanes. | |
| static constexpr simd | from_float (float value) noexcept |
| Broadcast float lanes without imposing an element normalization policy. | |
| static constexpr simd | unsafe_from_float32 (native_type value) noexcept |
| Adopt raw binary32 register storage without numerical conversion. | |
| static constexpr simd | load (T const *p) noexcept |
| Read all logical lanes from an unaligned element pointer. | |
| static constexpr simd | loadu (T const *p) noexcept |
| Read all logical lanes without an alignment promise. | |
| template<std::size_t Alignment = 1> | |
| static constexpr simd | load_memory (T const *p) noexcept |
| Load logical lanes; Alignment is the caller's byte-alignment promise. | |
| static constexpr simd | load_partial (T const *p, std::size_t count, T fill={}) noexcept |
| Read exactly count lanes and fill the remainder. Zero count permits null. | |
| static constexpr simd | from_bits (bits_type bits) noexcept |
| Adopt unsigned lane representations without conversion. | |
| static constexpr simd | load_bits (word_type const *p) noexcept |
| Read exact lane representations from unsigned words. | |
| static constexpr simd | load_bits_partial (word_type const *p, std::size_t count, word_type fill=0) noexcept |
| Read count representation words, filling remaining lanes; zero permits null. | |
| static constexpr simd | from_bitset (std::uint64_t bits) noexcept |
| Construct canonical mask lanes from a logical bitset. | |
| static constexpr simd | from_native (native_type x) noexcept |
| Adopt implementation storage; mask specializations normalize nonzero lanes. | |
| static constexpr simd | unsafe_from_native (native_type x) noexcept |
| Adopt implementation bits; mask callers must supply canonical lanes. | |
| static constexpr simd | load (T const *p) noexcept |
| Load exactly 16 unaligned bytes as N element objects. | |
| template<std::size_t Align> | |
| static constexpr simd | load_memory (T const *p) noexcept |
| Load all lanes; Align is the caller-provided pointer alignment. | |
| static constexpr simd | load_partial (T const *p, std::size_t n, T fill={}) noexcept |
| Read n lanes and fill the rest; require n <= N. Null is valid when n is zero. | |
| static constexpr simd | load_bits (word_type const *p) noexcept |
| Load lane representations from corresponding unsigned words. | |
| static constexpr simd | from_bits (bits_type x) noexcept |
| Adopt unsigned lane representations without numerical conversion. | |
Static Public Attributes | |
| static constexpr std::size_t | register_lanes =detail::polyfill_register_lanes<T,A>() |
| Number of logical lanes in each underlying native register. | |
| static constexpr std::size_t | register_count =(N+register_lanes-1)/register_lanes |
| Number of underlying registers, including a possible partial tail. | |
Friends | |
| void | operator+ (simd)=delete |
| Reject unary arithmetic on half instruction storage. | |
| void | operator- (simd)=delete |
| Reject unary arithmetic on half instruction storage. | |
| void | operator~ (simd)=delete |
| Use bits() for explicit bitwise operations on half representations. | |
| void | operator! (simd)=delete |
| Half storage does not define a predicate conversion. | |
| constexpr mask | operator!= (simd a, simd b) noexcept |
| Compare corresponding lanes for inequality; unordered floats are unequal. | |
| constexpr mask | operator> (simd a, simd b) noexcept |
| Compare corresponding lanes with the reverse ordered less-than relation. | |
| constexpr mask | operator<= (simd a, simd b) noexcept |
| Compare corresponding lanes for ordered less-than or equality. | |
| constexpr mask | operator>= (simd a, simd b) noexcept |
| Compare corresponding lanes for ordered greater-than or equality. | |
| constexpr simd | operator- (simd value) noexcept |
| Negate every logical lane with the underlying register's semantics. | |
| constexpr simd | operator~ (simd value) noexcept |
| Complement every logical lane representation. | |
| constexpr simd | operator! (simd value) noexcept |
| Complement every logical mask lane. | |
| constexpr bool | any (simd value) noexcept |
| Test whether any logical mask lane is true. | |
| constexpr bool | none (simd value) noexcept |
| Test whether every logical mask lane is false. | |
| constexpr bool | all (simd value) noexcept |
| Test whether every logical mask lane is true. | |
| template<class M> requires (std::same_as<M,mask_type> || std::same_as<M,predicate<N,A>> || std::same_as<M,vector_mask_type>) | |
| constexpr simd | select (M mask, simd a, simd b) |
| Choose each logical lane from a or b without reading padding as a result. | |
| constexpr simd | normal_pow2 (simd n) noexcept |
| Encode normal powers of two for integral exponents in [-126,127]. | |
|
template<std::size_t K> requires (simd_integer_element<T> && ((NATIVE_HOST_WASM!=0) || K<sizeof(T)*8)) | |
| constexpr simd | operator<< (simd value, imm_t< K >) |
| Shift logical lanes left by the valid immediate count. | |
|
template<std::size_t K> requires (simd_integer_element<T> && ((NATIVE_HOST_WASM!=0) || K<sizeof(T)*8)) | |
| constexpr simd | operator>> (simd value, imm_t< K >) |
| Shift logical lanes right by the valid immediate count, extending signed lanes. | |
| constexpr simd | operator<< (simd value, simd counts) noexcept |
| Shift each unsigned 32-bit lane by its corresponding count; counts >=32 yield zero. | |
| constexpr simd | operator>> (simd value, int count) noexcept |
| Shift every integral lane right by a runtime count. | |
| constexpr simd | operator<< (simd value, int count) noexcept |
| Shift every integral lane left by a runtime count. | |
| constexpr simd | fma (simd a, simd b, simd c) noexcept |
| Compute a*b+c with each register's fused lane semantics. | |
| constexpr simd | sqrt (simd value) noexcept |
| Compute square roots with each register's floating-point semantics. | |
| constexpr simd | popcount (simd value) |
| Count the set bits of each unsigned lane using the native chunk operation. | |
| constexpr simd | abs (simd value) noexcept |
| Clear the sign bit of each floating-point lane. | |
| constexpr simd | floor (simd value) noexcept |
| Round floating-point lanes toward negative infinity. | |
| constexpr simd | ceil (simd value) noexcept |
| Round floating-point lanes toward positive infinity. | |
| constexpr simd | trunc (simd value) noexcept |
| Round floating-point lanes toward zero. | |
| constexpr simd | min (simd a, simd b) noexcept |
| Select the smaller lane using the underlying floating-point comparison. | |
| constexpr simd | max (simd a, simd b) noexcept |
| Select the larger lane using the underlying floating-point comparison. | |
| constexpr simd | round_even (simd value) noexcept |
| Round to nearest integral values, choosing even at ties. | |
| constexpr simd | operator+ (simd a, simd b) noexcept |
| Add lanes; integer results wrap and floating results round to nearest-even. | |
| constexpr simd | operator- (simd a, simd b) noexcept |
| Subtract or negate lanes; integer results wrap and floating signs are preserved. | |
| constexpr simd | operator* (simd a, simd b) noexcept |
| Multiply lanes; integer results wrap and floating results round to nearest-even. | |
| constexpr simd | operator/ (simd a, simd b) noexcept |
| Divide floating lanes with WebAssembly IEEE semantics. | |
| constexpr simd | operator& (simd a, simd b) noexcept |
| Intersect representation bits. | |
| constexpr simd | operator| (simd a, simd b) noexcept |
| Unite representation bits. | |
| constexpr simd | operator^ (simd a, simd b) noexcept |
| Exclusive-or representation bits. | |
| constexpr simd | operator~ (simd a) noexcept |
| Complement every representation bit (or lane truth for masks). | |
| constexpr simd | operator- (simd a) noexcept |
| Subtract or negate lanes; integer results wrap and floating signs are preserved. | |
| constexpr mask_type | operator== (simd a, simd b) noexcept |
| Compare lane equality and return canonical mask lanes. | |
| constexpr mask_type | operator!= (simd a, simd b) noexcept |
| Compare lane inequality and return canonical mask lanes. | |
| constexpr mask_type | operator< (simd a, simd b) noexcept |
| Compare lanes using their signedness; unordered floating lanes are false. | |
| constexpr mask_type | operator<= (simd a, simd b) noexcept |
| Compare lanes using their signedness; unordered floating lanes are false. | |
| constexpr mask_type | operator> (simd a, simd b) noexcept |
| Compare lanes using their signedness; unordered floating lanes are false. | |
| constexpr mask_type | operator>= (simd a, simd b) noexcept |
| Compare lanes using their signedness; unordered floating lanes are false. | |
| constexpr simd | operator<< (simd a, unsigned n) noexcept |
| Shift integer lanes left, reducing the count modulo the lane width. | |
| template<std::size_t K> requires simd_integer_element<T> | |
| constexpr simd | operator<< (simd a, imm_t< K >) |
| Shift integer lanes left, reducing the count modulo the lane width. | |
| constexpr simd | operator>> (simd a, unsigned n) noexcept |
| Shift integer lanes right, extending signed lanes and reducing the count modulo their width. | |
| template<std::size_t K> requires simd_integer_element<T> | |
| constexpr simd | operator>> (simd a, imm_t< K >) |
| Shift integer lanes right, extending signed lanes and reducing the count modulo their width. | |
One complete WebAssembly SIMD128 register with semantic element lanes.
One register of representation-preserving instruction operands. This shape provides storage and transfer operations; arithmetic is supplied by the instruction modules supported by its architecture tag.
An explicitly permitted shape decomposed into the largest native registers. Native shapes retain their existing specializations. The final register's padding is excluded from memory transfers, comparisons and mask reductions. Scalar-only tags use one scalar per register; custom elements continue to supply their own semantics through simd_customization over this raw storage.
Definition at line 948 of file native.simd.ccm.
|
inlinestaticconstexprnoexcept |
Adopt register representations, normalizing Boolean and mask lane storage. Numeric representations and unspecified tail padding are preserved.
Definition at line 115 of file polyfill_body.h.
|
friend |
Shift integer lanes left, reducing the count modulo the lane width.
Shift every lane left by K bits, discarding high bits. Require K smaller than the lane bit width.
Shift logical lanes left by the valid immediate count.
Definition at line 6478 of file simd_family.h.
|
friend |
Shift integer lanes right, extending signed lanes and reducing the count modulo their width.
Shift every lane right by K; signed lanes extend the sign, unsigned lanes shift in zero. Require K smaller than the lane bit width.
Shift logical lanes right by the valid immediate count, extending signed lanes.
Definition at line 6529 of file simd_family.h.
Count the set bits of each unsigned lane using the native chunk operation.
Count set bits independently in each unsigned integer lane. Byte populations use CNT on NEON and register nibble tables on x86.
Definition at line 475 of file polyfill_body.h.
|
friend |
Choose each logical lane from a or b without reading padding as a result.
Choose a in true lanes and b in false lanes; both operands are evaluated.
Definition at line 362 of file polyfill_body.h.