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_CONSTEXPR
64_mm_addsub_ps(__m128 __a, __m128 __b) {
65 return __builtin_ia32_addsubps((__v4sf)__a, (__v4sf)__b);
66}
67
68/// Horizontally adds the adjacent pairs of values contained in two
69/// 128-bit vectors of [4 x float].
70///
71/// \headerfile <x86intrin.h>
72///
73/// This intrinsic corresponds to the <c> VHADDPS </c> instruction.
74///
75/// \param __a
76/// A 128-bit vector of [4 x float] containing one of the source operands.
77/// The horizontal sums of the values are stored in the lower bits of the
78/// destination.
79/// \param __b
80/// A 128-bit vector of [4 x float] containing one of the source operands.
81/// The horizontal sums of the values are stored in the upper bits of the
82/// destination.
83/// \returns A 128-bit vector of [4 x float] containing the horizontal sums of
84/// both operands.
85static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hadd_ps(__m128 __a,
86 __m128 __b) {
87 return __builtin_ia32_haddps((__v4sf)__a, (__v4sf)__b);
88}
89
90/// Horizontally subtracts the adjacent pairs of values contained in two
91/// 128-bit vectors of [4 x float].
92///
93/// \headerfile <x86intrin.h>
94///
95/// This intrinsic corresponds to the <c> VHSUBPS </c> instruction.
96///
97/// \param __a
98/// A 128-bit vector of [4 x float] containing one of the source operands.
99/// The horizontal differences between the values are stored in the lower
100/// bits of the destination.
101/// \param __b
102/// A 128-bit vector of [4 x float] containing one of the source operands.
103/// The horizontal differences between the values are stored in the upper
104/// bits of the destination.
105/// \returns A 128-bit vector of [4 x float] containing the horizontal
106/// differences of both operands.
107static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_hsub_ps(__m128 __a,
108 __m128 __b) {
109 return __builtin_ia32_hsubps((__v4sf)__a, (__v4sf)__b);
110}
111
112/// Moves and duplicates odd-indexed values from a 128-bit vector
113/// of [4 x float] to float values stored in a 128-bit vector of
114/// [4 x float].
115///
116/// \headerfile <x86intrin.h>
117///
118/// This intrinsic corresponds to the <c> VMOVSHDUP </c> instruction.
119///
120/// \param __a
121/// A 128-bit vector of [4 x float]. \n
122/// Bits [127:96] of the source are written to bits [127:96] and [95:64] of
123/// the destination. \n
124/// Bits [63:32] of the source are written to bits [63:32] and [31:0] of the
125/// destination.
126/// \returns A 128-bit vector of [4 x float] containing the moved and duplicated
127/// values.
128static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
130{
131 return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 1, 1, 3, 3);
132}
133
134/// Duplicates even-indexed values from a 128-bit vector of
135/// [4 x float] to float values stored in a 128-bit vector of [4 x float].
136///
137/// \headerfile <x86intrin.h>
138///
139/// This intrinsic corresponds to the <c> VMOVSLDUP </c> instruction.
140///
141/// \param __a
142/// A 128-bit vector of [4 x float] \n
143/// Bits [95:64] of the source are written to bits [127:96] and [95:64] of
144/// the destination. \n
145/// Bits [31:0] of the source are written to bits [63:32] and [31:0] of the
146/// destination.
147/// \returns A 128-bit vector of [4 x float] containing the moved and duplicated
148/// values.
149static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR
151{
152 return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 2, 2);
153}
154
155/// Adds the even-indexed values and subtracts the odd-indexed values of
156/// two 128-bit vectors of [2 x double].
157///
158/// \headerfile <x86intrin.h>
159///
160/// This intrinsic corresponds to the <c> VADDSUBPD </c> instruction.
161///
162/// \param __a
163/// A 128-bit vector of [2 x double] containing the left source operand.
164/// \param __b
165/// A 128-bit vector of [2 x double] containing the right source operand.
166/// \returns A 128-bit vector of [2 x double] containing the alternating sums
167/// and differences of both operands.
168static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
169_mm_addsub_pd(__m128d __a, __m128d __b) {
170 return __builtin_ia32_addsubpd((__v2df)__a, (__v2df)__b);
171}
172
173/// Horizontally adds the pairs of values contained in two 128-bit
174/// vectors of [2 x double].
175///
176/// \headerfile <x86intrin.h>
177///
178/// This intrinsic corresponds to the <c> VHADDPD </c> instruction.
179///
180/// \param __a
181/// A 128-bit vector of [2 x double] containing one of the source operands.
182/// The horizontal sum of the values is stored in the lower bits of the
183/// destination.
184/// \param __b
185/// A 128-bit vector of [2 x double] containing one of the source operands.
186/// The horizontal sum of the values is stored in the upper bits of the
187/// destination.
188/// \returns A 128-bit vector of [2 x double] containing the horizontal sums of
189/// both operands.
190static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
191_mm_hadd_pd(__m128d __a, __m128d __b) {
192 return __builtin_ia32_haddpd((__v2df)__a, (__v2df)__b);
193}
194
195/// Horizontally subtracts the pairs of values contained in two 128-bit
196/// vectors of [2 x double].
197///
198/// \headerfile <x86intrin.h>
199///
200/// This intrinsic corresponds to the <c> VHSUBPD </c> instruction.
201///
202/// \param __a
203/// A 128-bit vector of [2 x double] containing one of the source operands.
204/// The horizontal difference of the values is stored in the lower bits of
205/// the destination.
206/// \param __b
207/// A 128-bit vector of [2 x double] containing one of the source operands.
208/// The horizontal difference of the values is stored in the upper bits of
209/// the destination.
210/// \returns A 128-bit vector of [2 x double] containing the horizontal
211/// differences of both operands.
212static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
213_mm_hsub_pd(__m128d __a, __m128d __b) {
214 return __builtin_ia32_hsubpd((__v2df)__a, (__v2df)__b);
215}
216
217/// Moves and duplicates one double-precision value to double-precision
218/// values stored in a 128-bit vector of [2 x double].
219///
220/// \headerfile <x86intrin.h>
221///
222/// \code
223/// __m128d _mm_loaddup_pd(double const *dp);
224/// \endcode
225///
226/// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction.
227///
228/// \param dp
229/// A pointer to a double-precision value to be moved and duplicated.
230/// \returns A 128-bit vector of [2 x double] containing the moved and
231/// duplicated values.
232#define _mm_loaddup_pd(dp) _mm_load1_pd(dp)
233
234/// Moves and duplicates the double-precision value in the lower bits of
235/// a 128-bit vector of [2 x double] to double-precision values stored in a
236/// 128-bit vector of [2 x double].
237///
238/// \headerfile <x86intrin.h>
239///
240/// This intrinsic corresponds to the <c> VMOVDDUP </c> instruction.
241///
242/// \param __a
243/// A 128-bit vector of [2 x double]. Bits [63:0] are written to bits
244/// [127:64] and [63:0] of the destination.
245/// \returns A 128-bit vector of [2 x double] containing the moved and
246/// duplicated values.
247static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR
249{
250 return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
251}
252
253/// Establishes a linear address memory range to be monitored and puts
254/// the processor in the monitor event pending state. Data stored in the
255/// monitored address range causes the processor to exit the pending state.
256///
257/// The \c MONITOR instruction can be used in kernel mode, and in other modes
258/// if MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
259///
260/// \headerfile <x86intrin.h>
261///
262/// This intrinsic corresponds to the \c MONITOR instruction.
263///
264/// \param __p
265/// The memory range to be monitored. The size of the range is determined by
266/// CPUID function 0000_0005h.
267/// \param __extensions
268/// Optional extensions for the monitoring state.
269/// \param __hints
270/// Optional hints for the monitoring state.
271static __inline__ void __DEFAULT_FN_ATTRS
272_mm_monitor(void const *__p, unsigned __extensions, unsigned __hints)
273{
274 __builtin_ia32_monitor(__p, __extensions, __hints);
275}
276
277/// Used with the \c MONITOR instruction to wait while the processor is in
278/// the monitor event pending state. Data stored in the monitored address
279/// range, or an interrupt, causes the processor to exit the pending state.
280///
281/// The \c MWAIT instruction can be used in kernel mode, and in other modes if
282/// MSR <c> C001_0015h[MonMwaitUserEn] </c> is set.
283///
284/// \headerfile <x86intrin.h>
285///
286/// This intrinsic corresponds to the \c MWAIT instruction.
287///
288/// \param __extensions
289/// Optional extensions for the monitoring state, which can vary by
290/// processor.
291/// \param __hints
292/// Optional hints for the monitoring state, which can vary by processor.
293static __inline__ void __DEFAULT_FN_ATTRS
294_mm_mwait(unsigned __extensions, unsigned __hints)
295{
296 __builtin_ia32_mwait(__extensions, __hints);
297}
298
299#undef __DEFAULT_FN_ATTRS
300#undef __DEFAULT_FN_ATTRS_CONSTEXPR
301
302#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:169
static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _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__ 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:294
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:107
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:248
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:150
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:85
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:213
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:129
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:272
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:191