xref: /openbsd-src/gnu/llvm/clang/lib/Headers/cmpccxaddintrin.h (revision 12c855180aad702bbcca06e0398d774beeafb155)
1*12c85518Srobert /*===--------------- cmpccxaddintrin.h - CMPCCXADD intrinsics--------------===
2*12c85518Srobert  *
3*12c85518Srobert  *
4*12c85518Srobert  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*12c85518Srobert  * See https://llvm.org/LICENSE.txt for license information.
6*12c85518Srobert  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*12c85518Srobert  *
8*12c85518Srobert  *===-----------------------------------------------------------------------===
9*12c85518Srobert  */
10*12c85518Srobert #ifndef __X86GPRINTRIN_H
11*12c85518Srobert #error                                                                         \
12*12c85518Srobert     "Never use <cmpccxaddintrin.h> directly; include <x86gprintrin.h> instead."
13*12c85518Srobert #endif // __X86GPRINTRIN_H
14*12c85518Srobert 
15*12c85518Srobert #ifndef __CMPCCXADDINTRIN_H
16*12c85518Srobert #define __CMPCCXADDINTRIN_H
17*12c85518Srobert #ifdef __x86_64__
18*12c85518Srobert 
19*12c85518Srobert typedef enum {
20*12c85518Srobert   _CMPCCX_O,   /* Overflow.  */
21*12c85518Srobert   _CMPCCX_NO,  /* No overflow.  */
22*12c85518Srobert   _CMPCCX_B,   /* Below.  */
23*12c85518Srobert   _CMPCCX_NB,  /* Not below.  */
24*12c85518Srobert   _CMPCCX_Z,   /* Zero.  */
25*12c85518Srobert   _CMPCCX_NZ,  /* Not zero.  */
26*12c85518Srobert   _CMPCCX_BE,  /* Below or equal.  */
27*12c85518Srobert   _CMPCCX_NBE, /* Neither below nor equal.  */
28*12c85518Srobert   _CMPCCX_S,   /* Sign.  */
29*12c85518Srobert   _CMPCCX_NS,  /* No sign.  */
30*12c85518Srobert   _CMPCCX_P,   /* Parity.  */
31*12c85518Srobert   _CMPCCX_NP,  /* No parity.  */
32*12c85518Srobert   _CMPCCX_L,   /* Less.  */
33*12c85518Srobert   _CMPCCX_NL,  /* Not less.  */
34*12c85518Srobert   _CMPCCX_LE,  /* Less or equal.  */
35*12c85518Srobert   _CMPCCX_NLE, /* Neither less nor equal.  */
36*12c85518Srobert } _CMPCCX_ENUM;
37*12c85518Srobert 
38*12c85518Srobert /// Compares the value from the memory __A with the value of __B. If the
39*12c85518Srobert /// specified condition __D is met, then add the third operand __C to the
40*12c85518Srobert /// __A and write it into __A, else the value of __A is unchanged. The return
41*12c85518Srobert /// value is the original value of __A.
42*12c85518Srobert ///
43*12c85518Srobert /// \headerfile <immintrin.h>
44*12c85518Srobert ///
45*12c85518Srobert /// This intrinsic corresponds to the \c CMPCCXADD instructions.
46*12c85518Srobert ///
47*12c85518Srobert /// \param __A
48*12c85518Srobert ///    __A pointer specifying the memory address.
49*12c85518Srobert ///
50*12c85518Srobert /// \param __B
51*12c85518Srobert ///   A integer operand.
52*12c85518Srobert ///
53*12c85518Srobert /// \param __C
54*12c85518Srobert ///   A integer operand.
55*12c85518Srobert ///
56*12c85518Srobert /// \param __D
57*12c85518Srobert ///   The specified condition.
58*12c85518Srobert ///
59*12c85518Srobert /// \returns a integer which is the original value of first operand.
60*12c85518Srobert 
61*12c85518Srobert #define _cmpccxadd_epi32(__A, __B, __C, __D)                                   \
62*12c85518Srobert   ((int)(__builtin_ia32_cmpccxadd32((void *)(__A), (int)(__B), (int)(__C),     \
63*12c85518Srobert                                     (int)(__D))))
64*12c85518Srobert 
65*12c85518Srobert #define _cmpccxadd_epi64(__A, __B, __C, __D)                                   \
66*12c85518Srobert   ((long long)(__builtin_ia32_cmpccxadd64((void *)(__A), (long long)(__B),     \
67*12c85518Srobert                                           (long long)(__C), (int)(__D))))
68*12c85518Srobert 
69*12c85518Srobert #endif // __x86_64__
70*12c85518Srobert #endif // __CMPCCXADDINTRIN_H
71