2013-10-01 01:25:14 +08:00
|
|
|
/*===---- tbmintrin.h - TBM 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
|
2013-10-01 01:25:14 +08:00
|
|
|
*
|
|
|
|
*===-----------------------------------------------------------------------===
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __X86INTRIN_H
|
|
|
|
#error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __TBMINTRIN_H
|
|
|
|
#define __TBMINTRIN_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__("tbm")))
|
2015-06-17 15:09:20 +08:00
|
|
|
|
2015-11-11 11:47:10 +08:00
|
|
|
#define __bextri_u32(a, b) \
|
|
|
|
((unsigned int)__builtin_ia32_bextri_u32((unsigned int)(a), \
|
|
|
|
(unsigned int)(b)))
|
2013-10-01 01:25:14 +08:00
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcfill_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a & (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blci_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a | ~(__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcic_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a & (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcmsk_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a ^ (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcs_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a | (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blsfill_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a | (__a - 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blsic_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a | (__a - 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__t1mskc_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a | (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned int __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__tzmsk_u32(unsigned int __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a & (__a - 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __x86_64__
|
2015-11-11 11:47:10 +08:00
|
|
|
#define __bextri_u64(a, b) \
|
|
|
|
((unsigned long long)__builtin_ia32_bextri_u64((unsigned long long)(a), \
|
|
|
|
(unsigned long long)(b)))
|
2013-10-06 01:08:42 +08:00
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcfill_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a & (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blci_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a | ~(__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcic_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a & (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcmsk_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a ^ (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blcs_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a | (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blsfill_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return __a | (__a - 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__blsic_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a | (__a - 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__t1mskc_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a | (__a + 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
static __inline__ unsigned long long __DEFAULT_FN_ATTRS
|
2016-02-12 10:22:53 +08:00
|
|
|
__tzmsk_u64(unsigned long long __a)
|
2013-10-01 01:25:14 +08:00
|
|
|
{
|
2016-02-12 10:22:53 +08:00
|
|
|
return ~__a & (__a - 1);
|
2013-10-01 01:25:14 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-06-30 21:36:19 +08:00
|
|
|
#undef __DEFAULT_FN_ATTRS
|
2015-06-17 15:09:20 +08:00
|
|
|
|
2013-10-01 01:25:14 +08:00
|
|
|
#endif /* __TBMINTRIN_H */
|