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 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
19 
20 /* Intrinsics that are available only if __ADX__ defined */
21 static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
_addcarryx_u32(unsigned char __cf,unsigned int __x,unsigned int __y,unsigned int * __p)22 _addcarryx_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
23                unsigned int *__p)
24 {
25   return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
26 }
27 
28 #ifdef __x86_64__
29 static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
_addcarryx_u64(unsigned char __cf,unsigned long long __x,unsigned long long __y,unsigned long long * __p)30 _addcarryx_u64(unsigned char __cf, unsigned long long __x,
31                unsigned long long __y, unsigned long long  *__p)
32 {
33   return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);
34 }
35 #endif
36 
37 /* Intrinsics that are also available if __ADX__ undefined */
38 static __inline unsigned char __DEFAULT_FN_ATTRS
_addcarry_u32(unsigned char __cf,unsigned int __x,unsigned int __y,unsigned int * __p)39 _addcarry_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
40               unsigned int *__p)
41 {
42   return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
43 }
44 
45 #ifdef __x86_64__
46 static __inline unsigned char __DEFAULT_FN_ATTRS
_addcarry_u64(unsigned char __cf,unsigned long long __x,unsigned long long __y,unsigned long long * __p)47 _addcarry_u64(unsigned char __cf, unsigned long long __x,
48               unsigned long long __y, unsigned long long  *__p)
49 {
50   return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);
51 }
52 #endif
53 
54 static __inline unsigned char __DEFAULT_FN_ATTRS
_subborrow_u32(unsigned char __cf,unsigned int __x,unsigned int __y,unsigned int * __p)55 _subborrow_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
56               unsigned int *__p)
57 {
58   return __builtin_ia32_subborrow_u32(__cf, __x, __y, __p);
59 }
60 
61 #ifdef __x86_64__
62 static __inline unsigned char __DEFAULT_FN_ATTRS
_subborrow_u64(unsigned char __cf,unsigned long long __x,unsigned long long __y,unsigned long long * __p)63 _subborrow_u64(unsigned char __cf, unsigned long long __x,
64                unsigned long long __y, unsigned long long  *__p)
65 {
66   return __builtin_ia32_subborrow_u64(__cf, __x, __y, __p);
67 }
68 #endif
69 
70 #undef __DEFAULT_FN_ATTRS
71 
72 #endif /* __ADXINTRIN_H */
73