1 /*===---- bmi2intrin.h - BMI2 intrinsics -----------------------------------===
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
7 *===-----------------------------------------------------------------------===
10 #if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
11 #error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
14 #ifndef __BMI2INTRIN_H
15 #define __BMI2INTRIN_H
17 /* Define the default attributes for the functions in this file. */
18 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi2")))
20 static __inline__
unsigned int __DEFAULT_FN_ATTRS
21 _bzhi_u32(unsigned int __X
, unsigned int __Y
)
23 return __builtin_ia32_bzhi_si(__X
, __Y
);
26 static __inline__
unsigned int __DEFAULT_FN_ATTRS
27 _pdep_u32(unsigned int __X
, unsigned int __Y
)
29 return __builtin_ia32_pdep_si(__X
, __Y
);
32 static __inline__
unsigned int __DEFAULT_FN_ATTRS
33 _pext_u32(unsigned int __X
, unsigned int __Y
)
35 return __builtin_ia32_pext_si(__X
, __Y
);
40 static __inline__
unsigned long long __DEFAULT_FN_ATTRS
41 _bzhi_u64(unsigned long long __X
, unsigned long long __Y
)
43 return __builtin_ia32_bzhi_di(__X
, __Y
);
46 static __inline__
unsigned long long __DEFAULT_FN_ATTRS
47 _pdep_u64(unsigned long long __X
, unsigned long long __Y
)
49 return __builtin_ia32_pdep_di(__X
, __Y
);
52 static __inline__
unsigned long long __DEFAULT_FN_ATTRS
53 _pext_u64(unsigned long long __X
, unsigned long long __Y
)
55 return __builtin_ia32_pext_di(__X
, __Y
);
58 static __inline__
unsigned long long __DEFAULT_FN_ATTRS
59 _mulx_u64 (unsigned long long __X
, unsigned long long __Y
,
60 unsigned long long *__P
)
62 unsigned __int128 __res
= (unsigned __int128
) __X
* __Y
;
63 *__P
= (unsigned long long) (__res
>> 64);
64 return (unsigned long long) __res
;
67 #else /* !__x86_64__ */
69 static __inline__
unsigned int __DEFAULT_FN_ATTRS
70 _mulx_u32 (unsigned int __X
, unsigned int __Y
, unsigned int *__P
)
72 unsigned long long __res
= (unsigned long long) __X
* __Y
;
73 *__P
= (unsigned int) (__res
>> 32);
74 return (unsigned int) __res
;
77 #endif /* !__x86_64__ */
79 #undef __DEFAULT_FN_ATTRS
81 #endif /* __BMI2INTRIN_H */