|
15 | 15 | #define __ADXINTRIN_H
|
16 | 16 |
|
17 | 17 | /* Define the default attributes for the functions in this file. */
|
18 |
| -#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) |
| 18 | +#define __DEFAULT_FN_ATTRS \ |
| 19 | + __attribute__((__always_inline__, __nodebug__, __target__("adx"))) |
19 | 20 |
|
20 | 21 | /* Use C++ inline semantics in C++, GNU inline for C mode. */
|
21 | 22 | #if defined(__cplusplus)
|
@@ -53,10 +54,10 @@ extern "C" {
|
53 | 54 | /// \param __p
|
54 | 55 | /// Pointer to memory for storing the sum.
|
55 | 56 | /// \returns The 8-bit unsigned carry-out value.
|
56 |
| -__INLINE unsigned char |
57 |
| - __attribute__((__always_inline__, __nodebug__, __target__("adx"))) |
58 |
| - _addcarryx_u32(unsigned char __cf, unsigned int __x, unsigned int __y, |
59 |
| - unsigned int *__p) { |
| 57 | +__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarryx_u32(unsigned char __cf, |
| 58 | + unsigned int __x, |
| 59 | + unsigned int __y, |
| 60 | + unsigned int *__p) { |
60 | 61 | return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
|
61 | 62 | }
|
62 | 63 |
|
@@ -84,144 +85,18 @@ __INLINE unsigned char
|
84 | 85 | /// \param __p
|
85 | 86 | /// Pointer to memory for storing the sum.
|
86 | 87 | /// \returns The 8-bit unsigned carry-out value.
|
87 |
| -__INLINE unsigned char |
88 |
| - __attribute__((__always_inline__, __nodebug__, __target__("adx"))) |
89 |
| - _addcarryx_u64(unsigned char __cf, unsigned long long __x, |
90 |
| - unsigned long long __y, unsigned long long *__p) { |
91 |
| - return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p); |
92 |
| -} |
93 |
| -#endif |
94 |
| - |
95 |
| -/* Intrinsics that are also available if __ADX__ is undefined. */ |
96 |
| - |
97 |
| -/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated |
98 |
| -/// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory |
99 |
| -/// at \a __p, and returns the 8-bit carry-out (carry flag). |
100 |
| -/// |
101 |
| -/// \code{.operation} |
102 |
| -/// temp := (__cf == 0) ? 0 : 1 |
103 |
| -/// Store32(__p, __x + __y + temp) |
104 |
| -/// result := CF |
105 |
| -/// \endcode |
106 |
| -/// |
107 |
| -/// \headerfile <immintrin.h> |
108 |
| -/// |
109 |
| -/// This intrinsic corresponds to the \c ADC instruction. |
110 |
| -/// |
111 |
| -/// \param __cf |
112 |
| -/// The 8-bit unsigned carry flag; any non-zero value indicates carry. |
113 |
| -/// \param __x |
114 |
| -/// A 32-bit unsigned addend. |
115 |
| -/// \param __y |
116 |
| -/// A 32-bit unsigned addend. |
117 |
| -/// \param __p |
118 |
| -/// Pointer to memory for storing the sum. |
119 |
| -/// \returns The 8-bit unsigned carry-out value. |
120 |
| -__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarry_u32(unsigned char __cf, |
121 |
| - unsigned int __x, |
122 |
| - unsigned int __y, |
123 |
| - unsigned int *__p) { |
124 |
| - return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p); |
125 |
| -} |
126 |
| - |
127 |
| -#ifdef __x86_64__ |
128 |
| -/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated |
129 |
| -/// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory |
130 |
| -/// at \a __p, and returns the 8-bit carry-out (carry flag). |
131 |
| -/// |
132 |
| -/// \code{.operation} |
133 |
| -/// temp := (__cf == 0) ? 0 : 1 |
134 |
| -/// Store64(__p, __x + __y + temp) |
135 |
| -/// result := CF |
136 |
| -/// \endcode |
137 |
| -/// |
138 |
| -/// \headerfile <immintrin.h> |
139 |
| -/// |
140 |
| -/// This intrinsic corresponds to the \c ADC instruction. |
141 |
| -/// |
142 |
| -/// \param __cf |
143 |
| -/// The 8-bit unsigned carry flag; any non-zero value indicates carry. |
144 |
| -/// \param __x |
145 |
| -/// A 64-bit unsigned addend. |
146 |
| -/// \param __y |
147 |
| -/// A 64-bit unsigned addend. |
148 |
| -/// \param __p |
149 |
| -/// Pointer to memory for storing the sum. |
150 |
| -/// \returns The 8-bit unsigned carry-out value. |
151 | 88 | __INLINE unsigned char __DEFAULT_FN_ATTRS
|
152 |
| -_addcarry_u64(unsigned char __cf, unsigned long long __x, |
153 |
| - unsigned long long __y, unsigned long long *__p) { |
154 |
| - return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p); |
155 |
| -} |
156 |
| -#endif |
157 |
| - |
158 |
| -/// Adds unsigned 32-bit integer \a __y to 0 or 1 as indicated by the carry |
159 |
| -/// flag \a __cf, and subtracts the result from unsigned 32-bit integer |
160 |
| -/// \a __x. Stores the unsigned 32-bit difference in the memory at \a __p, |
161 |
| -/// and returns the 8-bit carry-out (carry or overflow flag). |
162 |
| -/// |
163 |
| -/// \code{.operation} |
164 |
| -/// temp := (__cf == 0) ? 0 : 1 |
165 |
| -/// Store32(__p, __x - (__y + temp)) |
166 |
| -/// result := CF |
167 |
| -/// \endcode |
168 |
| -/// |
169 |
| -/// \headerfile <immintrin.h> |
170 |
| -/// |
171 |
| -/// This intrinsic corresponds to the \c SBB instruction. |
172 |
| -/// |
173 |
| -/// \param __cf |
174 |
| -/// The 8-bit unsigned carry flag; any non-zero value indicates carry. |
175 |
| -/// \param __x |
176 |
| -/// The 32-bit unsigned minuend. |
177 |
| -/// \param __y |
178 |
| -/// The 32-bit unsigned subtrahend. |
179 |
| -/// \param __p |
180 |
| -/// Pointer to memory for storing the difference. |
181 |
| -/// \returns The 8-bit unsigned carry-out value. |
182 |
| -__INLINE unsigned char __DEFAULT_FN_ATTRS _subborrow_u32(unsigned char __cf, |
183 |
| - unsigned int __x, |
184 |
| - unsigned int __y, |
185 |
| - unsigned int *__p) { |
186 |
| - return __builtin_ia32_subborrow_u32(__cf, __x, __y, __p); |
187 |
| -} |
188 |
| - |
189 |
| -#ifdef __x86_64__ |
190 |
| -/// Adds unsigned 64-bit integer \a __y to 0 or 1 as indicated by the carry |
191 |
| -/// flag \a __cf, and subtracts the result from unsigned 64-bit integer |
192 |
| -/// \a __x. Stores the unsigned 64-bit difference in the memory at \a __p, |
193 |
| -/// and returns the 8-bit carry-out (carry or overflow flag). |
194 |
| -/// |
195 |
| -/// \code{.operation} |
196 |
| -/// temp := (__cf == 0) ? 0 : 1 |
197 |
| -/// Store64(__p, __x - (__y + temp)) |
198 |
| -/// result := CF |
199 |
| -/// \endcode |
200 |
| -/// |
201 |
| -/// \headerfile <immintrin.h> |
202 |
| -/// |
203 |
| -/// This intrinsic corresponds to the \c ADC instruction. |
204 |
| -/// |
205 |
| -/// \param __cf |
206 |
| -/// The 8-bit unsigned carry flag; any non-zero value indicates carry. |
207 |
| -/// \param __x |
208 |
| -/// The 64-bit unsigned minuend. |
209 |
| -/// \param __y |
210 |
| -/// The 64-bit unsigned subtrahend. |
211 |
| -/// \param __p |
212 |
| -/// Pointer to memory for storing the difference. |
213 |
| -/// \returns The 8-bit unsigned carry-out value. |
214 |
| -__INLINE unsigned char __DEFAULT_FN_ATTRS |
215 |
| -_subborrow_u64(unsigned char __cf, unsigned long long __x, |
| 89 | +_addcarryx_u64(unsigned char __cf, unsigned long long __x, |
216 | 90 | unsigned long long __y, unsigned long long *__p) {
|
217 |
| - return __builtin_ia32_subborrow_u64(__cf, __x, __y, __p); |
| 91 | + return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p); |
218 | 92 | }
|
219 | 93 | #endif
|
220 | 94 |
|
221 | 95 | #if defined(__cplusplus)
|
222 | 96 | }
|
223 | 97 | #endif
|
224 | 98 |
|
| 99 | +#undef __INLINE |
225 | 100 | #undef __DEFAULT_FN_ATTRS
|
226 | 101 |
|
227 | 102 | #endif /* __ADXINTRIN_H */
|
0 commit comments