2011-12-26 10:31:10 +08:00
|
|
|
/*===---- bmi2intrin.h - BMI2 intrinsics -----------------------------------===
|
|
|
|
*
|
2019-04-09 04:51:30 +08:00
|
|
|
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
* See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-12-26 10:31:10 +08:00
|
|
|
*
|
|
|
|
*===-----------------------------------------------------------------------===
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
|
|
|
|
#error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __BMI2INTRIN_H
|
|
|
|
#define __BMI2INTRIN_H
|
|
|
|
|
2015-06-17 15:09:20 +08:00
|
|
|
/* Define the default attributes for the functions in this file. */
|
2015-06-30 21:36:19 +08:00
|
|
|
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi2")))
|
2015-06-17 15:09:20 +08:00
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2011-12-26 10:31:10 +08:00
|
|
|
_bzhi_u32(unsigned int __X, unsigned int __Y)
|
|
|
|
{
|
|
|
|
return __builtin_ia32_bzhi_si(__X, __Y);
|
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2011-12-26 10:31:10 +08:00
|
|
|
_pdep_u32(unsigned int __X, unsigned int __Y)
|
|
|
|
{
|
|
|
|
return __builtin_ia32_pdep_si(__X, __Y);
|
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2011-12-26 10:31:10 +08:00
|
|
|
_pext_u32(unsigned int __X, unsigned int __Y)
|
|
|
|
{
|
|
|
|
return __builtin_ia32_pext_si(__X, __Y);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2011-12-26 10:31:10 +08:00
|
|
|
_bzhi_u64(unsigned long long __X, unsigned long long __Y)
|
|
|
|
{
|
|
|
|
return __builtin_ia32_bzhi_di(__X, __Y);
|
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2011-12-26 10:31:10 +08:00
|
|
|
_pdep_u64(unsigned long long __X, unsigned long long __Y)
|
|
|
|
{
|
|
|
|
return __builtin_ia32_pdep_di(__X, __Y);
|
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2011-12-26 10:31:10 +08:00
|
|
|
_pext_u64(unsigned long long __X, unsigned long long __Y)
|
|
|
|
{
|
|
|
|
return __builtin_ia32_pext_di(__X, __Y);
|
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2012-10-06 02:50:09 +08:00
|
|
|
_mulx_u64 (unsigned long long __X, unsigned long long __Y,
|
|
|
|
unsigned long long *__P)
|
|
|
|
{
|
|
|
|
unsigned __int128 __res = (unsigned __int128) __X * __Y;
|
|
|
|
*__P = (unsigned long long) (__res >> 64);
|
|
|
|
return (unsigned long long) __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !__x86_64__ */
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2012-10-06 02:50:09 +08:00
|
|
|
_mulx_u32 (unsigned int __X, unsigned int __Y, unsigned int *__P)
|
|
|
|
{
|
|
|
|
unsigned long long __res = (unsigned long long) __X * __Y;
|
|
|
|
*__P = (unsigned int) (__res >> 32);
|
|
|
|
return (unsigned int) __res;
|
|
|
|
}
|
|
|
|
|
2011-12-26 10:31:10 +08:00
|
|
|
#endif /* !__x86_64__ */
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
#undef __DEFAULT_FN_ATTRS
|
2015-06-17 15:09:20 +08:00
|
|
|
|
2011-12-26 10:31:10 +08:00
|
|
|
#endif /* __BMI2INTRIN_H */
|