1 /*===---- adcintrin.h - ADC intrinsics -------------------------------------===
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
7 *===-----------------------------------------------------------------------===
13 #if !defined(__i386__) && !defined(__x86_64__)
14 #error "This header is only meant to be used on x86 and x64 architecture"
17 /* Define the default attributes for the functions in this file. */
18 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
20 /* Use C++ inline semantics in C++, GNU inline for C mode. */
21 #if defined(__cplusplus)
22 #define __INLINE __inline
24 #define __INLINE static __inline
27 #if defined(__cplusplus)
31 /// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated
32 /// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory
33 /// at \a __p, and returns the 8-bit carry-out (carry flag).
36 /// temp := (__cf == 0) ? 0 : 1
37 /// Store32(__p, __x + __y + temp)
41 /// \headerfile <immintrin.h>
43 /// This intrinsic corresponds to the \c ADC instruction.
46 /// The 8-bit unsigned carry flag; any non-zero value indicates carry.
48 /// A 32-bit unsigned addend.
50 /// A 32-bit unsigned addend.
52 /// Pointer to memory for storing the sum.
53 /// \returns The 8-bit unsigned carry-out value.
54 __INLINE
unsigned char __DEFAULT_FN_ATTRS
_addcarry_u32(unsigned char __cf
,
58 return __builtin_ia32_addcarryx_u32(__cf
, __x
, __y
, __p
);
61 /// Adds unsigned 32-bit integer \a __y to 0 or 1 as indicated by the carry
62 /// flag \a __cf, and subtracts the result from unsigned 32-bit integer
63 /// \a __x. Stores the unsigned 32-bit difference in the memory at \a __p,
64 /// and returns the 8-bit carry-out (carry or overflow flag).
67 /// temp := (__cf == 0) ? 0 : 1
68 /// Store32(__p, __x - (__y + temp))
72 /// \headerfile <immintrin.h>
74 /// This intrinsic corresponds to the \c SBB instruction.
77 /// The 8-bit unsigned carry flag; any non-zero value indicates carry.
79 /// The 32-bit unsigned minuend.
81 /// The 32-bit unsigned subtrahend.
83 /// Pointer to memory for storing the difference.
84 /// \returns The 8-bit unsigned carry-out value.
85 __INLINE
unsigned char __DEFAULT_FN_ATTRS
_subborrow_u32(unsigned char __cf
,
89 return __builtin_ia32_subborrow_u32(__cf
, __x
, __y
, __p
);
93 /// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated
94 /// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory
95 /// at \a __p, and returns the 8-bit carry-out (carry flag).
98 /// temp := (__cf == 0) ? 0 : 1
99 /// Store64(__p, __x + __y + temp)
103 /// \headerfile <immintrin.h>
105 /// This intrinsic corresponds to the \c ADC instruction.
108 /// The 8-bit unsigned carry flag; any non-zero value indicates carry.
110 /// A 64-bit unsigned addend.
112 /// A 64-bit unsigned addend.
114 /// Pointer to memory for storing the sum.
115 /// \returns The 8-bit unsigned carry-out value.
116 __INLINE
unsigned char __DEFAULT_FN_ATTRS
117 _addcarry_u64(unsigned char __cf
, unsigned long long __x
,
118 unsigned long long __y
, unsigned long long *__p
) {
119 return __builtin_ia32_addcarryx_u64(__cf
, __x
, __y
, __p
);
122 /// Adds unsigned 64-bit integer \a __y to 0 or 1 as indicated by the carry
123 /// flag \a __cf, and subtracts the result from unsigned 64-bit integer
124 /// \a __x. Stores the unsigned 64-bit difference in the memory at \a __p,
125 /// and returns the 8-bit carry-out (carry or overflow flag).
127 /// \code{.operation}
128 /// temp := (__cf == 0) ? 0 : 1
129 /// Store64(__p, __x - (__y + temp))
133 /// \headerfile <immintrin.h>
135 /// This intrinsic corresponds to the \c ADC instruction.
138 /// The 8-bit unsigned carry flag; any non-zero value indicates carry.
140 /// The 64-bit unsigned minuend.
142 /// The 64-bit unsigned subtrahend.
144 /// Pointer to memory for storing the difference.
145 /// \returns The 8-bit unsigned carry-out value.
146 __INLINE
unsigned char __DEFAULT_FN_ATTRS
147 _subborrow_u64(unsigned char __cf
, unsigned long long __x
,
148 unsigned long long __y
, unsigned long long *__p
) {
149 return __builtin_ia32_subborrow_u64(__cf
, __x
, __y
, __p
);
153 #if defined(__cplusplus)
158 #undef __DEFAULT_FN_ATTRS
160 #endif /* __ADCINTRIN_H */