Path: blob/main/contrib/llvm-project/clang/lib/Headers/ammintrin.h
35233 views
/*===---- ammintrin.h - SSE4a intrinsics -----------------------------------===1*2* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3* See https://llvm.org/LICENSE.txt for license information.4* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5*6*===-----------------------------------------------------------------------===7*/89#ifndef __AMMINTRIN_H10#define __AMMINTRIN_H1112#if !defined(__i386__) && !defined(__x86_64__)13#error "This header is only meant to be used on x86 and x64 architecture"14#endif1516#include <pmmintrin.h>1718/* Define the default attributes for the functions in this file. */19#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4a"), __min_vector_width__(128)))2021/// Extracts the specified bits from the lower 64 bits of the 128-bit22/// integer vector operand at the index \a idx and of the length \a len.23///24/// \headerfile <x86intrin.h>25///26/// \code27/// __m128i _mm_extracti_si64(__m128i x, const int len, const int idx);28/// \endcode29///30/// This intrinsic corresponds to the <c> EXTRQ </c> instruction.31///32/// \param x33/// The value from which bits are extracted.34/// \param len35/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]36/// are zero, the length is interpreted as 64.37/// \param idx38/// Bits [5:0] specify the index of the least significant bit; the other39/// bits are ignored. If the sum of the index and length is greater than 64,40/// the result is undefined. If the length and index are both zero, bits41/// [63:0] of parameter \a x are extracted. If the length is zero but the42/// index is non-zero, the result is undefined.43/// \returns A 128-bit integer vector whose lower 64 bits contain the bits44/// extracted from the source operand.45#define _mm_extracti_si64(x, len, idx) \46((__m128i)__builtin_ia32_extrqi((__v2di)(__m128i)(x), \47(char)(len), (char)(idx)))4849/// Extracts the specified bits from the lower 64 bits of the 128-bit50/// integer vector operand at the index and of the length specified by51/// \a __y.52///53/// \headerfile <x86intrin.h>54///55/// This intrinsic corresponds to the <c> EXTRQ </c> instruction.56///57/// \param __x58/// The value from which bits are extracted.59/// \param __y60/// Specifies the index of the least significant bit at [13:8] and the61/// length at [5:0]; all other bits are ignored. If bits [5:0] are zero, the62/// length is interpreted as 64. If the sum of the index and length is63/// greater than 64, the result is undefined. If the length and index are64/// both zero, bits [63:0] of parameter \a __x are extracted. If the length65/// is zero but the index is non-zero, the result is undefined.66/// \returns A 128-bit vector whose lower 64 bits contain the bits extracted67/// from the source operand.68static __inline__ __m128i __DEFAULT_FN_ATTRS69_mm_extract_si64(__m128i __x, __m128i __y)70{71return (__m128i)__builtin_ia32_extrq((__v2di)__x, (__v16qi)__y);72}7374/// Inserts bits of a specified length from the source integer vector75/// \a y into the lower 64 bits of the destination integer vector \a x at76/// the index \a idx and of the length \a len.77///78/// \headerfile <x86intrin.h>79///80/// \code81/// __m128i _mm_inserti_si64(__m128i x, __m128i y, const int len,82/// const int idx);83/// \endcode84///85/// This intrinsic corresponds to the <c> INSERTQ </c> instruction.86///87/// \param x88/// The destination operand where bits will be inserted. The inserted bits89/// are defined by the length \a len and by the index \a idx specifying the90/// least significant bit.91/// \param y92/// The source operand containing the bits to be extracted. The extracted93/// bits are the least significant bits of operand \a y of length \a len.94/// \param len95/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]96/// are zero, the length is interpreted as 64.97/// \param idx98/// Bits [5:0] specify the index of the least significant bit; the other99/// bits are ignored. If the sum of the index and length is greater than 64,100/// the result is undefined. If the length and index are both zero, bits101/// [63:0] of parameter \a y are inserted into parameter \a x. If the length102/// is zero but the index is non-zero, the result is undefined.103/// \returns A 128-bit integer vector containing the original lower 64-bits of104/// destination operand \a x with the specified bitfields replaced by the105/// lower bits of source operand \a y. The upper 64 bits of the return value106/// are undefined.107#define _mm_inserti_si64(x, y, len, idx) \108((__m128i)__builtin_ia32_insertqi((__v2di)(__m128i)(x), \109(__v2di)(__m128i)(y), \110(char)(len), (char)(idx)))111112/// Inserts bits of a specified length from the source integer vector113/// \a __y into the lower 64 bits of the destination integer vector \a __x114/// at the index and of the length specified by \a __y.115///116/// \headerfile <x86intrin.h>117///118/// This intrinsic corresponds to the <c> INSERTQ </c> instruction.119///120/// \param __x121/// The destination operand where bits will be inserted. The inserted bits122/// are defined by the length and by the index of the least significant bit123/// specified by operand \a __y.124/// \param __y125/// The source operand containing the bits to be extracted. The extracted126/// bits are the least significant bits of operand \a __y with length127/// specified by bits [69:64]. These are inserted into the destination at the128/// index specified by bits [77:72]; all other bits are ignored. If bits129/// [69:64] are zero, the length is interpreted as 64. If the sum of the130/// index and length is greater than 64, the result is undefined. If the131/// length and index are both zero, bits [63:0] of parameter \a __y are132/// inserted into parameter \a __x. If the length is zero but the index is133/// non-zero, the result is undefined.134/// \returns A 128-bit integer vector containing the original lower 64-bits of135/// destination operand \a __x with the specified bitfields replaced by the136/// lower bits of source operand \a __y. The upper 64 bits of the return137/// value are undefined.138static __inline__ __m128i __DEFAULT_FN_ATTRS139_mm_insert_si64(__m128i __x, __m128i __y)140{141return (__m128i)__builtin_ia32_insertq((__v2di)__x, (__v2di)__y);142}143144/// Stores a 64-bit double-precision value in a 64-bit memory location.145/// To minimize caching, the data is flagged as non-temporal (unlikely to be146/// used again soon).147///148/// \headerfile <x86intrin.h>149///150/// This intrinsic corresponds to the <c> MOVNTSD </c> instruction.151///152/// \param __p153/// The 64-bit memory location used to store the register value.154/// \param __a155/// The 64-bit double-precision floating-point register value to be stored.156static __inline__ void __DEFAULT_FN_ATTRS157_mm_stream_sd(void *__p, __m128d __a)158{159__builtin_ia32_movntsd((double *)__p, (__v2df)__a);160}161162/// Stores a 32-bit single-precision floating-point value in a 32-bit163/// memory location. To minimize caching, the data is flagged as164/// non-temporal (unlikely to be used again soon).165///166/// \headerfile <x86intrin.h>167///168/// This intrinsic corresponds to the <c> MOVNTSS </c> instruction.169///170/// \param __p171/// The 32-bit memory location used to store the register value.172/// \param __a173/// The 32-bit single-precision floating-point register value to be stored.174static __inline__ void __DEFAULT_FN_ATTRS175_mm_stream_ss(void *__p, __m128 __a)176{177__builtin_ia32_movntss((float *)__p, (__v4sf)__a);178}179180#undef __DEFAULT_FN_ATTRS181182#endif /* __AMMINTRIN_H */183184185