Debian Codegraph @

src/x8-lut/gen/x8-lut-wasmsimd-u64.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-lut/wasmsimd.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2021 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11
12 #include <wasm_simd128.h>
13
14 #include "xnnpack/intrinsics-polyfill.h"
15 #include "xnnpack/lut.h"
16 #include "xnnpack/common.h"
17
18
19 void xnn_x8_lut_ukernel__wasmsimd_u64(
20 size_t batch,
21 const uint8_t* input,
22 uint8_t* output,
23 const uint8_t table[restrict XNN_MIN_ELEMENTS(256)])
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(uint8_t) == 0);
27 assert(input != NULL);
28 assert(output != NULL);
29
30 const v128_t vtable0 = wasm_v128_load(table);
31 const v128_t vtable1 = wasm_v128_load(table + 16);
32 const v128_t vtable2 = wasm_v128_load(table + 32);
33 const v128_t vtable3 = wasm_v128_load(table + 48);
34 const v128_t vtable4 = wasm_v128_load(table + 64);
35 const v128_t vtable5 = wasm_v128_load(table + 80);
36 const v128_t vtable6 = wasm_v128_load(table + 96);
37 const v128_t vtable7 = wasm_v128_load(table + 112);
38 const v128_t vtable8 = wasm_v128_load(table + 128);
39 const v128_t vtable9 = wasm_v128_load(table + 144);
40 const v128_t vtable10 = wasm_v128_load(table + 160);
41 const v128_t vtable11 = wasm_v128_load(table + 176);
42 const v128_t vtable12 = wasm_v128_load(table + 192);
43 const v128_t vtable13 = wasm_v128_load(table + 208);
44 const v128_t vtable14 = wasm_v128_load(table + 224);
45 const v128_t vtable15 = wasm_v128_load(table + 240);
46 const v128_t voffset = wasm_i8x16_const_splat(16);
47 for (; batch >= 64 * sizeof(uint8_t); batch -= 64 * sizeof(uint8_t)) {
48 v128_t vx0 = wasm_v128_load(input);
49 v128_t vx1 = wasm_v128_load(input + 16);
50 v128_t vx2 = wasm_v128_load(input + 32);
51 v128_t vx3 = wasm_v128_load(input + 48);
52 input += 64;
53
54 v128_t vy0 = wasm_i8x16_swizzle(vtable0, vx0);
55 v128_t vy1 = wasm_i8x16_swizzle(vtable0, vx1);
56 v128_t vy2 = wasm_i8x16_swizzle(vtable0, vx2);
57 v128_t vy3 = wasm_i8x16_swizzle(vtable0, vx3);
58
59 vx0 = wasm_i8x16_sub(vx0, voffset);
60 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable1, vx0));
61 vx1 = wasm_i8x16_sub(vx1, voffset);
62 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable1, vx1));
63 vx2 = wasm_i8x16_sub(vx2, voffset);
64 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable1, vx2));
65 vx3 = wasm_i8x16_sub(vx3, voffset);
66 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable1, vx3));
67 vx0 = wasm_i8x16_sub(vx0, voffset);
68 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable2, vx0));
69 vx1 = wasm_i8x16_sub(vx1, voffset);
70 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable2, vx1));
71 vx2 = wasm_i8x16_sub(vx2, voffset);
72 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable2, vx2));
73 vx3 = wasm_i8x16_sub(vx3, voffset);
74 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable2, vx3));
75 vx0 = wasm_i8x16_sub(vx0, voffset);
76 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable3, vx0));
77 vx1 = wasm_i8x16_sub(vx1, voffset);
78 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable3, vx1));
79 vx2 = wasm_i8x16_sub(vx2, voffset);
80 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable3, vx2));
81 vx3 = wasm_i8x16_sub(vx3, voffset);
82 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable3, vx3));
83 vx0 = wasm_i8x16_sub(vx0, voffset);
84 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable4, vx0));
85 vx1 = wasm_i8x16_sub(vx1, voffset);
86 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable4, vx1));
87 vx2 = wasm_i8x16_sub(vx2, voffset);
88 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable4, vx2));
89 vx3 = wasm_i8x16_sub(vx3, voffset);
90 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable4, vx3));
91 vx0 = wasm_i8x16_sub(vx0, voffset);
92 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable5, vx0));
93 vx1 = wasm_i8x16_sub(vx1, voffset);
94 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable5, vx1));
95 vx2 = wasm_i8x16_sub(vx2, voffset);
96 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable5, vx2));
97 vx3 = wasm_i8x16_sub(vx3, voffset);
98 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable5, vx3));
99 vx0 = wasm_i8x16_sub(vx0, voffset);
100 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable6, vx0));
101 vx1 = wasm_i8x16_sub(vx1, voffset);
102 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable6, vx1));
103 vx2 = wasm_i8x16_sub(vx2, voffset);
104 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable6, vx2));
105 vx3 = wasm_i8x16_sub(vx3, voffset);
106 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable6, vx3));
107 vx0 = wasm_i8x16_sub(vx0, voffset);
108 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable7, vx0));
109 vx1 = wasm_i8x16_sub(vx1, voffset);
110 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable7, vx1));
111 vx2 = wasm_i8x16_sub(vx2, voffset);
112 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable7, vx2));
113 vx3 = wasm_i8x16_sub(vx3, voffset);
114 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable7, vx3));
115 vx0 = wasm_i8x16_sub(vx0, voffset);
116 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable8, vx0));
117 vx1 = wasm_i8x16_sub(vx1, voffset);
118 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable8, vx1));
119 vx2 = wasm_i8x16_sub(vx2, voffset);
120 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable8, vx2));
121 vx3 = wasm_i8x16_sub(vx3, voffset);
122 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable8, vx3));
123 vx0 = wasm_i8x16_sub(vx0, voffset);
124 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable9, vx0));
125 vx1 = wasm_i8x16_sub(vx1, voffset);
126 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable9, vx1));
127 vx2 = wasm_i8x16_sub(vx2, voffset);
128 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable9, vx2));
129 vx3 = wasm_i8x16_sub(vx3, voffset);
130 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable9, vx3));
131 vx0 = wasm_i8x16_sub(vx0, voffset);
132 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable10, vx0));
133 vx1 = wasm_i8x16_sub(vx1, voffset);
134 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable10, vx1));
135 vx2 = wasm_i8x16_sub(vx2, voffset);
136 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable10, vx2));
137 vx3 = wasm_i8x16_sub(vx3, voffset);
138 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable10, vx3));
139 vx0 = wasm_i8x16_sub(vx0, voffset);
140 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable11, vx0));
141 vx1 = wasm_i8x16_sub(vx1, voffset);
142 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable11, vx1));
143 vx2 = wasm_i8x16_sub(vx2, voffset);
144 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable11, vx2));
145 vx3 = wasm_i8x16_sub(vx3, voffset);
146 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable11, vx3));
147 vx0 = wasm_i8x16_sub(vx0, voffset);
148 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable12, vx0));
149 vx1 = wasm_i8x16_sub(vx1, voffset);
150 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable12, vx1));
151 vx2 = wasm_i8x16_sub(vx2, voffset);
152 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable12, vx2));
153 vx3 = wasm_i8x16_sub(vx3, voffset);
154 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable12, vx3));
155 vx0 = wasm_i8x16_sub(vx0, voffset);
156 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable13, vx0));
157 vx1 = wasm_i8x16_sub(vx1, voffset);
158 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable13, vx1));
159 vx2 = wasm_i8x16_sub(vx2, voffset);
160 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable13, vx2));
161 vx3 = wasm_i8x16_sub(vx3, voffset);
162 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable13, vx3));
163 vx0 = wasm_i8x16_sub(vx0, voffset);
164 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable14, vx0));
165 vx1 = wasm_i8x16_sub(vx1, voffset);
166 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable14, vx1));
167 vx2 = wasm_i8x16_sub(vx2, voffset);
168 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable14, vx2));
169 vx3 = wasm_i8x16_sub(vx3, voffset);
170 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable14, vx3));
171 vx0 = wasm_i8x16_sub(vx0, voffset);
172 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable15, vx0));
173 vx1 = wasm_i8x16_sub(vx1, voffset);
174 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable15, vx1));
175 vx2 = wasm_i8x16_sub(vx2, voffset);
176 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable15, vx2));
177 vx3 = wasm_i8x16_sub(vx3, voffset);
178 vy3 = wasm_v128_or(vy3, wasm_i8x16_swizzle(vtable15, vx3));
179
180 wasm_v128_store(output, vy0);
181 wasm_v128_store(output + 16, vy1);
182 wasm_v128_store(output + 32, vy2);
183 wasm_v128_store(output + 48, vy3);
184 output += 64;
185 }
186 for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) {
187 v128_t vx = wasm_v128_load(input);
188 input += 16;
189
190 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
191
192 vx = wasm_i8x16_sub(vx, voffset);
193 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
194 vx = wasm_i8x16_sub(vx, voffset);
195 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
196 vx = wasm_i8x16_sub(vx, voffset);
197 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
198 vx = wasm_i8x16_sub(vx, voffset);
199 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
200 vx = wasm_i8x16_sub(vx, voffset);
201 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
202 vx = wasm_i8x16_sub(vx, voffset);
203 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
204 vx = wasm_i8x16_sub(vx, voffset);
205 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
206 vx = wasm_i8x16_sub(vx, voffset);
207 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
208 vx = wasm_i8x16_sub(vx, voffset);
209 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
210 vx = wasm_i8x16_sub(vx, voffset);
211 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
212 vx = wasm_i8x16_sub(vx, voffset);
213 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
214 vx = wasm_i8x16_sub(vx, voffset);
215 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
216 vx = wasm_i8x16_sub(vx, voffset);
217 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
218 vx = wasm_i8x16_sub(vx, voffset);
219 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
220 vx = wasm_i8x16_sub(vx, voffset);
221 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
222
223 wasm_v128_store(output, vy);
224 output += 16;
225 }
226 if XNN_UNLIKELY(batch != 0) {
227 v128_t vx = wasm_v128_load(input);
228
229 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
230
231 vx = wasm_i8x16_sub(vx, voffset);
232 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
233 vx = wasm_i8x16_sub(vx, voffset);
234 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
235 vx = wasm_i8x16_sub(vx, voffset);
236 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
237 vx = wasm_i8x16_sub(vx, voffset);
238 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
239 vx = wasm_i8x16_sub(vx, voffset);
240 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
241 vx = wasm_i8x16_sub(vx, voffset);
242 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
243 vx = wasm_i8x16_sub(vx, voffset);
244 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
245 vx = wasm_i8x16_sub(vx, voffset);
246 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
247 vx = wasm_i8x16_sub(vx, voffset);
248 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
249 vx = wasm_i8x16_sub(vx, voffset);
250 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
251 vx = wasm_i8x16_sub(vx, voffset);
252 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
253 vx = wasm_i8x16_sub(vx, voffset);
254 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
255 vx = wasm_i8x16_sub(vx, voffset);
256 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
257 vx = wasm_i8x16_sub(vx, voffset);
258 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
259 vx = wasm_i8x16_sub(vx, voffset);
260 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
261
262 if (batch & (8 * sizeof(uint8_t))) {
263 wasm_v128_store64_lane(output, vy, 0);
264 vy = wasm_v64x2_shuffle(vy, vy, 1, 1);
265 output += 8;
266 }
267 if (batch & (4 * sizeof(uint8_t))) {
268 wasm_v128_store32_lane(output, vy, 0);
269 vy = wasm_u64x2_shr(vy, 32);
270 output += 4;
271 }
272 if (batch & (2 * sizeof(uint8_t))) {
273 wasm_v128_store16_lane(output, vy, 0);
274 vy = wasm_u32x4_shr(vy, 16);
275 output += 2;
276 }
277 if (batch & (1 * sizeof(uint8_t))) {
278 wasm_v128_store8_lane(output, vy, 0);
279 }
280 }
281 }