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 | #define TEST_MSG "VEXT/VEXTQ" |
| 35 | void exec_vext (void) |
| 36 | { |
| 37 | /* vector_res = vext(vector1,vector2,offset), then store the result. */ |
| 38 | #define TEST_VEXT(Q, T1, T2, W, N, V) \ |
| 39 | VECT_VAR(vector_res, T1, W, N) = \ |
| 40 | vext##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \ |
| 41 | VECT_VAR(vector2, T1, W, N), \ |
| 42 | V); \ |
| 43 | vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N)) |
| 44 | |
| 45 | /* With ARM RVCT, we need to declare variables before any executable |
| 46 | statement */ |
| 47 | DECL_VARIABLE_ALL_VARIANTS(vector1); |
| 48 | DECL_VARIABLE_ALL_VARIANTS(vector2); |
| 49 | DECL_VARIABLE_ALL_VARIANTS(vector_res); |
| 50 | |
| 51 | clean_results (); |
| 52 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 53 | TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer); |
| 54 | VLOAD(vector1, buffer, , float, f, 32, 2); |
| 55 | VLOAD(vector1, buffer, q, float, f, 32, 4); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 56 | |
| 57 | /* Choose arbitrary initialization values */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 58 | VDUP(vector2, , int, s, 8, 8, 0x11); |
| 59 | VDUP(vector2, , int, s, 16, 4, 0x22); |
| 60 | VDUP(vector2, , int, s, 32, 2, 0x33); |
| 61 | VDUP(vector2, , int, s, 64, 1, 0x44); |
| 62 | VDUP(vector2, , uint, u, 8, 8, 0x55); |
| 63 | VDUP(vector2, , uint, u, 16, 4, 0x66); |
| 64 | VDUP(vector2, , uint, u, 32, 2, 0x77); |
| 65 | VDUP(vector2, , uint, u, 64, 1, 0x88); |
| 66 | VDUP(vector2, , poly, p, 8, 8, 0x55); |
| 67 | VDUP(vector2, , poly, p, 16, 4, 0x66); |
| 68 | VDUP(vector2, , float, f, 32, 2, 33.6f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 69 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 70 | VDUP(vector2, q, int, s, 8, 16, 0x11); |
| 71 | VDUP(vector2, q, int, s, 16, 8, 0x22); |
| 72 | VDUP(vector2, q, int, s, 32, 4, 0x33); |
| 73 | VDUP(vector2, q, int, s, 64, 2, 0x44); |
| 74 | VDUP(vector2, q, uint, u, 8, 16, 0x55); |
| 75 | VDUP(vector2, q, uint, u, 16, 8, 0x66); |
| 76 | VDUP(vector2, q, uint, u, 32, 4, 0x77); |
| 77 | VDUP(vector2, q, uint, u, 64, 2, 0x88); |
| 78 | VDUP(vector2, q, poly, p, 8, 16, 0x55); |
| 79 | VDUP(vector2, q, poly, p, 16, 8, 0x66); |
| 80 | VDUP(vector2, q, float, f, 32, 4, 33.2f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 81 | |
| 82 | /* Choose arbitrary extract offsets */ |
| 83 | TEST_VEXT(, int, s, 8, 8, 7); |
| 84 | TEST_VEXT(, int, s, 16, 4, 3); |
| 85 | TEST_VEXT(, int, s, 32, 2, 1); |
| 86 | TEST_VEXT(, int, s, 64, 1, 0); |
| 87 | TEST_VEXT(, uint, u, 8, 8, 6); |
| 88 | TEST_VEXT(, uint, u, 16, 4, 2); |
| 89 | TEST_VEXT(, uint, u, 32, 2, 1); |
| 90 | TEST_VEXT(, uint, u, 64, 1, 0); |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 91 | TEST_VEXT(, poly, p, 8, 8, 6); |
| 92 | TEST_VEXT(, poly, p, 16, 4, 2); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 93 | TEST_VEXT(, float, f, 32, 2, 1); |
| 94 | |
| 95 | TEST_VEXT(q, int, s, 8, 16, 14); |
| 96 | TEST_VEXT(q, int, s, 16, 8, 7); |
| 97 | TEST_VEXT(q, int, s, 32, 4, 3); |
| 98 | TEST_VEXT(q, int, s, 64, 2, 1); |
| 99 | TEST_VEXT(q, uint, u, 8, 16, 12); |
| 100 | TEST_VEXT(q, uint, u, 16, 8, 6); |
| 101 | TEST_VEXT(q, uint, u, 32, 4, 3); |
| 102 | TEST_VEXT(q, uint, u, 64, 2, 1); |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 103 | TEST_VEXT(q, poly, p, 8, 16, 12); |
| 104 | TEST_VEXT(q, poly, p, 16, 8, 6); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 105 | TEST_VEXT(q, float, f, 32, 4, 3); |
| 106 | |
| 107 | dump_results_hex (TEST_MSG); |
| 108 | } |