ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
bmiintrin.h
Go to the documentation of this file.
1 /*===---- bmiintrin.h - BMI intrinsics -------------------------------------===
2  *
3  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4  * See https://llvm.org/LICENSE.txt for license information.
5  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6  *
7  *===-----------------------------------------------------------------------===
8  */
9 
10 #if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
11 #error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
12 #endif
13 
14 #ifndef __BMIINTRIN_H
15 #define __BMIINTRIN_H
16 
17 /* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
18  instruction behaves as BSF on non-BMI targets, there is code that expects
19  to use it as a potentially faster version of BSF. */
20 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
21 
22 #define _tzcnt_u16(a) (__tzcnt_u16((a)))
23 
34 static __inline__ unsigned short __RELAXED_FN_ATTRS
35 __tzcnt_u16(unsigned short __X)
36 {
37  return __builtin_ia32_tzcnt_u16(__X);
38 }
39 
50 static __inline__ unsigned int __RELAXED_FN_ATTRS
51 __tzcnt_u32(unsigned int __X)
52 {
53  return __builtin_ia32_tzcnt_u32(__X);
54 }
55 
66 static __inline__ int __RELAXED_FN_ATTRS
67 _mm_tzcnt_32(unsigned int __X)
68 {
69  return __builtin_ia32_tzcnt_u32(__X);
70 }
71 
72 #define _tzcnt_u32(a) (__tzcnt_u32((a)))
73 
74 #ifdef __x86_64__
75 
86 static __inline__ unsigned long long __RELAXED_FN_ATTRS
87 __tzcnt_u64(unsigned long long __X)
88 {
89  return __builtin_ia32_tzcnt_u64(__X);
90 }
91 
102 static __inline__ long long __RELAXED_FN_ATTRS
103 _mm_tzcnt_64(unsigned long long __X)
104 {
105  return __builtin_ia32_tzcnt_u64(__X);
106 }
107 
108 #define _tzcnt_u64(a) (__tzcnt_u64((a)))
109 
110 #endif /* __x86_64__ */
111 
112 #undef __RELAXED_FN_ATTRS
113 
114 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
115  defined(__BMI__)
116 
117 /* Define the default attributes for the functions in this file. */
118 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
119 
120 #define _andn_u32(a, b) (__andn_u32((a), (b)))
121 
122 /* _bextr_u32 != __bextr_u32 */
123 #define _blsi_u32(a) (__blsi_u32((a)))
124 
125 #define _blsmsk_u32(a) (__blsmsk_u32((a)))
126 
127 #define _blsr_u32(a) (__blsr_u32((a)))
128 
142 static __inline__ unsigned int __DEFAULT_FN_ATTRS
143 __andn_u32(unsigned int __X, unsigned int __Y)
144 {
145  return ~__X & __Y;
146 }
147 
148 /* AMD-specified, double-leading-underscore version of BEXTR */
165 static __inline__ unsigned int __DEFAULT_FN_ATTRS
166 __bextr_u32(unsigned int __X, unsigned int __Y)
167 {
168  return __builtin_ia32_bextr_u32(__X, __Y);
169 }
170 
171 /* Intel-specified, single-leading-underscore version of BEXTR */
190 static __inline__ unsigned int __DEFAULT_FN_ATTRS
191 _bextr_u32(unsigned int __X, unsigned int __Y, unsigned int __Z)
192 {
193  return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
194 }
195 
196 /* Intel-specified, single-leading-underscore version of BEXTR2 */
213 static __inline__ unsigned int __DEFAULT_FN_ATTRS
214 _bextr2_u32(unsigned int __X, unsigned int __Y) {
215  return __builtin_ia32_bextr_u32(__X, __Y);
216 }
217 
229 static __inline__ unsigned int __DEFAULT_FN_ATTRS
230 __blsi_u32(unsigned int __X)
231 {
232  return __X & -__X;
233 }
234 
246 static __inline__ unsigned int __DEFAULT_FN_ATTRS
247 __blsmsk_u32(unsigned int __X)
248 {
249  return __X ^ (__X - 1);
250 }
251 
263 static __inline__ unsigned int __DEFAULT_FN_ATTRS
264 __blsr_u32(unsigned int __X)
265 {
266  return __X & (__X - 1);
267 }
268 
269 #ifdef __x86_64__
270 
271 #define _andn_u64(a, b) (__andn_u64((a), (b)))
272 
273 /* _bextr_u64 != __bextr_u64 */
274 #define _blsi_u64(a) (__blsi_u64((a)))
275 
276 #define _blsmsk_u64(a) (__blsmsk_u64((a)))
277 
278 #define _blsr_u64(a) (__blsr_u64((a)))
279 
293 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
294 __andn_u64 (unsigned long long __X, unsigned long long __Y)
295 {
296  return ~__X & __Y;
297 }
298 
299 /* AMD-specified, double-leading-underscore version of BEXTR */
316 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
317 __bextr_u64(unsigned long long __X, unsigned long long __Y)
318 {
319  return __builtin_ia32_bextr_u64(__X, __Y);
320 }
321 
322 /* Intel-specified, single-leading-underscore version of BEXTR */
341 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
342 _bextr_u64(unsigned long long __X, unsigned int __Y, unsigned int __Z)
343 {
344  return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
345 }
346 
347 /* Intel-specified, single-leading-underscore version of BEXTR2 */
364 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
365 _bextr2_u64(unsigned long long __X, unsigned long long __Y) {
366  return __builtin_ia32_bextr_u64(__X, __Y);
367 }
368 
380 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
381 __blsi_u64(unsigned long long __X)
382 {
383  return __X & -__X;
384 }
385 
397 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
398 __blsmsk_u64(unsigned long long __X)
399 {
400  return __X ^ (__X - 1);
401 }
402 
414 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
415 __blsr_u64(unsigned long long __X)
416 {
417  return __X & (__X - 1);
418 }
419 
420 #endif /* __x86_64__ */
421 
422 #undef __DEFAULT_FN_ATTRS
423 
424 #endif /* !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) \
425  || defined(__BMI__) */
426 
427 #endif /* __BMIINTRIN_H */
static __inline__ unsigned int __RELAXED_FN_ATTRS __tzcnt_u32(unsigned int __X)
Counts the number of trailing zero bits in the operand.
Definition: bmiintrin.h:51
#define __DEFAULT_FN_ATTRS
Definition: bmiintrin.h:118
static __inline__ unsigned int __DEFAULT_FN_ATTRS __bextr_u32(unsigned int __X, unsigned int __Y)
Extracts the specified bits from the first operand and returns them in the least significant bits of ...
Definition: bmiintrin.h:166
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blsmsk_u32(unsigned int __X)
Creates a mask whose bits are set to 1, using bit 0 up to and including the least significant bit tha...
Definition: bmiintrin.h:247
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blsi_u32(unsigned int __X)
Clears all bits in the source except for the least significant bit containing a value of 1 and return...
Definition: bmiintrin.h:230
static __inline__ unsigned int __DEFAULT_FN_ATTRS _bextr_u32(unsigned int __X, unsigned int __Y, unsigned int __Z)
Extracts the specified bits from the first operand and returns them in the least significant bits of ...
Definition: bmiintrin.h:191
static __inline__ unsigned int __DEFAULT_FN_ATTRS _bextr2_u32(unsigned int __X, unsigned int __Y)
Extracts the specified bits from the first operand and returns them in the least significant bits of ...
Definition: bmiintrin.h:214
#define __RELAXED_FN_ATTRS
Definition: bmiintrin.h:20
static __inline__ unsigned int __DEFAULT_FN_ATTRS __andn_u32(unsigned int __X, unsigned int __Y)
Performs a bitwise AND of the second operand with the one's complement of the first operand.
Definition: bmiintrin.h:143
static __inline__ unsigned short __RELAXED_FN_ATTRS __tzcnt_u16(unsigned short __X)
Counts the number of trailing zero bits in the operand.
Definition: bmiintrin.h:35
static __inline__ int __RELAXED_FN_ATTRS _mm_tzcnt_32(unsigned int __X)
Counts the number of trailing zero bits in the operand.
Definition: bmiintrin.h:67
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blsr_u32(unsigned int __X)
Clears the least significant bit that is set to 1 in the source operand and returns the result.
Definition: bmiintrin.h:264