blob: e487d4d839aece6b031edeee5fc7f248000b4aaf [file] [log] [blame]
Georgios Pinitas4ee8b152021-07-16 16:16:43 +01001/*
Michael Tyler7d9a6262023-02-01 16:37:07 +00002 * Copyright (c) 2021, 2023 Arm Limited.
Georgios Pinitas4ee8b152021-07-16 16:16:43 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
Michael Tyler7d9a6262023-02-01 16:37:07 +000013 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010015 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Michael Tyler7d9a6262023-02-01 16:37:07 +000020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010023 */
24
25#pragma once
26
27#ifdef __aarch64__
28
29namespace {
30
31void a64_transpose_interleave_12_2x4_fp32bf16(bfloat16 *out, const float *in, size_t width, size_t in_stride, size_t height)
32{
33 float *pad_row = reinterpret_cast<float *>(alloca(width * sizeof(float)));
34
35 if (height % 4) {
36 memset(pad_row, 0, width * sizeof(float));
37 }
38
39 size_t out_stride = 12 * roundup<size_t>(height, 4) * sizeof(bfloat16);
40
41 __asm__ __volatile__(
42 "cmp %x[height], #0x8\n"
43 "blt 10f\n"
44 "1:" // Main row loop: Head
Michael Tyler7d9a6262023-02-01 16:37:07 +000045 "mov x9, %x[in]\n"
46 "add x28, x9, %x[in_stride]\n"
47 "add x27, x28, %x[in_stride]\n"
48 "add x26, x27, %x[in_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010049 "add x25, x26, %x[in_stride]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000050 "mov x24, %x[width]\n"
51 "add x23, x25, %x[in_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010052 "add x22, x23, %x[in_stride]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000053 "add x20, x22, %x[in_stride]\n"
54 "cmp x24, #0x18\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010055 "add %x[in], x20, %x[in_stride]\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000056 "mov x21, %x[out]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010057 "sub %x[height], %x[height], #0x8\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010058 "blt 3f\n"
59 "2:" // Main row loop: Unroll column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +000060 "ldr q15, [x9], #0x10\n"
61 "ldr q17, [x28], #0x10\n"
62 "sub x24, x24, #0x18\n"
63 "cmp x24, #0x18\n"
64 "ldr q16, [x27], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +010065 "ldr q20, [x26], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000066 "zip1 v6.4s, v15.4s, v16.4s\n"
67 "zip1 v11.4s, v17.4s, v20.4s\n"
68 "ldr q2, [x25], #0x10\n"
69 "ldr q4, [x23], #0x10\n"
70 "zip2 v22.4s, v15.4s, v16.4s\n"
71 "zip2 v18.4s, v17.4s, v20.4s\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +000072 "ldr q17, [x22], #0x10\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +000073 "ldr q26, [x20], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +000074 "zip1 v9.4s, v2.4s, v17.4s\n"
75 "zip1 v10.4s, v4.4s, v26.4s\n"
76 "ldr q16, [x9], #0x10\n"
77 "ldr q27, [x28], #0x10\n"
78 "zip2 v3.4s, v2.4s, v17.4s\n"
79 "zip2 v30.4s, v4.4s, v26.4s\n"
80 "ldr q13, [x27], #0x10\n"
81 "ldr q1, [x26], #0x10\n"
82 "zip1 v23.4s, v16.4s, v13.4s\n"
83 "zip1 v5.4s, v27.4s, v1.4s\n"
84 "ldr q26, [x25], #0x10\n"
85 "ldr q14, [x23], #0x10\n"
86 "zip2 v0.4s, v16.4s, v13.4s\n"
87 "zip2 v2.4s, v27.4s, v1.4s\n"
88 "ldr q15, [x22], #0x10\n"
89 "ldr q8, [x20], #0x10\n"
90 "zip1 v31.4s, v26.4s, v15.4s\n"
91 "zip1 v4.4s, v14.4s, v8.4s\n"
92 "ldr q28, [x9], #0x10\n"
93 "ldr q19, [x28], #0x10\n"
94 "zip2 v21.4s, v26.4s, v15.4s\n"
95 "zip2 v16.4s, v14.4s, v8.4s\n"
96 "ldr q15, [x27], #0x10\n"
97 "ldr q1, [x26], #0x10\n"
98 "zip1 v17.4s, v28.4s, v15.4s\n"
99 "zip1 v8.4s, v19.4s, v1.4s\n"
100 "ldr q27, [x25], #0x10\n"
101 "ldr q20, [x23], #0x10\n"
102 "zip2 v7.4s, v28.4s, v15.4s\n"
103 "zip2 v15.4s, v19.4s, v1.4s\n"
104 "ldr q12, [x22], #0x10\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000105 "ldr q25, [x20], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000106 "zip1 v14.4s, v27.4s, v12.4s\n"
107 "zip1 v26.4s, v20.4s, v25.4s\n"
108 "ldr q13, [x9], #0x10\n"
109 "ldr q29, [x28], #0x10\n"
110 "zip2 v28.4s, v27.4s, v12.4s\n"
111 "zip2 v12.4s, v20.4s, v25.4s\n"
112 "ldr q27, [x27], #0x10\n"
113 "ldr q20, [x26], #0x10\n"
114 "zip1 v19.4s, v13.4s, v27.4s\n"
115 "zip1 v25.4s, v29.4s, v20.4s\n"
116 "ldr q24, [x25], #0x10\n"
117 "ldr q1, [x23], #0x10\n"
118 "zip2 v27.4s, v13.4s, v27.4s\n"
119 "zip2 v13.4s, v29.4s, v20.4s\n"
120 "ldr q20, [x22], #0x10\n"
121 "zip1 v29.4s, v24.4s, v20.4s\n"
122 "zip2 v20.4s, v24.4s, v20.4s\n"
123 "zip1 v24.4s, v6.4s, v11.4s\n"
124 ".inst 0x0ea16b18 // bfcvtn v24.4h, v24.4s\n"
125 "zip2 v11.4s, v6.4s, v11.4s\n"
126 "ldr q6, [x20], #0x10\n"
127 ".inst 0x4ea16978 // bfcvtn2 v24.8h, v11.4s\n"
128 "zip1 v11.4s, v1.4s, v6.4s\n"
129 "zip2 v6.4s, v1.4s, v6.4s\n"
130 "zip1 v1.4s, v22.4s, v18.4s\n"
131 ".inst 0x0ea16821 // bfcvtn v1.4h, v1.4s\n"
132 "zip2 v18.4s, v22.4s, v18.4s\n"
133 "ldr q22, [x9], #0x10\n"
134 ".inst 0x4ea16a41 // bfcvtn2 v1.8h, v18.4s\n"
135 "zip1 v18.4s, v23.4s, v5.4s\n"
136 ".inst 0x0ea16a52 // bfcvtn v18.4h, v18.4s\n"
137 "zip2 v5.4s, v23.4s, v5.4s\n"
138 "ldr q23, [x28], #0x10\n"
139 ".inst 0x4ea168b2 // bfcvtn2 v18.8h, v5.4s\n"
140 "zip1 v5.4s, v0.4s, v2.4s\n"
141 ".inst 0x0ea168a5 // bfcvtn v5.4h, v5.4s\n"
142 "zip2 v0.4s, v0.4s, v2.4s\n"
143 "ldr q2, [x27], #0x10\n"
144 ".inst 0x4ea16805 // bfcvtn2 v5.8h, v0.4s\n"
145 "zip1 v0.4s, v22.4s, v2.4s\n"
146 "zip2 v2.4s, v22.4s, v2.4s\n"
147 "zip1 v22.4s, v17.4s, v8.4s\n"
148 ".inst 0x0ea16ad6 // bfcvtn v22.4h, v22.4s\n"
149 "zip2 v8.4s, v17.4s, v8.4s\n"
150 "ldr q17, [x26], #0x10\n"
151 ".inst 0x4ea16916 // bfcvtn2 v22.8h, v8.4s\n"
152 "zip1 v8.4s, v23.4s, v17.4s\n"
153 "zip2 v23.4s, v23.4s, v17.4s\n"
154 "zip1 v17.4s, v7.4s, v15.4s\n"
155 ".inst 0x0ea16a31 // bfcvtn v17.4h, v17.4s\n"
156 "zip2 v7.4s, v7.4s, v15.4s\n"
157 "ldr q15, [x25], #0x10\n"
158 ".inst 0x4ea168f1 // bfcvtn2 v17.8h, v7.4s\n"
159 "zip1 v7.4s, v9.4s, v10.4s\n"
160 ".inst 0x0ea168e7 // bfcvtn v7.4h, v7.4s\n"
161 "zip2 v10.4s, v9.4s, v10.4s\n"
162 "ldr q9, [x23], #0x10\n"
163 ".inst 0x4ea16947 // bfcvtn2 v7.8h, v10.4s\n"
164 "zip1 v10.4s, v3.4s, v30.4s\n"
165 ".inst 0x0ea1694a // bfcvtn v10.4h, v10.4s\n"
166 "zip2 v30.4s, v3.4s, v30.4s\n"
167 "ldr q3, [x22], #0x10\n"
168 ".inst 0x4ea16bca // bfcvtn2 v10.8h, v30.4s\n"
169 "zip1 v30.4s, v15.4s, v3.4s\n"
170 "zip2 v15.4s, v15.4s, v3.4s\n"
171 "zip1 v3.4s, v31.4s, v4.4s\n"
172 ".inst 0x0ea16863 // bfcvtn v3.4h, v3.4s\n"
173 "zip2 v31.4s, v31.4s, v4.4s\n"
174 "ldr q4, [x20], #0x10\n"
175 ".inst 0x4ea16be3 // bfcvtn2 v3.8h, v31.4s\n"
176 "zip1 v31.4s, v9.4s, v4.4s\n"
177 "zip2 v4.4s, v9.4s, v4.4s\n"
178 "zip1 v9.4s, v21.4s, v16.4s\n"
179 ".inst 0x0ea16929 // bfcvtn v9.4h, v9.4s\n"
180 "zip2 v16.4s, v21.4s, v16.4s\n"
181 "ldr q21, [x9], #0x10\n"
182 ".inst 0x4ea16a09 // bfcvtn2 v9.8h, v16.4s\n"
183 "zip1 v16.4s, v14.4s, v26.4s\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000184 ".inst 0x0ea16a10 // bfcvtn v16.4h, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000185 "zip2 v14.4s, v14.4s, v26.4s\n"
186 "ldr q26, [x28], #0x10\n"
187 ".inst 0x4ea169d0 // bfcvtn2 v16.8h, v14.4s\n"
188 "zip1 v14.4s, v28.4s, v12.4s\n"
189 ".inst 0x0ea169ce // bfcvtn v14.4h, v14.4s\n"
190 "zip2 v12.4s, v28.4s, v12.4s\n"
191 "ldr q28, [x27], #0x10\n"
192 ".inst 0x4ea1698e // bfcvtn2 v14.8h, v12.4s\n"
193 "zip1 v12.4s, v21.4s, v28.4s\n"
194 "zip2 v28.4s, v21.4s, v28.4s\n"
195 "zip1 v21.4s, v19.4s, v25.4s\n"
196 ".inst 0x0ea16ab5 // bfcvtn v21.4h, v21.4s\n"
197 "zip2 v19.4s, v19.4s, v25.4s\n"
198 "ldr q25, [x26], #0x10\n"
199 ".inst 0x4ea16a75 // bfcvtn2 v21.8h, v19.4s\n"
200 "zip1 v19.4s, v26.4s, v25.4s\n"
201 "zip2 v25.4s, v26.4s, v25.4s\n"
202 "zip1 v26.4s, v27.4s, v13.4s\n"
203 ".inst 0x0ea16b5a // bfcvtn v26.4h, v26.4s\n"
204 "zip2 v13.4s, v27.4s, v13.4s\n"
205 "ldr q27, [x25], #0x10\n"
206 ".inst 0x4ea169ba // bfcvtn2 v26.8h, v13.4s\n"
207 "zip1 v13.4s, v0.4s, v8.4s\n"
208 ".inst 0x0ea169ad // bfcvtn v13.4h, v13.4s\n"
209 "zip2 v8.4s, v0.4s, v8.4s\n"
210 "ldr q0, [x23], #0x10\n"
211 ".inst 0x4ea1690d // bfcvtn2 v13.8h, v8.4s\n"
212 "zip1 v8.4s, v2.4s, v23.4s\n"
213 ".inst 0x0ea16908 // bfcvtn v8.4h, v8.4s\n"
214 "zip2 v23.4s, v2.4s, v23.4s\n"
215 "ldr q2, [x22], #0x10\n"
216 ".inst 0x4ea16ae8 // bfcvtn2 v8.8h, v23.4s\n"
217 "ldr q23, [x20], #0x10\n"
218 "str q24, [x21, #0x0]\n"
219 "zip1 v24.4s, v27.4s, v2.4s\n"
220 "zip2 v27.4s, v27.4s, v2.4s\n"
221 "zip1 v2.4s, v0.4s, v23.4s\n"
222 "zip2 v23.4s, v0.4s, v23.4s\n"
223 "str q1, [x21, #0x10]\n"
224 "zip1 v0.4s, v12.4s, v19.4s\n"
225 "zip1 v1.4s, v28.4s, v25.4s\n"
226 "str q18, [x21, #0x20]\n"
227 "zip1 v18.4s, v29.4s, v11.4s\n"
228 ".inst 0x0ea16800 // bfcvtn v0.4h, v0.4s\n"
229 "str q5, [x21, #0x30]\n"
230 "zip1 v5.4s, v20.4s, v6.4s\n"
231 "zip2 v19.4s, v12.4s, v19.4s\n"
232 "str q22, [x21, #0x40]\n"
233 "zip1 v12.4s, v30.4s, v31.4s\n"
234 "zip1 v22.4s, v15.4s, v4.4s\n"
235 "str q17, [x21, #0x50]\n"
236 "zip1 v17.4s, v24.4s, v2.4s\n"
237 ".inst 0x0ea16821 // bfcvtn v1.4h, v1.4s\n"
238 "str q7, [x21, #0x60]\n"
239 "zip1 v7.4s, v27.4s, v23.4s\n"
240 "zip2 v25.4s, v28.4s, v25.4s\n"
241 "str q10, [x21, #0x70]\n"
242 ".inst 0x0ea16a52 // bfcvtn v18.4h, v18.4s\n"
243 "zip2 v29.4s, v29.4s, v11.4s\n"
244 "str q3, [x21, #0x80]\n"
245 ".inst 0x0ea168ab // bfcvtn v11.4h, v5.4s\n"
246 "zip2 v10.4s, v20.4s, v6.4s\n"
247 "str q9, [x21, #0x90]\n"
248 ".inst 0x0ea16986 // bfcvtn v6.4h, v12.4s\n"
249 "zip2 v12.4s, v30.4s, v31.4s\n"
250 "str q16, [x21, #0xa0]\n"
251 ".inst 0x0ea16ac5 // bfcvtn v5.4h, v22.4s\n"
252 "zip2 v4.4s, v15.4s, v4.4s\n"
253 "str q14, [x21, #0xb0]\n"
254 "add x21, x21, %x[out_stride]\n"
255 ".inst 0x0ea16a2f // bfcvtn v15.4h, v17.4s\n"
256 "zip2 v20.4s, v24.4s, v2.4s\n"
257 "str q21, [x21, #0x0]\n"
258 ".inst 0x0ea168fc // bfcvtn v28.4h, v7.4s\n"
259 "zip2 v30.4s, v27.4s, v23.4s\n"
260 "str q26, [x21, #0x10]\n"
261 ".inst 0x4ea16a60 // bfcvtn2 v0.8h, v19.4s\n"
262 ".inst 0x4ea16b21 // bfcvtn2 v1.8h, v25.4s\n"
263 "str q13, [x21, #0x20]\n"
264 ".inst 0x4ea16bb2 // bfcvtn2 v18.8h, v29.4s\n"
265 ".inst 0x4ea1694b // bfcvtn2 v11.8h, v10.4s\n"
266 "str q8, [x21, #0x30]\n"
267 ".inst 0x4ea16986 // bfcvtn2 v6.8h, v12.4s\n"
268 ".inst 0x4ea16885 // bfcvtn2 v5.8h, v4.4s\n"
269 "str q0, [x21, #0x40]\n"
270 ".inst 0x4ea16a8f // bfcvtn2 v15.8h, v20.4s\n"
271 ".inst 0x4ea16bdc // bfcvtn2 v28.8h, v30.4s\n"
272 "str q1, [x21, #0x50]\n"
273 "str q18, [x21, #0x60]\n"
274 "str q11, [x21, #0x70]\n"
275 "str q6, [x21, #0x80]\n"
276 "str q5, [x21, #0x90]\n"
277 "str q15, [x21, #0xa0]\n"
278 "str q28, [x21, #0xb0]\n"
279 "add x21, x21, %x[out_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100280 "bge 2b\n"
281 "3:" // Main row loop: Unroll column loop skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000282 "cmp x24, #0xc\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100283 "blt 5f\n"
284 "4:" // Main row loop: Column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000285 "ldr q20, [x9], #0x10\n"
286 "ldr q9, [x28], #0x10\n"
287 "sub x24, x24, #0xc\n"
288 "cmp x24, #0xc\n"
289 "ldr q8, [x27], #0x10\n"
290 "ldr q1, [x26], #0x10\n"
291 "zip1 v7.4s, v20.4s, v8.4s\n"
292 "zip1 v19.4s, v9.4s, v1.4s\n"
293 "ldr q6, [x25], #0x10\n"
294 "ldr q16, [x23], #0x10\n"
295 "zip2 v5.4s, v20.4s, v8.4s\n"
296 "zip2 v18.4s, v9.4s, v1.4s\n"
297 "ldr q27, [x22], #0x10\n"
298 "ldr q14, [x20], #0x10\n"
299 "zip1 v26.4s, v6.4s, v27.4s\n"
300 "zip1 v15.4s, v16.4s, v14.4s\n"
301 "ldr q1, [x9], #0x10\n"
302 "ldr q30, [x28], #0x10\n"
303 "zip2 v24.4s, v6.4s, v27.4s\n"
304 "zip2 v25.4s, v16.4s, v14.4s\n"
305 "ldr q13, [x27], #0x10\n"
306 "ldr q17, [x26], #0x10\n"
307 "zip1 v10.4s, v1.4s, v13.4s\n"
308 "zip1 v16.4s, v30.4s, v17.4s\n"
309 "ldr q4, [x25], #0x10\n"
310 "ldr q11, [x23], #0x10\n"
311 "zip2 v0.4s, v1.4s, v13.4s\n"
312 "zip2 v27.4s, v30.4s, v17.4s\n"
313 "ldr q28, [x22], #0x10\n"
314 "ldr q12, [x20], #0x10\n"
315 "zip1 v22.4s, v4.4s, v28.4s\n"
316 "zip1 v13.4s, v11.4s, v12.4s\n"
317 "ldr q31, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100318 "ldr q17, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000319 "zip2 v14.4s, v4.4s, v28.4s\n"
320 "zip2 v12.4s, v11.4s, v12.4s\n"
321 "ldr q2, [x27], #0x10\n"
322 "ldr q3, [x26], #0x10\n"
323 "zip1 v8.4s, v31.4s, v2.4s\n"
324 "zip1 v4.4s, v17.4s, v3.4s\n"
325 "ldr q23, [x25], #0x10\n"
326 "ldr q1, [x23], #0x10\n"
327 "zip2 v28.4s, v31.4s, v2.4s\n"
328 "zip2 v29.4s, v17.4s, v3.4s\n"
329 "ldr q11, [x22], #0x10\n"
330 "ldr q17, [x20], #0x10\n"
331 "zip1 v9.4s, v23.4s, v11.4s\n"
332 "zip1 v21.4s, v1.4s, v17.4s\n"
333 "zip2 v11.4s, v23.4s, v11.4s\n"
334 "zip2 v17.4s, v1.4s, v17.4s\n"
335 "zip1 v2.4s, v7.4s, v19.4s\n"
336 "zip1 v31.4s, v5.4s, v18.4s\n"
337 "zip1 v3.4s, v10.4s, v16.4s\n"
338 "zip1 v6.4s, v0.4s, v27.4s\n"
339 "zip1 v1.4s, v8.4s, v4.4s\n"
340 "zip1 v30.4s, v28.4s, v29.4s\n"
341 "zip1 v20.4s, v26.4s, v15.4s\n"
342 "zip1 v23.4s, v24.4s, v25.4s\n"
343 ".inst 0x0ea16842 // bfcvtn v2.4h, v2.4s\n"
344 "zip2 v7.4s, v7.4s, v19.4s\n"
345 "zip1 v19.4s, v22.4s, v13.4s\n"
346 ".inst 0x0ea16bff // bfcvtn v31.4h, v31.4s\n"
347 "zip2 v18.4s, v5.4s, v18.4s\n"
348 "zip1 v5.4s, v14.4s, v12.4s\n"
349 ".inst 0x0ea16863 // bfcvtn v3.4h, v3.4s\n"
350 "zip2 v16.4s, v10.4s, v16.4s\n"
351 "zip1 v10.4s, v9.4s, v21.4s\n"
352 ".inst 0x0ea168c6 // bfcvtn v6.4h, v6.4s\n"
353 "zip2 v0.4s, v0.4s, v27.4s\n"
354 "zip1 v27.4s, v11.4s, v17.4s\n"
355 ".inst 0x0ea16821 // bfcvtn v1.4h, v1.4s\n"
356 "zip2 v4.4s, v8.4s, v4.4s\n"
357 ".inst 0x0ea16bde // bfcvtn v30.4h, v30.4s\n"
358 "zip2 v29.4s, v28.4s, v29.4s\n"
359 ".inst 0x0ea16a9c // bfcvtn v28.4h, v20.4s\n"
360 "zip2 v15.4s, v26.4s, v15.4s\n"
361 ".inst 0x0ea16ae8 // bfcvtn v8.4h, v23.4s\n"
362 "zip2 v26.4s, v24.4s, v25.4s\n"
363 ".inst 0x0ea16a79 // bfcvtn v25.4h, v19.4s\n"
364 "zip2 v24.4s, v22.4s, v13.4s\n"
365 ".inst 0x0ea168b7 // bfcvtn v23.4h, v5.4s\n"
366 "zip2 v22.4s, v14.4s, v12.4s\n"
367 ".inst 0x0ea16945 // bfcvtn v5.4h, v10.4s\n"
368 "zip2 v20.4s, v9.4s, v21.4s\n"
369 ".inst 0x0ea16b73 // bfcvtn v19.4h, v27.4s\n"
370 "zip2 v17.4s, v11.4s, v17.4s\n"
371 ".inst 0x4ea168e2 // bfcvtn2 v2.8h, v7.4s\n"
372 ".inst 0x4ea16a5f // bfcvtn2 v31.8h, v18.4s\n"
373 "str q2, [x21, #0x0]\n"
374 ".inst 0x4ea16a03 // bfcvtn2 v3.8h, v16.4s\n"
375 ".inst 0x4ea16806 // bfcvtn2 v6.8h, v0.4s\n"
376 "str q31, [x21, #0x10]\n"
377 ".inst 0x4ea16881 // bfcvtn2 v1.8h, v4.4s\n"
378 ".inst 0x4ea16bbe // bfcvtn2 v30.8h, v29.4s\n"
379 "str q3, [x21, #0x20]\n"
380 ".inst 0x4ea169fc // bfcvtn2 v28.8h, v15.4s\n"
381 ".inst 0x4ea16b48 // bfcvtn2 v8.8h, v26.4s\n"
382 "str q6, [x21, #0x30]\n"
383 ".inst 0x4ea16b19 // bfcvtn2 v25.8h, v24.4s\n"
384 ".inst 0x4ea16ad7 // bfcvtn2 v23.8h, v22.4s\n"
385 "str q1, [x21, #0x40]\n"
386 ".inst 0x4ea16a85 // bfcvtn2 v5.8h, v20.4s\n"
387 ".inst 0x4ea16a33 // bfcvtn2 v19.8h, v17.4s\n"
388 "str q30, [x21, #0x50]\n"
389 "str q28, [x21, #0x60]\n"
390 "str q8, [x21, #0x70]\n"
391 "str q25, [x21, #0x80]\n"
392 "str q23, [x21, #0x90]\n"
393 "str q5, [x21, #0xa0]\n"
394 "str q19, [x21, #0xb0]\n"
395 "add x21, x21, %x[out_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100396 "bge 4b\n"
397 "5:" // Main row loop: Column loop skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000398 "cmp x24, #0x4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100399 "blt 7f\n"
400 "6:" // Main row loop: width 4 loop: loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000401 "ldr q23, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100402 "ldr q20, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000403 "sub x24, x24, #0x4\n"
404 "cmp x24, #0x4\n"
405 "ldr q17, [x27], #0x10\n"
406 "ldr q16, [x26], #0x10\n"
407 "zip1 v22.4s, v23.4s, v17.4s\n"
408 "zip1 v21.4s, v20.4s, v16.4s\n"
409 "ldr q19, [x25], #0x10\n"
410 "ldr q18, [x23], #0x10\n"
411 "zip2 v28.4s, v23.4s, v17.4s\n"
412 "zip2 v20.4s, v20.4s, v16.4s\n"
413 "ldr q17, [x22], #0x10\n"
414 "ldr q16, [x20], #0x10\n"
415 "zip1 v27.4s, v19.4s, v17.4s\n"
416 "zip1 v26.4s, v18.4s, v16.4s\n"
417 "zip2 v25.4s, v19.4s, v17.4s\n"
418 "zip2 v24.4s, v18.4s, v16.4s\n"
419 "zip1 v19.4s, v22.4s, v21.4s\n"
420 "zip1 v18.4s, v28.4s, v20.4s\n"
421 "zip1 v17.4s, v27.4s, v26.4s\n"
422 "zip1 v16.4s, v25.4s, v24.4s\n"
423 ".inst 0x0ea16a77 // bfcvtn v23.4h, v19.4s\n"
424 "zip2 v22.4s, v22.4s, v21.4s\n"
425 ".inst 0x0ea16a55 // bfcvtn v21.4h, v18.4s\n"
426 "zip2 v20.4s, v28.4s, v20.4s\n"
427 ".inst 0x0ea16a33 // bfcvtn v19.4h, v17.4s\n"
428 "zip2 v18.4s, v27.4s, v26.4s\n"
429 ".inst 0x0ea16a11 // bfcvtn v17.4h, v16.4s\n"
430 "zip2 v16.4s, v25.4s, v24.4s\n"
431 ".inst 0x4ea16ad7 // bfcvtn2 v23.8h, v22.4s\n"
432 ".inst 0x4ea16a95 // bfcvtn2 v21.8h, v20.4s\n"
433 "str q23, [x21, #0x0]\n"
434 ".inst 0x4ea16a53 // bfcvtn2 v19.8h, v18.4s\n"
435 ".inst 0x4ea16a11 // bfcvtn2 v17.8h, v16.4s\n"
436 "str q21, [x21, #0x10]\n"
437 "str q19, [x21, #0x60]\n"
438 "str q17, [x21, #0x70]\n"
439 "add x21, x21, #0x20\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100440 "bge 6b\n"
441 "7:" // Main row loop: width 4 loop: skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000442 "cmp x24, #0x1\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100443 "blt 9f\n"
444 "8:" // Main row loop: width 1 loop: loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000445 "ldr s19, [x9], #0x4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100446 "ldr s18, [x28], #0x4\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000447 "sub x24, x24, #0x1\n"
448 "cmp x24, #0x1\n"
449 "ldr s17, [x27], #0x4\n"
450 "ldr s16, [x26], #0x4\n"
451 "zip1 v17.4s, v19.4s, v17.4s\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000452 "zip1 v16.4s, v18.4s, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000453 "ldr s20, [x25], #0x4\n"
454 "ldr s19, [x23], #0x4\n"
455 "zip1 v16.4s, v17.4s, v16.4s\n"
456 ".inst 0x0ea16a12 // bfcvtn v18.4h, v16.4s\n"
457 "ldr s17, [x22], #0x4\n"
458 "ldr s16, [x20], #0x4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100459 "zip1 v17.4s, v20.4s, v17.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000460 "zip1 v16.4s, v19.4s, v16.4s\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100461 "zip1 v16.4s, v17.4s, v16.4s\n"
462 ".inst 0x0ea16a10 // bfcvtn v16.4h, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000463 "str d18, [x21, #0x0]\n"
464 "str d16, [x21, #0x60]\n"
465 "add x21, x21, #0x8\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100466 "bge 8b\n"
467 "9:" // Main row loop: width 1 loop: skip
Michael Tylerbe13cea2023-01-17 11:04:14 +0000468 "cmp %x[height], #0x8\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000469 "add %x[out], %x[out], #0xc0\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100470 "bge 1b\n"
471 "cbz %x[height], 20f\n"
472 "10:" // Main loop skip
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100473 "11:" // Tail row loop: Head
Michael Tyler7d9a6262023-02-01 16:37:07 +0000474 "mov x9, %x[in]\n"
475 "add x28, x9, %x[in_stride]\n"
476 "add x27, x28, %x[in_stride]\n"
477 "mov x20, %x[width]\n"
478 "add x26, x27, %x[in_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100479 "cmp %x[height], #0x3\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000480 "add %x[in], x26, %x[in_stride]\n"
Michael Tylerbe13cea2023-01-17 11:04:14 +0000481 "csel x26, x26, %x[pad_row], GT\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000482 "csel x27, x27, %x[pad_row], GE\n"
483 "cmp %x[height], #0x1\n"
484 "csel x28, x28, %x[pad_row], GT\n"
485 "cmp x20, #0x18\n"
486 "mov x21, %x[out]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100487 "sub %x[height], %x[height], #0x4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100488 "blt 13f\n"
489 "12:" // Tail row loop: Unroll column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000490 "ldr q22, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100491 "ldr q18, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000492 "sub x20, x20, #0x18\n"
493 "cmp x20, #0x18\n"
494 "ldr q17, [x27], #0x10\n"
495 "ldr q16, [x26], #0x10\n"
496 "zip1 v19.4s, v22.4s, v17.4s\n"
497 "zip1 v21.4s, v18.4s, v16.4s\n"
498 "ldr q24, [x9], #0x10\n"
499 "ldr q20, [x28], #0x10\n"
500 "zip2 v10.4s, v22.4s, v17.4s\n"
501 "zip2 v2.4s, v18.4s, v16.4s\n"
502 "ldr q17, [x27], #0x10\n"
503 "ldr q16, [x26], #0x10\n"
504 "zip1 v22.4s, v24.4s, v17.4s\n"
505 "zip1 v4.4s, v20.4s, v16.4s\n"
506 "ldr q23, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100507 "ldr q18, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000508 "zip2 v29.4s, v24.4s, v17.4s\n"
509 "zip2 v1.4s, v20.4s, v16.4s\n"
510 "ldr q17, [x27], #0x10\n"
511 "ldr q16, [x26], #0x10\n"
512 "zip1 v30.4s, v23.4s, v17.4s\n"
513 "zip1 v31.4s, v18.4s, v16.4s\n"
514 "ldr q24, [x9], #0x10\n"
515 "ldr q20, [x28], #0x10\n"
516 "zip2 v23.4s, v23.4s, v17.4s\n"
517 "zip2 v28.4s, v18.4s, v16.4s\n"
518 "ldr q17, [x27], #0x10\n"
519 "ldr q16, [x26], #0x10\n"
520 "zip1 v25.4s, v24.4s, v17.4s\n"
521 "zip1 v26.4s, v20.4s, v16.4s\n"
522 "ldr q14, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100523 "ldr q18, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000524 "zip2 v24.4s, v24.4s, v17.4s\n"
525 "zip2 v15.4s, v20.4s, v16.4s\n"
526 "ldr q17, [x27], #0x10\n"
527 "ldr q16, [x26], #0x10\n"
528 "zip1 v12.4s, v14.4s, v17.4s\n"
529 "zip1 v13.4s, v18.4s, v16.4s\n"
530 "ldr q7, [x9], #0x10\n"
531 "ldr q3, [x28], #0x10\n"
532 "zip2 v0.4s, v14.4s, v17.4s\n"
533 "zip2 v9.4s, v18.4s, v16.4s\n"
534 "ldr q17, [x27], #0x10\n"
535 "ldr q16, [x26], #0x10\n"
536 "zip1 v14.4s, v7.4s, v17.4s\n"
537 "zip1 v8.4s, v3.4s, v16.4s\n"
538 "zip2 v7.4s, v7.4s, v17.4s\n"
539 "zip2 v11.4s, v3.4s, v16.4s\n"
540 "zip1 v18.4s, v19.4s, v21.4s\n"
541 "zip1 v6.4s, v10.4s, v2.4s\n"
542 "zip1 v5.4s, v22.4s, v4.4s\n"
543 "zip1 v16.4s, v29.4s, v1.4s\n"
544 "zip1 v27.4s, v30.4s, v31.4s\n"
545 "zip1 v3.4s, v23.4s, v28.4s\n"
546 "zip1 v17.4s, v25.4s, v26.4s\n"
547 "zip1 v20.4s, v24.4s, v15.4s\n"
548 ".inst 0x0ea16a52 // bfcvtn v18.4h, v18.4s\n"
549 "zip2 v19.4s, v19.4s, v21.4s\n"
550 "zip1 v21.4s, v12.4s, v13.4s\n"
551 ".inst 0x0ea168c6 // bfcvtn v6.4h, v6.4s\n"
552 "zip2 v10.4s, v10.4s, v2.4s\n"
553 "zip1 v2.4s, v0.4s, v9.4s\n"
554 ".inst 0x0ea168a5 // bfcvtn v5.4h, v5.4s\n"
555 "zip2 v4.4s, v22.4s, v4.4s\n"
556 "zip1 v22.4s, v14.4s, v8.4s\n"
557 ".inst 0x0ea16a10 // bfcvtn v16.4h, v16.4s\n"
558 "zip2 v1.4s, v29.4s, v1.4s\n"
559 "zip1 v29.4s, v7.4s, v11.4s\n"
560 ".inst 0x0ea16b7b // bfcvtn v27.4h, v27.4s\n"
561 "zip2 v30.4s, v30.4s, v31.4s\n"
562 ".inst 0x0ea1687f // bfcvtn v31.4h, v3.4s\n"
563 "zip2 v23.4s, v23.4s, v28.4s\n"
564 ".inst 0x0ea16a23 // bfcvtn v3.4h, v17.4s\n"
565 "zip2 v28.4s, v25.4s, v26.4s\n"
566 ".inst 0x0ea16a9a // bfcvtn v26.4h, v20.4s\n"
567 "zip2 v25.4s, v24.4s, v15.4s\n"
568 ".inst 0x0ea16ab8 // bfcvtn v24.4h, v21.4s\n"
569 "zip2 v12.4s, v12.4s, v13.4s\n"
570 ".inst 0x0ea16855 // bfcvtn v21.4h, v2.4s\n"
571 "zip2 v13.4s, v0.4s, v9.4s\n"
572 ".inst 0x0ea16ac2 // bfcvtn v2.4h, v22.4s\n"
573 "zip2 v0.4s, v14.4s, v8.4s\n"
574 ".inst 0x0ea16ba9 // bfcvtn v9.4h, v29.4s\n"
575 "zip2 v17.4s, v7.4s, v11.4s\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100576 ".inst 0x4ea16a72 // bfcvtn2 v18.8h, v19.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000577 ".inst 0x4ea16946 // bfcvtn2 v6.8h, v10.4s\n"
578 "str q18, [x21, #0x0]\n"
579 ".inst 0x4ea16885 // bfcvtn2 v5.8h, v4.4s\n"
580 ".inst 0x4ea16830 // bfcvtn2 v16.8h, v1.4s\n"
581 "str q6, [x21, #0x10]\n"
582 ".inst 0x4ea16bdb // bfcvtn2 v27.8h, v30.4s\n"
583 ".inst 0x4ea16aff // bfcvtn2 v31.8h, v23.4s\n"
584 "str q5, [x21, #0x20]\n"
585 "str q16, [x21, #0x30]\n"
586 ".inst 0x4ea16b83 // bfcvtn2 v3.8h, v28.4s\n"
587 ".inst 0x4ea16b3a // bfcvtn2 v26.8h, v25.4s\n"
588 "str q27, [x21, #0x40]\n"
589 ".inst 0x4ea16998 // bfcvtn2 v24.8h, v12.4s\n"
590 ".inst 0x4ea169b5 // bfcvtn2 v21.8h, v13.4s\n"
591 "str q31, [x21, #0x50]\n"
592 "add x21, x21, %x[out_stride]\n"
593 ".inst 0x4ea16802 // bfcvtn2 v2.8h, v0.4s\n"
594 ".inst 0x4ea16a29 // bfcvtn2 v9.8h, v17.4s\n"
595 "str q3, [x21, #0x0]\n"
596 "str q26, [x21, #0x10]\n"
597 "str q24, [x21, #0x20]\n"
598 "str q21, [x21, #0x30]\n"
599 "str q2, [x21, #0x40]\n"
600 "str q9, [x21, #0x50]\n"
601 "add x21, x21, %x[out_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100602 "bge 12b\n"
603 "13:" // Tail row loop: Unroll column loop skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000604 "cmp x20, #0xc\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100605 "blt 15f\n"
606 "14:" // Tail row loop: Column loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000607 "ldr q19, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100608 "ldr q18, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000609 "sub x20, x20, #0xc\n"
610 "cmp x20, #0xc\n"
611 "ldr q17, [x27], #0x10\n"
612 "ldr q16, [x26], #0x10\n"
613 "zip1 v26.4s, v19.4s, v17.4s\n"
614 "zip1 v25.4s, v18.4s, v16.4s\n"
615 "ldr q21, [x9], #0x10\n"
616 "ldr q20, [x28], #0x10\n"
617 "zip2 v24.4s, v19.4s, v17.4s\n"
618 "zip2 v23.4s, v18.4s, v16.4s\n"
619 "ldr q17, [x27], #0x10\n"
620 "ldr q16, [x26], #0x10\n"
621 "zip1 v2.4s, v21.4s, v17.4s\n"
622 "zip1 v22.4s, v20.4s, v16.4s\n"
623 "ldr q19, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100624 "ldr q18, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000625 "zip2 v1.4s, v21.4s, v17.4s\n"
626 "zip2 v0.4s, v20.4s, v16.4s\n"
627 "ldr q17, [x27], #0x10\n"
628 "ldr q16, [x26], #0x10\n"
629 "zip1 v31.4s, v19.4s, v17.4s\n"
630 "zip1 v30.4s, v18.4s, v16.4s\n"
631 "zip2 v29.4s, v19.4s, v17.4s\n"
632 "zip2 v28.4s, v18.4s, v16.4s\n"
633 "zip1 v21.4s, v26.4s, v25.4s\n"
634 "zip1 v20.4s, v24.4s, v23.4s\n"
635 "zip1 v19.4s, v2.4s, v22.4s\n"
636 "zip1 v18.4s, v1.4s, v0.4s\n"
637 "zip1 v17.4s, v31.4s, v30.4s\n"
638 "zip1 v16.4s, v29.4s, v28.4s\n"
639 ".inst 0x0ea16abb // bfcvtn v27.4h, v21.4s\n"
640 "zip2 v26.4s, v26.4s, v25.4s\n"
641 ".inst 0x0ea16a99 // bfcvtn v25.4h, v20.4s\n"
642 "zip2 v24.4s, v24.4s, v23.4s\n"
643 ".inst 0x0ea16a77 // bfcvtn v23.4h, v19.4s\n"
644 "zip2 v22.4s, v2.4s, v22.4s\n"
645 ".inst 0x0ea16a55 // bfcvtn v21.4h, v18.4s\n"
646 "zip2 v20.4s, v1.4s, v0.4s\n"
647 ".inst 0x0ea16a33 // bfcvtn v19.4h, v17.4s\n"
648 "zip2 v18.4s, v31.4s, v30.4s\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100649 ".inst 0x0ea16a11 // bfcvtn v17.4h, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000650 "zip2 v16.4s, v29.4s, v28.4s\n"
651 ".inst 0x4ea16b5b // bfcvtn2 v27.8h, v26.4s\n"
652 ".inst 0x4ea16b19 // bfcvtn2 v25.8h, v24.4s\n"
653 "str q27, [x21, #0x0]\n"
654 ".inst 0x4ea16ad7 // bfcvtn2 v23.8h, v22.4s\n"
655 ".inst 0x4ea16a95 // bfcvtn2 v21.8h, v20.4s\n"
656 "str q25, [x21, #0x10]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100657 ".inst 0x4ea16a53 // bfcvtn2 v19.8h, v18.4s\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100658 ".inst 0x4ea16a11 // bfcvtn2 v17.8h, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000659 "str q23, [x21, #0x20]\n"
660 "str q21, [x21, #0x30]\n"
661 "str q19, [x21, #0x40]\n"
662 "str q17, [x21, #0x50]\n"
663 "add x21, x21, %x[out_stride]\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100664 "bge 14b\n"
665 "15:" // Tail row loop: Column loop skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000666 "cmp x20, #0x4\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100667 "blt 17f\n"
668 "16:" // Tail row loop: width 4 loop: loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000669 "ldr q20, [x9], #0x10\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100670 "ldr q19, [x28], #0x10\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000671 "sub x20, x20, #0x4\n"
672 "cmp x20, #0x4\n"
673 "ldr q17, [x27], #0x10\n"
674 "ldr q16, [x26], #0x10\n"
675 "zip1 v22.4s, v20.4s, v17.4s\n"
676 "zip1 v18.4s, v19.4s, v16.4s\n"
677 "zip2 v21.4s, v20.4s, v17.4s\n"
678 "zip2 v20.4s, v19.4s, v16.4s\n"
679 "zip1 v17.4s, v22.4s, v18.4s\n"
680 "zip1 v16.4s, v21.4s, v20.4s\n"
681 ".inst 0x0ea16a33 // bfcvtn v19.4h, v17.4s\n"
682 "zip2 v18.4s, v22.4s, v18.4s\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100683 ".inst 0x0ea16a11 // bfcvtn v17.4h, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000684 "zip2 v16.4s, v21.4s, v20.4s\n"
685 ".inst 0x4ea16a53 // bfcvtn2 v19.8h, v18.4s\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100686 ".inst 0x4ea16a11 // bfcvtn2 v17.8h, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000687 "str q19, [x21, #0x0]\n"
688 "str q17, [x21, #0x10]\n"
689 "add x21, x21, #0x20\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100690 "bge 16b\n"
691 "17:" // Tail row loop: width 4 loop: skip
Michael Tyler7d9a6262023-02-01 16:37:07 +0000692 "cmp x20, #0x1\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100693 "blt 19f\n"
694 "18:" // Tail row loop: width 1 loop: loop
Michael Tyler7d9a6262023-02-01 16:37:07 +0000695 "ldr s19, [x9], #0x4\n"
696 "ldr s18, [x28], #0x4\n"
697 "sub x20, x20, #0x1\n"
698 "cmp x20, #0x1\n"
699 "ldr s17, [x27], #0x4\n"
700 "ldr s16, [x26], #0x4\n"
701 "zip1 v17.4s, v19.4s, v17.4s\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100702 "zip1 v16.4s, v18.4s, v16.4s\n"
703 "zip1 v16.4s, v17.4s, v16.4s\n"
704 ".inst 0x0ea16a10 // bfcvtn v16.4h, v16.4s\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000705 "str d16, [x21, #0x0]\n"
706 "add x21, x21, #0x8\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100707 "bge 18b\n"
708 "19:" // Tail row loop: width 1 loop: skip
Michael Tylerbe13cea2023-01-17 11:04:14 +0000709 "cmp %x[height], #0x1\n"
Michael Tyler7d9a6262023-02-01 16:37:07 +0000710 "add %x[out], %x[out], #0x60\n"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100711 "bge 11b\n"
712 "20:" // Done
713
714 : [height] "+&r" (height), [in] "+&r" (in), [out] "+&r" (out)
715 : [in_stride] "r" (in_stride), [out_stride] "r" (out_stride), [pad_row] "r" (pad_row), [width] "r" (width)
Michael Tyler7d9a6262023-02-01 16:37:07 +0000716 : "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", "x9", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28"
Georgios Pinitas4ee8b152021-07-16 16:16:43 +0100717 );
718}
719
720} // anonymous namespace
721template<>
722void Transform<12, 4, true, VLType::None>(
723 bfloat16 *out, const float *in, int stride, int x0, int xmax, int k0, int kmax)
724{
725 a64_transpose_interleave_12_2x4_fp32bf16(
726 out,
727 in + k0 * stride + x0,
728 (xmax-x0),
729 stride * sizeof(float),
730 (kmax-k0)
731 );
732}
733
734#endif