Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1 | /* |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 2 | * Copyright (c) 2019-2021 Arm Limited. |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 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 |
| 14 | * all 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 |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 22 | * IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #ifdef __aarch64__ |
| 26 | |
| 27 | template<> |
| 28 | void interleave_block<8, 2, VLType::None, false>( |
| 29 | float * &out_ptr, const float * const * in, size_t width, size_t height, |
| 30 | size_t row_offset, bool |
| 31 | ) |
| 32 | { |
| 33 | __asm__ __volatile__( |
| 34 | "ldr x27, [%x[in], #0x0]\n" |
| 35 | "cmp %x[height], #0x8\n" |
| 36 | "ldr x26, [%x[in], #0x8]\n" |
| 37 | "add x27, x27, %x[row_offset], LSL #2\n" |
| 38 | "ldr x25, [%x[in], #0x10]\n" |
| 39 | "ldr x24, [%x[in], #0x18]\n" |
| 40 | "add x26, x26, %x[row_offset], LSL #2\n" |
| 41 | "ldr x23, [%x[in], #0x20]\n" |
| 42 | "add x25, x25, %x[row_offset], LSL #2\n" |
| 43 | "ldr x22, [%x[in], #0x28]\n" |
| 44 | "ldr x21, [%x[in], #0x30]\n" |
| 45 | "add x24, x24, %x[row_offset], LSL #2\n" |
| 46 | "ldr x20, [%x[in], #0x38]\n" |
| 47 | "add x23, x23, %x[row_offset], LSL #2\n" |
| 48 | "add x22, x22, %x[row_offset], LSL #2\n" |
| 49 | "add x21, x21, %x[row_offset], LSL #2\n" |
| 50 | "add x20, x20, %x[row_offset], LSL #2\n" |
| 51 | "beq 1f\n" |
| 52 | "mov x20, x27\n" |
| 53 | "cmp %x[height], #0x2\n" |
| 54 | "csel x26, x26, x27, GE\n" |
| 55 | "csel x25, x25, x27, GT\n" |
| 56 | "cmp %x[height], #0x4\n" |
| 57 | "csel x24, x24, x27, GE\n" |
| 58 | "csel x23, x23, x27, GT\n" |
| 59 | "cmp %x[height], #0x6\n" |
| 60 | "csel x22, x22, x27, GE\n" |
| 61 | "csel x21, x21, x27, GT\n" |
| 62 | "1:" // no_pointer_adj |
| 63 | "prfm pldl1keep, [x27, #0x0]\n" |
| 64 | "cmp %x[width], #0x4\n" |
| 65 | "prfm pldl1keep, [x26, #0x0]\n" |
| 66 | "prfm pldl1keep, [x25, #0x0]\n" |
| 67 | "prfm pldl1keep, [x24, #0x0]\n" |
| 68 | "prfm pldl1keep, [x23, #0x0]\n" |
| 69 | "prfm pldl1keep, [x22, #0x0]\n" |
| 70 | "prfm pldl1keep, [x21, #0x0]\n" |
| 71 | "prfm pldl1keep, [x20, #0x0]\n" |
| 72 | "prfm pldl1keep, [x27, #0x40]\n" |
| 73 | "prfm pldl1keep, [x26, #0x40]\n" |
| 74 | "prfm pldl1keep, [x25, #0x40]\n" |
| 75 | "prfm pldl1keep, [x24, #0x40]\n" |
| 76 | "prfm pldl1keep, [x23, #0x40]\n" |
| 77 | "prfm pldl1keep, [x22, #0x40]\n" |
| 78 | "prfm pldl1keep, [x21, #0x40]\n" |
| 79 | "prfm pldl1keep, [x20, #0x40]\n" |
| 80 | "blt 3f\n" |
| 81 | "2:" // Main loop head |
| 82 | "ldr q27, [x27], #0x10\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 83 | "subs %x[width], %x[width], #0x4\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 84 | "ldr q24, [x26], #0x10\n" |
| 85 | "zip1 v26.2d, v27.2d, v24.2d\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 86 | "ldr q25, [x25], #0x10\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 87 | "cmp %x[width], #0x4\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 88 | "zip2 v24.2d, v27.2d, v24.2d\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 89 | "ldr q21, [x24], #0x10\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 90 | "ldr q23, [x23], #0x10\n" |
| 91 | "zip1 v22.2d, v25.2d, v21.2d\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 92 | "ldr q18, [x22], #0x10\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 93 | "zip2 v21.2d, v25.2d, v21.2d\n" |
| 94 | "ldr q20, [x21], #0x10\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 95 | "ldr q16, [x20], #0x10\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 96 | "zip1 v19.2d, v23.2d, v18.2d\n" |
| 97 | "prfm pldl1keep, [x27, #0x70]\n" |
| 98 | "zip2 v18.2d, v23.2d, v18.2d\n" |
| 99 | "prfm pldl1keep, [x26, #0x70]\n" |
| 100 | "zip1 v17.2d, v20.2d, v16.2d\n" |
| 101 | "prfm pldl1keep, [x25, #0x70]\n" |
| 102 | "zip2 v16.2d, v20.2d, v16.2d\n" |
| 103 | "prfm pldl1keep, [x24, #0x70]\n" |
| 104 | "prfm pldl1keep, [x23, #0x70]\n" |
| 105 | "prfm pldl1keep, [x22, #0x70]\n" |
| 106 | "prfm pldl1keep, [x21, #0x70]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 107 | "prfm pldl1keep, [x20, #0x70]\n" |
| 108 | "str q26, [%x[out_ptr], #0x0]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 109 | "str q22, [%x[out_ptr], #0x10]\n" |
| 110 | "str q19, [%x[out_ptr], #0x20]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 111 | "str q17, [%x[out_ptr], #0x30]\n" |
| 112 | "str q24, [%x[out_ptr], #0x40]\n" |
| 113 | "str q21, [%x[out_ptr], #0x50]\n" |
| 114 | "str q18, [%x[out_ptr], #0x60]\n" |
| 115 | "str q16, [%x[out_ptr], #0x70]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 116 | "add %x[out_ptr], %x[out_ptr], #0x80\n" |
| 117 | "bge 2b\n" |
| 118 | "3:" // Main loop skip |
| 119 | "cbz %x[width], 6f\n" |
| 120 | "tbz %x[width], #1, 4f\n" |
| 121 | "ldr d27, [x27], #0x8\n" |
| 122 | "ldr d24, [x26], #0x8\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 123 | "mov x19, #0x1\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 124 | "ldr d25, [x25], #0x8\n" |
| 125 | "ldr d21, [x24], #0x8\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 126 | "ldr d23, [x23], #0x8\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 127 | "ldr d18, [x22], #0x8\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 128 | "ldr d20, [x21], #0x8\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 129 | "ldr d16, [x20], #0x8\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 130 | "tbz %x[width], #0, 5f\n" |
| 131 | "ld1 { v27.s }[2], [x27]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 132 | "mov x19, #0x2\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 133 | "ld1 { v24.s }[2], [x26]\n" |
| 134 | "ld1 { v25.s }[2], [x25]\n" |
| 135 | "ld1 { v21.s }[2], [x24]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 136 | "ld1 { v23.s }[2], [x23]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 137 | "ld1 { v18.s }[2], [x22]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 138 | "ld1 { v20.s }[2], [x21]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 139 | "ld1 { v16.s }[2], [x20]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 140 | "b 5f\n" |
| 141 | "4:" // odd_loads_1_0 |
| 142 | "ldr s27, [x27, #0x0]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 143 | "mov x19, #0x1\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 144 | "ldr s24, [x26, #0x0]\n" |
| 145 | "ldr s25, [x25, #0x0]\n" |
| 146 | "ldr s21, [x24, #0x0]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 147 | "ldr s23, [x23, #0x0]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 148 | "ldr s18, [x22, #0x0]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 149 | "ldr s20, [x21, #0x0]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 150 | "ldr s16, [x20, #0x0]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 151 | "5:" // Odd load end |
| 152 | "zip1 v26.2d, v27.2d, v24.2d\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 153 | "str q26, [%x[out_ptr], #0x0]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 154 | "zip1 v22.2d, v25.2d, v21.2d\n" |
| 155 | "subs x19, x19, #0x1\n" |
| 156 | "zip1 v19.2d, v23.2d, v18.2d\n" |
| 157 | "str q22, [%x[out_ptr], #0x10]\n" |
| 158 | "zip1 v17.2d, v20.2d, v16.2d\n" |
| 159 | "str q19, [%x[out_ptr], #0x20]\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 160 | "str q17, [%x[out_ptr], #0x30]\n" |
| 161 | "add %x[out_ptr], %x[out_ptr], #0x40\n" |
| 162 | "beq 6f\n" |
| 163 | "zip2 v24.2d, v27.2d, v24.2d\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 164 | "str q24, [%x[out_ptr], #0x0]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 165 | "zip2 v21.2d, v25.2d, v21.2d\n" |
| 166 | "zip2 v18.2d, v23.2d, v18.2d\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 167 | "str q21, [%x[out_ptr], #0x10]\n" |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 168 | "zip2 v16.2d, v20.2d, v16.2d\n" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 169 | "str q18, [%x[out_ptr], #0x20]\n" |
| 170 | "str q16, [%x[out_ptr], #0x30]\n" |
| 171 | "add %x[out_ptr], %x[out_ptr], #0x40\n" |
| 172 | "6:" // Odds skip |
| 173 | |
Georgios Pinitas | e28cf39 | 2021-01-31 05:18:43 +0000 | [diff] [blame] | 174 | : [out_ptr] "+&r" (out_ptr), [width] "+&r" (width) |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 175 | : [height] "r" (height), [in] "r" (in), [row_offset] "r" (row_offset) |
| 176 | : "cc", "memory", "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25", "v26", "v27", "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27" |
| 177 | ); |
| 178 | } |
| 179 | |
| 180 | |
| 181 | #endif // __aarch64__ |