1073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon/* 2073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 3c94d4c1e27bb7e2b2869cc230872669df1459533Christophe LyonCopyright (c) 2009, 2010, 2011, 2012 STMicroelectronics 4073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonWritten by Christophe Lyon 5073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 6073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonPermission is hereby granted, free of charge, to any person obtaining a copy 7073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonof this software and associated documentation files (the "Software"), to deal 8073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonin the Software without restriction, including without limitation the rights 9073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonto use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyoncopies of the Software, and to permit persons to whom the Software is 11073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonfurnished to do so, subject to the following conditions: 12073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 13073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonThe above copyright notice and this permission notice shall be included in 14073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonall copies or substantial portions of the Software. 15073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 16073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonTHE SOFTWARE. 23073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 24073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon*/ 25073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 261775be0bcaa673c19bb1f60f0c1bce1b91cdb414Christophe Lyon#if defined(__arm__) || defined(__aarch64__) 27073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include <arm_neon.h> 28073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#else 290dab5f72da4b2434882b51b44ac377af9e3160feChristophe Lyon#include "stm-arm-neon.h" 30073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#endif 31073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 32073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include "stm-arm-neon-ref.h" 33073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 34073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define INSN vqdmulh 35073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_MSG "VQDMULH_LANE" 36073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define FNNAME1(NAME) void exec_ ## NAME ## _lane (void) 37073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define FNNAME(NAME) FNNAME1(NAME) 38073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 39073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonFNNAME (INSN) 40073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon{ 41073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon /* vector_res = vqdmulh_lane(vector,vector2,lane), then store the result. */ 424a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon#define TEST_VQDMULH_LANE2(INSN, Q, T1, T2, W, N, N2, L) \ 43c1cc7826d74587e0dc1c855810633a219b161ab3Christophe Lyon Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \ 444a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon VECT_VAR(vector_res, T1, W, N) = \ 454a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon INSN##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), \ 464a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon VECT_VAR(vector2, T1, W, N2), \ 474a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon L); \ 484a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ 494a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon VECT_VAR(vector_res, T1, W, N)); \ 504a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon dump_neon_cumulative_sat(TEST_MSG, xSTR(INSN##Q##_lane_##T2##W), \ 514a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon xSTR(T1), W, N) 52073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 53073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon /* Two auxliary macros are necessary to expand INSN */ 54073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_VQDMULH_LANE1(INSN, Q, T1, T2, W, N, N2, L) \ 55073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE2(INSN, Q, T1, T2, W, N, N2, L) 56073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 57073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_VQDMULH_LANE(Q, T1, T2, W, N, N2, L) \ 58073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE1(INSN, Q, T1, T2, W, N, N2, L) 59073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 60073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon /* With ARM RVCT, we need to declare variables before any executable 61073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon statement */ 62073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector, int, 16, 4); 63073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector, int, 32, 2); 64073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector, int, 16, 8); 65073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector, int, 32, 4); 66073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 67073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector_res, int, 16, 4); 68073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector_res, int, 32, 2); 69073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector_res, int, 16, 8); 70073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector_res, int, 32, 4); 71073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 72073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon /* vector2: vqdmulh_lane and vqdmulhq_lane have a 2nd argument with 73073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon the same number of elements, so we need only one variable of each 74073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon type. */ 75073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector2, int, 16, 4); 76073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon DECL_VARIABLE(vector2, int, 32, 2); 77073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 78073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon clean_results (); 79073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 80f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VLOAD(vector, buffer, , int, s, 16, 4); 81f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VLOAD(vector, buffer, , int, s, 32, 2); 82073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 83f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VLOAD(vector, buffer, q, int, s, 16, 8); 84f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VLOAD(vector, buffer, q, int, s, 32, 4); 85073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 86073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon /* Initialize vector2 */ 87f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector2, , int, s, 16, 4, 0x55); 88f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector2, , int, s, 32, 2, 0xBB); 89073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 90073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon /* Choose lane arbitrarily */ 914a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon fprintf(ref_file, "\n%s cumulative saturation output:\n", TEST_MSG); 92073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(, int, s, 16, 4, 4, 2); 93073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(, int, s, 32, 2, 2, 1); 94073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(q, int, s, 16, 8, 4, 3); 95073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(q, int, s, 32, 4, 2, 0); 96073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 97073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon /* FIXME: only a subset of the result buffers are used, but we 98073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon output all of them */ 99073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon dump_results_hex (TEST_MSG); 100073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 101073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 102f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector, , int, s, 16, 4, 0x8000); 103f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector, , int, s, 32, 2, 0x80000000); 104f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector, q, int, s, 16, 8, 0x8000); 105f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector, q, int, s, 32, 4, 0x80000000); 106f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector2, , int, s, 16, 4, 0x8000); 107f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon VDUP(vector2, , int, s, 32, 2, 0x80000000); 108073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon 1094a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon fprintf(ref_file, "\n%s cumulative saturation output:\n", 1104a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon TEST_MSG " (check mul cumulative saturation)"); 111073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(, int, s, 16, 4, 4, 3); 112073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(, int, s, 32, 2, 2, 1); 113073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(q, int, s, 16, 8, 4, 2); 114073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon TEST_VQDMULH_LANE(q, int, s, 32, 4, 2, 1); 1154a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon dump_results_hex2 (TEST_MSG, " (check mul cumulative saturation)"); 116073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon} 117