blob: f6233ef5031fa17796536e3f4d596c6373ea0004 [file] [log] [blame]
Pablo Telloeb82fd22018-02-23 13:43:50 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2018 Arm Limited.
Pablo Telloeb82fd22018-02-23 13:43:50 +00003 *
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 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
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
20 * 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.
23 */
24#pragma once
25
26#ifdef __aarch64__
27
28#include "transpose_interleave_common.hpp"
29
30// Generic unblocked transposed 6x32-bit sized specialisation
31template <>
32template <typename T>
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000033inline void TransformImpl<6, 1, true, 4, 4, VLType::None>::Transform(
Anthony Barbier5f707732018-07-03 16:22:02 +010034 T* out, const T* const in, const int stride,
35 const int x0, const int xmax, const int k0, const int kmax
36) {
37 // Redirect to a 12 x uint16_t specialisation
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000038 TransformImpl<12, 1, true, 2, 2, VLType::None>::Transform(
Anthony Barbier5f707732018-07-03 16:22:02 +010039 reinterpret_cast<uint16_t *>(out),
Kohei Takahashicedb78f2018-08-23 10:23:52 +090040 reinterpret_cast<const uint16_t *>(in),
Anthony Barbier5f707732018-07-03 16:22:02 +010041 stride*2, x0*2, xmax*2, k0, kmax
42 );
Pablo Telloeb82fd22018-02-23 13:43:50 +000043}
44
45// Generic 12x16-bit sized specialisation
46template <>
47template <typename T>
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000048inline void TransformImpl<12, 1, true, 2, 2, VLType::None>::Transform(
Anthony Barbier5f707732018-07-03 16:22:02 +010049 T* out, const T* const in, const int stride,
50 const int x0, const int xmax, const int k0, const int kmax
51) {
52 // Redirect to a uint16_t specialisation
53 Transform(
54 reinterpret_cast<uint16_t *>(out),
Kohei Takahashicedb78f2018-08-23 10:23:52 +090055 reinterpret_cast<const uint16_t *>(in),
Anthony Barbier5f707732018-07-03 16:22:02 +010056 stride, x0, xmax, k0, kmax
57 );
Pablo Telloeb82fd22018-02-23 13:43:50 +000058}
59
60// Specialised 12 x uint16_t version
61template <>
Anthony Barbier5f707732018-07-03 16:22:02 +010062inline void TransposeInterleaveCommon<12, uint16_t, uint16_t>::moveblock_1x1(const uint16_t *&in0, uint16_t *out) {
63 __asm volatile (
64 "LDR q0, [%[in0]]\n"
65 "STR q0, [%[out]]\n"
66 "LDR d1, [%[in0], #0x10]\n"
67 "STR d1, [%[out], #0x10]\n"
68 "ADD %x[in0], %x[in0], #0x18\n"
69 ASM_PREFETCH("[%[in0], #192]")
70 : [in0] "+r" (in0),
71 [out] "+r" (out)
72 :
73 : "v0", "v1", "memory"
74 );
Pablo Telloeb82fd22018-02-23 13:43:50 +000075}
76
77template <>
Anthony Barbier5f707732018-07-03 16:22:02 +010078inline void TransposeInterleaveCommon<12, uint16_t, uint16_t>::moveblock_1x2(const uint16_t *&in0, const uint16_t *&in1, uint16_t *out) {
79 __asm volatile (
80 "LDR q0, [%[in0]]\n"
81 "LDR d1, [%[in0], #0x10]\n"
82 "ADD %x[in0], %x[in0], #0x18\n"
83 ASM_PREFETCH("[%[in0], #192]")
Pablo Telloeb82fd22018-02-23 13:43:50 +000084
Anthony Barbier5f707732018-07-03 16:22:02 +010085 "LDR x21, [%[in1]]\n"
86 "LDR q2, [%[in1], #0x08]\n"
87 "INS v1.d[1], x21\n"
88 "ADD %x[in1], %x[in1], #0x18\n"
89 "STP q0, q1, [%[out]]\n"
90 "STR q2, [%x[out], #0x20]\n"
91 ASM_PREFETCH("[%[in1], #192]")
92 : [in0] "+r" (in0),
93 [in1] "+r" (in1),
94 [out] "+r" (out)
95 :
96 : "x21", "v0", "v1", "v2", "memory"
97 );
Pablo Telloeb82fd22018-02-23 13:43:50 +000098}
99
100template <>
Anthony Barbier5f707732018-07-03 16:22:02 +0100101inline void TransposeInterleaveCommon<12, uint16_t, uint16_t>::moveblock_1x4(const uint16_t *&in0, const uint16_t *&in1, const uint16_t *&in2, const uint16_t *&in3, uint16_t *out) {
102 __asm __volatile (
103 "LDR q0, [%x[in0]], #0x10\n"
104 "STR q0, [%x[out]]\n"
105 "LDR d1, [%x[in0]], #0x08\n"
106 ASM_PREFETCH("[%[in0], #192]")
107 "STR d1, [%x[out], #0x10]\n"
Pablo Telloeb82fd22018-02-23 13:43:50 +0000108
Anthony Barbier5f707732018-07-03 16:22:02 +0100109 "LDR q0, [%x[in1]], #0x10\n"
110 "STR q0, [%x[out], #0x18]\n"
111 "LDR d1, [%x[in1]], #0x08\n"
112 ASM_PREFETCH("[%[in1], #192]")
113 "STR d1, [%x[out], #0x28]\n"
Pablo Telloeb82fd22018-02-23 13:43:50 +0000114
Anthony Barbier5f707732018-07-03 16:22:02 +0100115 "LDR q0, [%x[in2]], #0x10\n"
116 "STR q0, [%x[out], #0x30]\n"
117 "LDR d1, [%x[in2]], #0x08\n"
118 ASM_PREFETCH("[%[in2], #192]")
119 "STR d1, [%x[out], #0x40]\n"
Pablo Telloeb82fd22018-02-23 13:43:50 +0000120
Anthony Barbier5f707732018-07-03 16:22:02 +0100121 "LDR q0, [%x[in3]], #0x10\n"
122 "STR q0, [%x[out], #0x48]\n"
123 "LDR d1, [%x[in3]], #0x08\n"
124 ASM_PREFETCH("[%[in3], #192]")
125 "STR d1, [%x[out], #0x58]\n"
126 : [in0] "+r" (in0),
127 [in1] "+r" (in1),
128 [in2] "+r" (in2),
129 [in3] "+r" (in3),
130 [out] "+r" (out)
131 :
132 : "v0", "v1", "memory"
133 );
Pablo Telloeb82fd22018-02-23 13:43:50 +0000134}
135
136template <>
137template <>
Georgios Pinitasc0b6f762020-11-02 01:37:17 +0000138inline void TransformImpl<12, 1, true, 2, 2, VLType::None>::Transform(
Anthony Barbier5f707732018-07-03 16:22:02 +0100139 uint16_t* out, const uint16_t* const in, const int stride,
140 const int x0, const int xmax, const int k0, const int kmax
141) {
142 TransposeInterleaveCommon<12, uint16_t, uint16_t>::Transform(out, in, stride, x0, xmax, k0, kmax);
Pablo Telloeb82fd22018-02-23 13:43:50 +0000143}
144
145#endif // __aarch64__