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#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("tbm"))) 19 20#define __bextri_u32(a, b) \ 21 ((unsigned int)__builtin_ia32_bextri_u32((unsigned int)(a), \ 22 (unsigned int)(b))) 23 24static __inline__ unsigned int __DEFAULT_FN_ATTRS 25__blcfill_u32(unsigned int __a) 26{ 27 return __a & (__a + 1); 28} 29 30static __inline__ unsigned int __DEFAULT_FN_ATTRS 31__blci_u32(unsigned int __a) 32{ 33 return __a | ~(__a + 1); 34} 35 36static __inline__ unsigned int __DEFAULT_FN_ATTRS 37__blcic_u32(unsigned int __a) 38{ 39 return ~__a & (__a + 1); 40} 41 42static __inline__ unsigned int __DEFAULT_FN_ATTRS 43__blcmsk_u32(unsigned int __a) 44{ 45 return __a ^ (__a + 1); 46} 47 48static __inline__ unsigned int __DEFAULT_FN_ATTRS 49__blcs_u32(unsigned int __a) 50{ 51 return __a | (__a + 1); 52} 53 54static __inline__ unsigned int __DEFAULT_FN_ATTRS 55__blsfill_u32(unsigned int __a) 56{ 57 return __a | (__a - 1); 58} 59 60static __inline__ unsigned int __DEFAULT_FN_ATTRS 61__blsic_u32(unsigned int __a) 62{ 63 return ~__a | (__a - 1); 64} 65 66static __inline__ unsigned int __DEFAULT_FN_ATTRS 67__t1mskc_u32(unsigned int __a) 68{ 69 return ~__a | (__a + 1); 70} 71 72static __inline__ unsigned int __DEFAULT_FN_ATTRS 73__tzmsk_u32(unsigned int __a) 74{ 75 return ~__a & (__a - 1); 76} 77 78#ifdef __x86_64__ 79#define __bextri_u64(a, b) \ 80 ((unsigned long long)__builtin_ia32_bextri_u64((unsigned long long)(a), \ 81 (unsigned long long)(b))) 82 83static __inline__ unsigned long long __DEFAULT_FN_ATTRS 84__blcfill_u64(unsigned long long __a) 85{ 86 return __a & (__a + 1); 87} 88 89static __inline__ unsigned long long __DEFAULT_FN_ATTRS 90__blci_u64(unsigned long long __a) 91{ 92 return __a | ~(__a + 1); 93} 94 95static __inline__ unsigned long long __DEFAULT_FN_ATTRS 96__blcic_u64(unsigned long long __a) 97{ 98 return ~__a & (__a + 1); 99} 100 101static __inline__ unsigned long long __DEFAULT_FN_ATTRS 102__blcmsk_u64(unsigned long long __a) 103{ 104 return __a ^ (__a + 1); 105} 106 107static __inline__ unsigned long long __DEFAULT_FN_ATTRS 108__blcs_u64(unsigned long long __a) 109{ 110 return __a | (__a + 1); 111} 112 113static __inline__ unsigned long long __DEFAULT_FN_ATTRS 114__blsfill_u64(unsigned long long __a) 115{ 116 return __a | (__a - 1); 117} 118 119static __inline__ unsigned long long __DEFAULT_FN_ATTRS 120__blsic_u64(unsigned long long __a) 121{ 122 return ~__a | (__a - 1); 123} 124 125static __inline__ unsigned long long __DEFAULT_FN_ATTRS 126__t1mskc_u64(unsigned long long __a) 127{ 128 return ~__a | (__a + 1); 129} 130 131static __inline__ unsigned long long __DEFAULT_FN_ATTRS 132__tzmsk_u64(unsigned long long __a) 133{ 134 return ~__a & (__a - 1); 135} 136#endif 137 138#undef __DEFAULT_FN_ATTRS 139 140#endif /* __TBMINTRIN_H */ 141