1 /* 2 3 Copyright (c) 2009, 2010, 2011, 2013 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 #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 "VBSL/VBSLQ" 35 void exec_vbsl (void) 36 { 37 /* Basic test: y=vbsl(unsigned_vec,x,x), then store the result. */ 38 #define TEST_VBSL(T3, Q, T1, T2, W, N) \ 39 VECT_VAR(vector_res, T1, W, N) = \ 40 vbsl##Q##_##T2##W(VECT_VAR(vector_first, T3, W, N), \ 41 VECT_VAR(vector, T1, W, N), \ 42 VECT_VAR(vector2, T1, W, N)); \ 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(vector); 48 DECL_VARIABLE_ALL_VARIANTS(vector2); 49 DECL_VARIABLE_ALL_VARIANTS(vector_res); 50 51 DECL_VARIABLE_UNSIGNED_VARIANTS(vector_first); 52 53 clean_results (); 54 55 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer); 56 VLOAD(vector, buffer, , float, f, 32, 2); 57 VLOAD(vector, buffer, q, float, f, 32, 4); 58 59 /* Choose init value arbitrarily, will be used for vector 60 comparison. As we want different values for each type variant, we 61 can't use generic initialization macros. */ 62 VDUP(vector2, , int, s, 8, 8, -10); 63 VDUP(vector2, , int, s, 16, 4, -14); 64 VDUP(vector2, , int, s, 32, 2, -30); 65 VDUP(vector2, , int, s, 64, 1, -33); 66 VDUP(vector2, , uint, u, 8, 8, 0xF3); 67 VDUP(vector2, , uint, u, 16, 4, 0xFFF2); 68 VDUP(vector2, , uint, u, 32, 2, 0xFFFFFFF0); 69 VDUP(vector2, , uint, u, 64, 1, 0xFFFFFFF3); 70 VDUP(vector2, , float, f, 32, 2, -30.3f); 71 VDUP(vector2, , poly, p, 8, 8, 0xF3); 72 VDUP(vector2, , poly, p, 16, 4, 0xFFF2); 73 74 VDUP(vector2, q, int, s, 8, 16, -10); 75 VDUP(vector2, q, int, s, 16, 8, -14); 76 VDUP(vector2, q, int, s, 32, 4, -30); 77 VDUP(vector2, q, int, s, 64, 2, -33); 78 VDUP(vector2, q, uint, u, 8, 16, 0xF3); 79 VDUP(vector2, q, uint, u, 16, 8, 0xFFF2); 80 VDUP(vector2, q, uint, u, 32, 4, 0xFFFFFFF0); 81 VDUP(vector2, q, uint, u, 64, 2, 0xFFFFFFF3); 82 VDUP(vector2, q, poly, p, 8, 16, 0xF3); 83 VDUP(vector2, q, poly, p, 16, 8, 0xFFF2); 84 VDUP(vector2, q, float, f, 32, 4, -30.4f); 85 86 VDUP(vector_first, , uint, u, 8, 8, 0xF4); 87 VDUP(vector_first, , uint, u, 16, 4, 0xFFF6); 88 VDUP(vector_first, , uint, u, 32, 2, 0xFFFFFFF2); 89 VDUP(vector_first, , uint, u, 64, 1, 0xFFFFFFF2); 90 VDUP(vector_first, q, uint, u, 8, 16, 0xF4); 91 VDUP(vector_first, q, uint, u, 16, 8, 0xFFF6); 92 VDUP(vector_first, q, uint, u, 32, 4, 0xFFFFFFF2); 93 VDUP(vector_first, q, uint, u, 64, 2, 0xFFFFFFF2); 94 95 TEST_MACRO_ALL_VARIANTS_1_5(TEST_VBSL, uint); 96 TEST_VBSL(uint, , poly, p, 8, 8); 97 TEST_VBSL(uint, , poly, p, 16, 4); 98 TEST_VBSL(uint, q, poly, p, 8, 16); 99 TEST_VBSL(uint, q, poly, p, 16, 8); 100 TEST_VBSL(uint, , float, f, 32, 2); 101 TEST_VBSL(uint, q, float, f, 32, 4); 102 103 dump_results_hex (TEST_MSG); 104 } 105