| 1 |
/*===---- tbmintrin.h - TBM 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 |
#ifndef __X86INTRIN_H |
| 11 |
#error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead." |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifndef __TBMINTRIN_H |
| 15 |
#define __TBMINTRIN_H |
| 16 |
|
| 17 |
/* Define the default attributes for the functions in this file. */ |
| 18 |
#if defined(__cplusplus) && (__cplusplus >= 201103L) |
| 19 |
#define __DEFAULT_FN_ATTRS \ |
| 20 |
__attribute__((__always_inline__, __nodebug__, __target__("tbm"))) constexpr |
| 21 |
#else |
| 22 |
#define __DEFAULT_FN_ATTRS \ |
| 23 |
__attribute__((__always_inline__, __nodebug__, __target__("tbm"))) |
| 24 |
#endif |
| 25 |
|
| 26 |
#define __bextri_u32(a, b) \ |
| 27 |
((unsigned int)__builtin_ia32_bextri_u32((unsigned int)(a), \ |
| 28 |
(unsigned int)(b))) |
| 29 |
|
| 30 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 31 |
__blcfill_u32(unsigned int __a) { |
| 32 |
return __a & (__a + 1); |
| 33 |
} |
| 34 |
|
| 35 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 36 |
__blci_u32(unsigned int __a) { |
| 37 |
return __a | ~(__a + 1); |
| 38 |
} |
| 39 |
|
| 40 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 41 |
__blcic_u32(unsigned int __a) { |
| 42 |
return ~__a & (__a + 1); |
| 43 |
} |
| 44 |
|
| 45 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 46 |
__blcmsk_u32(unsigned int __a) { |
| 47 |
return __a ^ (__a + 1); |
| 48 |
} |
| 49 |
|
| 50 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 51 |
__blcs_u32(unsigned int __a) { |
| 52 |
return __a | (__a + 1); |
| 53 |
} |
| 54 |
|
| 55 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 56 |
__blsfill_u32(unsigned int __a) { |
| 57 |
return __a | (__a - 1); |
| 58 |
} |
| 59 |
|
| 60 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 61 |
__blsic_u32(unsigned int __a) { |
| 62 |
return ~__a | (__a - 1); |
| 63 |
} |
| 64 |
|
| 65 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 66 |
__t1mskc_u32(unsigned int __a) { |
| 67 |
return ~__a | (__a + 1); |
| 68 |
} |
| 69 |
|
| 70 |
static __inline__ unsigned int __DEFAULT_FN_ATTRS |
| 71 |
__tzmsk_u32(unsigned int __a) { |
| 72 |
return ~__a & (__a - 1); |
| 73 |
} |
| 74 |
|
| 75 |
#ifdef __x86_64__ |
| 76 |
#define __bextri_u64(a, b) \ |
| 77 |
((unsigned long long)__builtin_ia32_bextri_u64((unsigned long long)(a), \ |
| 78 |
(unsigned long long)(b))) |
| 79 |
|
| 80 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 81 |
__blcfill_u64(unsigned long long __a) { |
| 82 |
return __a & (__a + 1); |
| 83 |
} |
| 84 |
|
| 85 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 86 |
__blci_u64(unsigned long long __a) { |
| 87 |
return __a | ~(__a + 1); |
| 88 |
} |
| 89 |
|
| 90 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 91 |
__blcic_u64(unsigned long long __a) { |
| 92 |
return ~__a & (__a + 1); |
| 93 |
} |
| 94 |
|
| 95 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 96 |
__blcmsk_u64(unsigned long long __a) { |
| 97 |
return __a ^ (__a + 1); |
| 98 |
} |
| 99 |
|
| 100 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 101 |
__blcs_u64(unsigned long long __a) { |
| 102 |
return __a | (__a + 1); |
| 103 |
} |
| 104 |
|
| 105 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 106 |
__blsfill_u64(unsigned long long __a) { |
| 107 |
return __a | (__a - 1); |
| 108 |
} |
| 109 |
|
| 110 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 111 |
__blsic_u64(unsigned long long __a) { |
| 112 |
return ~__a | (__a - 1); |
| 113 |
} |
| 114 |
|
| 115 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 116 |
__t1mskc_u64(unsigned long long __a) { |
| 117 |
return ~__a | (__a + 1); |
| 118 |
} |
| 119 |
|
| 120 |
static __inline__ unsigned long long __DEFAULT_FN_ATTRS |
| 121 |
__tzmsk_u64(unsigned long long __a) { |
| 122 |
return ~__a & (__a - 1); |
| 123 |
} |
| 124 |
#endif |
| 125 |
|
| 126 |
#undef __DEFAULT_FN_ATTRS |
| 127 |
|
| 128 |
#endif /* __TBMINTRIN_H */ |