blob: 72b9ed08f40c5a3bf242f9c30da343e7868ed97a [file] [log] [blame]
Logan Chien2833ffb2018-10-09 10:03:24 +08001/*===---- adxintrin.h - ADX intrinsics -------------------------------------===
2 *
Logan Chiendf4f7662019-09-04 16:45:23 -07003 * 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
Logan Chien2833ffb2018-10-09 10:03:24 +08006 *
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 */
21static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
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__
29static __inline unsigned char __attribute__((__always_inline__, __nodebug__, __target__("adx")))
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 */
38static __inline unsigned char __DEFAULT_FN_ATTRS
39_addcarry_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
40 unsigned int *__p)
41{
Logan Chiendbcf4122019-03-21 10:50:25 +080042 return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p);
Logan Chien2833ffb2018-10-09 10:03:24 +080043}
44
45#ifdef __x86_64__
46static __inline unsigned char __DEFAULT_FN_ATTRS
47_addcarry_u64(unsigned char __cf, unsigned long long __x,
48 unsigned long long __y, unsigned long long *__p)
49{
Logan Chiendbcf4122019-03-21 10:50:25 +080050 return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p);
Logan Chien2833ffb2018-10-09 10:03:24 +080051}
52#endif
53
54static __inline unsigned char __DEFAULT_FN_ATTRS
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__
62static __inline unsigned char __DEFAULT_FN_ATTRS
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 */