Path: blob/master/tools/android-sdk/renderscript/clang-include/ammintrin.h
496 views
/*===---- ammintrin.h - SSE4a intrinsics -----------------------------------===1*2* Permission is hereby granted, free of charge, to any person obtaining a copy3* of this software and associated documentation files (the "Software"), to deal4* in the Software without restriction, including without limitation the rights5* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell6* copies of the Software, and to permit persons to whom the Software is7* furnished to do so, subject to the following conditions:8*9* The above copyright notice and this permission notice shall be included in10* all copies or substantial portions of the Software.11*12* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR13* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE15* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER16* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,17* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN18* THE SOFTWARE.19*20*===-----------------------------------------------------------------------===21*/2223#ifndef __AMMINTRIN_H24#define __AMMINTRIN_H2526#include <pmmintrin.h>2728/* Define the default attributes for the functions in this file. */29#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4a")))3031/// \brief Extracts the specified bits from the lower 64 bits of the 128-bit32/// integer vector operand at the index idx and of the length len.33///34/// \headerfile <x86intrin.h>35///36/// \code37/// __m128i _mm_extracti_si64(__m128i x, const int len, const int idx);38/// \endcode39///40/// This intrinsic corresponds to the \c EXTRQ instruction.41///42/// \param x43/// The value from which bits are extracted.44/// \param len45/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]46/// are zero, the length is interpreted as 64.47/// \param idx48/// Bits [5:0] specify the index of the least significant bit; the other49/// bits are ignored. If the sum of the index and length is greater than 64,50/// the result is undefined. If the length and index are both zero, bits51/// [63:0] of parameter x are extracted. If the length is zero but the index52/// is non-zero, the result is undefined.53/// \returns A 128-bit integer vector whose lower 64 bits contain the bits54/// extracted from the source operand.55#define _mm_extracti_si64(x, len, idx) \56((__m128i)__builtin_ia32_extrqi((__v2di)(__m128i)(x), \57(char)(len), (char)(idx)))5859/// \brief Extracts the specified bits from the lower 64 bits of the 128-bit60/// integer vector operand at the index and of the length specified by __y.61///62/// \headerfile <x86intrin.h>63///64/// This intrinsic corresponds to the \c EXTRQ instruction.65///66/// \param __x67/// The value from which bits are extracted.68/// \param __y69/// Specifies the index of the least significant bit at [13:8] and the70/// length at [5:0]; all other bits are ignored. If bits [5:0] are zero, the71/// length is interpreted as 64. If the sum of the index and length is72/// greater than 64, the result is undefined. If the length and index are73/// both zero, bits [63:0] of parameter __x are extracted. If the length is74/// zero but the index is non-zero, the result is undefined.75/// \returns A 128-bit vector whose lower 64 bits contain the bits extracted76/// from the source operand.77static __inline__ __m128i __DEFAULT_FN_ATTRS78_mm_extract_si64(__m128i __x, __m128i __y)79{80return (__m128i)__builtin_ia32_extrq((__v2di)__x, (__v16qi)__y);81}8283/// \brief Inserts bits of a specified length from the source integer vector y84/// into the lower 64 bits of the destination integer vector x at the index85/// idx and of the length len.86///87/// \headerfile <x86intrin.h>88///89/// \code90/// __m128i _mm_inserti_si64(__m128i x, __m128i y, const int len,91/// const int idx);92/// \endcode93///94/// This intrinsic corresponds to the \c INSERTQ instruction.95///96/// \param x97/// The destination operand where bits will be inserted. The inserted bits98/// are defined by the length len and by the index idx specifying the least99/// significant bit.100/// \param y101/// The source operand containing the bits to be extracted. The extracted102/// bits are the least significant bits of operand y of length len.103/// \param len104/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]105/// are zero, the length is interpreted as 64.106/// \param idx107/// Bits [5:0] specify the index of the least significant bit; the other108/// bits are ignored. If the sum of the index and length is greater than 64,109/// the result is undefined. If the length and index are both zero, bits110/// [63:0] of parameter y are inserted into parameter x. If the length is111/// zero but the index is non-zero, the result is undefined.112/// \returns A 128-bit integer vector containing the original lower 64-bits of113/// destination operand x with the specified bitfields replaced by the lower114/// bits of source operand y. The upper 64 bits of the return value are115/// undefined.116117#define _mm_inserti_si64(x, y, len, idx) \118((__m128i)__builtin_ia32_insertqi((__v2di)(__m128i)(x), \119(__v2di)(__m128i)(y), \120(char)(len), (char)(idx)))121122/// \brief Inserts bits of a specified length from the source integer vector123/// __y into the lower 64 bits of the destination integer vector __x at the124/// index and of the length specified by __y.125///126/// \headerfile <x86intrin.h>127///128/// This intrinsic corresponds to the \c INSERTQ instruction.129///130/// \param __x131/// The destination operand where bits will be inserted. The inserted bits132/// are defined by the length and by the index of the least significant bit133/// specified by operand __y.134/// \param __y135/// The source operand containing the bits to be extracted. The extracted136/// bits are the least significant bits of operand __y with length specified137/// by bits [69:64]. These are inserted into the destination at the index138/// specified by bits [77:72]; all other bits are ignored. If bits [69:64]139/// are zero, the length is interpreted as 64. If the sum of the index and140/// length is greater than 64, the result is undefined. If the length and141/// index are both zero, bits [63:0] of parameter __y are inserted into142/// parameter __x. If the length is zero but the index is non-zero, the143/// result is undefined.144/// \returns A 128-bit integer vector containing the original lower 64-bits of145/// destination operand __x with the specified bitfields replaced by the146/// lower bits of source operand __y. The upper 64 bits of the return value147/// are undefined.148149static __inline__ __m128i __DEFAULT_FN_ATTRS150_mm_insert_si64(__m128i __x, __m128i __y)151{152return (__m128i)__builtin_ia32_insertq((__v2di)__x, (__v2di)__y);153}154155/// \brief Stores a 64-bit double-precision value in a 64-bit memory location.156/// To minimize caching, the data is flagged as non-temporal (unlikely to be157/// used again soon).158///159/// \headerfile <x86intrin.h>160///161/// This intrinsic corresponds to the \c MOVNTSD instruction.162///163/// \param __p164/// The 64-bit memory location used to store the register value.165/// \param __a166/// The 64-bit double-precision floating-point register value to be stored.167static __inline__ void __DEFAULT_FN_ATTRS168_mm_stream_sd(double *__p, __m128d __a)169{170__builtin_ia32_movntsd(__p, (__v2df)__a);171}172173/// \brief Stores a 32-bit single-precision floating-point value in a 32-bit174/// memory location. To minimize caching, the data is flagged as175/// non-temporal (unlikely to be used again soon).176///177/// \headerfile <x86intrin.h>178///179/// This intrinsic corresponds to the \c MOVNTSS instruction.180///181/// \param __p182/// The 32-bit memory location used to store the register value.183/// \param __a184/// The 32-bit single-precision floating-point register value to be stored.185static __inline__ void __DEFAULT_FN_ATTRS186_mm_stream_ss(float *__p, __m128 __a)187{188__builtin_ia32_movntss(__p, (__v4sf)__a);189}190191#undef __DEFAULT_FN_ATTRS192193#endif /* __AMMINTRIN_H */194195196