clang  3.7.0
tbmintrin.h
Go to the documentation of this file.
1 /*===---- 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 the default attributes for the functions in this file. */
36 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
37 
38 #define __bextri_u32(a, b) (__builtin_ia32_bextri_u32((a), (b)))
39 
40 static __inline__ unsigned int __DEFAULT_FN_ATTRS
41 __blcfill_u32(unsigned int a)
42 {
43  return a & (a + 1);
44 }
45 
46 static __inline__ unsigned int __DEFAULT_FN_ATTRS
47 __blci_u32(unsigned int a)
48 {
49  return a | ~(a + 1);
50 }
51 
52 static __inline__ unsigned int __DEFAULT_FN_ATTRS
53 __blcic_u32(unsigned int a)
54 {
55  return ~a & (a + 1);
56 }
57 
58 static __inline__ unsigned int __DEFAULT_FN_ATTRS
59 __blcmsk_u32(unsigned int a)
60 {
61  return a ^ (a + 1);
62 }
63 
64 static __inline__ unsigned int __DEFAULT_FN_ATTRS
65 __blcs_u32(unsigned int a)
66 {
67  return a | (a + 1);
68 }
69 
70 static __inline__ unsigned int __DEFAULT_FN_ATTRS
71 __blsfill_u32(unsigned int a)
72 {
73  return a | (a - 1);
74 }
75 
76 static __inline__ unsigned int __DEFAULT_FN_ATTRS
77 __blsic_u32(unsigned int a)
78 {
79  return ~a | (a - 1);
80 }
81 
82 static __inline__ unsigned int __DEFAULT_FN_ATTRS
83 __t1mskc_u32(unsigned int a)
84 {
85  return ~a | (a + 1);
86 }
87 
88 static __inline__ unsigned int __DEFAULT_FN_ATTRS
89 __tzmsk_u32(unsigned int a)
90 {
91  return ~a & (a - 1);
92 }
93 
94 #ifdef __x86_64__
95 #define __bextri_u64(a, b) (__builtin_ia32_bextri_u64((a), (int)(b)))
96 
97 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
98 __blcfill_u64(unsigned long long a)
99 {
100  return a & (a + 1);
101 }
102 
103 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
104 __blci_u64(unsigned long long a)
105 {
106  return a | ~(a + 1);
107 }
108 
109 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
110 __blcic_u64(unsigned long long a)
111 {
112  return ~a & (a + 1);
113 }
114 
115 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
116 __blcmsk_u64(unsigned long long a)
117 {
118  return a ^ (a + 1);
119 }
120 
121 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
122 __blcs_u64(unsigned long long a)
123 {
124  return a | (a + 1);
125 }
126 
127 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
128 __blsfill_u64(unsigned long long a)
129 {
130  return a | (a - 1);
131 }
132 
133 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
134 __blsic_u64(unsigned long long a)
135 {
136  return ~a | (a - 1);
137 }
138 
139 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
140 __t1mskc_u64(unsigned long long a)
141 {
142  return ~a | (a + 1);
143 }
144 
145 static __inline__ unsigned long long __DEFAULT_FN_ATTRS
146 __tzmsk_u64(unsigned long long a)
147 {
148  return ~a & (a - 1);
149 }
150 #endif
151 
152 #undef __DEFAULT_FN_ATTRS
153 
154 #endif /* __TBMINTRIN_H */
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blcic_u32(unsigned int a)
Definition: tbmintrin.h:53
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blsfill_u32(unsigned int a)
Definition: tbmintrin.h:71
static __inline__ unsigned int __DEFAULT_FN_ATTRS __t1mskc_u32(unsigned int a)
Definition: tbmintrin.h:83
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blci_u32(unsigned int a)
Definition: tbmintrin.h:47
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blsic_u32(unsigned int a)
Definition: tbmintrin.h:77
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blcs_u32(unsigned int a)
Definition: tbmintrin.h:65
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blcfill_u32(unsigned int a)
Definition: tbmintrin.h:41
#define __DEFAULT_FN_ATTRS
Definition: tbmintrin.h:36
static __inline__ unsigned int __DEFAULT_FN_ATTRS __blcmsk_u32(unsigned int a)
Definition: tbmintrin.h:59
static __inline__ unsigned int __DEFAULT_FN_ATTRS __tzmsk_u32(unsigned int a)
Definition: tbmintrin.h:89