| 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-exception |
| 6 | * |
| 7 | *===-----------------------------------------------------------------------=== |
| 8 | */ |
| 9 | |
| 10 | #ifndef __IMMINTRIN_H |
| 11 | #error "Never use <adxintrin.h> directly; include <immintrin.h> instead." |
| 12 | #endif |
| 13 | |
| 14 | #ifndef __ADXINTRIN_H |
| 15 | #define __ADXINTRIN_H |
| 16 | |
| 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"))) constexpr |
| 21 | #else |
| 22 | #define __DEFAULT_FN_ATTRS \ |
| 23 | __attribute__((__always_inline__, __nodebug__, __target__("adx"))) |
| 24 | #endif |
| 25 | |
| 26 | /* Use C++ inline semantics in C++, GNU inline for C mode. */ |
| 27 | #if defined(__cplusplus) |
| 28 | #define __INLINE __inline |
| 29 | #else |
| 30 | #define __INLINE static __inline |
| 31 | #endif |
| 32 | |
| 33 | #if defined(__cplusplus) |
| 34 | extern "C" { |
| 35 | #endif |
| 36 | |
| 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 indicated |
| 40 | /// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory |
| 41 | /// at \a __p, and returns the 8-bit carry-out (carry flag). |
| 42 | /// |
| 43 | /// \code{.operation} |
| 44 | /// temp := (__cf == 0) ? 0 : 1 |
| 45 | /// Store32(__p, __x + __y + temp) |
| 46 | /// result := CF |
| 47 | /// \endcode |
| 48 | /// |
| 49 | /// \headerfile <immintrin.h> |
| 50 | /// |
| 51 | /// This intrinsic corresponds to the \c ADCX instruction. |
| 52 | /// |
| 53 | /// \param __cf |
| 54 | /// The 8-bit unsigned carry flag; any non-zero value indicates carry. |
| 55 | /// \param __x |
| 56 | /// A 32-bit unsigned addend. |
| 57 | /// \param __y |
| 58 | /// A 32-bit unsigned addend. |
| 59 | /// \param __p |
| 60 | /// 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 indicated |
| 71 | /// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory |
| 72 | /// at \a __p, and returns the 8-bit carry-out (carry flag). |
| 73 | /// |
| 74 | /// \code{.operation} |
| 75 | /// temp := (__cf == 0) ? 0 : 1 |
| 76 | /// Store64(__p, __x + __y + temp) |
| 77 | /// result := CF |
| 78 | /// \endcode |
| 79 | /// |
| 80 | /// \headerfile <immintrin.h> |
| 81 | /// |
| 82 | /// This intrinsic corresponds to the \c ADCX instruction. |
| 83 | /// |
| 84 | /// \param __cf |
| 85 | /// The 8-bit unsigned carry flag; any non-zero value indicates carry. |
| 86 | /// \param __x |
| 87 | /// A 64-bit unsigned addend. |
| 88 | /// \param __y |
| 89 | /// A 64-bit unsigned addend. |
| 90 | /// \param __p |
| 91 | /// Pointer to memory for storing the sum. |
| 92 | /// \returns The 8-bit unsigned carry-out value. |
| 93 | __INLINE unsigned char __DEFAULT_FN_ATTRS |
| 94 | _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 | #endif |
| 99 | |
| 100 | #if defined(__cplusplus) |
| 101 | } |
| 102 | #endif |
| 103 | |
| 104 | #undef __INLINE |
| 105 | #undef __DEFAULT_FN_ATTRS |
| 106 | |
| 107 | #endif /* __ADXINTRIN_H */ |