Debian Codegraph @

src/x8-lut/gen/x8-lut-wasmsimd-u32.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_u32(
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 >= 32 * sizeof(uint8_t); batch -= 32 * sizeof(uint8_t)) {
48 v128_t vx0 = wasm_v128_load(input);
49 v128_t vx1 = wasm_v128_load(input + 16);
50 input += 32;
51
52 v128_t vy0 = wasm_i8x16_swizzle(vtable0, vx0);
53 v128_t vy1 = wasm_i8x16_swizzle(vtable0, vx1);
54
55 vx0 = wasm_i8x16_sub(vx0, voffset);
56 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable1, vx0));
57 vx1 = wasm_i8x16_sub(vx1, voffset);
58 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable1, vx1));
59 vx0 = wasm_i8x16_sub(vx0, voffset);
60 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable2, vx0));
61 vx1 = wasm_i8x16_sub(vx1, voffset);
62 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable2, vx1));
63 vx0 = wasm_i8x16_sub(vx0, voffset);
64 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable3, vx0));
65 vx1 = wasm_i8x16_sub(vx1, voffset);
66 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable3, vx1));
67 vx0 = wasm_i8x16_sub(vx0, voffset);
68 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable4, vx0));
69 vx1 = wasm_i8x16_sub(vx1, voffset);
70 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable4, vx1));
71 vx0 = wasm_i8x16_sub(vx0, voffset);
72 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable5, vx0));
73 vx1 = wasm_i8x16_sub(vx1, voffset);
74 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable5, vx1));
75 vx0 = wasm_i8x16_sub(vx0, voffset);
76 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable6, vx0));
77 vx1 = wasm_i8x16_sub(vx1, voffset);
78 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable6, vx1));
79 vx0 = wasm_i8x16_sub(vx0, voffset);
80 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable7, vx0));
81 vx1 = wasm_i8x16_sub(vx1, voffset);
82 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable7, vx1));
83 vx0 = wasm_i8x16_sub(vx0, voffset);
84 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable8, vx0));
85 vx1 = wasm_i8x16_sub(vx1, voffset);
86 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable8, vx1));
87 vx0 = wasm_i8x16_sub(vx0, voffset);
88 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable9, vx0));
89 vx1 = wasm_i8x16_sub(vx1, voffset);
90 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable9, vx1));
91 vx0 = wasm_i8x16_sub(vx0, voffset);
92 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable10, vx0));
93 vx1 = wasm_i8x16_sub(vx1, voffset);
94 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable10, vx1));
95 vx0 = wasm_i8x16_sub(vx0, voffset);
96 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable11, vx0));
97 vx1 = wasm_i8x16_sub(vx1, voffset);
98 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable11, vx1));
99 vx0 = wasm_i8x16_sub(vx0, voffset);
100 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable12, vx0));
101 vx1 = wasm_i8x16_sub(vx1, voffset);
102 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable12, vx1));
103 vx0 = wasm_i8x16_sub(vx0, voffset);
104 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable13, vx0));
105 vx1 = wasm_i8x16_sub(vx1, voffset);
106 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable13, vx1));
107 vx0 = wasm_i8x16_sub(vx0, voffset);
108 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable14, vx0));
109 vx1 = wasm_i8x16_sub(vx1, voffset);
110 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable14, vx1));
111 vx0 = wasm_i8x16_sub(vx0, voffset);
112 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable15, vx0));
113 vx1 = wasm_i8x16_sub(vx1, voffset);
114 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable15, vx1));
115
116 wasm_v128_store(output, vy0);
117 wasm_v128_store(output + 16, vy1);
118 output += 32;
119 }
120 for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) {
121 v128_t vx = wasm_v128_load(input);
122 input += 16;
123
124 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
125
126 vx = wasm_i8x16_sub(vx, voffset);
127 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
128 vx = wasm_i8x16_sub(vx, voffset);
129 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
130 vx = wasm_i8x16_sub(vx, voffset);
131 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
132 vx = wasm_i8x16_sub(vx, voffset);
133 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
134 vx = wasm_i8x16_sub(vx, voffset);
135 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
136 vx = wasm_i8x16_sub(vx, voffset);
137 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
138 vx = wasm_i8x16_sub(vx, voffset);
139 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
140 vx = wasm_i8x16_sub(vx, voffset);
141 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
142 vx = wasm_i8x16_sub(vx, voffset);
143 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
144 vx = wasm_i8x16_sub(vx, voffset);
145 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
146 vx = wasm_i8x16_sub(vx, voffset);
147 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
148 vx = wasm_i8x16_sub(vx, voffset);
149 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
150 vx = wasm_i8x16_sub(vx, voffset);
151 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
152 vx = wasm_i8x16_sub(vx, voffset);
153 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
154 vx = wasm_i8x16_sub(vx, voffset);
155 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
156
157 wasm_v128_store(output, vy);
158 output += 16;
159 }
160 if XNN_UNLIKELY(batch != 0) {
161 v128_t vx = wasm_v128_load(input);
162
163 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
164
165 vx = wasm_i8x16_sub(vx, voffset);
166 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
167 vx = wasm_i8x16_sub(vx, voffset);
168 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
169 vx = wasm_i8x16_sub(vx, voffset);
170 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
171 vx = wasm_i8x16_sub(vx, voffset);
172 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
173 vx = wasm_i8x16_sub(vx, voffset);
174 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
175 vx = wasm_i8x16_sub(vx, voffset);
176 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
177 vx = wasm_i8x16_sub(vx, voffset);
178 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
179 vx = wasm_i8x16_sub(vx, voffset);
180 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
181 vx = wasm_i8x16_sub(vx, voffset);
182 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
183 vx = wasm_i8x16_sub(vx, voffset);
184 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
185 vx = wasm_i8x16_sub(vx, voffset);
186 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
187 vx = wasm_i8x16_sub(vx, voffset);
188 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
189 vx = wasm_i8x16_sub(vx, voffset);
190 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
191 vx = wasm_i8x16_sub(vx, voffset);
192 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
193 vx = wasm_i8x16_sub(vx, voffset);
194 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
195
196 if (batch & (8 * sizeof(uint8_t))) {
197 wasm_v128_store64_lane(output, vy, 0);
198 vy = wasm_v64x2_shuffle(vy, vy, 1, 1);
199 output += 8;
200 }
201 if (batch & (4 * sizeof(uint8_t))) {
202 wasm_v128_store32_lane(output, vy, 0);
203 vy = wasm_u64x2_shr(vy, 32);
204 output += 4;
205 }
206 if (batch & (2 * sizeof(uint8_t))) {
207 wasm_v128_store16_lane(output, vy, 0);
208 vy = wasm_u32x4_shr(vy, 16);
209 output += 2;
210 }
211 if (batch & (1 * sizeof(uint8_t))) {
212 wasm_v128_store8_lane(output, vy, 0);
213 }
214 }
215 }