Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | Copyright (c) 2009, 2010, 2011 STMicroelectronics |
| 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 | |
| 26 | #ifdef __arm__ |
| 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 | |
| 53 | TEST_MACRO_ALL_VARIANTS_2_5(TEST_VLOAD, vector1, buffer); |
| 54 | TEST_VLOAD(vector1, buffer, , float, f, 32, 2); |
| 55 | TEST_VLOAD(vector1, buffer, q, float, f, 32, 4); |
| 56 | |
| 57 | /* Choose arbitrary initialization values */ |
| 58 | TEST_VDUP(vector2, , int, s, 8, 8, 0x11); |
| 59 | TEST_VDUP(vector2, , int, s, 16, 4, 0x22); |
| 60 | TEST_VDUP(vector2, , int, s, 32, 2, 0x33); |
| 61 | TEST_VDUP(vector2, , int, s, 64, 1, 0x44); |
| 62 | TEST_VDUP(vector2, , uint, u, 8, 8, 0x55); |
| 63 | TEST_VDUP(vector2, , uint, u, 16, 4, 0x66); |
| 64 | TEST_VDUP(vector2, , uint, u, 32, 2, 0x77); |
| 65 | TEST_VDUP(vector2, , uint, u, 64, 1, 0x88); |
Christophe Lyon | bd9ecf4 | 2011-07-19 16:30:50 +0200 | [diff] [blame] | 66 | TEST_VDUP(vector2, , float, f, 32, 2, 33.6f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 67 | |
| 68 | TEST_VDUP(vector2, q, int, s, 8, 16, 0x11); |
| 69 | TEST_VDUP(vector2, q, int, s, 16, 8, 0x22); |
| 70 | TEST_VDUP(vector2, q, int, s, 32, 4, 0x33); |
| 71 | TEST_VDUP(vector2, q, int, s, 64, 2, 0x44); |
| 72 | TEST_VDUP(vector2, q, uint, u, 8, 16, 0x55); |
| 73 | TEST_VDUP(vector2, q, uint, u, 16, 8, 0x66); |
| 74 | TEST_VDUP(vector2, q, uint, u, 32, 4, 0x77); |
| 75 | TEST_VDUP(vector2, q, uint, u, 64, 2, 0x88); |
Christophe Lyon | bd9ecf4 | 2011-07-19 16:30:50 +0200 | [diff] [blame] | 76 | TEST_VDUP(vector2, q, float, f, 32, 4, 33.2f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 77 | |
| 78 | /* Choose arbitrary extract offsets */ |
| 79 | TEST_VEXT(, int, s, 8, 8, 7); |
| 80 | TEST_VEXT(, int, s, 16, 4, 3); |
| 81 | TEST_VEXT(, int, s, 32, 2, 1); |
| 82 | TEST_VEXT(, int, s, 64, 1, 0); |
| 83 | TEST_VEXT(, uint, u, 8, 8, 6); |
| 84 | TEST_VEXT(, uint, u, 16, 4, 2); |
| 85 | TEST_VEXT(, uint, u, 32, 2, 1); |
| 86 | TEST_VEXT(, uint, u, 64, 1, 0); |
| 87 | TEST_VEXT(, float, f, 32, 2, 1); |
| 88 | |
| 89 | TEST_VEXT(q, int, s, 8, 16, 14); |
| 90 | TEST_VEXT(q, int, s, 16, 8, 7); |
| 91 | TEST_VEXT(q, int, s, 32, 4, 3); |
| 92 | TEST_VEXT(q, int, s, 64, 2, 1); |
| 93 | TEST_VEXT(q, uint, u, 8, 16, 12); |
| 94 | TEST_VEXT(q, uint, u, 16, 8, 6); |
| 95 | TEST_VEXT(q, uint, u, 32, 4, 3); |
| 96 | TEST_VEXT(q, uint, u, 64, 2, 1); |
| 97 | TEST_VEXT(q, float, f, 32, 4, 3); |
| 98 | |
| 99 | dump_results_hex (TEST_MSG); |
| 100 | } |