2012-05-30 03:10:17 +08:00
|
|
|
/*===---- ammintrin.h - SSE4a intrinsics -----------------------------------===
|
|
|
|
*
|
2019-04-09 04:51:30 +08:00
|
|
|
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
* See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-05-30 03:10:17 +08:00
|
|
|
*
|
|
|
|
*===-----------------------------------------------------------------------===
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __AMMINTRIN_H
|
|
|
|
#define __AMMINTRIN_H
|
|
|
|
|
2021-09-13 21:27:24 +08:00
|
|
|
#if !defined(__i386__) && !defined(__x86_64__)
|
|
|
|
#error "This header is only meant to be used on x86 and x64 architecture"
|
|
|
|
#endif
|
|
|
|
|
2012-05-30 03:10:17 +08:00
|
|
|
#include <pmmintrin.h>
|
|
|
|
|
2015-06-17 15:09:20 +08:00
|
|
|
/* Define the default attributes for the functions in this file. */
|
2018-07-10 03:00:16 +08:00
|
|
|
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4a"), __min_vector_width__(128)))
|
2015-06-17 15:09:20 +08:00
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Extracts the specified bits from the lower 64 bits of the 128-bit
|
2016-12-09 01:57:23 +08:00
|
|
|
/// integer vector operand at the index \a idx and of the length \a len.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \headerfile <x86intrin.h>
|
|
|
|
///
|
2015-09-12 10:55:19 +08:00
|
|
|
/// \code
|
2015-05-28 09:25:25 +08:00
|
|
|
/// __m128i _mm_extracti_si64(__m128i x, const int len, const int idx);
|
2015-09-12 10:55:19 +08:00
|
|
|
/// \endcode
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
2016-12-10 02:35:50 +08:00
|
|
|
/// This intrinsic corresponds to the <c> EXTRQ </c> instruction.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \param x
|
|
|
|
/// The value from which bits are extracted.
|
|
|
|
/// \param len
|
|
|
|
/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]
|
|
|
|
/// are zero, the length is interpreted as 64.
|
|
|
|
/// \param idx
|
2015-09-12 10:55:19 +08:00
|
|
|
/// Bits [5:0] specify the index of the least significant bit; the other
|
2016-04-27 15:14:02 +08:00
|
|
|
/// bits are ignored. If the sum of the index and length is greater than 64,
|
|
|
|
/// the result is undefined. If the length and index are both zero, bits
|
2016-12-09 01:57:23 +08:00
|
|
|
/// [63:0] of parameter \a x are extracted. If the length is zero but the
|
|
|
|
/// index is non-zero, the result is undefined.
|
2015-05-28 09:25:25 +08:00
|
|
|
/// \returns A 128-bit integer vector whose lower 64 bits contain the bits
|
|
|
|
/// extracted from the source operand.
|
2012-05-30 03:10:17 +08:00
|
|
|
#define _mm_extracti_si64(x, len, idx) \
|
|
|
|
((__m128i)__builtin_ia32_extrqi((__v2di)(__m128i)(x), \
|
|
|
|
(char)(len), (char)(idx)))
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Extracts the specified bits from the lower 64 bits of the 128-bit
|
2016-12-09 01:57:23 +08:00
|
|
|
/// integer vector operand at the index and of the length specified by
|
|
|
|
/// \a __y.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \headerfile <x86intrin.h>
|
|
|
|
///
|
2016-12-10 02:35:50 +08:00
|
|
|
/// This intrinsic corresponds to the <c> EXTRQ </c> instruction.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \param __x
|
|
|
|
/// The value from which bits are extracted.
|
|
|
|
/// \param __y
|
2016-04-27 15:14:02 +08:00
|
|
|
/// Specifies the index of the least significant bit at [13:8] and the
|
|
|
|
/// length at [5:0]; all other bits are ignored. If bits [5:0] are zero, the
|
|
|
|
/// length is interpreted as 64. If the sum of the index and length is
|
|
|
|
/// greater than 64, the result is undefined. If the length and index are
|
2016-12-09 01:57:23 +08:00
|
|
|
/// both zero, bits [63:0] of parameter \a __x are extracted. If the length
|
|
|
|
/// is zero but the index is non-zero, the result is undefined.
|
2015-09-12 10:55:19 +08:00
|
|
|
/// \returns A 128-bit vector whose lower 64 bits contain the bits extracted
|
2015-05-28 09:25:25 +08:00
|
|
|
/// from the source operand.
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ __m128i __DEFAULT_FN_ATTRS
|
2012-05-30 03:10:17 +08:00
|
|
|
_mm_extract_si64(__m128i __x, __m128i __y)
|
|
|
|
{
|
|
|
|
return (__m128i)__builtin_ia32_extrq((__v2di)__x, (__v16qi)__y);
|
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Inserts bits of a specified length from the source integer vector
|
2016-12-09 01:57:23 +08:00
|
|
|
/// \a y into the lower 64 bits of the destination integer vector \a x at
|
|
|
|
/// the index \a idx and of the length \a len.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \headerfile <x86intrin.h>
|
|
|
|
///
|
2015-09-12 10:55:19 +08:00
|
|
|
/// \code
|
2015-05-28 09:25:25 +08:00
|
|
|
/// __m128i _mm_inserti_si64(__m128i x, __m128i y, const int len,
|
|
|
|
/// const int idx);
|
2015-09-12 10:55:19 +08:00
|
|
|
/// \endcode
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
2016-12-10 02:35:50 +08:00
|
|
|
/// This intrinsic corresponds to the <c> INSERTQ </c> instruction.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \param x
|
2015-09-12 10:55:19 +08:00
|
|
|
/// The destination operand where bits will be inserted. The inserted bits
|
2016-12-09 01:57:23 +08:00
|
|
|
/// are defined by the length \a len and by the index \a idx specifying the
|
|
|
|
/// least significant bit.
|
2015-05-28 09:25:25 +08:00
|
|
|
/// \param y
|
2015-09-12 10:55:19 +08:00
|
|
|
/// The source operand containing the bits to be extracted. The extracted
|
2016-12-09 01:57:23 +08:00
|
|
|
/// bits are the least significant bits of operand \a y of length \a len.
|
2015-05-28 09:25:25 +08:00
|
|
|
/// \param len
|
|
|
|
/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]
|
|
|
|
/// are zero, the length is interpreted as 64.
|
|
|
|
/// \param idx
|
2015-09-12 10:55:19 +08:00
|
|
|
/// Bits [5:0] specify the index of the least significant bit; the other
|
2016-04-27 15:14:02 +08:00
|
|
|
/// bits are ignored. If the sum of the index and length is greater than 64,
|
|
|
|
/// the result is undefined. If the length and index are both zero, bits
|
2016-12-09 01:57:23 +08:00
|
|
|
/// [63:0] of parameter \a y are inserted into parameter \a x. If the length
|
|
|
|
/// is zero but the index is non-zero, the result is undefined.
|
2016-04-27 15:14:02 +08:00
|
|
|
/// \returns A 128-bit integer vector containing the original lower 64-bits of
|
2016-12-09 01:57:23 +08:00
|
|
|
/// destination operand \a x with the specified bitfields replaced by the
|
|
|
|
/// lower bits of source operand \a y. The upper 64 bits of the return value
|
|
|
|
/// are undefined.
|
2012-05-30 03:10:17 +08:00
|
|
|
#define _mm_inserti_si64(x, y, len, idx) \
|
|
|
|
((__m128i)__builtin_ia32_insertqi((__v2di)(__m128i)(x), \
|
|
|
|
(__v2di)(__m128i)(y), \
|
|
|
|
(char)(len), (char)(idx)))
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Inserts bits of a specified length from the source integer vector
|
2016-12-09 01:57:23 +08:00
|
|
|
/// \a __y into the lower 64 bits of the destination integer vector \a __x
|
|
|
|
/// at the index and of the length specified by \a __y.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \headerfile <x86intrin.h>
|
|
|
|
///
|
2016-12-10 02:35:50 +08:00
|
|
|
/// This intrinsic corresponds to the <c> INSERTQ </c> instruction.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \param __x
|
2015-09-12 10:55:19 +08:00
|
|
|
/// The destination operand where bits will be inserted. The inserted bits
|
|
|
|
/// are defined by the length and by the index of the least significant bit
|
2016-12-09 01:57:23 +08:00
|
|
|
/// specified by operand \a __y.
|
2015-05-28 09:25:25 +08:00
|
|
|
/// \param __y
|
2015-09-12 10:55:19 +08:00
|
|
|
/// The source operand containing the bits to be extracted. The extracted
|
2016-12-09 01:57:23 +08:00
|
|
|
/// bits are the least significant bits of operand \a __y with length
|
|
|
|
/// specified by bits [69:64]. These are inserted into the destination at the
|
|
|
|
/// index specified by bits [77:72]; all other bits are ignored. If bits
|
|
|
|
/// [69:64] are zero, the length is interpreted as 64. If the sum of the
|
|
|
|
/// index and length is greater than 64, the result is undefined. If the
|
|
|
|
/// length and index are both zero, bits [63:0] of parameter \a __y are
|
|
|
|
/// inserted into parameter \a __x. If the length is zero but the index is
|
|
|
|
/// non-zero, the result is undefined.
|
2016-04-27 15:14:02 +08:00
|
|
|
/// \returns A 128-bit integer vector containing the original lower 64-bits of
|
2016-12-09 01:57:23 +08:00
|
|
|
/// destination operand \a __x with the specified bitfields replaced by the
|
|
|
|
/// lower bits of source operand \a __y. The upper 64 bits of the return
|
|
|
|
/// value are undefined.
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ __m128i __DEFAULT_FN_ATTRS
|
2012-05-30 03:10:17 +08:00
|
|
|
_mm_insert_si64(__m128i __x, __m128i __y)
|
|
|
|
{
|
|
|
|
return (__m128i)__builtin_ia32_insertq((__v2di)__x, (__v2di)__y);
|
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Stores a 64-bit double-precision value in a 64-bit memory location.
|
2015-05-28 09:25:25 +08:00
|
|
|
/// To minimize caching, the data is flagged as non-temporal (unlikely to be
|
|
|
|
/// used again soon).
|
|
|
|
///
|
|
|
|
/// \headerfile <x86intrin.h>
|
|
|
|
///
|
2016-12-10 02:35:50 +08:00
|
|
|
/// This intrinsic corresponds to the <c> MOVNTSD </c> instruction.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \param __p
|
|
|
|
/// The 64-bit memory location used to store the register value.
|
|
|
|
/// \param __a
|
2016-04-27 15:14:02 +08:00
|
|
|
/// The 64-bit double-precision floating-point register value to be stored.
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ void __DEFAULT_FN_ATTRS
|
2012-05-30 03:10:17 +08:00
|
|
|
_mm_stream_sd(double *__p, __m128d __a)
|
|
|
|
{
|
|
|
|
__builtin_ia32_movntsd(__p, (__v2df)__a);
|
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Stores a 32-bit single-precision floating-point value in a 32-bit
|
2015-05-28 09:25:25 +08:00
|
|
|
/// memory location. To minimize caching, the data is flagged as
|
|
|
|
/// non-temporal (unlikely to be used again soon).
|
|
|
|
///
|
|
|
|
/// \headerfile <x86intrin.h>
|
|
|
|
///
|
2016-12-10 02:35:50 +08:00
|
|
|
/// This intrinsic corresponds to the <c> MOVNTSS </c> instruction.
|
2015-05-28 09:25:25 +08:00
|
|
|
///
|
|
|
|
/// \param __p
|
|
|
|
/// The 32-bit memory location used to store the register value.
|
|
|
|
/// \param __a
|
2016-04-27 15:14:02 +08:00
|
|
|
/// The 32-bit single-precision floating-point register value to be stored.
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ void __DEFAULT_FN_ATTRS
|
2012-05-30 03:10:17 +08:00
|
|
|
_mm_stream_ss(float *__p, __m128 __a)
|
|
|
|
{
|
|
|
|
__builtin_ia32_movntss(__p, (__v4sf)__a);
|
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
#undef __DEFAULT_FN_ATTRS
|
2015-06-17 15:09:20 +08:00
|
|
|
|
2012-05-30 03:10:17 +08:00
|
|
|
#endif /* __AMMINTRIN_H */
|