Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 1 | /*===---- adxintrin.h - ADX intrinsics -------------------------------------=== |
| 2 | * |
Logan Chien | df4f766 | 2019-09-04 16:45:23 -0700 | [diff] [blame] | 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 |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 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"))) |
| 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"))) |
| 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 |
| 39 | _addcarry_u32(unsigned char __cf, unsigned int __x, unsigned int __y, |
| 40 | unsigned int *__p) |
| 41 | { |
Logan Chien | dbcf412 | 2019-03-21 10:50:25 +0800 | [diff] [blame] | 42 | return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p); |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | #ifdef __x86_64__ |
| 46 | static __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 Chien | dbcf412 | 2019-03-21 10:50:25 +0800 | [diff] [blame] | 50 | return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p); |
Logan Chien | 2833ffb | 2018-10-09 10:03:24 +0800 | [diff] [blame] | 51 | } |
| 52 | #endif |
| 53 | |
| 54 | static __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__ |
| 62 | static __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 */ |