blob: bcbe2b84d88ce8e5865666f5a859c42730ce29f8 [file] [log] [blame]
Pablo Telloeb82fd22018-02-23 13:43:50 +00001/*
Georgios Pinitas5aa1a0b2020-07-02 20:02:20 +01002 * Copyright (c) 2017-2020 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 12x32-bit sized specialisation
31template <>
32template <typename T>
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000033inline void TransformImpl<12, 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 24 x uint16_t specialisation
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000038 TransformImpl<24, 1, true, 2, 2, VLType::None>::Transform(
Anthony Barbier5f707732018-07-03 16:22:02 +010039 reinterpret_cast<uint16_t *>(out),
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010040 reinterpret_cast<const uint16_t * const>(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 24x16-bit sized specialisation
46template <>
47template <typename T>
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000048inline void TransformImpl<24, 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),
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010055 reinterpret_cast<const uint16_t * const>(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 24 x uint16_t version
61template <>
Anthony Barbier5f707732018-07-03 16:22:02 +010062inline void TransposeInterleaveCommon<24, uint16_t, uint16_t>::moveblock_1x1(const uint16_t *&in0, uint16_t *out) {
63 __asm __volatile (
Pablo Telloeb82fd22018-02-23 13:43:50 +000064 "LDP q0, q1, [%[in0]], #32\n"
65 "STP q0, q1, [%[out]]\n"
Anthony Barbier5f707732018-07-03 16:22:02 +010066 ASM_PREFETCH("[%[in0], #192]")
67 "LDR q2, [%[in0]], #16\n"
68 "STR q2, [%[out], #32]\n"
69 : [in0] "+r" (in0), [out] "+r" (out)
70 :
71 : "v0", "v1", "v2", "memory"
72 );
73}
Pablo Telloeb82fd22018-02-23 13:43:50 +000074
Anthony Barbier5f707732018-07-03 16:22:02 +010075template <>
76inline void TransposeInterleaveCommon<24, uint16_t, uint16_t>::moveblock_1x2(const uint16_t *&in0, const uint16_t *&in1,uint16_t *out) {
77 __asm __volatile (
78 "LDP q0, q1, [%[in0]], #32\n"
79 "STP q0, q1, [%[out]]\n"
80 ASM_PREFETCH("[%[in0], #192]")
81 "LDR q2, [%[in0]], #16\n"
82 "LDP q3, q4, [%[in1]], #32\n"
83 "STP q2, q3, [%[out], #32]\n"
84 ASM_PREFETCH("[%[in1], #192]")
85 "LDR q5, [%[in1]], #16\n"
86 "STP q4, q5, [%[out], #64]\n"
87 : [in0] "+r" (in0), [in1] "+r" (in1), [out] "+r" (out)
88 :
89 : "v0", "v1", "v2", "v3", "v4", "v5", "memory"
90 );
91}
92
93template <>
94inline void TransposeInterleaveCommon<24, 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) {
95 __asm __volatile (
96 "LDP q0, q1, [%[in0]], #32\n"
97 "STP q0, q1, [%[out]]\n"
98 "LDR q2, [%[in0]], #16\n"
99 ASM_PREFETCH("[%[in0], #192]")
100 "LDP q3, q4, [%[in1]], #32\n"
101 "STP q2, q3, [%[out], #32]\n"
102 "LDR q5, [%[in1]], #16\n"
103 ASM_PREFETCH("[%[in1], #192]")
104 "STP q4, q5, [%[out], #64]\n"
105 "LDP q6, q7, [%[in2]], #32\n"
106 "STP q6, q7, [%[out], #96]\n"
107 "LDR q8, [%[in2]], #16\n"
108 ASM_PREFETCH("[%[in2], #192]")
109 "LDP q9, q10, [%[in3]], #32\n"
110 "STP q8, q9, [%[out], #128]\n"
111 "LDR q11, [%[in3]], #16\n"
112 "STP q10, q11, [%[out], #160]\n"
113 ASM_PREFETCH("[%[in3], #192]")
114
115 : [in0] "+r" (in0), [in1] "+r" (in1), [in2] "+r" (in2), [in3] "+r" (in3), [out] "+r" (out)
116 :
117 : "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "memory"
118 );
Pablo Telloeb82fd22018-02-23 13:43:50 +0000119}
120
121template <>
122template <>
Georgios Pinitasc0b6f762020-11-02 01:37:17 +0000123inline void TransformImpl<24, 1, true, 2, 2, VLType::None>::Transform(
Anthony Barbier5f707732018-07-03 16:22:02 +0100124 uint16_t* out, const uint16_t* const in, const int stride,
125 const int x0, const int xmax, const int k0, const int kmax
126) {
127 TransposeInterleaveCommon<24, uint16_t, uint16_t>::Transform(out, in, stride, x0, xmax, k0, kmax);
Pablo Telloeb82fd22018-02-23 13:43:50 +0000128}
129
Anthony Barbier5f707732018-07-03 16:22:02 +0100130#endif // __arch64__