aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Headers/raointintrin.h
blob: d3290eb62abf8c0bbf5bc1929bad4854fa8b4275 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*===----------------------- raointintrin.h - RAOINT ------------------------===
 *
 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 * See https://llvm.org/LICENSE.txt for license information.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 *
 *===-----------------------------------------------------------------------===
 */

#ifndef __X86GPRINTRIN_H
#error "Never use <raointintrin.h> directly; include <x86gprintrin.h> instead."
#endif // __X86GPRINTRIN_H

#ifndef __RAOINTINTRIN_H
#define __RAOINTINTRIN_H

#define __DEFAULT_FN_ATTRS                                                     \
  __attribute__((__always_inline__, __nodebug__, __target__("raoint")))

/// Atomically add a 32-bit value at memory operand \a __A and a 32-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AADD instruction.
///
/// \param __A
///    A pointer to a 32-bit memory location.
/// \param __B
///    A 32-bit integer value.
///
/// \code{.operation}
/// MEM[__A+31:__A] := MEM[__A+31:__A] + __B[31:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _aadd_i32(int *__A, int __B) {
  __builtin_ia32_aadd32((int *)__A, __B);
}

/// Atomically and a 32-bit value at memory operand \a __A and a 32-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AAND instruction.
///
/// \param __A
///    A pointer to a 32-bit memory location.
/// \param __B
///    A 32-bit integer value.
///
/// \code{.operation}
/// MEM[__A+31:__A] := MEM[__A+31:__A] AND __B[31:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _aand_i32(int *__A, int __B) {
  __builtin_ia32_aand32((int *)__A, __B);
}

/// Atomically or a 32-bit value at memory operand \a __A and a 32-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AOR instruction.
///
/// \param __A
///    A pointer to a 32-bit memory location.
/// \param __B
///    A 32-bit integer value.
///
/// \code{.operation}
/// MEM[__A+31:__A] := MEM[__A+31:__A] OR __B[31:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _aor_i32(int *__A, int __B) {
  __builtin_ia32_aor32((int *)__A, __B);
}

/// Atomically xor a 32-bit value at memory operand \a __A and a 32-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AXOR instruction.
///
/// \param __A
///    A pointer to a 32-bit memory location.
/// \param __B
///    A 32-bit integer value.
///
/// \code{.operation}
/// MEM[__A+31:__A] := MEM[__A+31:__A] XOR __B[31:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _axor_i32(int *__A, int __B) {
  __builtin_ia32_axor32((int *)__A, __B);
}

#ifdef __x86_64__
/// Atomically add a 64-bit value at memory operand \a __A and a 64-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AADD instruction.
///
/// \param __A
///    A pointer to a 64-bit memory location.
/// \param __B
///    A 64-bit integer value.
///
/// \code{.operation}
/// MEM[__A+63:__A] := MEM[__A+63:__A] + __B[63:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _aadd_i64(long long *__A,
                                                    long long __B) {
  __builtin_ia32_aadd64((long long *)__A, __B);
}

/// Atomically and a 64-bit value at memory operand \a __A and a 64-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AAND instruction.
///
/// \param __A
///    A pointer to a 64-bit memory location.
/// \param __B
///    A 64-bit integer value.
///
/// \code{.operation}
/// MEM[__A+63:__A] := MEM[__A+63:__A] AND __B[63:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _aand_i64(long long *__A,
                                                    long long __B) {
  __builtin_ia32_aand64((long long *)__A, __B);
}

/// Atomically or a 64-bit value at memory operand \a __A and a 64-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AOR instruction.
///
/// \param __A
///    A pointer to a 64-bit memory location.
/// \param __B
///    A 64-bit integer value.
///
/// \code{.operation}
/// MEM[__A+63:__A] := MEM[__A+63:__A] OR __B[63:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _aor_i64(long long *__A,
                                                   long long __B) {
  __builtin_ia32_aor64((long long *)__A, __B);
}

/// Atomically xor a 64-bit value at memory operand \a __A and a 64-bit \a __B,
///    and store the result to the same memory location.
///
///    This intrinsic should be used for contention or weak ordering. It may
///    result in bad performance for hot data used by single thread only.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the \c AXOR instruction.
///
/// \param __A
///    A pointer to a 64-bit memory location.
/// \param __B
///    A 64-bit integer value.
///
/// \code{.operation}
/// MEM[__A+63:__A] := MEM[__A+63:__A] XOR __B[63:0]
/// \endcode
static __inline__ void __DEFAULT_FN_ATTRS _axor_i64(long long *__A,
                                                    long long __B) {
  __builtin_ia32_axor64((long long *)__A, __B);
}
#endif // __x86_64__

#undef __DEFAULT_FN_ATTRS
#endif // __RAOINTINTRIN_H