Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/include/compat/pmmintrin.h
6171 views
1
/*
2
* Copyright 2020 The Emscripten Authors. All rights reserved.
3
* Emscripten is available under two separate licenses, the MIT license and the
4
* University of Illinois/NCSA Open Source License. Both these licenses can be
5
* found in the LICENSE file.
6
*/
7
#ifndef __emscripten_pmmintrin_h__
8
#define __emscripten_pmmintrin_h__
9
10
#ifndef __SSE3__
11
#error "SSE3 instruction set not enabled"
12
#endif
13
14
#include <emmintrin.h>
15
16
static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
17
_mm_lddqu_si128(__m128i const *__p)
18
{
19
return _mm_loadu_si128(__p);
20
}
21
22
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
23
_mm_addsub_ps(__m128 __a, __m128 __b)
24
{
25
return _mm_add_ps(__a, _mm_mul_ps(__b, _mm_set_ps(1.f, -1.f, 1.f, -1.f)));
26
}
27
28
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
29
_mm_hadd_ps(__m128 __a, __m128 __b)
30
{
31
return _mm_add_ps(_mm_shuffle_ps(__a, __b, _MM_SHUFFLE(2, 0, 2, 0)), _mm_shuffle_ps(__a, __b, _MM_SHUFFLE(3, 1, 3, 1)));
32
}
33
34
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
35
_mm_hsub_ps(__m128 __a, __m128 __b)
36
{
37
return _mm_sub_ps(_mm_shuffle_ps(__a, __b, _MM_SHUFFLE(2, 0, 2, 0)), _mm_shuffle_ps(__a, __b, _MM_SHUFFLE(3, 1, 3, 1)));
38
}
39
40
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
41
_mm_movehdup_ps(__m128 __a)
42
{
43
return (__m128)wasm_i32x4_shuffle(__a, __a, 1, 1, 3, 3);
44
}
45
46
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
47
_mm_moveldup_ps(__m128 __a)
48
{
49
return (__m128)wasm_i32x4_shuffle(__a, __a, 0, 0, 2, 2);
50
}
51
52
static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
53
_mm_addsub_pd(__m128d __a, __m128d __b)
54
{
55
return _mm_add_pd(__a, _mm_mul_pd(__b, _mm_set_pd(1.0, -1.0)));
56
}
57
58
static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
59
_mm_hadd_pd(__m128d __a, __m128d __b)
60
{
61
return _mm_add_pd(_mm_shuffle_pd(__a, __b, _MM_SHUFFLE2(0, 0)), _mm_shuffle_pd(__a, __b, _MM_SHUFFLE2(1, 1)));
62
}
63
64
static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
65
_mm_hsub_pd(__m128d __a, __m128d __b)
66
{
67
return _mm_sub_pd(_mm_shuffle_pd(__a, __b, _MM_SHUFFLE2(0, 0)), _mm_shuffle_pd(__a, __b, _MM_SHUFFLE2(1, 1)));
68
}
69
70
#define _mm_loaddup_pd(dp) _mm_load1_pd(dp)
71
72
static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
73
_mm_movedup_pd(__m128d __a)
74
{
75
return (__m128d)wasm_i64x2_shuffle(__a, __a, 0, 0);
76
}
77
78
#define _MM_DENORMALS_ZERO_ON (0x0040)
79
#define _MM_DENORMALS_ZERO_OFF (0x0000)
80
#define _MM_DENORMALS_ZERO_MASK (0x0040)
81
#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
82
83
// Unavailable functions:
84
// #define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x)))
85
// void _mm_monitor(void const *__p, unsigned __extensions, unsigned __hints);
86
// void _mm_mwait(unsigned __extensions, unsigned __hints);
87
88
#endif /* __emscripten_pmmintrin_h__ */
89
90