11 #error "Never use <ia32intrin.h> directly; include <x86intrin.h> instead."
14 #ifndef __IA32INTRIN_H
15 #define __IA32INTRIN_H
31 return __builtin_ctz(__A);
46 static __inline__
int __attribute__((__always_inline__, __nodebug__))
48 return 31 - __builtin_clz(__A);
62 static __inline__
int __attribute__((__always_inline__, __nodebug__))
64 return __builtin_bswap32(__A);
67 static __inline__
int __attribute__((__always_inline__, __nodebug__))
69 return __builtin_bswap32(__A);
72 #define _bit_scan_forward(A) __bsfd((A))
73 #define _bit_scan_reverse(A) __bsrd((A))
88 static __inline__
int __attribute__((__always_inline__, __nodebug__))
89 __bsfq(
long long __A) {
90 return __builtin_ctzll(__A);
105 static __inline__
int __attribute__((__always_inline__, __nodebug__))
106 __bsrq(
long long __A) {
107 return 63 - __builtin_clzll(__A);
121 static __inline__
long long __attribute__((__always_inline__, __nodebug__))
122 __bswapq(
long long __A) {
123 return __builtin_bswap64(__A);
126 #define _bswap64(A) __bswapq((A))
141 static __inline__
int __attribute__((__always_inline__, __nodebug__))
142 __popcntd(
unsigned int __A)
144 return __builtin_popcount(__A);
147 #define _popcnt32(A) __popcntd((A))
162 static __inline__
long long __attribute__((__always_inline__, __nodebug__))
163 __popcntq(
unsigned long long __A)
165 return __builtin_popcountll(__A);
168 #define _popcnt64(A) __popcntq((A))
172 static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__))
175 return __builtin_ia32_readeflags_u64();
178 static __inline__
void __attribute__((__always_inline__, __nodebug__))
179 __writeeflags(
unsigned long long __f)
181 __builtin_ia32_writeeflags_u64(__f);
185 static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__))
188 return __builtin_ia32_readeflags_u32();
191 static __inline__
void __attribute__((__always_inline__, __nodebug__))
192 __writeeflags(
unsigned int __f)
194 __builtin_ia32_writeeflags_u32(__f);
209 _castf32_u32(
float __A) {
211 __builtin_memcpy(&D, &__A,
sizeof(__A));
225 static __inline__
unsigned long long __attribute__((__always_inline__))
226 _castf64_u64(
double __A) {
227 unsigned long long D;
228 __builtin_memcpy(&D, &__A,
sizeof(__A));
243 _castu32_f32(
unsigned int __A) {
245 __builtin_memcpy(&D, &__A,
sizeof(__A));
260 _castu64_f64(
unsigned long long __A) {
262 __builtin_memcpy(&D, &__A,
sizeof(__A));
281 static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__, __target__(
"sse4.2")))
282 __crc32b(
unsigned int __C,
unsigned char __D)
284 return __builtin_ia32_crc32qi(
__C,
__D);
302 static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__, __target__(
"sse4.2")))
303 __crc32w(
unsigned int __C,
unsigned short __D)
305 return __builtin_ia32_crc32hi(
__C,
__D);
323 static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__, __target__(
"sse4.2")))
324 __crc32d(
unsigned int __C,
unsigned int __D)
326 return __builtin_ia32_crc32si(
__C,
__D);
345 static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__, __target__(
"sse4.2")))
346 __crc32q(
unsigned long long __C,
unsigned long long __D)
348 return __builtin_ia32_crc32di(
__C,
__D);
352 static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__))
354 return __builtin_ia32_rdpmc(__A);
358 static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__))
359 __rdtscp(
unsigned int *__A) {
360 return __builtin_ia32_rdtscp(__A);
363 #define _rdtsc() __rdtsc()
365 #define _rdpmc(A) __rdpmc(A)
367 static __inline__
void __attribute__((__always_inline__, __nodebug__))
369 __builtin_ia32_wbinvd();
372 static __inline__
unsigned char __attribute__((__always_inline__, __nodebug__))
373 __rolb(
unsigned char __X,
int __C) {
374 return __builtin_rotateleft8(__X,
__C);
377 static __inline__
unsigned char __attribute__((__always_inline__, __nodebug__))
378 __rorb(
unsigned char __X,
int __C) {
379 return __builtin_rotateright8(__X,
__C);
382 static __inline__
unsigned short __attribute__((__always_inline__, __nodebug__))
383 __rolw(
unsigned short __X,
int __C) {
384 return __builtin_rotateleft16(__X,
__C);
387 static __inline__
unsigned short __attribute__((__always_inline__, __nodebug__))
388 __rorw(
unsigned short __X,
int __C) {
389 return __builtin_rotateright16(__X,
__C);
392 static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__))
393 __rold(
unsigned int __X,
int __C) {
394 return __builtin_rotateleft32(__X,
__C);
397 static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__))
398 __rord(
unsigned int __X,
int __C) {
399 return __builtin_rotateright32(__X,
__C);
403 static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__))
404 __rolq(
unsigned long long __X,
int __C) {
405 return __builtin_rotateleft64(__X,
__C);
408 static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__))
409 __rorq(
unsigned long long __X,
int __C) {
410 return __builtin_rotateright64(__X,
__C);
418 #define _lrotl(a,b) __rolq((a), (b))
419 #define _lrotr(a,b) __rorq((a), (b))
421 #define _lrotl(a,b) __rold((a), (b))
422 #define _lrotr(a,b) __rord((a), (b))
424 #define _rotl(a,b) __rold((a), (b))
425 #define _rotr(a,b) __rord((a), (b))
429 #define _rotwl(a,b) __rolw((a), (b))
430 #define _rotwr(a,b) __rorw((a), (b))
static __inline__ int __attribute__((__always_inline__, __nodebug__)) __bsfd(int __A)
Find the first set bit starting from the lsb.
static __inline__ unsigned int unsigned char __D
static __inline__ unsigned char int __C