1/* 2 3Copyright (c) 2009, 2010, 2011, 2013 STMicroelectronics 4Written by Christophe Lyon 5 6Permission is hereby granted, free of charge, to any person obtaining a copy 7of this software and associated documentation files (the "Software"), to deal 8in the Software without restriction, including without limitation the rights 9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10copies of the Software, and to permit persons to whom the Software is 11furnished to do so, subject to the following conditions: 12 13The above copyright notice and this permission notice shall be included in 14all copies or substantial portions of the Software. 15 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22THE SOFTWARE. 23 24*/ 25 26#if defined(__arm__) || defined(__aarch64__) 27#include <arm_neon.h> 28#else 29#include "stm-arm-neon.h" 30#endif 31 32#include "stm-arm-neon-ref.h" 33 34#define TEST_MSG "VEXT/VEXTQ" 35void 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(VLOAD, vector1, buffer); 54 VLOAD(vector1, buffer, , float, f, 32, 2); 55 VLOAD(vector1, buffer, q, float, f, 32, 4); 56 57 /* Choose arbitrary initialization values */ 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); 69 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); 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); 91 TEST_VEXT(, poly, p, 8, 8, 6); 92 TEST_VEXT(, poly, p, 16, 4, 2); 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); 103 TEST_VEXT(q, poly, p, 8, 16, 12); 104 TEST_VEXT(q, poly, p, 16, 8, 6); 105 TEST_VEXT(q, float, f, 32, 4, 3); 106 107 dump_results_hex (TEST_MSG); 108} 109