Path: blob/main/contrib/llvm-project/clang/lib/Headers/adcintrin.h
35233 views
/*===---- adcintrin.h - ADC intrinsics -------------------------------------===1*2* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3* See https://llvm.org/LICENSE.txt for license information.4* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5*6*===-----------------------------------------------------------------------===7*/89#ifndef __ADCINTRIN_H10#define __ADCINTRIN_H1112#if !defined(__i386__) && !defined(__x86_64__)13#error "This header is only meant to be used on x86 and x64 architecture"14#endif1516/* Define the default attributes for the functions in this file. */17#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))1819/* Use C++ inline semantics in C++, GNU inline for C mode. */20#if defined(__cplusplus)21#define __INLINE __inline22#else23#define __INLINE static __inline24#endif2526#if defined(__cplusplus)27extern "C" {28#endif2930/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated31/// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory32/// at \a __p, and returns the 8-bit carry-out (carry flag).33///34/// \code{.operation}35/// temp := (__cf == 0) ? 0 : 136/// Store32(__p, __x + __y + temp)37/// result := CF38/// \endcode39///40/// \headerfile <immintrin.h>41///42/// This intrinsic corresponds to the \c ADC instruction.43///44/// \param __cf45/// The 8-bit unsigned carry flag; any non-zero value indicates carry.46/// \param __x47/// A 32-bit unsigned addend.48/// \param __y49/// A 32-bit unsigned addend.50/// \param __p51/// Pointer to memory for storing the sum.52/// \returns The 8-bit unsigned carry-out value.53__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarry_u32(unsigned char __cf,54unsigned int __x,55unsigned int __y,56unsigned int *__p) {57return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);58}5960/// Adds unsigned 32-bit integer \a __y to 0 or 1 as indicated by the carry61/// flag \a __cf, and subtracts the result from unsigned 32-bit integer62/// \a __x. Stores the unsigned 32-bit difference in the memory at \a __p,63/// and returns the 8-bit carry-out (carry or overflow flag).64///65/// \code{.operation}66/// temp := (__cf == 0) ? 0 : 167/// Store32(__p, __x - (__y + temp))68/// result := CF69/// \endcode70///71/// \headerfile <immintrin.h>72///73/// This intrinsic corresponds to the \c SBB instruction.74///75/// \param __cf76/// The 8-bit unsigned carry flag; any non-zero value indicates carry.77/// \param __x78/// The 32-bit unsigned minuend.79/// \param __y80/// The 32-bit unsigned subtrahend.81/// \param __p82/// Pointer to memory for storing the difference.83/// \returns The 8-bit unsigned carry-out value.84__INLINE unsigned char __DEFAULT_FN_ATTRS _subborrow_u32(unsigned char __cf,85unsigned int __x,86unsigned int __y,87unsigned int *__p) {88return __builtin_ia32_subborrow_u32(__cf, __x, __y, __p);89}9091#ifdef __x86_64__92/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated93/// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory94/// at \a __p, and returns the 8-bit carry-out (carry flag).95///96/// \code{.operation}97/// temp := (__cf == 0) ? 0 : 198/// Store64(__p, __x + __y + temp)99/// result := CF100/// \endcode101///102/// \headerfile <immintrin.h>103///104/// This intrinsic corresponds to the \c ADC instruction.105///106/// \param __cf107/// The 8-bit unsigned carry flag; any non-zero value indicates carry.108/// \param __x109/// A 64-bit unsigned addend.110/// \param __y111/// A 64-bit unsigned addend.112/// \param __p113/// Pointer to memory for storing the sum.114/// \returns The 8-bit unsigned carry-out value.115__INLINE unsigned char __DEFAULT_FN_ATTRS116_addcarry_u64(unsigned char __cf, unsigned long long __x,117unsigned long long __y, unsigned long long *__p) {118return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);119}120121/// Adds unsigned 64-bit integer \a __y to 0 or 1 as indicated by the carry122/// flag \a __cf, and subtracts the result from unsigned 64-bit integer123/// \a __x. Stores the unsigned 64-bit difference in the memory at \a __p,124/// and returns the 8-bit carry-out (carry or overflow flag).125///126/// \code{.operation}127/// temp := (__cf == 0) ? 0 : 1128/// Store64(__p, __x - (__y + temp))129/// result := CF130/// \endcode131///132/// \headerfile <immintrin.h>133///134/// This intrinsic corresponds to the \c ADC instruction.135///136/// \param __cf137/// The 8-bit unsigned carry flag; any non-zero value indicates carry.138/// \param __x139/// The 64-bit unsigned minuend.140/// \param __y141/// The 64-bit unsigned subtrahend.142/// \param __p143/// Pointer to memory for storing the difference.144/// \returns The 8-bit unsigned carry-out value.145__INLINE unsigned char __DEFAULT_FN_ATTRS146_subborrow_u64(unsigned char __cf, unsigned long long __x,147unsigned long long __y, unsigned long long *__p) {148return __builtin_ia32_subborrow_u64(__cf, __x, __y, __p);149}150#endif151152#if defined(__cplusplus)153}154#endif155156#undef __INLINE157#undef __DEFAULT_FN_ATTRS158159#endif /* __ADCINTRIN_H */160161162