Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 3 | Copyright (c) 2009, 2010, 2011, 2013 STMicroelectronics |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 4 | Written by Christophe Lyon |
| 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 deal |
| 8 | in the Software without restriction, including without limitation the rights |
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | 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 FROM, |
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | THE SOFTWARE. |
| 23 | |
| 24 | */ |
| 25 | |
Christophe Lyon | 1775be0 | 2014-07-10 13:46:54 +0200 | [diff] [blame] | 26 | #if defined(__arm__) || defined(__aarch64__) |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 27 | #include <arm_neon.h> |
| 28 | #else |
Christophe Lyon | 0dab5f7 | 2011-07-19 17:14:09 +0200 | [diff] [blame] | 29 | #include "stm-arm-neon.h" |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #include "stm-arm-neon-ref.h" |
| 33 | |
| 34 | #ifndef INSN_NAME |
| 35 | #define INSN_NAME vuzp |
| 36 | #define TEST_MSG "VUZP/VUZPQ" |
| 37 | #endif |
| 38 | |
| 39 | #define FNNAME1(NAME) void exec_ ## NAME (void) |
| 40 | #define FNNAME(NAME) FNNAME1(NAME) |
| 41 | |
| 42 | FNNAME (INSN_NAME) |
| 43 | { |
| 44 | /* In this case, output variables are arrays of vectors */ |
| 45 | #define DECL_VUZP(T1, W, N) \ |
| 46 | VECT_ARRAY_TYPE(T1, W, N, 2) VECT_ARRAY_VAR(result_vec, T1, W, N, 2); \ |
| 47 | VECT_VAR_DECL(result_bis, T1, W, N)[2 * N] |
| 48 | |
| 49 | /* We need to use a temporary result buffer (result_bis), because |
| 50 | the one used for other tests is not large enough. A subset of the |
| 51 | result data is moved from result_bis to result, and it is this |
| 52 | subset which is used to check the actual behaviour. The next |
| 53 | macro enables to move another chunk of data from result_bis to |
| 54 | result. */ |
| 55 | #define TEST_VUZP(INSN, Q, T1, T2, W, N) \ |
| 56 | VECT_ARRAY_VAR(result_vec, T1, W, N, 2) = \ |
| 57 | INSN##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \ |
| 58 | VECT_VAR(vector2, T1, W, N)); \ |
| 59 | vst2##Q##_##T2##W(VECT_VAR(result_bis, T1, W, N), \ |
| 60 | VECT_ARRAY_VAR(result_vec, T1, W, N, 2)); \ |
| 61 | memcpy(VECT_VAR(result, T1, W, N), VECT_VAR(result_bis, T1, W, N), \ |
| 62 | sizeof(VECT_VAR(result, T1, W, N))); |
| 63 | |
| 64 | /* Overwrite "result" with the contents of "result_bis"[X] */ |
| 65 | #define TEST_EXTRA_CHUNK(T1, W, N, X) \ |
Christophe Lyon | 3f968e4 | 2013-01-10 18:49:49 +0100 | [diff] [blame] | 66 | memcpy(VECT_VAR(result, T1, W, N), &(VECT_VAR(result_bis, T1, W, N)[X*N]), \ |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 67 | sizeof(VECT_VAR(result, T1, W, N))); |
| 68 | |
| 69 | /* With ARM RVCT, we need to declare variables before any executable |
| 70 | statement */ |
| 71 | DECL_VARIABLE_ALL_VARIANTS(vector1); |
| 72 | DECL_VARIABLE_ALL_VARIANTS(vector2); |
| 73 | |
| 74 | /* We don't need 64 bits variants */ |
| 75 | #define DECL_ALL_VUZP() \ |
| 76 | DECL_VUZP(int, 8, 8); \ |
| 77 | DECL_VUZP(int, 16, 4); \ |
| 78 | DECL_VUZP(int, 32, 2); \ |
| 79 | DECL_VUZP(uint, 8, 8); \ |
| 80 | DECL_VUZP(uint, 16, 4); \ |
| 81 | DECL_VUZP(uint, 32, 2); \ |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 82 | DECL_VUZP(poly, 8, 8); \ |
| 83 | DECL_VUZP(poly, 16, 4); \ |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 84 | DECL_VUZP(float, 32, 2); \ |
| 85 | DECL_VUZP(int, 8, 16); \ |
| 86 | DECL_VUZP(int, 16, 8); \ |
| 87 | DECL_VUZP(int, 32, 4); \ |
| 88 | DECL_VUZP(uint, 8, 16); \ |
| 89 | DECL_VUZP(uint, 16, 8); \ |
| 90 | DECL_VUZP(uint, 32, 4); \ |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 91 | DECL_VUZP(poly, 8, 16); \ |
| 92 | DECL_VUZP(poly, 16, 8); \ |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 93 | DECL_VUZP(float, 32, 4) |
| 94 | |
| 95 | DECL_ALL_VUZP(); |
| 96 | |
| 97 | /* Initialize input "vector" from "buffer" */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 98 | TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer); |
| 99 | VLOAD(vector1, buffer, , float, f, 32, 2); |
| 100 | VLOAD(vector1, buffer, q, float, f, 32, 4); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 101 | |
| 102 | /* Choose arbitrary initialization values */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 103 | VDUP(vector2, , int, s, 8, 8, 0x11); |
| 104 | VDUP(vector2, , int, s, 16, 4, 0x22); |
| 105 | VDUP(vector2, , int, s, 32, 2, 0x33); |
| 106 | VDUP(vector2, , uint, u, 8, 8, 0x55); |
| 107 | VDUP(vector2, , uint, u, 16, 4, 0x66); |
| 108 | VDUP(vector2, , uint, u, 32, 2, 0x77); |
| 109 | VDUP(vector2, , poly, p, 8, 8, 0x55); |
| 110 | VDUP(vector2, , poly, p, 16, 4, 0x66); |
| 111 | VDUP(vector2, , float, f, 32, 2, 33.6f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 112 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 113 | VDUP(vector2, q, int, s, 8, 16, 0x11); |
| 114 | VDUP(vector2, q, int, s, 16, 8, 0x22); |
| 115 | VDUP(vector2, q, int, s, 32, 4, 0x33); |
| 116 | VDUP(vector2, q, uint, u, 8, 16, 0x55); |
| 117 | VDUP(vector2, q, uint, u, 16, 8, 0x66); |
| 118 | VDUP(vector2, q, uint, u, 32, 4, 0x77); |
| 119 | VDUP(vector2, q, poly, p, 8, 16, 0x55); |
| 120 | VDUP(vector2, q, poly, p, 16, 8, 0x66); |
| 121 | VDUP(vector2, q, float, f, 32, 4, 33.8f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 122 | |
| 123 | #define TEST_ALL_VUZP(INSN) \ |
| 124 | TEST_VUZP(INSN, , int, s, 8, 8); \ |
| 125 | TEST_VUZP(INSN, , int, s, 16, 4); \ |
| 126 | TEST_VUZP(INSN, , int, s, 32, 2); \ |
| 127 | TEST_VUZP(INSN, , uint, u, 8, 8); \ |
| 128 | TEST_VUZP(INSN, , uint, u, 16, 4); \ |
| 129 | TEST_VUZP(INSN, , uint, u, 32, 2); \ |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 130 | TEST_VUZP(INSN, , poly, p, 8, 8); \ |
| 131 | TEST_VUZP(INSN, , poly, p, 16, 4); \ |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 132 | TEST_VUZP(INSN, , float, f, 32, 2); \ |
| 133 | TEST_VUZP(INSN, q, int, s, 8, 16); \ |
| 134 | TEST_VUZP(INSN, q, int, s, 16, 8); \ |
| 135 | TEST_VUZP(INSN, q, int, s, 32, 4); \ |
| 136 | TEST_VUZP(INSN, q, uint, u, 8, 16); \ |
| 137 | TEST_VUZP(INSN, q, uint, u, 16, 8); \ |
| 138 | TEST_VUZP(INSN, q, uint, u, 32, 4); \ |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 139 | TEST_VUZP(INSN, q, poly, p, 8, 16); \ |
| 140 | TEST_VUZP(INSN, q, poly, p, 16, 8); \ |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 141 | TEST_VUZP(INSN, q, float, f, 32, 4) |
| 142 | |
| 143 | #define TEST_ALL_EXTRA_CHUNKS() \ |
| 144 | TEST_EXTRA_CHUNK(int, 8, 8, 1); \ |
| 145 | TEST_EXTRA_CHUNK(int, 16, 4, 1); \ |
| 146 | TEST_EXTRA_CHUNK(int, 32, 2, 1); \ |
| 147 | TEST_EXTRA_CHUNK(uint, 8, 8, 1); \ |
| 148 | TEST_EXTRA_CHUNK(uint, 16, 4, 1); \ |
| 149 | TEST_EXTRA_CHUNK(uint, 32, 2, 1); \ |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 150 | TEST_EXTRA_CHUNK(poly, 8, 8, 1); \ |
| 151 | TEST_EXTRA_CHUNK(poly, 16, 4, 1); \ |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 152 | TEST_EXTRA_CHUNK(float, 32, 2, 1); \ |
| 153 | TEST_EXTRA_CHUNK(int, 8, 16, 1); \ |
| 154 | TEST_EXTRA_CHUNK(int, 16, 8, 1); \ |
| 155 | TEST_EXTRA_CHUNK(int, 32, 4, 1); \ |
| 156 | TEST_EXTRA_CHUNK(uint, 8, 16, 1); \ |
| 157 | TEST_EXTRA_CHUNK(uint, 16, 8, 1); \ |
| 158 | TEST_EXTRA_CHUNK(uint, 32, 4, 1); \ |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 159 | TEST_EXTRA_CHUNK(poly, 8, 16, 1); \ |
| 160 | TEST_EXTRA_CHUNK(poly, 16, 8, 1); \ |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 161 | TEST_EXTRA_CHUNK(float, 32, 4, 1) |
| 162 | |
| 163 | /* Check vuzp/vuzpq */ |
| 164 | clean_results (); |
| 165 | TEST_ALL_VUZP(INSN_NAME); |
| 166 | |
| 167 | dump_results_hex2 (TEST_MSG, " chunk 0"); |
| 168 | |
| 169 | TEST_ALL_EXTRA_CHUNKS(); |
| 170 | dump_results_hex2 (TEST_MSG, " chunk 1"); |
| 171 | } |