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 #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 #ifndef INSN_NAME 35 #define INSN_NAME vtst 36 #define TEST_MSG "VTST/VTSTQ" 37 #endif 38 39 /* Can't use the standard ref_v_binary_op.c template because vtst has 40 no 64 bits variant, and outputs are always of uint type */ 41 #define FNNAME1(NAME) void exec_ ## NAME (void) 42 #define FNNAME(NAME) FNNAME1(NAME) 43 44 FNNAME (INSN_NAME) 45 { 46 /* Basic test: y=OP(x,x), then store the result. */ 47 #define TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \ 48 VECT_VAR(vector_res, uint, W, N) = \ 49 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \ 50 VECT_VAR(vector2, T1, W, N)); \ 51 vst1##Q##_u##W(VECT_VAR(result, uint, W, N), \ 52 VECT_VAR(vector_res, uint, W, N)) 53 54 #define TEST_BINARY_OP(INSN, Q, T1, T2, W, N) \ 55 TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \ 56 57 /* With ARM RVCT, we need to declare variables before any executable 58 statement */ 59 DECL_VARIABLE_ALL_VARIANTS(vector); 60 DECL_VARIABLE_ALL_VARIANTS(vector2); 61 DECL_VARIABLE_UNSIGNED_VARIANTS(vector_res); 62 63 64 clean_results (); 65 66 /* Initialize input "vector" from "buffer" */ 67 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer); 68 69 /* Choose init value arbitrarily, will be used as comparison value */ 70 VDUP(vector2, , int, s, 8, 8, 15); 71 VDUP(vector2, , int, s, 16, 4, 5); 72 VDUP(vector2, , int, s, 32, 2, 1); 73 VDUP(vector2, , uint, u, 8, 8, 15); 74 VDUP(vector2, , uint, u, 16, 4, 5); 75 VDUP(vector2, , uint, u, 32, 2, 1); 76 VDUP(vector2, q, int, s, 8, 16, 15); 77 VDUP(vector2, q, int, s, 16, 8, 5); 78 VDUP(vector2, q, int, s, 32, 4, 1); 79 VDUP(vector2, q, uint, u, 8, 16, 15); 80 VDUP(vector2, q, uint, u, 16, 8, 5); 81 VDUP(vector2, q, uint, u, 32, 4, 1); 82 83 #define TEST_MACRO_NO64BIT_VARIANT_1_5(MACRO, VAR, T1, T2) \ 84 MACRO(VAR, , T1, T2, 8, 8); \ 85 MACRO(VAR, , T1, T2, 16, 4); \ 86 MACRO(VAR, , T1, T2, 32, 2); \ 87 MACRO(VAR, q, T1, T2, 8, 16); \ 88 MACRO(VAR, q, T1, T2, 16, 8); \ 89 MACRO(VAR, q, T1, T2, 32, 4) 90 91 /* Split the test, as both signed and unsigned variants output their 92 result in an unsigned form (thus the same output variable is used 93 in these tests) */ 94 TEST_MACRO_NO64BIT_VARIANT_1_5(TEST_BINARY_OP, INSN_NAME, int, s); 95 dump_results_hex2 (TEST_MSG, " (signed input)"); 96 97 TEST_MACRO_NO64BIT_VARIANT_1_5(TEST_BINARY_OP, INSN_NAME, uint, u); 98 dump_results_hex2 (TEST_MSG, " (unsigned input)"); 99 } 100