108 lines · c
1/*===---- adxintrin.h - ADX intrinsics -------------------------------------===2 *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-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10#ifndef __IMMINTRIN_H11#error "Never use <adxintrin.h> directly; include <immintrin.h> instead."12#endif13 14#ifndef __ADXINTRIN_H15#define __ADXINTRIN_H16 17/* Define the default attributes for the functions in this file. */18#if defined(__cplusplus) && (__cplusplus >= 201103L)19#define __DEFAULT_FN_ATTRS \20 __attribute__((__always_inline__, __nodebug__, __target__("adx"))) constexpr21#else22#define __DEFAULT_FN_ATTRS \23 __attribute__((__always_inline__, __nodebug__, __target__("adx")))24#endif25 26/* Use C++ inline semantics in C++, GNU inline for C mode. */27#if defined(__cplusplus)28#define __INLINE __inline29#else30#define __INLINE static __inline31#endif32 33#if defined(__cplusplus)34extern "C" {35#endif36 37/* Intrinsics that are available only if __ADX__ is defined. */38 39/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated40/// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory41/// at \a __p, and returns the 8-bit carry-out (carry flag).42///43/// \code{.operation}44/// temp := (__cf == 0) ? 0 : 145/// Store32(__p, __x + __y + temp)46/// result := CF47/// \endcode48///49/// \headerfile <immintrin.h>50///51/// This intrinsic corresponds to the \c ADCX instruction.52///53/// \param __cf54/// The 8-bit unsigned carry flag; any non-zero value indicates carry.55/// \param __x56/// A 32-bit unsigned addend.57/// \param __y58/// A 32-bit unsigned addend.59/// \param __p60/// Pointer to memory for storing the sum.61/// \returns The 8-bit unsigned carry-out value.62__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarryx_u32(unsigned char __cf,63 unsigned int __x,64 unsigned int __y,65 unsigned int *__p) {66 return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);67}68 69#ifdef __x86_64__70/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated71/// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory72/// at \a __p, and returns the 8-bit carry-out (carry flag).73///74/// \code{.operation}75/// temp := (__cf == 0) ? 0 : 176/// Store64(__p, __x + __y + temp)77/// result := CF78/// \endcode79///80/// \headerfile <immintrin.h>81///82/// This intrinsic corresponds to the \c ADCX instruction.83///84/// \param __cf85/// The 8-bit unsigned carry flag; any non-zero value indicates carry.86/// \param __x87/// A 64-bit unsigned addend.88/// \param __y89/// A 64-bit unsigned addend.90/// \param __p91/// Pointer to memory for storing the sum.92/// \returns The 8-bit unsigned carry-out value.93__INLINE unsigned char __DEFAULT_FN_ATTRS94_addcarryx_u64(unsigned char __cf, unsigned long long __x,95 unsigned long long __y, unsigned long long *__p) {96 return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);97}98#endif99 100#if defined(__cplusplus)101}102#endif103 104#undef __INLINE105#undef __DEFAULT_FN_ATTRS106 107#endif /* __ADXINTRIN_H */108