| 1 |
/* Template file for saturating binary operator validation. |
| 2 |
|
| 3 |
This file is meant to be included by the relevant test files, which |
| 4 |
have to define the intrinsic family to test. If a given intrinsic |
| 5 |
supports variants which are not supported by all the other |
| 6 |
saturating binary operators, these can be tested by providing a |
| 7 |
definition for EXTRA_TESTS. */ |
| 8 |
|
| 9 |
#include <arm_neon.h> |
| 10 |
#include "arm-neon-ref.h" |
| 11 |
#include "compute-ref-data.h" |
| 12 |
|
| 13 |
#define FNNAME1(NAME) exec_ ## NAME |
| 14 |
#define FNNAME(NAME) FNNAME1(NAME) |
| 15 |
|
| 16 |
void FNNAME (INSN_NAME) (void) |
| 17 |
{ |
| 18 |
/* vector_res = OP(vector1,vector2), then store the result. */ |
| 19 |
|
| 20 |
#define TEST_BINARY_SAT_OP1(INSN, Q, T1, T2, W, N, CMT) \ |
| 21 |
Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \ |
| 22 |
VECT_VAR(vector_res, T1, W, N) = \ |
| 23 |
INSN##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \ |
| 24 |
VECT_VAR(vector2, T1, W, N)); \ |
| 25 |
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ |
| 26 |
VECT_VAR(vector_res, T1, W, N)) |
| 27 |
|
| 28 |
#define TEST_BINARY_SAT_OP(INSN, Q, T1, T2, W, N, CMT) \ |
| 29 |
TEST_BINARY_SAT_OP1(INSN, Q, T1, T2, W, N, CMT) |
| 30 |
|
| 31 |
DECL_VARIABLE_ALL_VARIANTS(vector1); |
| 32 |
DECL_VARIABLE_ALL_VARIANTS(vector2); |
| 33 |
DECL_VARIABLE_ALL_VARIANTS(vector_res); |
| 34 |
|
| 35 |
clean_results (); |
| 36 |
|
| 37 |
/* Initialize input "vector1" from "buffer". */ |
| 38 |
TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer); |
| 39 |
|
| 40 |
/* Choose arbitrary initialization values. */ |
| 41 |
VDUP(vector2, , int, s, 8, 8, 0x11); |
| 42 |
VDUP(vector2, , int, s, 16, 4, 0x22); |
| 43 |
VDUP(vector2, , int, s, 32, 2, 0x33); |
| 44 |
VDUP(vector2, , int, s, 64, 1, 0x44); |
| 45 |
VDUP(vector2, , uint, u, 8, 8, 0x55); |
| 46 |
VDUP(vector2, , uint, u, 16, 4, 0x66); |
| 47 |
VDUP(vector2, , uint, u, 32, 2, 0x77); |
| 48 |
VDUP(vector2, , uint, u, 64, 1, 0x88); |
| 49 |
|
| 50 |
VDUP(vector2, q, int, s, 8, 16, 0x11); |
| 51 |
VDUP(vector2, q, int, s, 16, 8, 0x22); |
| 52 |
VDUP(vector2, q, int, s, 32, 4, 0x33); |
| 53 |
VDUP(vector2, q, int, s, 64, 2, 0x44); |
| 54 |
VDUP(vector2, q, uint, u, 8, 16, 0x55); |
| 55 |
VDUP(vector2, q, uint, u, 16, 8, 0x66); |
| 56 |
VDUP(vector2, q, uint, u, 32, 4, 0x77); |
| 57 |
VDUP(vector2, q, uint, u, 64, 2, 0x88); |
| 58 |
|
| 59 |
/* Apply a saturating binary operator named INSN_NAME. */ |
| 60 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8, ""); |
| 61 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4, ""); |
| 62 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2, ""); |
| 63 |
TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, ""); |
| 64 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8, ""); |
| 65 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4, ""); |
| 66 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2, ""); |
| 67 |
TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1, ""); |
| 68 |
|
| 69 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16, ""); |
| 70 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8, ""); |
| 71 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4, ""); |
| 72 |
TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, ""); |
| 73 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16, ""); |
| 74 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8, ""); |
| 75 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4, ""); |
| 76 |
TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, ""); |
| 77 |
|
| 78 |
CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, ""); |
| 79 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, ""); |
| 80 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, ""); |
| 81 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected, ""); |
| 82 |
CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, ""); |
| 83 |
CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, ""); |
| 84 |
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, ""); |
| 85 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected, ""); |
| 86 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, ""); |
| 87 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, ""); |
| 88 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, ""); |
| 89 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected, ""); |
| 90 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, ""); |
| 91 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, ""); |
| 92 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, ""); |
| 93 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected, ""); |
| 94 |
|
| 95 |
#ifdef EXTRA_TESTS |
| 96 |
EXTRA_TESTS(); |
| 97 |
#endif |
| 98 |
} |
| 99 |
|
| 100 |
int main (void) |
| 101 |
{ |
| 102 |
FNNAME (INSN_NAME) (); |
| 103 |
|
| 104 |
return 0; |
| 105 |
} |