clang 22.0.0git
pmmintrin.h
Go to the documentation of this file.
1/*===---- pmmintrin.h - SSE3 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 __PMMINTRIN_H
11#define __PMMINTRIN_H
12
13#if !defined(__i386__) && !defined(__x86_64__)
14#error "This header is only meant to be used on x86 and x64 architecture"
15#endif
16
17#include <emmintrin.h>
18
19/* Define the default attributes for the functions in this file. */
20#define __DEFAULT_FN_ATTRS \
21 __attribute__((__always_inline__, __nodebug__, __target__("sse3"), \
22 __min_vector_width__(128)))
23
24#if defined(__cplusplus) && (__cplusplus >= 201103L)
25#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
26#else
27#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
28#endif
29
30/// Loads data from an unaligned memory location to elements in a 128-bit
31/// vector.
32///
33/// If the address of the data is not 16-byte aligned, the instruction may
34/// read two adjacent aligned blocks of memory to retrieve the requested
35/// data.
36///
37/// \headerfile <x86intrin.h>
38///
39/// This intrinsic corresponds to the <c> VLDDQU </c> instruction.
40///
41/// \param __p
42/// A pointer to a 128-bit integer vector containing integer values.
43/// \returns A 128-bit vector containing the moved values.
44static __inline__ __m128i __DEFAULT_FN_ATTRS
45_mm_lddqu_si128(__m128i_u const *__p)
46{
47 return (__m128i)__builtin_ia32_lddqu((char const *)__p);
48}
49
50/// Adds the even-indexed values and subtracts the odd-indexed values of
51/// two 128-bit vectors of [4 x float].
52///
53/// \headerfile <x86intrin.h>
54///
55/// This intrinsic corresponds to the <c> VADDSUBPS </c> instruction.
56///
57/// \param __a
58/// A 128-bit vector of [4 x float] containing the left source operand.
59/// \param __b
60/// A 128-bit vector of [4 x float] containing the right source operand.
61/// \returns A 128-bit vector of [4 x float] containing the alternating sums and
62/// differences of both operands.
63static __inline__ __m128 __DEFAULT_FN_ATTRS
64_mm_addsub_ps(__m128 __a, __m128 __b)
65{
66 return __builtin_ia32_addsubps((__v4sf)__a, (__v4sf)__b);
67}
68
69/// Horizontally adds the adjacent pairs of values contained in two
70/// 128-bit vectors of [4 x float].
71///
72/// \headerfile <x86intrin.h>
73///
74/// This intrinsic corresponds to the <c> VHADDPS </c> instruction.
75///
76/// \param __a
77/// A 128-bit vector of [4 x float] containing one of the source operands.
78/// The horizontal sums of the values are stored in the lower bits of the
79/// destination.
80/// \param __b
81/// A 128-bit vector of [4 x float] containing one of the source operands.
82/// The horizontal sums of the values are stored in the upper bits of the
83/// destination.
84/// \returns A 128-bit vector of [4 x float] containing the horizontal sums of
85/// both operands.
86static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hadd_ps(__m128 __a,
87 __m128 __b) {
88 return __builtin_ia32_haddps((__v4sf)__a, (__v4sf)__b);
89}
90
91/// Horizontally subtracts the adjacent pairs of values contained in two
92/// 128-bit vectors of [4 x float].
93///
94/// \headerfile <x86intrin.h>
95///
96/// This intrinsic corresponds to the <c> VHSUBPS </c> instruction.
97///
98/// \param __a
99/// A 128-bit vector of [4 x float] containing one of the source operands.
100/// The horizontal differences between the values are stored in the lower
101/// bits of the destination.
102/// \param __b
103/// A 128-bit vector of [4 x float] containing one of the source operands.
104/// The horizontal differences between the values are stored in the upper
105/// bits of the destination.
106/// \returns A 128-bit vector of [4 x float] containing the horizontal
107/// differences of both operands.
108static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hsub_ps(__m128 __a,
109 __m128 __b) {
110 return __builtin_ia32_hsubps((__v4sf)__a, (__v4sf)__b);
111}
112
113/// Moves and duplicates odd-indexed values from a 128-bit vector
114/// of [4 x float] to float values stored in a 128-bit vector of
115/// [4 x float].
116///
117/// \headerfile <x86intrin.h>
118///
119/// This intrinsic corresponds to the <c> VMOVSHDUP </c> instruction.
120///
121/// \param __a
122/// A 128-bit vector of [4 x float]. \n
123/// Bits [127:96] of the source are written to bits [127:96] and [95:64] of
124/// the destination. \n
125/// Bits [63:32] of the source are written to bits [63:32] and [31:0] of the
126/// destination.
127/// \returns A 128-bit vector of [4 x float] containing the moved and duplicated
128/// values.
129static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
131{
132 return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 1, 1, 3, 3);
133}
134
135/// Duplicates even-indexed values from a 128-bit vector of
136/// [4 x float] to float values stored in a 128-bit vector of [4 x float].
137///
138/// \headerfile <x86intrin.h>
139///
140/// This intrinsic corresponds to the <c> VMOVSLDUP </c> instruction.
141///
142/// \param __a
143/// A 128-bit vector of [4 x float] \n
144/// Bits [95:64] of the source are written to bits [127:96] and [95:64] of
145/// the destination. \n
146/// Bits [31:0] of the source are written to bits [63:32] and [31:0] of the
147/// destination.
148/// \returns A 128-bit vector of [4 x float] containing the moved and duplicated
149/// values.
150static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
152{
153 return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 2, 2);
154}
155
156/// Adds the even-indexed values and subtracts the odd-indexed values of
157/// two 128-bit vectors of [2 x double].
158///
159/// \headerfile <x86intrin.h>
160///
161/// This intrinsic corresponds to the <c> VADDSUBPD </c> instruction.
162///
163/// \param __a
164/// A 128-bit vector of [2 x double] containing the left source operand.
165/// \param __b
166/// A 128-bit vector of [2 x double] containing the right source operand.
167/// \returns A 128-bit vector of [2 x double] containing the alternating sums
168/// and differences of both operands.
169static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
170_mm_addsub_pd(__m128d __a, __m128d __b) {
171 return __builtin_ia32_addsubpd((__v2df)__a, (__v2df)__b);
172}
173
174/// Horizontally adds the pairs of values contained in two 128-bit
175/// vectors of [2 x double].
176///
177/// \headerfile <x86intrin.h>
178///
179/// This intrinsic corresponds to the <c> VHADDPD </c> instruction.
180///
181/// \param __a
182/// A 128-bit vector of [2 x double] containing one of the source operands.
183/// The horizontal sum of the values is stored in the lower bits of the
184/// destination.
185/// \param __b
186/// A 128-bit vector of [2 x double] containing one of the source operands.
187/// The horizontal sum of the values is stored in the upper bits of the
188/// destination.
189/// \returns A 128-bit vector of [2 x double] containing the horizontal sums of
190/// both operands.
191static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
192_mm_hadd_pd(__m128d __a, __m128d __b) {
193 return __builtin_ia32_haddpd((__v2df)__a, (__v2df)__b);
194}
195
196/// Horizontally subtracts the pairs of values contained in two 128-bit
197/// vectors of [2 x double].
198///
199/// \headerfile <x86intrin.h>
200///
201/// This intrinsic corresponds to the <c> VHSUBPD </c> instruction.
202///
203/// \param __a
204/// A 128-bit vector of [2 x double] containing one of the source operands.
205/// The horizontal difference of the values is stored in the lower bits of
206/// the destination.
207/// \param __b
208/// A 128-bit vector of [2 x double] containing one of the source operands.
209/// The horizontal difference of the values is stored in the upper bits of
210/// the destination.
211/// \returns A 128-bit vector of [2 x double] containing the horizontal
212/// differences of both operands.
213static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
214_mm_hsub_pd(__m128d __a, __m128d __b) {
215 return __builtin_ia32_hsubpd((__v2df)__a, (__v2df)__b);
216}
217
218/// Moves and duplicates one double-precision value to double-precision
219/// values stored in a 128-bit vector of [2 x double].
220///
221/// \headerfile <x86intrin.h>
222///
223/// \code
224/// __m128d _mm_loaddup_pd(double const *dp);
225/// \endcode
226///
227/// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction.
228///
229/// \param dp
230/// A pointer to a double-precision value to be moved and duplicated.
231/// \returns A 128-bit vector of [2 x double] containing the moved and
232/// duplicated values.
233#define _mm_loaddup_pd(dp) _mm_load1_pd(dp)
234
235/// Moves and duplicates the double-precision value in the lower bits of
236/// a 128-bit vector of [2 x double] to double-precision values stored in a
237/// 128-bit vector of [2 x double].
238///
239/// \headerfile <x86intrin.h>
240///
241/// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction.
242///
243/// \param __a
244/// A 128-bit vector of [2 x double]. Bits [63:0] are written to bits
245/// [127:64] and [63:0] of the destination.
246/// \returns A 128-bit vector of [2 x double] containing the moved and
247/// duplicated values.
248static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
250{
251 return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
252}
253
254/// Establishes a linear address memory range to be monitored and puts
255/// the processor in the monitor event pending state. Data stored in the
256/// monitored address range causes the processor to exit the pending state.
257///
258/// The \c MONITOR instruction can be used in kernel mode, and in other modes
259/// if MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
260///
261/// \headerfile <x86intrin.h>
262///
263/// This intrinsic corresponds to the \c MONITOR instruction.
264///
265/// \param __p
266/// The memory range to be monitored. The size of the range is determined by
267/// CPUID function 0000_0005h.
268/// \param __extensions
269/// Optional extensions for the monitoring state.
270/// \param __hints
271/// Optional hints for the monitoring state.
272static __inline__ void __DEFAULT_FN_ATTRS
273_mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
274{
275 __builtin_ia32_monitor(__p, __extensions, __hints);
276}
277
278/// Used with the \c MONITOR instruction to wait while the processor is in
279/// the monitor event pending state. Data stored in the monitored address
280/// range, or an interrupt, causes the processor to exit the pending state.
281///
282/// The \c MWAIT instruction can be used in kernel mode, and in other modes if
283/// MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
284///
285/// \headerfile <x86intrin.h>
286///
287/// This intrinsic corresponds to the \c MWAIT instruction.
288///
289/// \param __extensions
290/// Optional extensions for the monitoring state, which can vary by
291/// processor.
292/// \param __hints
293/// Optional hints for the monitoring state, which can vary by processor.
294static __inline__ void __DEFAULT_FN_ATTRS
295_mm_mwait(unsigned __extensions, unsigned __hints)
296{
297 __builtin_ia32_mwait(__extensions, __hints);
298}
299
300#undef __DEFAULT_FN_ATTRS
301#undef __DEFAULT_FN_ATTRS_CONSTEXPR
302
303#endif /* __PMMINTRIN_H */
#define __DEFAULT_FN_ATTRS
static __inline__ vector float vector float __b
Definition altivec.h:578
static __inline__ uint32_t volatile uint32_t * __p
Definition arm_acle.h:57
#define __DEFAULT_FN_ATTRS_CONSTEXPR
static __inline__ void int __a
Definition emmintrin.h:4077
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_addsub_pd(__m128d __a, __m128d __b)
Adds the even-indexed values and subtracts the odd-indexed values of two 128-bit vectors of [2 x doub...
Definition pmmintrin.h:170
static __inline__ void __DEFAULT_FN_ATTRS _mm_mwait(unsigned __extensions, unsigned __hints)
Used with the MONITOR instruction to wait while the processor is in the monitor event pending state.
Definition pmmintrin.h:295
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hsub_ps(__m128 __a, __m128 __b)
Horizontally subtracts the adjacent pairs of values contained in two 128-bit vectors of [4 x float].
Definition pmmintrin.h:108
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_movedup_pd(__m128d __a)
Moves and duplicates the double-precision value in the lower bits of a 128-bit vector of [2 x double]...
Definition pmmintrin.h:249
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_moveldup_ps(__m128 __a)
Duplicates even-indexed values from a 128-bit vector of [4 x float] to float values stored in a 128-b...
Definition pmmintrin.h:151
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hadd_ps(__m128 __a, __m128 __b)
Horizontally adds the adjacent pairs of values contained in two 128-bit vectors of [4 x float].
Definition pmmintrin.h:86
static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_addsub_ps(__m128 __a, __m128 __b)
Adds the even-indexed values and subtracts the odd-indexed values of two 128-bit vectors of [4 x floa...
Definition pmmintrin.h:64
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hsub_pd(__m128d __a, __m128d __b)
Horizontally subtracts the pairs of values contained in two 128-bit vectors of [2 x double].
Definition pmmintrin.h:214
static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_lddqu_si128(__m128i_u const *__p)
Loads data from an unaligned memory location to elements in a 128-bit vector.
Definition pmmintrin.h:45
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_movehdup_ps(__m128 __a)
Moves and duplicates odd-indexed values from a 128-bit vector of [4 x float] to float values stored i...
Definition pmmintrin.h:130
static __inline__ void __DEFAULT_FN_ATTRS _mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
Establishes a linear address memory range to be monitored and puts the processor in the monitor event...
Definition pmmintrin.h:273
static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hadd_pd(__m128d __a, __m128d __b)
Horizontally adds the pairs of values contained in two 128-bit vectors of [2 x double].
Definition pmmintrin.h:192