blob: 587bec366a742c04a2cde1da07905e9023030a56 [file] [log] [blame]
Pablo Telloeb82fd22018-02-23 13:43:50 +00001/*
2 * Copyright (c) 2017-2018 ARM Limited.
3 *
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 __arm__
27
28#include "transpose_interleave_common.hpp"
29
30// Generic unblocked transposed 8x32-bit sized specialisation
31template <>
32template <typename T>
David Manselld93991e2018-07-06 14:52:52 +010033inline void TransformImpl<8, 1, true, 4, 4, false>::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 16x uint16_t specialisation
David Manselld93991e2018-07-06 14:52:52 +010038 TransformImpl<16, 1, true, 2, 2, false>::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>
David Manselld93991e2018-07-06 14:52:52 +010048inline void TransformImpl<16, 1, true, 2, 2, false>::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 16 x uint16_t version
61template <>
Anthony Barbier5f707732018-07-03 16:22:02 +010062inline void TransposeInterleaveCommon<16, uint16_t, uint16_t>::moveblock_1x1(const uint16_t *&in0, uint16_t *out) {
63 __asm volatile (
64 "VLD1.32 {d0-d3}, [%[in0]]!\n"
65 "VST1.32 {d0-d3}, [%[out]]\n"
66 ASM_PREFETCH("[%[in0], #192]")
67 : [in0] "+r" (in0),
68 [out] "+r" (out)
69 :
70 : "q0", "q1", "memory"
71 );
Pablo Telloeb82fd22018-02-23 13:43:50 +000072}
73
74template <>
Anthony Barbier5f707732018-07-03 16:22:02 +010075inline void TransposeInterleaveCommon<16, uint16_t, uint16_t>::moveblock_1x2(const uint16_t *&in0, const uint16_t *&in1, uint16_t *out) {
76 __asm volatile (
77 "VLD1.32 {d0-d3}, [%[in0]]!\n"
78 "VST1.32 {d0-d3}, [%[out]]!\n"
79 ASM_PREFETCH("[%[in0], #192]")
80 "VLD1.32 {d0-d3}, [%[in1]]!\n"
81 "VST1.32 {d0-d3}, [%[out]]\n"
82 ASM_PREFETCH("[%[in1], #192]")
83 "SUB %[out], %[out], #32\n"
84 : [in0] "+r" (in0),
85 [in1] "+r" (in1),
86 [out] "+r" (out)
87 :
88 : "q0", "q1", "memory"
89 );
Pablo Telloeb82fd22018-02-23 13:43:50 +000090}
91
92template <>
Anthony Barbier5f707732018-07-03 16:22:02 +010093inline void TransposeInterleaveCommon<16, 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) {
94 __asm __volatile (
95 "VLD1.32 {d0-d3}, [%[in0]]!\n"
96 "VST1.32 {d0-d3}, [%[out]]!\n"
97 ASM_PREFETCH("[%[in0], #192]")
98 "VLD1.32 {d0-d3}, [%[in1]]!\n"
99 "VST1.32 {d0-d3}, [%[out]]!\n"
100 ASM_PREFETCH("[%[in1], #192]")
101 "VLD1.32 {d0-d3}, [%[in2]]!\n"
102 "VST1.32 {d0-d3}, [%[out]]!\n"
103 ASM_PREFETCH("[%[in2], #192]")
104 "VLD1.32 {d0-d3}, [%[in3]]!\n"
105 "VST1.32 {d0-d3}, [%[out]]\n"
106 ASM_PREFETCH("[%[in3], #192]")
107 "SUB %[out], %[out], #96\n"
108 : [in0] "+r" (in0),
109 [in1] "+r" (in1),
110 [in2] "+r" (in2),
111 [in3] "+r" (in3),
112 [out] "+r" (out)
113 :
114 : "q0", "q1", "memory"
115 );
Pablo Telloeb82fd22018-02-23 13:43:50 +0000116}
117
118template <>
119template <>
David Manselld93991e2018-07-06 14:52:52 +0100120inline void TransformImpl<16, 1, true, 2, 2, false>::Transform(
Anthony Barbier5f707732018-07-03 16:22:02 +0100121 uint16_t* out, const uint16_t* const in, const int stride,
122 const int x0, const int xmax, const int k0, const int kmax
123) {
124 TransposeInterleaveCommon<16, uint16_t, uint16_t>::Transform(out, in, stride, x0, xmax, k0, kmax);
Pablo Telloeb82fd22018-02-23 13:43:50 +0000125}
126
127#endif // __arm__