Debian Codegraph @

src/x8-lut/gen/x8-lut-wasmsimd-u16.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_u16(
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 >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) {
48 v128_t vx = wasm_v128_load(input);
49 input += 16;
50
51 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
52
53 vx = wasm_i8x16_sub(vx, voffset);
54 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
55 vx = wasm_i8x16_sub(vx, voffset);
56 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
57 vx = wasm_i8x16_sub(vx, voffset);
58 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
59 vx = wasm_i8x16_sub(vx, voffset);
60 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
61 vx = wasm_i8x16_sub(vx, voffset);
62 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
63 vx = wasm_i8x16_sub(vx, voffset);
64 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
65 vx = wasm_i8x16_sub(vx, voffset);
66 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
67 vx = wasm_i8x16_sub(vx, voffset);
68 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
69 vx = wasm_i8x16_sub(vx, voffset);
70 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
71 vx = wasm_i8x16_sub(vx, voffset);
72 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
73 vx = wasm_i8x16_sub(vx, voffset);
74 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
75 vx = wasm_i8x16_sub(vx, voffset);
76 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
77 vx = wasm_i8x16_sub(vx, voffset);
78 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
79 vx = wasm_i8x16_sub(vx, voffset);
80 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
81 vx = wasm_i8x16_sub(vx, voffset);
82 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
83
84 wasm_v128_store(output, vy);
85 output += 16;
86 }
87 if XNN_UNLIKELY(batch != 0) {
88 v128_t vx = wasm_v128_load(input);
89
90 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
91
92 vx = wasm_i8x16_sub(vx, voffset);
93 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
94 vx = wasm_i8x16_sub(vx, voffset);
95 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
96 vx = wasm_i8x16_sub(vx, voffset);
97 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
98 vx = wasm_i8x16_sub(vx, voffset);
99 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
100 vx = wasm_i8x16_sub(vx, voffset);
101 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
102 vx = wasm_i8x16_sub(vx, voffset);
103 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
104 vx = wasm_i8x16_sub(vx, voffset);
105 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
106 vx = wasm_i8x16_sub(vx, voffset);
107 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
108 vx = wasm_i8x16_sub(vx, voffset);
109 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
110 vx = wasm_i8x16_sub(vx, voffset);
111 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
112 vx = wasm_i8x16_sub(vx, voffset);
113 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
114 vx = wasm_i8x16_sub(vx, voffset);
115 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
116 vx = wasm_i8x16_sub(vx, voffset);
117 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
118 vx = wasm_i8x16_sub(vx, voffset);
119 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
120 vx = wasm_i8x16_sub(vx, voffset);
121 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
122
123 if (batch & (8 * sizeof(uint8_t))) {
124 wasm_v128_store64_lane(output, vy, 0);
125 vy = wasm_v64x2_shuffle(vy, vy, 1, 1);
126 output += 8;
127 }
128 if (batch & (4 * sizeof(uint8_t))) {
129 wasm_v128_store32_lane(output, vy, 0);
130 vy = wasm_u64x2_shr(vy, 32);
131 output += 4;
132 }
133 if (batch & (2 * sizeof(uint8_t))) {
134 wasm_v128_store16_lane(output, vy, 0);
135 vy = wasm_u32x4_shr(vy, 16);
136 output += 2;
137 }
138 if (batch & (1 * sizeof(uint8_t))) {
139 wasm_v128_store8_lane(output, vy, 0);
140 }
141 }
142 }