| 1 |
/* Template file for 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 binary |
| 6 |
operators, these can be tested by providing a definition for |
| 7 |
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 |
/* Basic test: y=OP(x1,x2), then store the result. */ |
| 19 |
#define TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \ |
| 20 |
VECT_VAR(vector_res, T1, W, N) = \ |
| 21 |
INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \ |
| 22 |
VECT_VAR(vector2, T1, W, N)); \ |
| 23 |
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N)) |
| 24 |
|
| 25 |
#define TEST_BINARY_OP(INSN, Q, T1, T2, W, N) \ |
| 26 |
TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \ |
| 27 |
|
| 28 |
DECL_VARIABLE_ALL_VARIANTS(vector); |
| 29 |
DECL_VARIABLE_ALL_VARIANTS(vector2); |
| 30 |
DECL_VARIABLE_ALL_VARIANTS(vector_res); |
| 31 |
|
| 32 |
clean_results (); |
| 33 |
|
| 34 |
/* Initialize input "vector" from "buffer". */ |
| 35 |
TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer); |
| 36 |
|
| 37 |
/* Fill input vector2 with arbitrary values. */ |
| 38 |
VDUP(vector2, , int, s, 8, 8, 2); |
| 39 |
VDUP(vector2, , int, s, 16, 4, -4); |
| 40 |
VDUP(vector2, , int, s, 32, 2, 3); |
| 41 |
VDUP(vector2, , int, s, 64, 1, 100); |
| 42 |
VDUP(vector2, , uint, u, 8, 8, 20); |
| 43 |
VDUP(vector2, , uint, u, 16, 4, 30); |
| 44 |
VDUP(vector2, , uint, u, 32, 2, 40); |
| 45 |
VDUP(vector2, , uint, u, 64, 1, 2); |
| 46 |
VDUP(vector2, q, int, s, 8, 16, -10); |
| 47 |
VDUP(vector2, q, int, s, 16, 8, -20); |
| 48 |
VDUP(vector2, q, int, s, 32, 4, -30); |
| 49 |
VDUP(vector2, q, int, s, 64, 2, 24); |
| 50 |
VDUP(vector2, q, uint, u, 8, 16, 12); |
| 51 |
VDUP(vector2, q, uint, u, 16, 8, 3); |
| 52 |
VDUP(vector2, q, uint, u, 32, 4, 55); |
| 53 |
VDUP(vector2, q, uint, u, 64, 2, 3); |
| 54 |
|
| 55 |
/* Apply a binary operator named INSN_NAME. */ |
| 56 |
TEST_MACRO_ALL_VARIANTS_1_5(TEST_BINARY_OP, INSN_NAME); |
| 57 |
|
| 58 |
CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, ""); |
| 59 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, ""); |
| 60 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, ""); |
| 61 |
CHECK(TEST_MSG, int, 64, 1, PRIx64, expected, ""); |
| 62 |
CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, ""); |
| 63 |
CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, ""); |
| 64 |
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, ""); |
| 65 |
CHECK(TEST_MSG, uint, 64, 1, PRIx64, expected, ""); |
| 66 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, ""); |
| 67 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, ""); |
| 68 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, ""); |
| 69 |
CHECK(TEST_MSG, int, 64, 2, PRIx64, expected, ""); |
| 70 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, ""); |
| 71 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, ""); |
| 72 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, ""); |
| 73 |
CHECK(TEST_MSG, uint, 64, 2, PRIx64, expected, ""); |
| 74 |
|
| 75 |
#ifdef EXTRA_TESTS |
| 76 |
EXTRA_TESTS(); |
| 77 |
#endif |
| 78 |
} |
| 79 |
|
| 80 |
int main (void) |
| 81 |
{ |
| 82 |
FNNAME (INSN_NAME) (); |
| 83 |
|
| 84 |
return 0; |
| 85 |
} |