LMMS
Loading...
Searching...
No Matches
juce_SIMDRegister_Impl.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28namespace dsp
29{
30
31
32//==============================================================================
33template <typename Type>
35{
36 ElementAccess (const ElementAccess&) = default;
37 operator Type() const { return simd.get (idx); }
38 ElementAccess& operator= (Type scalar) noexcept { simd.set (idx, scalar); return *this; }
39 ElementAccess& operator= (const ElementAccess& o) noexcept { return operator= ((Type) o); }
40
41private:
42 friend struct SIMDRegister;
43 ElementAccess (SIMDRegister& owner, size_t index) noexcept : simd (owner), idx (index) {}
45 size_t idx;
46};
47
48#ifndef DOXYGEN
49//==============================================================================
50/* This class is used internally by SIMDRegister to abstract away differences
51 in operations which are different for complex and pure floating point types. */
52
53// the pure floating-point version
54template <typename Scalar>
56{
58
59 static vSIMDType JUCE_VECTOR_CALLTYPE load (const Scalar* a) noexcept
60 {
62 }
63
64 static void JUCE_VECTOR_CALLTYPE store (vSIMDType value, Scalar* dest) noexcept
65 {
67 }
68
69 static vSIMDType JUCE_VECTOR_CALLTYPE expand (Scalar s) noexcept
70 {
72 }
73
74 static Scalar JUCE_VECTOR_CALLTYPE get (vSIMDType v, std::size_t i) noexcept
75 {
77 }
78
79 static vSIMDType JUCE_VECTOR_CALLTYPE set (vSIMDType v, std::size_t i, Scalar s) noexcept
80 {
82 }
83
84 static Scalar JUCE_VECTOR_CALLTYPE sum (vSIMDType a) noexcept
85 {
87 }
88
93
98};
99
100// The pure complex version
101template <typename Scalar>
102struct CmplxSIMDOps<std::complex<Scalar>>
103{
105
107 {
108 return SIMDNativeOps<Scalar>::load (reinterpret_cast<const Scalar*> (a));
109 }
110
112 {
113 SIMDNativeOps<Scalar>::store (value, reinterpret_cast<Scalar*> (dest));
114 }
115
117 {
118 const int n = sizeof (vSIMDType) / sizeof (Scalar);
119
120 union
121 {
122 vSIMDType v;
123 Scalar floats[(size_t) n];
124 } u;
125
126 for (int i = 0; i < n; ++i)
127 u.floats[i] = (i & 1) == 0 ? s.real() : s.imag();
128
129 return u.v;
130 }
131
133 {
134 auto j = i << 1;
136 }
137
139 {
140 auto j = i << 1;
141 return SIMDNativeOps<Scalar>::set (SIMDNativeOps<Scalar>::set (v, j, s.real()), j + 1, s.imag());
142 }
143
145 {
147 auto* ptr = reinterpret_cast<const Scalar*> (&result);
148 return std::complex<Scalar> (ptr[0], ptr[1]);
149 }
150
155
160};
161#endif
162
163//==============================================================================
164 namespace util
165 {
166 template <typename Type>
167 inline void snapToZero (SIMDRegister<Type>&) noexcept {}
168 }
169
170} // namespace dsp
171
172// Extend some common used global functions to SIMDRegister types
173template <typename Type>
175template <typename Type>
177
178} // namespace juce
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
uint8_t a
Definition Spc_Cpu.h:141
register unsigned j
Definition inflate.c:1576
unsigned v[N_MAX]
Definition inflate.c:1584
struct huft * u[BMAX]
Definition inflate.c:1583
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
static PuglViewHint int value
Definition pugl.h:1708
#define JUCE_VECTOR_CALLTYPE
Definition juce_dsp.h:100
Definition juce_SIMDRegister_Impl.h:165
void snapToZero(SIMDRegister< Type > &) noexcept
Definition juce_SIMDRegister_Impl.h:167
Definition juce_AudioBlock.h:29
Definition carla_juce.cpp:31
jack_client_t client jack_client_t client jack_client_t client jack_client_t JackInfoShutdownCallback void arg jack_client_t jack_port_t port void func jack_client_t const char const char unsigned long flags const jack_port_t port jack_client_t jack_port_id_t port_id const jack_port_t const char port_name const jack_port_t port void * ptr
Definition juce_linux_JackAudio.cpp:79
Definition juce_Uuid.h:141
static std::complex< Scalar > JUCE_VECTOR_CALLTYPE sum(vSIMDType a) noexcept
Definition juce_SIMDRegister_Impl.h:144
static std::complex< Scalar > JUCE_VECTOR_CALLTYPE get(vSIMDType v, std::size_t i) noexcept
Definition juce_SIMDRegister_Impl.h:132
static vSIMDType JUCE_VECTOR_CALLTYPE expand(std::complex< Scalar > s) noexcept
Definition juce_SIMDRegister_Impl.h:116
static vSIMDType JUCE_VECTOR_CALLTYPE mul(vSIMDType a, vSIMDType b) noexcept
Definition juce_SIMDRegister_Impl.h:151
static vSIMDType JUCE_VECTOR_CALLTYPE muladd(vSIMDType a, vSIMDType b, vSIMDType c) noexcept
Definition juce_SIMDRegister_Impl.h:156
static vSIMDType JUCE_VECTOR_CALLTYPE load(const std::complex< Scalar > *a) noexcept
Definition juce_SIMDRegister_Impl.h:106
static void JUCE_VECTOR_CALLTYPE store(vSIMDType value, std::complex< Scalar > *dest) noexcept
Definition juce_SIMDRegister_Impl.h:111
typename SIMDNativeOps< Scalar >::vSIMDType vSIMDType
Definition juce_SIMDRegister_Impl.h:104
static vSIMDType JUCE_VECTOR_CALLTYPE set(vSIMDType v, std::size_t i, std::complex< Scalar > s) noexcept
Definition juce_SIMDRegister_Impl.h:138
Definition juce_SIMDRegister_Impl.h:56
static vSIMDType JUCE_VECTOR_CALLTYPE load(const Scalar *a) noexcept
Definition juce_SIMDRegister_Impl.h:59
typename SIMDNativeOps< ElementType >::vSIMDType vSIMDType
Definition juce_SIMDRegister_Impl.h:57
static void JUCE_VECTOR_CALLTYPE store(vSIMDType value, Scalar *dest) noexcept
Definition juce_SIMDRegister_Impl.h:64
static Scalar JUCE_VECTOR_CALLTYPE sum(vSIMDType a) noexcept
Definition juce_SIMDRegister_Impl.h:84
static vSIMDType JUCE_VECTOR_CALLTYPE muladd(vSIMDType a, vSIMDType b, vSIMDType c) noexcept
Definition juce_SIMDRegister_Impl.h:94
static vSIMDType JUCE_VECTOR_CALLTYPE mul(vSIMDType a, vSIMDType b) noexcept
Definition juce_SIMDRegister_Impl.h:89
static vSIMDType JUCE_VECTOR_CALLTYPE set(vSIMDType v, std::size_t i, Scalar s) noexcept
Definition juce_SIMDRegister_Impl.h:79
static vSIMDType JUCE_VECTOR_CALLTYPE expand(Scalar s) noexcept
Definition juce_SIMDRegister_Impl.h:69
static Scalar JUCE_VECTOR_CALLTYPE get(vSIMDType v, std::size_t i) noexcept
Definition juce_SIMDRegister_Impl.h:74
Definition juce_avx_SIMDNativeOps.h:52
size_t idx
Definition juce_SIMDRegister_Impl.h:45
SIMDRegister & simd
Definition juce_SIMDRegister_Impl.h:44
friend struct SIMDRegister
Definition juce_SIMDRegister_Impl.h:42
ElementAccess(const ElementAccess &)=default
ElementAccess(SIMDRegister &owner, size_t index) noexcept
Definition juce_SIMDRegister_Impl.h:43
Definition juce_SIMDRegister.h:63
static SIMDRegister JUCE_VECTOR_CALLTYPE max(SIMDRegister a, SIMDRegister b) noexcept
Definition juce_SIMDRegister.h:314
static SIMDRegister JUCE_VECTOR_CALLTYPE min(SIMDRegister a, SIMDRegister b) noexcept
Definition juce_SIMDRegister.h:311
Definition globals.h:33
int n
Definition crypt.c:458
return c
Definition crypt.c:175
b
Definition crypt.c:628
int result
Definition process.c:1455