123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781 |
- /*===---- tmmintrin.h - SSSE3 intrinsics -----------------------------------===
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *===-----------------------------------------------------------------------===
- */
- #ifndef __TMMINTRIN_H
- #define __TMMINTRIN_H
- #include <pmmintrin.h>
- /* Define the default attributes for the functions in this file. */
- #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("ssse3")))
- /// \brief Computes the absolute value of each of the packed 8-bit signed
- /// integers in the source operand and stores the 8-bit unsigned integer
- /// results in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PABSB instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [8 x i8].
- /// \returns A 64-bit integer vector containing the absolute values of the
- /// elements in the operand.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_abs_pi8(__m64 __a)
- {
- return (__m64)__builtin_ia32_pabsb((__v8qi)__a);
- }
- /// \brief Computes the absolute value of each of the packed 8-bit signed
- /// integers in the source operand and stores the 8-bit unsigned integer
- /// results in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPABSB instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [16 x i8].
- /// \returns A 128-bit integer vector containing the absolute values of the
- /// elements in the operand.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_abs_epi8(__m128i __a)
- {
- return (__m128i)__builtin_ia32_pabsb128((__v16qi)__a);
- }
- /// \brief Computes the absolute value of each of the packed 16-bit signed
- /// integers in the source operand and stores the 16-bit unsigned integer
- /// results in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PABSW instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [4 x i16].
- /// \returns A 64-bit integer vector containing the absolute values of the
- /// elements in the operand.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_abs_pi16(__m64 __a)
- {
- return (__m64)__builtin_ia32_pabsw((__v4hi)__a);
- }
- /// \brief Computes the absolute value of each of the packed 16-bit signed
- /// integers in the source operand and stores the 16-bit unsigned integer
- /// results in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPABSW instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [8 x i16].
- /// \returns A 128-bit integer vector containing the absolute values of the
- /// elements in the operand.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_abs_epi16(__m128i __a)
- {
- return (__m128i)__builtin_ia32_pabsw128((__v8hi)__a);
- }
- /// \brief Computes the absolute value of each of the packed 32-bit signed
- /// integers in the source operand and stores the 32-bit unsigned integer
- /// results in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PABSD instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [2 x i32].
- /// \returns A 64-bit integer vector containing the absolute values of the
- /// elements in the operand.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_abs_pi32(__m64 __a)
- {
- return (__m64)__builtin_ia32_pabsd((__v2si)__a);
- }
- /// \brief Computes the absolute value of each of the packed 32-bit signed
- /// integers in the source operand and stores the 32-bit unsigned integer
- /// results in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPABSD instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [4 x i32].
- /// \returns A 128-bit integer vector containing the absolute values of the
- /// elements in the operand.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_abs_epi32(__m128i __a)
- {
- return (__m128i)__builtin_ia32_pabsd128((__v4si)__a);
- }
- /// \brief Concatenates the two 128-bit integer vector operands, and
- /// right-shifts the result by the number of bytes specified in the immediate
- /// operand.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// \code
- /// __m128i _mm_alignr_epi8(__m128i a, __m128i b, const int n);
- /// \endcode
- ///
- /// This intrinsic corresponds to the \c PALIGNR instruction.
- ///
- /// \param a
- /// A 128-bit vector of [16 x i8] containing one of the source operands.
- /// \param b
- /// A 128-bit vector of [16 x i8] containing one of the source operands.
- /// \param n
- /// An immediate operand specifying how many bytes to right-shift the result.
- /// \returns A 128-bit integer vector containing the concatenated right-shifted
- /// value.
- #define _mm_alignr_epi8(a, b, n) __extension__ ({ \
- (__m128i)__builtin_ia32_palignr128((__v16qi)(__m128i)(a), \
- (__v16qi)(__m128i)(b), (n)); })
- /// \brief Concatenates the two 64-bit integer vector operands, and right-shifts
- /// the result by the number of bytes specified in the immediate operand.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// \code
- /// __m64 _mm_alignr_pi8(__m64 a, __m64 b, const int n);
- /// \endcode
- ///
- /// This intrinsic corresponds to the \c PALIGNR instruction.
- ///
- /// \param a
- /// A 64-bit vector of [8 x i8] containing one of the source operands.
- /// \param b
- /// A 64-bit vector of [8 x i8] containing one of the source operands.
- /// \param n
- /// An immediate operand specifying how many bytes to right-shift the result.
- /// \returns A 64-bit integer vector containing the concatenated right-shifted
- /// value.
- #define _mm_alignr_pi8(a, b, n) __extension__ ({ \
- (__m64)__builtin_ia32_palignr((__v8qi)(__m64)(a), (__v8qi)(__m64)(b), (n)); })
- /// \brief Horizontally adds the adjacent pairs of values contained in 2 packed
- /// 128-bit vectors of [8 x i16].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPHADDW instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the lower bits of the
- /// destination.
- /// \param __b
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the upper bits of the
- /// destination.
- /// \returns A 128-bit vector of [8 x i16] containing the horizontal sums of
- /// both operands.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_hadd_epi16(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_phaddw128((__v8hi)__a, (__v8hi)__b);
- }
- /// \brief Horizontally adds the adjacent pairs of values contained in 2 packed
- /// 128-bit vectors of [4 x i32].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPHADDD instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [4 x i32] containing one of the source operands. The
- /// horizontal sums of the values are stored in the lower bits of the
- /// destination.
- /// \param __b
- /// A 128-bit vector of [4 x i32] containing one of the source operands. The
- /// horizontal sums of the values are stored in the upper bits of the
- /// destination.
- /// \returns A 128-bit vector of [4 x i32] containing the horizontal sums of
- /// both operands.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_hadd_epi32(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_phaddd128((__v4si)__a, (__v4si)__b);
- }
- /// \brief Horizontally adds the adjacent pairs of values contained in 2 packed
- /// 64-bit vectors of [4 x i16].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PHADDW instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the lower bits of the
- /// destination.
- /// \param __b
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the upper bits of the
- /// destination.
- /// \returns A 64-bit vector of [4 x i16] containing the horizontal sums of both
- /// operands.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_hadd_pi16(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_phaddw((__v4hi)__a, (__v4hi)__b);
- }
- /// \brief Horizontally adds the adjacent pairs of values contained in 2 packed
- /// 64-bit vectors of [2 x i32].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PHADDD instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [2 x i32] containing one of the source operands. The
- /// horizontal sums of the values are stored in the lower bits of the
- /// destination.
- /// \param __b
- /// A 64-bit vector of [2 x i32] containing one of the source operands. The
- /// horizontal sums of the values are stored in the upper bits of the
- /// destination.
- /// \returns A 64-bit vector of [2 x i32] containing the horizontal sums of both
- /// operands.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_hadd_pi32(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_phaddd((__v2si)__a, (__v2si)__b);
- }
- /// \brief Horizontally adds the adjacent pairs of values contained in 2 packed
- /// 128-bit vectors of [8 x i16]. Positive sums greater than 7FFFh are
- /// saturated to 7FFFh. Negative sums less than 8000h are saturated to 8000h.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPHADDSW instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the lower bits of the
- /// destination.
- /// \param __b
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the upper bits of the
- /// destination.
- /// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated
- /// sums of both operands.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_hadds_epi16(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_phaddsw128((__v8hi)__a, (__v8hi)__b);
- }
- /// \brief Horizontally adds the adjacent pairs of values contained in 2 packed
- /// 64-bit vectors of [4 x i16]. Positive sums greater than 7FFFh are
- /// saturated to 7FFFh. Negative sums less than 8000h are saturated to 8000h.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PHADDSW instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the lower bits of the
- /// destination.
- /// \param __b
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal sums of the values are stored in the upper bits of the
- /// destination.
- /// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated
- /// sums of both operands.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_hadds_pi16(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_phaddsw((__v4hi)__a, (__v4hi)__b);
- }
- /// \brief Horizontally subtracts the adjacent pairs of values contained in 2
- /// packed 128-bit vectors of [8 x i16].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPHSUBW instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the lower bits of
- /// the destination.
- /// \param __b
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the upper bits of
- /// the destination.
- /// \returns A 128-bit vector of [8 x i16] containing the horizontal differences
- /// of both operands.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_hsub_epi16(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_phsubw128((__v8hi)__a, (__v8hi)__b);
- }
- /// \brief Horizontally subtracts the adjacent pairs of values contained in 2
- /// packed 128-bit vectors of [4 x i32].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPHSUBD instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [4 x i32] containing one of the source operands. The
- /// horizontal differences between the values are stored in the lower bits of
- /// the destination.
- /// \param __b
- /// A 128-bit vector of [4 x i32] containing one of the source operands. The
- /// horizontal differences between the values are stored in the upper bits of
- /// the destination.
- /// \returns A 128-bit vector of [4 x i32] containing the horizontal differences
- /// of both operands.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_hsub_epi32(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_phsubd128((__v4si)__a, (__v4si)__b);
- }
- /// \brief Horizontally subtracts the adjacent pairs of values contained in 2
- /// packed 64-bit vectors of [4 x i16].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PHSUBW instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the lower bits of
- /// the destination.
- /// \param __b
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the upper bits of
- /// the destination.
- /// \returns A 64-bit vector of [4 x i16] containing the horizontal differences
- /// of both operands.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_hsub_pi16(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_phsubw((__v4hi)__a, (__v4hi)__b);
- }
- /// \brief Horizontally subtracts the adjacent pairs of values contained in 2
- /// packed 64-bit vectors of [2 x i32].
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PHSUBD instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [2 x i32] containing one of the source operands. The
- /// horizontal differences between the values are stored in the lower bits of
- /// the destination.
- /// \param __b
- /// A 64-bit vector of [2 x i32] containing one of the source operands. The
- /// horizontal differences between the values are stored in the upper bits of
- /// the destination.
- /// \returns A 64-bit vector of [2 x i32] containing the horizontal differences
- /// of both operands.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_hsub_pi32(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_phsubd((__v2si)__a, (__v2si)__b);
- }
- /// \brief Horizontally subtracts the adjacent pairs of values contained in 2
- /// packed 128-bit vectors of [8 x i16]. Positive differences greater than
- /// 7FFFh are saturated to 7FFFh. Negative differences less than 8000h are
- /// saturated to 8000h.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPHSUBSW instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the lower bits of
- /// the destination.
- /// \param __b
- /// A 128-bit vector of [8 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the upper bits of
- /// the destination.
- /// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated
- /// differences of both operands.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_hsubs_epi16(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_phsubsw128((__v8hi)__a, (__v8hi)__b);
- }
- /// \brief Horizontally subtracts the adjacent pairs of values contained in 2
- /// packed 64-bit vectors of [4 x i16]. Positive differences greater than
- /// 7FFFh are saturated to 7FFFh. Negative differences less than 8000h are
- /// saturated to 8000h.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PHSUBSW instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the lower bits of
- /// the destination.
- /// \param __b
- /// A 64-bit vector of [4 x i16] containing one of the source operands. The
- /// horizontal differences between the values are stored in the upper bits of
- /// the destination.
- /// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated
- /// differences of both operands.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_hsubs_pi16(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_phsubsw((__v4hi)__a, (__v4hi)__b);
- }
- /// \brief Multiplies corresponding pairs of packed 8-bit unsigned integer
- /// values contained in the first source operand and packed 8-bit signed
- /// integer values contained in the second source operand, adds pairs of
- /// contiguous products with signed saturation, and writes the 16-bit sums to
- /// the corresponding bits in the destination.
- ///
- /// For example, bits [7:0] of both operands are multiplied, bits [15:8] of
- /// both operands are multiplied, and the sum of both results is written to
- /// bits [15:0] of the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPMADDUBSW instruction.
- ///
- /// \param __a
- /// A 128-bit integer vector containing the first source operand.
- /// \param __b
- /// A 128-bit integer vector containing the second source operand.
- /// \returns A 128-bit integer vector containing the sums of products of both
- /// operands: \n
- /// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n
- /// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n
- /// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n
- /// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7) \n
- /// \a R4 := (\a __a8 * \a __b8) + (\a __a9 * \a __b9) \n
- /// \a R5 := (\a __a10 * \a __b10) + (\a __a11 * \a __b11) \n
- /// \a R6 := (\a __a12 * \a __b12) + (\a __a13 * \a __b13) \n
- /// \a R7 := (\a __a14 * \a __b14) + (\a __a15 * \a __b15)
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_maddubs_epi16(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_pmaddubsw128((__v16qi)__a, (__v16qi)__b);
- }
- /// \brief Multiplies corresponding pairs of packed 8-bit unsigned integer
- /// values contained in the first source operand and packed 8-bit signed
- /// integer values contained in the second source operand, adds pairs of
- /// contiguous products with signed saturation, and writes the 16-bit sums to
- /// the corresponding bits in the destination.
- ///
- /// For example, bits [7:0] of both operands are multiplied, bits [15:8] of
- /// both operands are multiplied, and the sum of both results is written to
- /// bits [15:0] of the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PMADDUBSW instruction.
- ///
- /// \param __a
- /// A 64-bit integer vector containing the first source operand.
- /// \param __b
- /// A 64-bit integer vector containing the second source operand.
- /// \returns A 64-bit integer vector containing the sums of products of both
- /// operands: \n
- /// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n
- /// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n
- /// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n
- /// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7)
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_maddubs_pi16(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_pmaddubsw((__v8qi)__a, (__v8qi)__b);
- }
- /// \brief Multiplies packed 16-bit signed integer values, truncates the 32-bit
- /// products to the 18 most significant bits by right-shifting, rounds the
- /// truncated value by adding 1, and writes bits [16:1] to the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPMULHRSW instruction.
- ///
- /// \param __a
- /// A 128-bit vector of [8 x i16] containing one of the source operands.
- /// \param __b
- /// A 128-bit vector of [8 x i16] containing one of the source operands.
- /// \returns A 128-bit vector of [8 x i16] containing the rounded and scaled
- /// products of both operands.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_mulhrs_epi16(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_pmulhrsw128((__v8hi)__a, (__v8hi)__b);
- }
- /// \brief Multiplies packed 16-bit signed integer values, truncates the 32-bit
- /// products to the 18 most significant bits by right-shifting, rounds the
- /// truncated value by adding 1, and writes bits [16:1] to the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PMULHRSW instruction.
- ///
- /// \param __a
- /// A 64-bit vector of [4 x i16] containing one of the source operands.
- /// \param __b
- /// A 64-bit vector of [4 x i16] containing one of the source operands.
- /// \returns A 64-bit vector of [4 x i16] containing the rounded and scaled
- /// products of both operands.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_mulhrs_pi16(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_pmulhrsw((__v4hi)__a, (__v4hi)__b);
- }
- /// \brief Copies the 8-bit integers from a 128-bit integer vector to the
- /// destination or clears 8-bit values in the destination, as specified by
- /// the second source operand.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPSHUFB instruction.
- ///
- /// \param __a
- /// A 128-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 128-bit integer vector containing control bytes corresponding to
- /// positions in the destination:
- /// Bit 7: \n
- /// 1: Clear the corresponding byte in the destination. \n
- /// 0: Copy the selected source byte to the corresponding byte in the
- /// destination. \n
- /// Bits [6:4] Reserved. \n
- /// Bits [3:0] select the source byte to be copied.
- /// \returns A 128-bit integer vector containing the copied or cleared values.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_shuffle_epi8(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_pshufb128((__v16qi)__a, (__v16qi)__b);
- }
- /// \brief Copies the 8-bit integers from a 64-bit integer vector to the
- /// destination or clears 8-bit values in the destination, as specified by
- /// the second source operand.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PSHUFB instruction.
- ///
- /// \param __a
- /// A 64-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 64-bit integer vector containing control bytes corresponding to
- /// positions in the destination:
- /// Bit 7: \n
- /// 1: Clear the corresponding byte in the destination. \n
- /// 0: Copy the selected source byte to the corresponding byte in the
- /// destination. \n
- /// Bits [3:0] select the source byte to be copied.
- /// \returns A 64-bit integer vector containing the copied or cleared values.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_shuffle_pi8(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_pshufb((__v8qi)__a, (__v8qi)__b);
- }
- /// \brief For each 8-bit integer in the first source operand, perform one of
- /// the following actions as specified by the second source operand.
- ///
- /// If the byte in the second source is negative, calculate the two's
- /// complement of the corresponding byte in the first source, and write that
- /// value to the destination. If the byte in the second source is positive,
- /// copy the corresponding byte from the first source to the destination. If
- /// the byte in the second source is zero, clear the corresponding byte in
- /// the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPSIGNB instruction.
- ///
- /// \param __a
- /// A 128-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 128-bit integer vector containing control bytes corresponding to
- /// positions in the destination.
- /// \returns A 128-bit integer vector containing the resultant values.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_sign_epi8(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_psignb128((__v16qi)__a, (__v16qi)__b);
- }
- /// \brief For each 16-bit integer in the first source operand, perform one of
- /// the following actions as specified by the second source operand.
- ///
- /// If the word in the second source is negative, calculate the two's
- /// complement of the corresponding word in the first source, and write that
- /// value to the destination. If the word in the second source is positive,
- /// copy the corresponding word from the first source to the destination. If
- /// the word in the second source is zero, clear the corresponding word in
- /// the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPSIGNW instruction.
- ///
- /// \param __a
- /// A 128-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 128-bit integer vector containing control words corresponding to
- /// positions in the destination.
- /// \returns A 128-bit integer vector containing the resultant values.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_sign_epi16(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_psignw128((__v8hi)__a, (__v8hi)__b);
- }
- /// \brief For each 32-bit integer in the first source operand, perform one of
- /// the following actions as specified by the second source operand.
- ///
- /// If the doubleword in the second source is negative, calculate the two's
- /// complement of the corresponding word in the first source, and write that
- /// value to the destination. If the doubleword in the second source is
- /// positive, copy the corresponding word from the first source to the
- /// destination. If the doubleword in the second source is zero, clear the
- /// corresponding word in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c VPSIGND instruction.
- ///
- /// \param __a
- /// A 128-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 128-bit integer vector containing control doublewords corresponding to
- /// positions in the destination.
- /// \returns A 128-bit integer vector containing the resultant values.
- static __inline__ __m128i __DEFAULT_FN_ATTRS
- _mm_sign_epi32(__m128i __a, __m128i __b)
- {
- return (__m128i)__builtin_ia32_psignd128((__v4si)__a, (__v4si)__b);
- }
- /// \brief For each 8-bit integer in the first source operand, perform one of
- /// the following actions as specified by the second source operand.
- ///
- /// If the byte in the second source is negative, calculate the two's
- /// complement of the corresponding byte in the first source, and write that
- /// value to the destination. If the byte in the second source is positive,
- /// copy the corresponding byte from the first source to the destination. If
- /// the byte in the second source is zero, clear the corresponding byte in
- /// the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PSIGNB instruction.
- ///
- /// \param __a
- /// A 64-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 64-bit integer vector containing control bytes corresponding to
- /// positions in the destination.
- /// \returns A 64-bit integer vector containing the resultant values.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_sign_pi8(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_psignb((__v8qi)__a, (__v8qi)__b);
- }
- /// \brief For each 16-bit integer in the first source operand, perform one of
- /// the following actions as specified by the second source operand.
- ///
- /// If the word in the second source is negative, calculate the two's
- /// complement of the corresponding word in the first source, and write that
- /// value to the destination. If the word in the second source is positive,
- /// copy the corresponding word from the first source to the destination. If
- /// the word in the second source is zero, clear the corresponding word in
- /// the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PSIGNW instruction.
- ///
- /// \param __a
- /// A 64-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 64-bit integer vector containing control words corresponding to
- /// positions in the destination.
- /// \returns A 64-bit integer vector containing the resultant values.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_sign_pi16(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_psignw((__v4hi)__a, (__v4hi)__b);
- }
- /// \brief For each 32-bit integer in the first source operand, perform one of
- /// the following actions as specified by the second source operand.
- ///
- /// If the doubleword in the second source is negative, calculate the two's
- /// complement of the corresponding doubleword in the first source, and
- /// write that value to the destination. If the doubleword in the second
- /// source is positive, copy the corresponding doubleword from the first
- /// source to the destination. If the doubleword in the second source is
- /// zero, clear the corresponding doubleword in the destination.
- ///
- /// \headerfile <x86intrin.h>
- ///
- /// This intrinsic corresponds to the \c PSIGND instruction.
- ///
- /// \param __a
- /// A 64-bit integer vector containing the values to be copied.
- /// \param __b
- /// A 64-bit integer vector containing two control doublewords corresponding
- /// to positions in the destination.
- /// \returns A 64-bit integer vector containing the resultant values.
- static __inline__ __m64 __DEFAULT_FN_ATTRS
- _mm_sign_pi32(__m64 __a, __m64 __b)
- {
- return (__m64)__builtin_ia32_psignd((__v2si)__a, (__v2si)__b);
- }
- #undef __DEFAULT_FN_ATTRS
- #endif /* __TMMINTRIN_H */
|