1*344a7f5eSAndroid Build Coastguard Worker /*===---- ammintrin.h - SSE4a intrinsics -----------------------------------===
2*344a7f5eSAndroid Build Coastguard Worker *
3*344a7f5eSAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a copy
4*344a7f5eSAndroid Build Coastguard Worker * of this software and associated documentation files (the "Software"), to deal
5*344a7f5eSAndroid Build Coastguard Worker * in the Software without restriction, including without limitation the rights
6*344a7f5eSAndroid Build Coastguard Worker * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7*344a7f5eSAndroid Build Coastguard Worker * copies of the Software, and to permit persons to whom the Software is
8*344a7f5eSAndroid Build Coastguard Worker * furnished to do so, subject to the following conditions:
9*344a7f5eSAndroid Build Coastguard Worker *
10*344a7f5eSAndroid Build Coastguard Worker * The above copyright notice and this permission notice shall be included in
11*344a7f5eSAndroid Build Coastguard Worker * all copies or substantial portions of the Software.
12*344a7f5eSAndroid Build Coastguard Worker *
13*344a7f5eSAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14*344a7f5eSAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15*344a7f5eSAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16*344a7f5eSAndroid Build Coastguard Worker * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17*344a7f5eSAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18*344a7f5eSAndroid Build Coastguard Worker * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19*344a7f5eSAndroid Build Coastguard Worker * THE SOFTWARE.
20*344a7f5eSAndroid Build Coastguard Worker *
21*344a7f5eSAndroid Build Coastguard Worker *===-----------------------------------------------------------------------===
22*344a7f5eSAndroid Build Coastguard Worker */
23*344a7f5eSAndroid Build Coastguard Worker
24*344a7f5eSAndroid Build Coastguard Worker #ifndef __AMMINTRIN_H
25*344a7f5eSAndroid Build Coastguard Worker #define __AMMINTRIN_H
26*344a7f5eSAndroid Build Coastguard Worker
27*344a7f5eSAndroid Build Coastguard Worker #include <pmmintrin.h>
28*344a7f5eSAndroid Build Coastguard Worker
29*344a7f5eSAndroid Build Coastguard Worker /* Define the default attributes for the functions in this file. */
30*344a7f5eSAndroid Build Coastguard Worker #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4a")))
31*344a7f5eSAndroid Build Coastguard Worker
32*344a7f5eSAndroid Build Coastguard Worker /// \brief Extracts the specified bits from the lower 64 bits of the 128-bit
33*344a7f5eSAndroid Build Coastguard Worker /// integer vector operand at the index idx and of the length len.
34*344a7f5eSAndroid Build Coastguard Worker ///
35*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
36*344a7f5eSAndroid Build Coastguard Worker ///
37*344a7f5eSAndroid Build Coastguard Worker /// \code
38*344a7f5eSAndroid Build Coastguard Worker /// __m128i _mm_extracti_si64(__m128i x, const int len, const int idx);
39*344a7f5eSAndroid Build Coastguard Worker /// \endcode
40*344a7f5eSAndroid Build Coastguard Worker ///
41*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c EXTRQ instruction.
42*344a7f5eSAndroid Build Coastguard Worker ///
43*344a7f5eSAndroid Build Coastguard Worker /// \param x
44*344a7f5eSAndroid Build Coastguard Worker /// The value from which bits are extracted.
45*344a7f5eSAndroid Build Coastguard Worker /// \param len
46*344a7f5eSAndroid Build Coastguard Worker /// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]
47*344a7f5eSAndroid Build Coastguard Worker /// are zero, the length is interpreted as 64.
48*344a7f5eSAndroid Build Coastguard Worker /// \param idx
49*344a7f5eSAndroid Build Coastguard Worker /// Bits [5:0] specify the index of the least significant bit; the other
50*344a7f5eSAndroid Build Coastguard Worker /// bits are ignored. If the sum of the index and length is greater than 64,
51*344a7f5eSAndroid Build Coastguard Worker /// the result is undefined. If the length and index are both zero, bits
52*344a7f5eSAndroid Build Coastguard Worker /// [63:0] of parameter x are extracted. If the length is zero but the index
53*344a7f5eSAndroid Build Coastguard Worker /// is non-zero, the result is undefined.
54*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector whose lower 64 bits contain the bits
55*344a7f5eSAndroid Build Coastguard Worker /// extracted from the source operand.
56*344a7f5eSAndroid Build Coastguard Worker #define _mm_extracti_si64(x, len, idx) \
57*344a7f5eSAndroid Build Coastguard Worker ((__m128i)__builtin_ia32_extrqi((__v2di)(__m128i)(x), \
58*344a7f5eSAndroid Build Coastguard Worker (char)(len), (char)(idx)))
59*344a7f5eSAndroid Build Coastguard Worker
60*344a7f5eSAndroid Build Coastguard Worker /// \brief Extracts the specified bits from the lower 64 bits of the 128-bit
61*344a7f5eSAndroid Build Coastguard Worker /// integer vector operand at the index and of the length specified by __y.
62*344a7f5eSAndroid Build Coastguard Worker ///
63*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
64*344a7f5eSAndroid Build Coastguard Worker ///
65*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c EXTRQ instruction.
66*344a7f5eSAndroid Build Coastguard Worker ///
67*344a7f5eSAndroid Build Coastguard Worker /// \param __x
68*344a7f5eSAndroid Build Coastguard Worker /// The value from which bits are extracted.
69*344a7f5eSAndroid Build Coastguard Worker /// \param __y
70*344a7f5eSAndroid Build Coastguard Worker /// Specifies the index of the least significant bit at [13:8] and the
71*344a7f5eSAndroid Build Coastguard Worker /// length at [5:0]; all other bits are ignored. If bits [5:0] are zero, the
72*344a7f5eSAndroid Build Coastguard Worker /// length is interpreted as 64. If the sum of the index and length is
73*344a7f5eSAndroid Build Coastguard Worker /// greater than 64, the result is undefined. If the length and index are
74*344a7f5eSAndroid Build Coastguard Worker /// both zero, bits [63:0] of parameter __x are extracted. If the length is
75*344a7f5eSAndroid Build Coastguard Worker /// zero but the index is non-zero, the result is undefined.
76*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit vector whose lower 64 bits contain the bits extracted
77*344a7f5eSAndroid Build Coastguard Worker /// from the source operand.
78*344a7f5eSAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_extract_si64(__m128i __x,__m128i __y)79*344a7f5eSAndroid Build Coastguard Worker _mm_extract_si64(__m128i __x, __m128i __y)
80*344a7f5eSAndroid Build Coastguard Worker {
81*344a7f5eSAndroid Build Coastguard Worker return (__m128i)__builtin_ia32_extrq((__v2di)__x, (__v16qi)__y);
82*344a7f5eSAndroid Build Coastguard Worker }
83*344a7f5eSAndroid Build Coastguard Worker
84*344a7f5eSAndroid Build Coastguard Worker /// \brief Inserts bits of a specified length from the source integer vector y
85*344a7f5eSAndroid Build Coastguard Worker /// into the lower 64 bits of the destination integer vector x at the index
86*344a7f5eSAndroid Build Coastguard Worker /// idx and of the length len.
87*344a7f5eSAndroid Build Coastguard Worker ///
88*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
89*344a7f5eSAndroid Build Coastguard Worker ///
90*344a7f5eSAndroid Build Coastguard Worker /// \code
91*344a7f5eSAndroid Build Coastguard Worker /// __m128i _mm_inserti_si64(__m128i x, __m128i y, const int len,
92*344a7f5eSAndroid Build Coastguard Worker /// const int idx);
93*344a7f5eSAndroid Build Coastguard Worker /// \endcode
94*344a7f5eSAndroid Build Coastguard Worker ///
95*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c INSERTQ instruction.
96*344a7f5eSAndroid Build Coastguard Worker ///
97*344a7f5eSAndroid Build Coastguard Worker /// \param x
98*344a7f5eSAndroid Build Coastguard Worker /// The destination operand where bits will be inserted. The inserted bits
99*344a7f5eSAndroid Build Coastguard Worker /// are defined by the length len and by the index idx specifying the least
100*344a7f5eSAndroid Build Coastguard Worker /// significant bit.
101*344a7f5eSAndroid Build Coastguard Worker /// \param y
102*344a7f5eSAndroid Build Coastguard Worker /// The source operand containing the bits to be extracted. The extracted
103*344a7f5eSAndroid Build Coastguard Worker /// bits are the least significant bits of operand y of length len.
104*344a7f5eSAndroid Build Coastguard Worker /// \param len
105*344a7f5eSAndroid Build Coastguard Worker /// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]
106*344a7f5eSAndroid Build Coastguard Worker /// are zero, the length is interpreted as 64.
107*344a7f5eSAndroid Build Coastguard Worker /// \param idx
108*344a7f5eSAndroid Build Coastguard Worker /// Bits [5:0] specify the index of the least significant bit; the other
109*344a7f5eSAndroid Build Coastguard Worker /// bits are ignored. If the sum of the index and length is greater than 64,
110*344a7f5eSAndroid Build Coastguard Worker /// the result is undefined. If the length and index are both zero, bits
111*344a7f5eSAndroid Build Coastguard Worker /// [63:0] of parameter y are inserted into parameter x. If the length is
112*344a7f5eSAndroid Build Coastguard Worker /// zero but the index is non-zero, the result is undefined.
113*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the original lower 64-bits of
114*344a7f5eSAndroid Build Coastguard Worker /// destination operand x with the specified bitfields replaced by the lower
115*344a7f5eSAndroid Build Coastguard Worker /// bits of source operand y. The upper 64 bits of the return value are
116*344a7f5eSAndroid Build Coastguard Worker /// undefined.
117*344a7f5eSAndroid Build Coastguard Worker
118*344a7f5eSAndroid Build Coastguard Worker #define _mm_inserti_si64(x, y, len, idx) \
119*344a7f5eSAndroid Build Coastguard Worker ((__m128i)__builtin_ia32_insertqi((__v2di)(__m128i)(x), \
120*344a7f5eSAndroid Build Coastguard Worker (__v2di)(__m128i)(y), \
121*344a7f5eSAndroid Build Coastguard Worker (char)(len), (char)(idx)))
122*344a7f5eSAndroid Build Coastguard Worker
123*344a7f5eSAndroid Build Coastguard Worker /// \brief Inserts bits of a specified length from the source integer vector
124*344a7f5eSAndroid Build Coastguard Worker /// __y into the lower 64 bits of the destination integer vector __x at the
125*344a7f5eSAndroid Build Coastguard Worker /// index and of the length specified by __y.
126*344a7f5eSAndroid Build Coastguard Worker ///
127*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
128*344a7f5eSAndroid Build Coastguard Worker ///
129*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c INSERTQ instruction.
130*344a7f5eSAndroid Build Coastguard Worker ///
131*344a7f5eSAndroid Build Coastguard Worker /// \param __x
132*344a7f5eSAndroid Build Coastguard Worker /// The destination operand where bits will be inserted. The inserted bits
133*344a7f5eSAndroid Build Coastguard Worker /// are defined by the length and by the index of the least significant bit
134*344a7f5eSAndroid Build Coastguard Worker /// specified by operand __y.
135*344a7f5eSAndroid Build Coastguard Worker /// \param __y
136*344a7f5eSAndroid Build Coastguard Worker /// The source operand containing the bits to be extracted. The extracted
137*344a7f5eSAndroid Build Coastguard Worker /// bits are the least significant bits of operand __y with length specified
138*344a7f5eSAndroid Build Coastguard Worker /// by bits [69:64]. These are inserted into the destination at the index
139*344a7f5eSAndroid Build Coastguard Worker /// specified by bits [77:72]; all other bits are ignored. If bits [69:64]
140*344a7f5eSAndroid Build Coastguard Worker /// are zero, the length is interpreted as 64. If the sum of the index and
141*344a7f5eSAndroid Build Coastguard Worker /// length is greater than 64, the result is undefined. If the length and
142*344a7f5eSAndroid Build Coastguard Worker /// index are both zero, bits [63:0] of parameter __y are inserted into
143*344a7f5eSAndroid Build Coastguard Worker /// parameter __x. If the length is zero but the index is non-zero, the
144*344a7f5eSAndroid Build Coastguard Worker /// result is undefined.
145*344a7f5eSAndroid Build Coastguard Worker /// \returns A 128-bit integer vector containing the original lower 64-bits of
146*344a7f5eSAndroid Build Coastguard Worker /// destination operand __x with the specified bitfields replaced by the
147*344a7f5eSAndroid Build Coastguard Worker /// lower bits of source operand __y. The upper 64 bits of the return value
148*344a7f5eSAndroid Build Coastguard Worker /// are undefined.
149*344a7f5eSAndroid Build Coastguard Worker
150*344a7f5eSAndroid Build Coastguard Worker static __inline__ __m128i __DEFAULT_FN_ATTRS
_mm_insert_si64(__m128i __x,__m128i __y)151*344a7f5eSAndroid Build Coastguard Worker _mm_insert_si64(__m128i __x, __m128i __y)
152*344a7f5eSAndroid Build Coastguard Worker {
153*344a7f5eSAndroid Build Coastguard Worker return (__m128i)__builtin_ia32_insertq((__v2di)__x, (__v2di)__y);
154*344a7f5eSAndroid Build Coastguard Worker }
155*344a7f5eSAndroid Build Coastguard Worker
156*344a7f5eSAndroid Build Coastguard Worker /// \brief Stores a 64-bit double-precision value in a 64-bit memory location.
157*344a7f5eSAndroid Build Coastguard Worker /// To minimize caching, the data is flagged as non-temporal (unlikely to be
158*344a7f5eSAndroid Build Coastguard Worker /// used again soon).
159*344a7f5eSAndroid Build Coastguard Worker ///
160*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
161*344a7f5eSAndroid Build Coastguard Worker ///
162*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c MOVNTSD instruction.
163*344a7f5eSAndroid Build Coastguard Worker ///
164*344a7f5eSAndroid Build Coastguard Worker /// \param __p
165*344a7f5eSAndroid Build Coastguard Worker /// The 64-bit memory location used to store the register value.
166*344a7f5eSAndroid Build Coastguard Worker /// \param __a
167*344a7f5eSAndroid Build Coastguard Worker /// The 64-bit double-precision floating-point register value to be stored.
168*344a7f5eSAndroid Build Coastguard Worker static __inline__ void __DEFAULT_FN_ATTRS
_mm_stream_sd(double * __p,__m128d __a)169*344a7f5eSAndroid Build Coastguard Worker _mm_stream_sd(double *__p, __m128d __a)
170*344a7f5eSAndroid Build Coastguard Worker {
171*344a7f5eSAndroid Build Coastguard Worker __builtin_ia32_movntsd(__p, (__v2df)__a);
172*344a7f5eSAndroid Build Coastguard Worker }
173*344a7f5eSAndroid Build Coastguard Worker
174*344a7f5eSAndroid Build Coastguard Worker /// \brief Stores a 32-bit single-precision floating-point value in a 32-bit
175*344a7f5eSAndroid Build Coastguard Worker /// memory location. To minimize caching, the data is flagged as
176*344a7f5eSAndroid Build Coastguard Worker /// non-temporal (unlikely to be used again soon).
177*344a7f5eSAndroid Build Coastguard Worker ///
178*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
179*344a7f5eSAndroid Build Coastguard Worker ///
180*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c MOVNTSS instruction.
181*344a7f5eSAndroid Build Coastguard Worker ///
182*344a7f5eSAndroid Build Coastguard Worker /// \param __p
183*344a7f5eSAndroid Build Coastguard Worker /// The 32-bit memory location used to store the register value.
184*344a7f5eSAndroid Build Coastguard Worker /// \param __a
185*344a7f5eSAndroid Build Coastguard Worker /// The 32-bit single-precision floating-point register value to be stored.
186*344a7f5eSAndroid Build Coastguard Worker static __inline__ void __DEFAULT_FN_ATTRS
_mm_stream_ss(float * __p,__m128 __a)187*344a7f5eSAndroid Build Coastguard Worker _mm_stream_ss(float *__p, __m128 __a)
188*344a7f5eSAndroid Build Coastguard Worker {
189*344a7f5eSAndroid Build Coastguard Worker __builtin_ia32_movntss(__p, (__v4sf)__a);
190*344a7f5eSAndroid Build Coastguard Worker }
191*344a7f5eSAndroid Build Coastguard Worker
192*344a7f5eSAndroid Build Coastguard Worker #undef __DEFAULT_FN_ATTRS
193*344a7f5eSAndroid Build Coastguard Worker
194*344a7f5eSAndroid Build Coastguard Worker #endif /* __AMMINTRIN_H */
195