10b57cec5SDimitry Andric /*===---- adxintrin.h - ADX intrinsics -------------------------------------=== 20b57cec5SDimitry Andric * 30b57cec5SDimitry Andric * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric * See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric * 70b57cec5SDimitry Andric *===-----------------------------------------------------------------------=== 80b57cec5SDimitry Andric */ 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric #ifndef __IMMINTRIN_H 110b57cec5SDimitry Andric #error "Never use <adxintrin.h> directly; include <immintrin.h> instead." 120b57cec5SDimitry Andric #endif 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #ifndef __ADXINTRIN_H 150b57cec5SDimitry Andric #define __ADXINTRIN_H 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric /* Define the default attributes for the functions in this file. */ 18*cb14a3feSDimitry Andric #define __DEFAULT_FN_ATTRS \ 19*cb14a3feSDimitry Andric __attribute__((__always_inline__, __nodebug__, __target__("adx"))) 200b57cec5SDimitry Andric 2106c3fb27SDimitry Andric /* Use C++ inline semantics in C++, GNU inline for C mode. */ 2206c3fb27SDimitry Andric #if defined(__cplusplus) 2306c3fb27SDimitry Andric #define __INLINE __inline 2406c3fb27SDimitry Andric #else 2506c3fb27SDimitry Andric #define __INLINE static __inline 2606c3fb27SDimitry Andric #endif 2706c3fb27SDimitry Andric 2806c3fb27SDimitry Andric #if defined(__cplusplus) 2906c3fb27SDimitry Andric extern "C" { 3006c3fb27SDimitry Andric #endif 3106c3fb27SDimitry Andric 3206c3fb27SDimitry Andric /* Intrinsics that are available only if __ADX__ is defined. */ 3306c3fb27SDimitry Andric 3406c3fb27SDimitry Andric /// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated 3506c3fb27SDimitry Andric /// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory 3606c3fb27SDimitry Andric /// at \a __p, and returns the 8-bit carry-out (carry flag). 3706c3fb27SDimitry Andric /// 3806c3fb27SDimitry Andric /// \code{.operation} 3906c3fb27SDimitry Andric /// temp := (__cf == 0) ? 0 : 1 4006c3fb27SDimitry Andric /// Store32(__p, __x + __y + temp) 4106c3fb27SDimitry Andric /// result := CF 4206c3fb27SDimitry Andric /// \endcode 4306c3fb27SDimitry Andric /// 4406c3fb27SDimitry Andric /// \headerfile <immintrin.h> 4506c3fb27SDimitry Andric /// 4606c3fb27SDimitry Andric /// This intrinsic corresponds to the \c ADCX instruction. 4706c3fb27SDimitry Andric /// 4806c3fb27SDimitry Andric /// \param __cf 4906c3fb27SDimitry Andric /// The 8-bit unsigned carry flag; any non-zero value indicates carry. 5006c3fb27SDimitry Andric /// \param __x 5106c3fb27SDimitry Andric /// A 32-bit unsigned addend. 5206c3fb27SDimitry Andric /// \param __y 5306c3fb27SDimitry Andric /// A 32-bit unsigned addend. 5406c3fb27SDimitry Andric /// \param __p 5506c3fb27SDimitry Andric /// Pointer to memory for storing the sum. 5606c3fb27SDimitry Andric /// \returns The 8-bit unsigned carry-out value. 57*cb14a3feSDimitry Andric __INLINE unsigned char __DEFAULT_FN_ATTRS _addcarryx_u32(unsigned char __cf, 58*cb14a3feSDimitry Andric unsigned int __x, 59*cb14a3feSDimitry Andric unsigned int __y, 6006c3fb27SDimitry Andric unsigned int *__p) { 610b57cec5SDimitry Andric return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p); 620b57cec5SDimitry Andric } 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric #ifdef __x86_64__ 6506c3fb27SDimitry Andric /// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated 6606c3fb27SDimitry Andric /// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory 6706c3fb27SDimitry Andric /// at \a __p, and returns the 8-bit carry-out (carry flag). 6806c3fb27SDimitry Andric /// 6906c3fb27SDimitry Andric /// \code{.operation} 7006c3fb27SDimitry Andric /// temp := (__cf == 0) ? 0 : 1 7106c3fb27SDimitry Andric /// Store64(__p, __x + __y + temp) 7206c3fb27SDimitry Andric /// result := CF 7306c3fb27SDimitry Andric /// \endcode 7406c3fb27SDimitry Andric /// 7506c3fb27SDimitry Andric /// \headerfile <immintrin.h> 7606c3fb27SDimitry Andric /// 7706c3fb27SDimitry Andric /// This intrinsic corresponds to the \c ADCX instruction. 7806c3fb27SDimitry Andric /// 7906c3fb27SDimitry Andric /// \param __cf 8006c3fb27SDimitry Andric /// The 8-bit unsigned carry flag; any non-zero value indicates carry. 8106c3fb27SDimitry Andric /// \param __x 8206c3fb27SDimitry Andric /// A 64-bit unsigned addend. 8306c3fb27SDimitry Andric /// \param __y 8406c3fb27SDimitry Andric /// A 64-bit unsigned addend. 8506c3fb27SDimitry Andric /// \param __p 8606c3fb27SDimitry Andric /// Pointer to memory for storing the sum. 8706c3fb27SDimitry Andric /// \returns The 8-bit unsigned carry-out value. 88*cb14a3feSDimitry Andric __INLINE unsigned char __DEFAULT_FN_ATTRS 890b57cec5SDimitry Andric _addcarryx_u64(unsigned char __cf, unsigned long long __x, 9006c3fb27SDimitry Andric unsigned long long __y, unsigned long long *__p) { 910b57cec5SDimitry Andric return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p); 920b57cec5SDimitry Andric } 930b57cec5SDimitry Andric #endif 940b57cec5SDimitry Andric 9506c3fb27SDimitry Andric #if defined(__cplusplus) 9606c3fb27SDimitry Andric } 9706c3fb27SDimitry Andric #endif 9806c3fb27SDimitry Andric 99*cb14a3feSDimitry Andric #undef __INLINE 1000b57cec5SDimitry Andric #undef __DEFAULT_FN_ATTRS 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andric #endif /* __ADXINTRIN_H */ 103