blob: 51c83f258ff39065adac0063b72f3eda04e7b719 [file] [log] [blame]
Yunzhong Gaof4e0b102013-09-30 17:25:14 +00001/*===---- tbmintrin.h - TBM intrinsics -------------------------------------===
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21 *===-----------------------------------------------------------------------===
22 */
23
24#ifndef __TBM__
25#error "TBM instruction set is not enabled"
26#endif
27
28#ifndef __X86INTRIN_H
29#error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead."
30#endif
31
32#ifndef __TBMINTRIN_H
33#define __TBMINTRIN_H
34
35#define __bextri_u32(a, b) (__builtin_ia32_bextri_u32((a), (b)))
36
37#ifdef __x86_64__
38#define __bextri_u64(a, b) (__builtin_ia32_bextri_u64((a), (b)))
39#endif
40
41static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
42__blcfill_u32(unsigned int a)
43{
44 return __builtin_ia32_blcfill_u32(a);
45}
46
47#ifdef __x86_64__
48static __inline__ unsigned long long __attribute__((__always_inline__,
49 __nodebug__))
50__blcfill_u64(unsigned long long a)
51{
52 return __builtin_ia32_blcfill_u64(a);
53}
54#endif
55
56static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
57__blci_u32(unsigned int a)
58{
59 return __builtin_ia32_blci_u32(a);
60}
61
62#ifdef __x86_64__
63static __inline__ unsigned long long __attribute__((__always_inline__,
64 __nodebug__))
65__blci_u64(unsigned long long a)
66{
67 return __builtin_ia32_blci_u64(a);
68}
69#endif
70
71static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
72__blcic_u32(unsigned int a)
73{
74 return __builtin_ia32_blcic_u32(a);
75}
76
77#ifdef __x86_64__
78static __inline__ unsigned long long __attribute__((__always_inline__,
79 __nodebug__))
80__blcic_u64(unsigned long long a)
81{
82 return __builtin_ia32_blcic_u64(a);
83}
84#endif
85
86static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
87__blcmsk_u32(unsigned int a)
88{
89 return __builtin_ia32_blcmsk_u32(a);
90}
91
92#ifdef __x86_64__
93static __inline__ unsigned long long __attribute__((__always_inline__,
94 __nodebug__))
95__blcmsk_u64(unsigned long long a)
96{
97 return __builtin_ia32_blcmsk_u64(a);
98}
99#endif
100
101static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
102__blcs_u32(unsigned int a)
103{
104 return __builtin_ia32_blcs_u32(a);
105}
106
107#ifdef __x86_64__
108static __inline__ unsigned long long __attribute__((__always_inline__,
109 __nodebug__))
110__blcs_u64(unsigned long long a)
111{
112 return __builtin_ia32_blcs_u64(a);
113}
114#endif
115
116static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
117__blsfill_u32(unsigned int a)
118{
119 return __builtin_ia32_blsfill_u32(a);
120}
121
122#ifdef __x86_64__
123static __inline__ unsigned long long __attribute__((__always_inline__,
124 __nodebug__))
125__blsfill_u64(unsigned long long a)
126{
127 return __builtin_ia32_blsfill_u64(a);
128}
129#endif
130
131static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
132__blsic_u32(unsigned int a)
133{
134 return __builtin_ia32_blsic_u32(a);
135}
136
137#ifdef __x86_64__
138static __inline__ unsigned long long __attribute__((__always_inline__,
139 __nodebug__))
140__blsic_u64(unsigned long long a)
141{
142 return __builtin_ia32_blsic_u64(a);
143}
144#endif
145
146static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
147__t1mskc_u32(unsigned int a)
148{
149 return __builtin_ia32_t1mskc_u32(a);
150}
151
152#ifdef __x86_64__
153static __inline__ unsigned long long __attribute__((__always_inline__,
154 __nodebug__))
155__t1mskc_u64(unsigned long long a)
156{
157 return __builtin_ia32_t1mskc_u64(a);
158}
159#endif
160
161static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
162__tzmsk_u32(unsigned int a)
163{
164 return __builtin_ia32_tzmsk_u32(a);
165}
166
167#ifdef __x86_64__
168static __inline__ unsigned long long __attribute__((__always_inline__,
169 __nodebug__))
170__tzmsk_u64(unsigned long long a)
171{
172 return __builtin_ia32_tzmsk_u64(a);
173}
174#endif
175
176#endif /* __TBMINTRIN_H */