Debian Codegraph @

third-party/simde/mips/msa/ld.h

raw
1 /* SPDX-License-Identifier: MIT
2 *
3 * Permission is hereby granted, free of charge, to any person
4 * obtaining a copy of this software and associated documentation
5 * files (the "Software"), to deal in the Software without
6 * restriction, including without limitation the rights to use, copy,
7 * modify, merge, publish, distribute, sublicense, and/or sell copies
8 * of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Copyright:
24 * 2021 Evan Nemerson <[email protected]>
25 */
26
27 #if !defined(SIMDE_MIPS_MSA_LD_H)
28 #define SIMDE_MIPS_MSA_LD_H
29
30 #include "types.h"
31
32 HEDLEY_DIAGNOSTIC_PUSH
33 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
34 SIMDE_BEGIN_DECLS_
35
36 SIMDE_FUNCTION_ATTRIBUTES
37 simde_v16i8
38 simde_msa_ld_b(const void * rs, const int s10)
39 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023) {
40 #if defined(SIMDE_MIPS_MSA_NATIVE)
41 return __msa_ld_b(rs, s10);
42 #else
43 simde_v16i8 r;
44
45 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
46
47 return r;
48 #endif
49 }
50 #if defined(SIMDE_MIPS_MSA_ENABLE_NATIVE_ALIASES)
51 #undef __msa_ld_b
52 #define __msa_ld_b(rs, s10) simde_msa_ld_b((rs), (s10))
53 #endif
54
55 SIMDE_FUNCTION_ATTRIBUTES
56 simde_v8i16
57 simde_msa_ld_h(const void * rs, const int s10)
58 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
59 HEDLEY_REQUIRE_MSG((s10 % sizeof(int16_t)) == 0, "`s10' must be a multiple of sizeof(int16_t)") {
60 #if defined(SIMDE_MIPS_MSA_NATIVE)
61 return __msa_ld_h(rs, s10);
62 #else
63 simde_v8i16 r;
64
65 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
66
67 return r;
68 #endif
69 }
70 #if defined(SIMDE_MIPS_MSA_ENABLE_NATIVE_ALIASES)
71 #undef __msa_ld_h
72 #define __msa_ld_h(rs, s10) simde_msa_ld_h((rs), (s10))
73 #endif
74
75 SIMDE_FUNCTION_ATTRIBUTES
76 simde_v4i32
77 simde_msa_ld_w(const void * rs, const int s10)
78 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
79 HEDLEY_REQUIRE_MSG((s10 % sizeof(int32_t)) == 0, "`s10' must be a multiple of sizeof(int32_t)") {
80 #if defined(SIMDE_MIPS_MSA_NATIVE)
81 return __msa_ld_w(rs, s10);
82 #else
83 simde_v4i32 r;
84
85 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
86
87 return r;
88 #endif
89 }
90 #if defined(SIMDE_MIPS_MSA_ENABLE_NATIVE_ALIASES)
91 #undef __msa_ld_w
92 #define __msa_ld_w(rs, s10) simde_msa_ld_w((rs), (s10))
93 #endif
94
95 SIMDE_FUNCTION_ATTRIBUTES
96 simde_v2i64
97 simde_msa_ld_d(const void * rs, const int s10)
98 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
99 HEDLEY_REQUIRE_MSG((s10 % sizeof(int64_t)) == 0, "`s10' must be a multiple of sizeof(int64_t)") {
100 #if defined(SIMDE_MIPS_MSA_NATIVE)
101 return __msa_ld_d(rs, s10);
102 #else
103 simde_v2i64 r;
104
105 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
106
107 return r;
108 #endif
109 }
110 #if defined(SIMDE_MIPS_MSA_ENABLE_NATIVE_ALIASES)
111 #undef __msa_ld_d
112 #define __msa_ld_d(rs, s10) simde_msa_ld_d((rs), (s10))
113 #endif
114
115 SIMDE_FUNCTION_ATTRIBUTES
116 simde_v16u8
117 simde_x_msa_ld_u_b(const void * rs, const int s10)
118 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023) {
119 #if defined(SIMDE_MIPS_MSA_NATIVE)
120 return HEDLEY_REINTERPRET_CAST(simde_v16u8, __msa_ld_b(rs, s10));
121 #else
122 simde_v16u8 r;
123
124 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
125
126 return r;
127 #endif
128 }
129
130 SIMDE_FUNCTION_ATTRIBUTES
131 simde_v8u16
132 simde_x_msa_ld_u_h(const void * rs, const int s10)
133 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
134 HEDLEY_REQUIRE_MSG((s10 % sizeof(int16_t)) == 0, "`s10' must be a multiple of sizeof(int16_t)") {
135 #if defined(SIMDE_MIPS_MSA_NATIVE)
136 return HEDLEY_REINTERPRET_CAST(simde_v8u16, __msa_ld_b(rs, s10));
137 #else
138 simde_v8u16 r;
139
140 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
141
142 return r;
143 #endif
144 }
145
146 SIMDE_FUNCTION_ATTRIBUTES
147 simde_v4u32
148 simde_x_msa_ld_u_w(const void * rs, const int s10)
149 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
150 HEDLEY_REQUIRE_MSG((s10 % sizeof(int32_t)) == 0, "`s10' must be a multiple of sizeof(int32_t)") {
151 #if defined(SIMDE_MIPS_MSA_NATIVE)
152 return HEDLEY_REINTERPRET_CAST(simde_v4u32, __msa_ld_b(rs, s10));
153 #else
154 simde_v4u32 r;
155
156 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
157
158 return r;
159 #endif
160 }
161
162 SIMDE_FUNCTION_ATTRIBUTES
163 simde_v2u64
164 simde_x_msa_ld_u_d(const void * rs, const int s10)
165 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
166 HEDLEY_REQUIRE_MSG((s10 % sizeof(int64_t)) == 0, "`s10' must be a multiple of sizeof(int64_t)") {
167 #if defined(SIMDE_MIPS_MSA_NATIVE)
168 return HEDLEY_REINTERPRET_CAST(simde_v2u64, __msa_ld_b(rs, s10));
169 #else
170 simde_v2u64 r;
171
172 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
173
174 return r;
175 #endif
176 }
177
178 SIMDE_FUNCTION_ATTRIBUTES
179 simde_v4f32
180 simde_x_msa_fld_w(const void * rs, const int s10)
181 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
182 HEDLEY_REQUIRE_MSG((s10 % sizeof(int32_t)) == 0, "`s10' must be a multiple of sizeof(int32_t)") {
183 #if defined(SIMDE_MIPS_MSA_NATIVE)
184 return HEDLEY_REINTERPRET_CAST(simde_v4f32, __msa_ld_b(rs, s10));
185 #else
186 simde_v4f32 r;
187
188 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
189
190 return r;
191 #endif
192 }
193
194 SIMDE_FUNCTION_ATTRIBUTES
195 simde_v2f64
196 simde_x_msa_fld_d(const void * rs, const int s10)
197 SIMDE_REQUIRE_CONSTANT_RANGE(s10, 0, 1023)
198 HEDLEY_REQUIRE_MSG((s10 % sizeof(int64_t)) == 0, "`s10' must be a multiple of sizeof(int64_t)") {
199 #if defined(SIMDE_MIPS_MSA_NATIVE)
200 return HEDLEY_REINTERPRET_CAST(simde_v2f64, __msa_ld_b(rs, s10));
201 #else
202 simde_v2f64 r;
203
204 simde_memcpy(&r, &(HEDLEY_REINTERPRET_CAST(const int8_t*, rs)[s10]), sizeof(r));
205
206 return r;
207 #endif
208 }
209
210 SIMDE_END_DECLS_
211 HEDLEY_DIAGNOSTIC_POP
212
213 #endif /* !defined(SIMDE_MIPS_MSA_LD_H) */