| 1 |
#include <arm_neon.h> |
| 2 |
#include "arm-neon-ref.h" |
| 3 |
#include "compute-ref-data.h" |
| 4 |
|
| 5 |
/* Expected results. */ |
| 6 |
VECT_VAR_DECL(expected,int,8,8) [] = { 0xf0, 0x1, 0x12, 0x23, |
| 7 |
0x34, 0x45, 0x56, 0x67 }; |
| 8 |
VECT_VAR_DECL(expected,int,16,4) [] = { 0xfde0, 0xfe02, 0xfe24, 0xfe46 }; |
| 9 |
VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffffcd0, 0xfffffd03 }; |
| 10 |
VECT_VAR_DECL(expected,uint,8,8) [] = { 0xc0, 0x4, 0x48, 0x8c, |
| 11 |
0xd0, 0x14, 0x58, 0x9c }; |
| 12 |
VECT_VAR_DECL(expected,uint,16,4) [] = { 0xfab0, 0xfb05, 0xfb5a, 0xfbaf }; |
| 13 |
VECT_VAR_DECL(expected,uint,32,2) [] = { 0xfffff9a0, 0xfffffa06 }; |
| 14 |
VECT_VAR_DECL(expected,poly,8,8) [] = { 0xc0, 0x84, 0x48, 0xc, |
| 15 |
0xd0, 0x94, 0x58, 0x1c }; |
| 16 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 17 |
VECT_VAR_DECL(expected, hfloat, 16, 4) [] = { 0xe02a, 0xdfcf, |
| 18 |
0xdf4a, 0xdec4 }; |
| 19 |
#endif |
| 20 |
VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0xc4053333, 0xc3f9c000 }; |
| 21 |
VECT_VAR_DECL(expected,int,8,16) [] = { 0x90, 0x7, 0x7e, 0xf5, |
| 22 |
0x6c, 0xe3, 0x5a, 0xd1, |
| 23 |
0x48, 0xbf, 0x36, 0xad, |
| 24 |
0x24, 0x9b, 0x12, 0x89 }; |
| 25 |
VECT_VAR_DECL(expected,int,16,8) [] = { 0xf780, 0xf808, 0xf890, 0xf918, |
| 26 |
0xf9a0, 0xfa28, 0xfab0, 0xfb38 }; |
| 27 |
VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffff670, 0xfffff709, |
| 28 |
0xfffff7a2, 0xfffff83b }; |
| 29 |
VECT_VAR_DECL(expected,uint,8,16) [] = { 0x60, 0xa, 0xb4, 0x5e, |
| 30 |
0x8, 0xb2, 0x5c, 0x6, |
| 31 |
0xb0, 0x5a, 0x4, 0xae, |
| 32 |
0x58, 0x2, 0xac, 0x56 }; |
| 33 |
VECT_VAR_DECL(expected,uint,16,8) [] = { 0xf450, 0xf50b, 0xf5c6, 0xf681, |
| 34 |
0xf73c, 0xf7f7, 0xf8b2, 0xf96d }; |
| 35 |
VECT_VAR_DECL(expected,uint,32,4) [] = { 0xfffff340, 0xfffff40c, |
| 36 |
0xfffff4d8, 0xfffff5a4 }; |
| 37 |
VECT_VAR_DECL(expected,poly,8,16) [] = { 0x60, 0xca, 0x34, 0x9e, |
| 38 |
0xc8, 0x62, 0x9c, 0x36, |
| 39 |
0x30, 0x9a, 0x64, 0xce, |
| 40 |
0x98, 0x32, 0xcc, 0x66 }; |
| 41 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 42 |
VECT_VAR_DECL(expected, hfloat, 16, 8) [] = { 0xe63a, 0xe5d6, 0xe573, 0xe50f, |
| 43 |
0xe4ac, 0xe448, 0xe3c8, 0xe301 }; |
| 44 |
#endif |
| 45 |
VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0xc4c73333, 0xc4bac000, |
| 46 |
0xc4ae4ccd, 0xc4a1d999 }; |
| 47 |
|
| 48 |
#define INSN_NAME vmul |
| 49 |
#define TEST_MSG "VMUL" |
| 50 |
|
| 51 |
#define FNNAME1(NAME) exec_ ## NAME |
| 52 |
#define FNNAME(NAME) FNNAME1(NAME) |
| 53 |
|
| 54 |
void FNNAME (INSN_NAME) (void) |
| 55 |
{ |
| 56 |
#define DECL_VMUL(T, W, N) \ |
| 57 |
DECL_VARIABLE(vector1, T, W, N); \ |
| 58 |
DECL_VARIABLE(vector2, T, W, N); \ |
| 59 |
DECL_VARIABLE(vector_res, T, W, N) |
| 60 |
|
| 61 |
/* vector_res = OP(vector1, vector2), then store the result. */ |
| 62 |
#define TEST_VMUL1(INSN, Q, T1, T2, W, N) \ |
| 63 |
VECT_VAR(vector_res, T1, W, N) = \ |
| 64 |
INSN##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \ |
| 65 |
VECT_VAR(vector2, T1, W, N)); \ |
| 66 |
vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ |
| 67 |
VECT_VAR(vector_res, T1, W, N)) |
| 68 |
|
| 69 |
#define TEST_VMUL(INSN, Q, T1, T2, W, N) \ |
| 70 |
TEST_VMUL1(INSN, Q, T1, T2, W, N) |
| 71 |
|
| 72 |
DECL_VMUL(int, 8, 8); |
| 73 |
DECL_VMUL(int, 16, 4); |
| 74 |
DECL_VMUL(int, 32, 2); |
| 75 |
DECL_VMUL(uint, 8, 8); |
| 76 |
DECL_VMUL(uint, 16, 4); |
| 77 |
DECL_VMUL(uint, 32, 2); |
| 78 |
DECL_VMUL(poly, 8, 8); |
| 79 |
DECL_VMUL(float, 32, 2); |
| 80 |
DECL_VMUL(int, 8, 16); |
| 81 |
DECL_VMUL(int, 16, 8); |
| 82 |
DECL_VMUL(int, 32, 4); |
| 83 |
DECL_VMUL(uint, 8, 16); |
| 84 |
DECL_VMUL(uint, 16, 8); |
| 85 |
DECL_VMUL(uint, 32, 4); |
| 86 |
DECL_VMUL(poly, 8, 16); |
| 87 |
DECL_VMUL(float, 32, 4); |
| 88 |
|
| 89 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 90 |
DECL_VARIABLE(vector1, float, 16, 4); |
| 91 |
DECL_VARIABLE(vector1, float, 16, 8); |
| 92 |
|
| 93 |
DECL_VARIABLE(vector2, float, 16, 4); |
| 94 |
DECL_VARIABLE(vector2, float, 16, 8); |
| 95 |
|
| 96 |
DECL_VARIABLE(vector_res, float, 16, 4); |
| 97 |
DECL_VARIABLE(vector_res, float, 16, 8); |
| 98 |
#endif |
| 99 |
|
| 100 |
clean_results (); |
| 101 |
|
| 102 |
/* Initialize input "vector1" from "buffer". */ |
| 103 |
VLOAD(vector1, buffer, , int, s, 8, 8); |
| 104 |
VLOAD(vector1, buffer, , int, s, 16, 4); |
| 105 |
VLOAD(vector1, buffer, , int, s, 32, 2); |
| 106 |
VLOAD(vector1, buffer, , uint, u, 8, 8); |
| 107 |
VLOAD(vector1, buffer, , uint, u, 16, 4); |
| 108 |
VLOAD(vector1, buffer, , uint, u, 32, 2); |
| 109 |
VLOAD(vector1, buffer, , poly, p, 8, 8); |
| 110 |
VLOAD(vector1, buffer, , float, f, 32, 2); |
| 111 |
VLOAD(vector1, buffer, q, int, s, 8, 16); |
| 112 |
VLOAD(vector1, buffer, q, int, s, 16, 8); |
| 113 |
VLOAD(vector1, buffer, q, int, s, 32, 4); |
| 114 |
VLOAD(vector1, buffer, q, uint, u, 8, 16); |
| 115 |
VLOAD(vector1, buffer, q, uint, u, 16, 8); |
| 116 |
VLOAD(vector1, buffer, q, uint, u, 32, 4); |
| 117 |
VLOAD(vector1, buffer, q, poly, p, 8, 16); |
| 118 |
VLOAD(vector1, buffer, q, float, f, 32, 4); |
| 119 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 120 |
VLOAD(vector1, buffer, , float, f, 16, 4); |
| 121 |
VLOAD(vector1, buffer, q, float, f, 16, 8); |
| 122 |
#endif |
| 123 |
|
| 124 |
/* Choose init value arbitrarily. */ |
| 125 |
VDUP(vector2, , int, s, 8, 8, 0x11); |
| 126 |
VDUP(vector2, , int, s, 16, 4, 0x22); |
| 127 |
VDUP(vector2, , int, s, 32, 2, 0x33); |
| 128 |
VDUP(vector2, , uint, u, 8, 8, 0x44); |
| 129 |
VDUP(vector2, , uint, u, 16, 4, 0x55); |
| 130 |
VDUP(vector2, , uint, u, 32, 2, 0x66); |
| 131 |
VDUP(vector2, , poly, p, 8, 8, 0x44); |
| 132 |
VDUP(vector2, , float, f, 32, 2, 33.3f); |
| 133 |
VDUP(vector2, q, int, s, 8, 16, 0x77); |
| 134 |
VDUP(vector2, q, int, s, 16, 8, 0x88); |
| 135 |
VDUP(vector2, q, int, s, 32, 4, 0x99); |
| 136 |
VDUP(vector2, q, uint, u, 8, 16, 0xAA); |
| 137 |
VDUP(vector2, q, uint, u, 16, 8, 0xBB); |
| 138 |
VDUP(vector2, q, uint, u, 32, 4, 0xCC); |
| 139 |
VDUP(vector2, q, poly, p, 8, 16, 0xAA); |
| 140 |
VDUP(vector2, q, float, f, 32, 4, 99.6f); |
| 141 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 142 |
VDUP(vector2, , float, f, 16, 4, 33.3f); |
| 143 |
VDUP(vector2, q, float, f, 16, 8, 99.6f); |
| 144 |
#endif |
| 145 |
|
| 146 |
/* Execute the tests. */ |
| 147 |
TEST_VMUL(INSN_NAME, , int, s, 8, 8); |
| 148 |
TEST_VMUL(INSN_NAME, , int, s, 16, 4); |
| 149 |
TEST_VMUL(INSN_NAME, , int, s, 32, 2); |
| 150 |
TEST_VMUL(INSN_NAME, , uint, u, 8, 8); |
| 151 |
TEST_VMUL(INSN_NAME, , uint, u, 16, 4); |
| 152 |
TEST_VMUL(INSN_NAME, , uint, u, 32, 2); |
| 153 |
TEST_VMUL(INSN_NAME, , poly, p, 8, 8); |
| 154 |
TEST_VMUL(INSN_NAME, , float, f, 32, 2); |
| 155 |
TEST_VMUL(INSN_NAME, q, int, s, 8, 16); |
| 156 |
TEST_VMUL(INSN_NAME, q, int, s, 16, 8); |
| 157 |
TEST_VMUL(INSN_NAME, q, int, s, 32, 4); |
| 158 |
TEST_VMUL(INSN_NAME, q, uint, u, 8, 16); |
| 159 |
TEST_VMUL(INSN_NAME, q, uint, u, 16, 8); |
| 160 |
TEST_VMUL(INSN_NAME, q, uint, u, 32, 4); |
| 161 |
TEST_VMUL(INSN_NAME, q, poly, p, 8, 16); |
| 162 |
TEST_VMUL(INSN_NAME, q, float, f, 32, 4); |
| 163 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 164 |
TEST_VMUL(INSN_NAME, , float, f, 16, 4); |
| 165 |
TEST_VMUL(INSN_NAME, q, float, f, 16, 8); |
| 166 |
#endif |
| 167 |
|
| 168 |
CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, ""); |
| 169 |
CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, ""); |
| 170 |
CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, ""); |
| 171 |
CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, ""); |
| 172 |
CHECK(TEST_MSG, uint, 16, 4, PRIx16, expected, ""); |
| 173 |
CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, ""); |
| 174 |
CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected, ""); |
| 175 |
CHECK_FP(TEST_MSG, float, 32, 2, PRIx32, expected, ""); |
| 176 |
CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, ""); |
| 177 |
CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, ""); |
| 178 |
CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, ""); |
| 179 |
CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, ""); |
| 180 |
CHECK(TEST_MSG, uint, 16, 8, PRIx16, expected, ""); |
| 181 |
CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, ""); |
| 182 |
CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected, ""); |
| 183 |
CHECK_FP(TEST_MSG, float, 32, 4, PRIx32, expected, ""); |
| 184 |
#if defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 185 |
CHECK_FP(TEST_MSG, float, 16, 4, PRIx16, expected, ""); |
| 186 |
CHECK_FP(TEST_MSG, float, 16, 8, PRIx16, expected, ""); |
| 187 |
#endif |
| 188 |
} |
| 189 |
|
| 190 |
int main (void) |
| 191 |
{ |
| 192 |
FNNAME (INSN_NAME) (); |
| 193 |
|
| 194 |
return 0; |
| 195 |
} |