xref: /aosp_15_r20/prebuilts/sdk/renderscript/clang-include/bmiintrin.h (revision 344a7f5ef16c479e7a7f54ee6567a9d112f9e72b)
1*344a7f5eSAndroid Build Coastguard Worker /*===---- bmiintrin.h - BMI 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 #if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
25*344a7f5eSAndroid Build Coastguard Worker #error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
26*344a7f5eSAndroid Build Coastguard Worker #endif
27*344a7f5eSAndroid Build Coastguard Worker 
28*344a7f5eSAndroid Build Coastguard Worker #ifndef __BMIINTRIN_H
29*344a7f5eSAndroid Build Coastguard Worker #define __BMIINTRIN_H
30*344a7f5eSAndroid Build Coastguard Worker 
31*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
32*344a7f5eSAndroid Build Coastguard Worker ///
33*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
34*344a7f5eSAndroid Build Coastguard Worker ///
35*344a7f5eSAndroid Build Coastguard Worker /// \code
36*344a7f5eSAndroid Build Coastguard Worker /// unsigned short _tzcnt_u16(unsigned short a);
37*344a7f5eSAndroid Build Coastguard Worker /// \endcode
38*344a7f5eSAndroid Build Coastguard Worker ///
39*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
40*344a7f5eSAndroid Build Coastguard Worker ///
41*344a7f5eSAndroid Build Coastguard Worker /// \param a
42*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 16-bit integer whose trailing zeros are to be counted.
43*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 16-bit integer containing the number of trailing zero
44*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
45*344a7f5eSAndroid Build Coastguard Worker #define _tzcnt_u16(a)     (__tzcnt_u16((a)))
46*344a7f5eSAndroid Build Coastguard Worker 
47*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs a bitwise AND of the second operand with the one's
48*344a7f5eSAndroid Build Coastguard Worker ///    complement of the first operand.
49*344a7f5eSAndroid Build Coastguard Worker ///
50*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
51*344a7f5eSAndroid Build Coastguard Worker ///
52*344a7f5eSAndroid Build Coastguard Worker /// \code
53*344a7f5eSAndroid Build Coastguard Worker /// unsigned int _andn_u32(unsigned int a, unsigned int b);
54*344a7f5eSAndroid Build Coastguard Worker /// \endcode
55*344a7f5eSAndroid Build Coastguard Worker ///
56*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c ANDN instruction.
57*344a7f5eSAndroid Build Coastguard Worker ///
58*344a7f5eSAndroid Build Coastguard Worker /// \param a
59*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer containing one of the operands.
60*344a7f5eSAndroid Build Coastguard Worker /// \param b
61*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer containing one of the operands.
62*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the bitwise AND of the second
63*344a7f5eSAndroid Build Coastguard Worker ///    operand with the one's complement of the first operand.
64*344a7f5eSAndroid Build Coastguard Worker #define _andn_u32(a, b)   (__andn_u32((a), (b)))
65*344a7f5eSAndroid Build Coastguard Worker 
66*344a7f5eSAndroid Build Coastguard Worker /* _bextr_u32 != __bextr_u32 */
67*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears all bits in the source except for the least significant bit
68*344a7f5eSAndroid Build Coastguard Worker ///    containing a value of 1 and returns the result.
69*344a7f5eSAndroid Build Coastguard Worker ///
70*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
71*344a7f5eSAndroid Build Coastguard Worker ///
72*344a7f5eSAndroid Build Coastguard Worker /// \code
73*344a7f5eSAndroid Build Coastguard Worker /// unsigned int _blsi_u32(unsigned int a);
74*344a7f5eSAndroid Build Coastguard Worker /// \endcode
75*344a7f5eSAndroid Build Coastguard Worker ///
76*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSI instruction.
77*344a7f5eSAndroid Build Coastguard Worker ///
78*344a7f5eSAndroid Build Coastguard Worker /// \param a
79*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer whose bits are to be cleared.
80*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the result of clearing the bits from
81*344a7f5eSAndroid Build Coastguard Worker ///    the source operand.
82*344a7f5eSAndroid Build Coastguard Worker #define _blsi_u32(a)      (__blsi_u32((a)))
83*344a7f5eSAndroid Build Coastguard Worker 
84*344a7f5eSAndroid Build Coastguard Worker /// \brief Creates a mask whose bits are set to 1, using bit 0 up to and
85*344a7f5eSAndroid Build Coastguard Worker ///    including the least siginificant bit that is set to 1 in the source
86*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
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 /// unsigned int _blsmsk_u32(unsigned int a);
92*344a7f5eSAndroid Build Coastguard Worker /// \endcode
93*344a7f5eSAndroid Build Coastguard Worker ///
94*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSMSK instruction.
95*344a7f5eSAndroid Build Coastguard Worker ///
96*344a7f5eSAndroid Build Coastguard Worker /// \param a
97*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer used to create the mask.
98*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the newly created mask.
99*344a7f5eSAndroid Build Coastguard Worker #define _blsmsk_u32(a)    (__blsmsk_u32((a)))
100*344a7f5eSAndroid Build Coastguard Worker 
101*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears the least siginificant bit that is set to 1 in the source
102*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
103*344a7f5eSAndroid Build Coastguard Worker ///
104*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
105*344a7f5eSAndroid Build Coastguard Worker ///
106*344a7f5eSAndroid Build Coastguard Worker /// \code
107*344a7f5eSAndroid Build Coastguard Worker /// unsigned int _blsr_u32(unsigned int a);
108*344a7f5eSAndroid Build Coastguard Worker /// \endcode
109*344a7f5eSAndroid Build Coastguard Worker ///
110*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSR instruction.
111*344a7f5eSAndroid Build Coastguard Worker ///
112*344a7f5eSAndroid Build Coastguard Worker /// \param a
113*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer containing the operand to be cleared.
114*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the result of clearing the source
115*344a7f5eSAndroid Build Coastguard Worker ///    operand.
116*344a7f5eSAndroid Build Coastguard Worker #define _blsr_u32(a)      (__blsr_u32((a)))
117*344a7f5eSAndroid Build Coastguard Worker 
118*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
119*344a7f5eSAndroid Build Coastguard Worker ///
120*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
121*344a7f5eSAndroid Build Coastguard Worker ///
122*344a7f5eSAndroid Build Coastguard Worker /// \code
123*344a7f5eSAndroid Build Coastguard Worker /// unsigned int _tzcnt_u32(unsigned int a);
124*344a7f5eSAndroid Build Coastguard Worker /// \endcode
125*344a7f5eSAndroid Build Coastguard Worker ///
126*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
127*344a7f5eSAndroid Build Coastguard Worker ///
128*344a7f5eSAndroid Build Coastguard Worker /// \param a
129*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 32-bit integer whose trailing zeros are to be counted.
130*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 32-bit integer containing the number of trailing zero
131*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
132*344a7f5eSAndroid Build Coastguard Worker #define _tzcnt_u32(a)     (__tzcnt_u32((a)))
133*344a7f5eSAndroid Build Coastguard Worker 
134*344a7f5eSAndroid Build Coastguard Worker /* Define the default attributes for the functions in this file. */
135*344a7f5eSAndroid Build Coastguard Worker #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
136*344a7f5eSAndroid Build Coastguard Worker 
137*344a7f5eSAndroid Build Coastguard Worker /* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
138*344a7f5eSAndroid Build Coastguard Worker    instruction behaves as BSF on non-BMI targets, there is code that expects
139*344a7f5eSAndroid Build Coastguard Worker    to use it as a potentially faster version of BSF. */
140*344a7f5eSAndroid Build Coastguard Worker #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
141*344a7f5eSAndroid Build Coastguard Worker 
142*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
143*344a7f5eSAndroid Build Coastguard Worker ///
144*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
145*344a7f5eSAndroid Build Coastguard Worker ///
146*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
147*344a7f5eSAndroid Build Coastguard Worker ///
148*344a7f5eSAndroid Build Coastguard Worker /// \param __X
149*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 16-bit integer whose trailing zeros are to be counted.
150*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 16-bit integer containing the number of trailing zero
151*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
152*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned short __RELAXED_FN_ATTRS
__tzcnt_u16(unsigned short __X)153*344a7f5eSAndroid Build Coastguard Worker __tzcnt_u16(unsigned short __X)
154*344a7f5eSAndroid Build Coastguard Worker {
155*344a7f5eSAndroid Build Coastguard Worker   return __X ? __builtin_ctzs(__X) : 16;
156*344a7f5eSAndroid Build Coastguard Worker }
157*344a7f5eSAndroid Build Coastguard Worker 
158*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs a bitwise AND of the second operand with the one's
159*344a7f5eSAndroid Build Coastguard Worker ///    complement of the first operand.
160*344a7f5eSAndroid Build Coastguard Worker ///
161*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
162*344a7f5eSAndroid Build Coastguard Worker ///
163*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c ANDN instruction.
164*344a7f5eSAndroid Build Coastguard Worker ///
165*344a7f5eSAndroid Build Coastguard Worker /// \param __X
166*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer containing one of the operands.
167*344a7f5eSAndroid Build Coastguard Worker /// \param __Y
168*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer containing one of the operands.
169*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the bitwise AND of the second
170*344a7f5eSAndroid Build Coastguard Worker ///    operand with the one's complement of the first operand.
171*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned int __DEFAULT_FN_ATTRS
__andn_u32(unsigned int __X,unsigned int __Y)172*344a7f5eSAndroid Build Coastguard Worker __andn_u32(unsigned int __X, unsigned int __Y)
173*344a7f5eSAndroid Build Coastguard Worker {
174*344a7f5eSAndroid Build Coastguard Worker   return ~__X & __Y;
175*344a7f5eSAndroid Build Coastguard Worker }
176*344a7f5eSAndroid Build Coastguard Worker 
177*344a7f5eSAndroid Build Coastguard Worker /* AMD-specified, double-leading-underscore version of BEXTR */
178*344a7f5eSAndroid Build Coastguard Worker /// \brief Extracts the specified bits from the first operand and returns them
179*344a7f5eSAndroid Build Coastguard Worker ///    in the least significant bits of the result.
180*344a7f5eSAndroid Build Coastguard Worker ///
181*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
182*344a7f5eSAndroid Build Coastguard Worker ///
183*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BEXTR instruction.
184*344a7f5eSAndroid Build Coastguard Worker ///
185*344a7f5eSAndroid Build Coastguard Worker /// \param __X
186*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer whose bits are to be extracted.
187*344a7f5eSAndroid Build Coastguard Worker /// \param __Y
188*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer used to specify which bits are extracted. Bits [7:0]
189*344a7f5eSAndroid Build Coastguard Worker ///    specify the index of the least significant bit. Bits [15:8] specify the
190*344a7f5eSAndroid Build Coastguard Worker ///    number of bits to be extracted.
191*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer whose least significant bits contain the
192*344a7f5eSAndroid Build Coastguard Worker ///    extracted bits.
193*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned int __DEFAULT_FN_ATTRS
__bextr_u32(unsigned int __X,unsigned int __Y)194*344a7f5eSAndroid Build Coastguard Worker __bextr_u32(unsigned int __X, unsigned int __Y)
195*344a7f5eSAndroid Build Coastguard Worker {
196*344a7f5eSAndroid Build Coastguard Worker   return __builtin_ia32_bextr_u32(__X, __Y);
197*344a7f5eSAndroid Build Coastguard Worker }
198*344a7f5eSAndroid Build Coastguard Worker 
199*344a7f5eSAndroid Build Coastguard Worker /* Intel-specified, single-leading-underscore version of BEXTR */
200*344a7f5eSAndroid Build Coastguard Worker /// \brief Extracts the specified bits from the first operand and returns them
201*344a7f5eSAndroid Build Coastguard Worker ///    in the least significant bits of the result.
202*344a7f5eSAndroid Build Coastguard Worker ///
203*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
204*344a7f5eSAndroid Build Coastguard Worker ///
205*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BEXTR instruction.
206*344a7f5eSAndroid Build Coastguard Worker ///
207*344a7f5eSAndroid Build Coastguard Worker /// \param __X
208*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer whose bits are to be extracted.
209*344a7f5eSAndroid Build Coastguard Worker /// \param __Y
210*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer used to specify the index of the least significant
211*344a7f5eSAndroid Build Coastguard Worker ///    bit for the bits to be extracted. Bits [7:0] specify the index.
212*344a7f5eSAndroid Build Coastguard Worker /// \param __Z
213*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer used to specify the number of bits to be extracted.
214*344a7f5eSAndroid Build Coastguard Worker ///    Bits [7:0] specify the number of bits.
215*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer whose least significant bits contain the
216*344a7f5eSAndroid Build Coastguard Worker ///    extracted bits.
217*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned int __DEFAULT_FN_ATTRS
_bextr_u32(unsigned int __X,unsigned int __Y,unsigned int __Z)218*344a7f5eSAndroid Build Coastguard Worker _bextr_u32(unsigned int __X, unsigned int __Y, unsigned int __Z)
219*344a7f5eSAndroid Build Coastguard Worker {
220*344a7f5eSAndroid Build Coastguard Worker   return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
221*344a7f5eSAndroid Build Coastguard Worker }
222*344a7f5eSAndroid Build Coastguard Worker 
223*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears all bits in the source except for the least significant bit
224*344a7f5eSAndroid Build Coastguard Worker ///    containing a value of 1 and returns the result.
225*344a7f5eSAndroid Build Coastguard Worker ///
226*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
227*344a7f5eSAndroid Build Coastguard Worker ///
228*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSI instruction.
229*344a7f5eSAndroid Build Coastguard Worker ///
230*344a7f5eSAndroid Build Coastguard Worker /// \param __X
231*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer whose bits are to be cleared.
232*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the result of clearing the bits from
233*344a7f5eSAndroid Build Coastguard Worker ///    the source operand.
234*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned int __DEFAULT_FN_ATTRS
__blsi_u32(unsigned int __X)235*344a7f5eSAndroid Build Coastguard Worker __blsi_u32(unsigned int __X)
236*344a7f5eSAndroid Build Coastguard Worker {
237*344a7f5eSAndroid Build Coastguard Worker   return __X & -__X;
238*344a7f5eSAndroid Build Coastguard Worker }
239*344a7f5eSAndroid Build Coastguard Worker 
240*344a7f5eSAndroid Build Coastguard Worker /// \brief Creates a mask whose bits are set to 1, using bit 0 up to and
241*344a7f5eSAndroid Build Coastguard Worker ///    including the least siginificant bit that is set to 1 in the source
242*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
243*344a7f5eSAndroid Build Coastguard Worker ///
244*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
245*344a7f5eSAndroid Build Coastguard Worker ///
246*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSMSK instruction.
247*344a7f5eSAndroid Build Coastguard Worker ///
248*344a7f5eSAndroid Build Coastguard Worker /// \param __X
249*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer used to create the mask.
250*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the newly created mask.
251*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned int __DEFAULT_FN_ATTRS
__blsmsk_u32(unsigned int __X)252*344a7f5eSAndroid Build Coastguard Worker __blsmsk_u32(unsigned int __X)
253*344a7f5eSAndroid Build Coastguard Worker {
254*344a7f5eSAndroid Build Coastguard Worker   return __X ^ (__X - 1);
255*344a7f5eSAndroid Build Coastguard Worker }
256*344a7f5eSAndroid Build Coastguard Worker 
257*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears the least siginificant bit that is set to 1 in the source
258*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
259*344a7f5eSAndroid Build Coastguard Worker ///
260*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
261*344a7f5eSAndroid Build Coastguard Worker ///
262*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSR instruction.
263*344a7f5eSAndroid Build Coastguard Worker ///
264*344a7f5eSAndroid Build Coastguard Worker /// \param __X
265*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer containing the operand to be cleared.
266*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned integer containing the result of clearing the source
267*344a7f5eSAndroid Build Coastguard Worker ///    operand.
268*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned int __DEFAULT_FN_ATTRS
__blsr_u32(unsigned int __X)269*344a7f5eSAndroid Build Coastguard Worker __blsr_u32(unsigned int __X)
270*344a7f5eSAndroid Build Coastguard Worker {
271*344a7f5eSAndroid Build Coastguard Worker   return __X & (__X - 1);
272*344a7f5eSAndroid Build Coastguard Worker }
273*344a7f5eSAndroid Build Coastguard Worker 
274*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
275*344a7f5eSAndroid Build Coastguard Worker ///
276*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
277*344a7f5eSAndroid Build Coastguard Worker ///
278*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
279*344a7f5eSAndroid Build Coastguard Worker ///
280*344a7f5eSAndroid Build Coastguard Worker /// \param __X
281*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 32-bit integer whose trailing zeros are to be counted.
282*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 32-bit integer containing the number of trailing zero
283*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
284*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned int __RELAXED_FN_ATTRS
__tzcnt_u32(unsigned int __X)285*344a7f5eSAndroid Build Coastguard Worker __tzcnt_u32(unsigned int __X)
286*344a7f5eSAndroid Build Coastguard Worker {
287*344a7f5eSAndroid Build Coastguard Worker   return __X ? __builtin_ctz(__X) : 32;
288*344a7f5eSAndroid Build Coastguard Worker }
289*344a7f5eSAndroid Build Coastguard Worker 
290*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
291*344a7f5eSAndroid Build Coastguard Worker ///
292*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
293*344a7f5eSAndroid Build Coastguard Worker ///
294*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
295*344a7f5eSAndroid Build Coastguard Worker ///
296*344a7f5eSAndroid Build Coastguard Worker /// \param __X
297*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 32-bit integer whose trailing zeros are to be counted.
298*344a7f5eSAndroid Build Coastguard Worker /// \returns An 32-bit integer containing the number of trailing zero
299*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
300*344a7f5eSAndroid Build Coastguard Worker static __inline__ int __RELAXED_FN_ATTRS
_mm_tzcnt_32(unsigned int __X)301*344a7f5eSAndroid Build Coastguard Worker _mm_tzcnt_32(unsigned int __X)
302*344a7f5eSAndroid Build Coastguard Worker {
303*344a7f5eSAndroid Build Coastguard Worker   return __X ? __builtin_ctz(__X) : 32;
304*344a7f5eSAndroid Build Coastguard Worker }
305*344a7f5eSAndroid Build Coastguard Worker 
306*344a7f5eSAndroid Build Coastguard Worker #ifdef __x86_64__
307*344a7f5eSAndroid Build Coastguard Worker 
308*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs a bitwise AND of the second operand with the one's
309*344a7f5eSAndroid Build Coastguard Worker ///    complement of the first operand.
310*344a7f5eSAndroid Build Coastguard Worker ///
311*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
312*344a7f5eSAndroid Build Coastguard Worker ///
313*344a7f5eSAndroid Build Coastguard Worker /// \code
314*344a7f5eSAndroid Build Coastguard Worker /// unsigned long long _andn_u64 (unsigned long long a, unsigned long long b);
315*344a7f5eSAndroid Build Coastguard Worker /// \endcode
316*344a7f5eSAndroid Build Coastguard Worker ///
317*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c ANDN instruction.
318*344a7f5eSAndroid Build Coastguard Worker ///
319*344a7f5eSAndroid Build Coastguard Worker /// \param a
320*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer containing one of the operands.
321*344a7f5eSAndroid Build Coastguard Worker /// \param b
322*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer containing one of the operands.
323*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the bitwise AND of the second
324*344a7f5eSAndroid Build Coastguard Worker ///    operand with the one's complement of the first operand.
325*344a7f5eSAndroid Build Coastguard Worker #define _andn_u64(a, b)   (__andn_u64((a), (b)))
326*344a7f5eSAndroid Build Coastguard Worker 
327*344a7f5eSAndroid Build Coastguard Worker /* _bextr_u64 != __bextr_u64 */
328*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears all bits in the source except for the least significant bit
329*344a7f5eSAndroid Build Coastguard Worker ///    containing a value of 1 and returns the result.
330*344a7f5eSAndroid Build Coastguard Worker ///
331*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
332*344a7f5eSAndroid Build Coastguard Worker ///
333*344a7f5eSAndroid Build Coastguard Worker /// \code
334*344a7f5eSAndroid Build Coastguard Worker /// unsigned long long _blsi_u64(unsigned long long a);
335*344a7f5eSAndroid Build Coastguard Worker /// \endcode
336*344a7f5eSAndroid Build Coastguard Worker ///
337*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSI instruction.
338*344a7f5eSAndroid Build Coastguard Worker ///
339*344a7f5eSAndroid Build Coastguard Worker /// \param a
340*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer whose bits are to be cleared.
341*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the result of clearing the
342*344a7f5eSAndroid Build Coastguard Worker ///    bits from the source operand.
343*344a7f5eSAndroid Build Coastguard Worker #define _blsi_u64(a)      (__blsi_u64((a)))
344*344a7f5eSAndroid Build Coastguard Worker 
345*344a7f5eSAndroid Build Coastguard Worker /// \brief Creates a mask whose bits are set to 1, using bit 0 up to and
346*344a7f5eSAndroid Build Coastguard Worker ///    including the least siginificant bit that is set to 1 in the source
347*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
348*344a7f5eSAndroid Build Coastguard Worker ///
349*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
350*344a7f5eSAndroid Build Coastguard Worker ///
351*344a7f5eSAndroid Build Coastguard Worker /// \code
352*344a7f5eSAndroid Build Coastguard Worker /// unsigned long long _blsmsk_u64(unsigned long long a);
353*344a7f5eSAndroid Build Coastguard Worker /// \endcode
354*344a7f5eSAndroid Build Coastguard Worker ///
355*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSMSK instruction.
356*344a7f5eSAndroid Build Coastguard Worker ///
357*344a7f5eSAndroid Build Coastguard Worker /// \param a
358*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer used to create the mask.
359*344a7f5eSAndroid Build Coastguard Worker /// \returns A unsigned 64-bit integer containing the newly created mask.
360*344a7f5eSAndroid Build Coastguard Worker #define _blsmsk_u64(a)    (__blsmsk_u64((a)))
361*344a7f5eSAndroid Build Coastguard Worker 
362*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears the least siginificant bit that is set to 1 in the source
363*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
364*344a7f5eSAndroid Build Coastguard Worker ///
365*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
366*344a7f5eSAndroid Build Coastguard Worker ///
367*344a7f5eSAndroid Build Coastguard Worker /// \code
368*344a7f5eSAndroid Build Coastguard Worker /// unsigned long long _blsr_u64(unsigned long long a);
369*344a7f5eSAndroid Build Coastguard Worker /// \endcode
370*344a7f5eSAndroid Build Coastguard Worker ///
371*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSR instruction.
372*344a7f5eSAndroid Build Coastguard Worker ///
373*344a7f5eSAndroid Build Coastguard Worker /// \param a
374*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer containing the operand to be cleared.
375*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the result of clearing the
376*344a7f5eSAndroid Build Coastguard Worker ///    source operand.
377*344a7f5eSAndroid Build Coastguard Worker #define _blsr_u64(a)      (__blsr_u64((a)))
378*344a7f5eSAndroid Build Coastguard Worker 
379*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
380*344a7f5eSAndroid Build Coastguard Worker ///
381*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
382*344a7f5eSAndroid Build Coastguard Worker ///
383*344a7f5eSAndroid Build Coastguard Worker /// \code
384*344a7f5eSAndroid Build Coastguard Worker /// unsigned long long _tzcnt_u64(unsigned long long a);
385*344a7f5eSAndroid Build Coastguard Worker /// \endcode
386*344a7f5eSAndroid Build Coastguard Worker ///
387*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
388*344a7f5eSAndroid Build Coastguard Worker ///
389*344a7f5eSAndroid Build Coastguard Worker /// \param a
390*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer whose trailing zeros are to be counted.
391*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the number of trailing zero
392*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
393*344a7f5eSAndroid Build Coastguard Worker #define _tzcnt_u64(a)     (__tzcnt_u64((a)))
394*344a7f5eSAndroid Build Coastguard Worker 
395*344a7f5eSAndroid Build Coastguard Worker /// \brief Performs a bitwise AND of the second operand with the one's
396*344a7f5eSAndroid Build Coastguard Worker ///    complement of the first operand.
397*344a7f5eSAndroid Build Coastguard Worker ///
398*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
399*344a7f5eSAndroid Build Coastguard Worker ///
400*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c ANDN instruction.
401*344a7f5eSAndroid Build Coastguard Worker ///
402*344a7f5eSAndroid Build Coastguard Worker /// \param __X
403*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer containing one of the operands.
404*344a7f5eSAndroid Build Coastguard Worker /// \param __Y
405*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer containing one of the operands.
406*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the bitwise AND of the second
407*344a7f5eSAndroid Build Coastguard Worker ///    operand with the one's complement of the first operand.
408*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned long long __DEFAULT_FN_ATTRS
__andn_u64(unsigned long long __X,unsigned long long __Y)409*344a7f5eSAndroid Build Coastguard Worker __andn_u64 (unsigned long long __X, unsigned long long __Y)
410*344a7f5eSAndroid Build Coastguard Worker {
411*344a7f5eSAndroid Build Coastguard Worker   return ~__X & __Y;
412*344a7f5eSAndroid Build Coastguard Worker }
413*344a7f5eSAndroid Build Coastguard Worker 
414*344a7f5eSAndroid Build Coastguard Worker /* AMD-specified, double-leading-underscore version of BEXTR */
415*344a7f5eSAndroid Build Coastguard Worker /// \brief Extracts the specified bits from the first operand and returns them
416*344a7f5eSAndroid Build Coastguard Worker ///    in the least significant bits of the result.
417*344a7f5eSAndroid Build Coastguard Worker ///
418*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
419*344a7f5eSAndroid Build Coastguard Worker ///
420*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BEXTR instruction.
421*344a7f5eSAndroid Build Coastguard Worker ///
422*344a7f5eSAndroid Build Coastguard Worker /// \param __X
423*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer whose bits are to be extracted.
424*344a7f5eSAndroid Build Coastguard Worker /// \param __Y
425*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer used to specify which bits are extracted. Bits
426*344a7f5eSAndroid Build Coastguard Worker ///    [7:0] specify the index of the least significant bit. Bits [15:8] specify
427*344a7f5eSAndroid Build Coastguard Worker ///    the number of bits to be extracted.
428*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer whose least significant bits contain the
429*344a7f5eSAndroid Build Coastguard Worker ///    extracted bits.
430*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned long long __DEFAULT_FN_ATTRS
__bextr_u64(unsigned long long __X,unsigned long long __Y)431*344a7f5eSAndroid Build Coastguard Worker __bextr_u64(unsigned long long __X, unsigned long long __Y)
432*344a7f5eSAndroid Build Coastguard Worker {
433*344a7f5eSAndroid Build Coastguard Worker   return __builtin_ia32_bextr_u64(__X, __Y);
434*344a7f5eSAndroid Build Coastguard Worker }
435*344a7f5eSAndroid Build Coastguard Worker 
436*344a7f5eSAndroid Build Coastguard Worker /* Intel-specified, single-leading-underscore version of BEXTR */
437*344a7f5eSAndroid Build Coastguard Worker /// \brief Extracts the specified bits from the first operand and returns them
438*344a7f5eSAndroid Build Coastguard Worker ///     in the least significant bits of the result.
439*344a7f5eSAndroid Build Coastguard Worker ///
440*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
441*344a7f5eSAndroid Build Coastguard Worker ///
442*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BEXTR instruction.
443*344a7f5eSAndroid Build Coastguard Worker ///
444*344a7f5eSAndroid Build Coastguard Worker /// \param __X
445*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer whose bits are to be extracted.
446*344a7f5eSAndroid Build Coastguard Worker /// \param __Y
447*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer used to specify the index of the least significant
448*344a7f5eSAndroid Build Coastguard Worker ///    bit for the bits to be extracted. Bits [7:0] specify the index.
449*344a7f5eSAndroid Build Coastguard Worker /// \param __Z
450*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned integer used to specify the number of bits to be extracted.
451*344a7f5eSAndroid Build Coastguard Worker ///    Bits [7:0] specify the number of bits.
452*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer whose least significant bits contain the
453*344a7f5eSAndroid Build Coastguard Worker ///    extracted bits.
454*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned long long __DEFAULT_FN_ATTRS
_bextr_u64(unsigned long long __X,unsigned int __Y,unsigned int __Z)455*344a7f5eSAndroid Build Coastguard Worker _bextr_u64(unsigned long long __X, unsigned int __Y, unsigned int __Z)
456*344a7f5eSAndroid Build Coastguard Worker {
457*344a7f5eSAndroid Build Coastguard Worker   return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
458*344a7f5eSAndroid Build Coastguard Worker }
459*344a7f5eSAndroid Build Coastguard Worker 
460*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears all bits in the source except for the least significant bit
461*344a7f5eSAndroid Build Coastguard Worker ///    containing a value of 1 and returns the result.
462*344a7f5eSAndroid Build Coastguard Worker ///
463*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
464*344a7f5eSAndroid Build Coastguard Worker ///
465*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSI instruction.
466*344a7f5eSAndroid Build Coastguard Worker ///
467*344a7f5eSAndroid Build Coastguard Worker /// \param __X
468*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer whose bits are to be cleared.
469*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the result of clearing the
470*344a7f5eSAndroid Build Coastguard Worker ///    bits from the source operand.
471*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned long long __DEFAULT_FN_ATTRS
__blsi_u64(unsigned long long __X)472*344a7f5eSAndroid Build Coastguard Worker __blsi_u64(unsigned long long __X)
473*344a7f5eSAndroid Build Coastguard Worker {
474*344a7f5eSAndroid Build Coastguard Worker   return __X & -__X;
475*344a7f5eSAndroid Build Coastguard Worker }
476*344a7f5eSAndroid Build Coastguard Worker 
477*344a7f5eSAndroid Build Coastguard Worker /// \brief Creates a mask whose bits are set to 1, using bit 0 up to and
478*344a7f5eSAndroid Build Coastguard Worker ///    including the least siginificant bit that is set to 1 in the source
479*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
480*344a7f5eSAndroid Build Coastguard Worker ///
481*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
482*344a7f5eSAndroid Build Coastguard Worker ///
483*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSMSK instruction.
484*344a7f5eSAndroid Build Coastguard Worker ///
485*344a7f5eSAndroid Build Coastguard Worker /// \param __X
486*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer used to create the mask.
487*344a7f5eSAndroid Build Coastguard Worker /// \returns A unsigned 64-bit integer containing the newly created mask.
488*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned long long __DEFAULT_FN_ATTRS
__blsmsk_u64(unsigned long long __X)489*344a7f5eSAndroid Build Coastguard Worker __blsmsk_u64(unsigned long long __X)
490*344a7f5eSAndroid Build Coastguard Worker {
491*344a7f5eSAndroid Build Coastguard Worker   return __X ^ (__X - 1);
492*344a7f5eSAndroid Build Coastguard Worker }
493*344a7f5eSAndroid Build Coastguard Worker 
494*344a7f5eSAndroid Build Coastguard Worker /// \brief Clears the least siginificant bit that is set to 1 in the source
495*344a7f5eSAndroid Build Coastguard Worker ///    operand and returns the result.
496*344a7f5eSAndroid Build Coastguard Worker ///
497*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
498*344a7f5eSAndroid Build Coastguard Worker ///
499*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c BLSR instruction.
500*344a7f5eSAndroid Build Coastguard Worker ///
501*344a7f5eSAndroid Build Coastguard Worker /// \param __X
502*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer containing the operand to be cleared.
503*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the result of clearing the
504*344a7f5eSAndroid Build Coastguard Worker ///    source operand.
505*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned long long __DEFAULT_FN_ATTRS
__blsr_u64(unsigned long long __X)506*344a7f5eSAndroid Build Coastguard Worker __blsr_u64(unsigned long long __X)
507*344a7f5eSAndroid Build Coastguard Worker {
508*344a7f5eSAndroid Build Coastguard Worker   return __X & (__X - 1);
509*344a7f5eSAndroid Build Coastguard Worker }
510*344a7f5eSAndroid Build Coastguard Worker 
511*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
512*344a7f5eSAndroid Build Coastguard Worker ///
513*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
514*344a7f5eSAndroid Build Coastguard Worker ///
515*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
516*344a7f5eSAndroid Build Coastguard Worker ///
517*344a7f5eSAndroid Build Coastguard Worker /// \param __X
518*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer whose trailing zeros are to be counted.
519*344a7f5eSAndroid Build Coastguard Worker /// \returns An unsigned 64-bit integer containing the number of trailing zero
520*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
521*344a7f5eSAndroid Build Coastguard Worker static __inline__ unsigned long long __RELAXED_FN_ATTRS
__tzcnt_u64(unsigned long long __X)522*344a7f5eSAndroid Build Coastguard Worker __tzcnt_u64(unsigned long long __X)
523*344a7f5eSAndroid Build Coastguard Worker {
524*344a7f5eSAndroid Build Coastguard Worker   return __X ? __builtin_ctzll(__X) : 64;
525*344a7f5eSAndroid Build Coastguard Worker }
526*344a7f5eSAndroid Build Coastguard Worker 
527*344a7f5eSAndroid Build Coastguard Worker /// \brief Counts the number of trailing zero bits in the operand.
528*344a7f5eSAndroid Build Coastguard Worker ///
529*344a7f5eSAndroid Build Coastguard Worker /// \headerfile <x86intrin.h>
530*344a7f5eSAndroid Build Coastguard Worker ///
531*344a7f5eSAndroid Build Coastguard Worker /// This intrinsic corresponds to the \c TZCNT instruction.
532*344a7f5eSAndroid Build Coastguard Worker ///
533*344a7f5eSAndroid Build Coastguard Worker /// \param __X
534*344a7f5eSAndroid Build Coastguard Worker ///    An unsigned 64-bit integer whose trailing zeros are to be counted.
535*344a7f5eSAndroid Build Coastguard Worker /// \returns An 64-bit integer containing the number of trailing zero
536*344a7f5eSAndroid Build Coastguard Worker ///    bits in the operand.
537*344a7f5eSAndroid Build Coastguard Worker static __inline__ long long __RELAXED_FN_ATTRS
_mm_tzcnt_64(unsigned long long __X)538*344a7f5eSAndroid Build Coastguard Worker _mm_tzcnt_64(unsigned long long __X)
539*344a7f5eSAndroid Build Coastguard Worker {
540*344a7f5eSAndroid Build Coastguard Worker   return __X ? __builtin_ctzll(__X) : 64;
541*344a7f5eSAndroid Build Coastguard Worker }
542*344a7f5eSAndroid Build Coastguard Worker 
543*344a7f5eSAndroid Build Coastguard Worker #endif /* __x86_64__ */
544*344a7f5eSAndroid Build Coastguard Worker 
545*344a7f5eSAndroid Build Coastguard Worker #undef __DEFAULT_FN_ATTRS
546*344a7f5eSAndroid Build Coastguard Worker #undef __RELAXED_FN_ATTRS
547*344a7f5eSAndroid Build Coastguard Worker 
548*344a7f5eSAndroid Build Coastguard Worker #endif /* __BMIINTRIN_H */
549