| 1 | /* |
| 2 | * Copyright(c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | /* |
| 19 | * Test instructions that might set bits in user status register (USR) |
| 20 | */ |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <stdint.h> |
| 24 | |
| 25 | int err; |
| 26 | |
| 27 | #include "hex_test.h" |
| 28 | |
| 29 | /* |
| 30 | * Some of the instructions tested are only available on certain versions |
| 31 | * of the Hexagon core |
| 32 | */ |
| 33 | #define CORE_HAS_AUDIO (__HEXAGON_ARCH__ >= 67 && defined(__HEXAGON_AUDIO__)) |
| 34 | #define CORE_IS_V67 (__HEXAGON_ARCH__ >= 67) |
| 35 | |
| 36 | /* |
| 37 | * Templates for functions to execute an instruction |
| 38 | * |
| 39 | * The templates vary by the number of arguments and the types of the args |
| 40 | * and result. We use one letter in the macro name for the result and each |
| 41 | * argument: |
| 42 | * x unknown (specified in a subsequent template) or don't care |
| 43 | * R register (32 bits) |
| 44 | * P pair (64 bits) |
| 45 | * p predicate |
| 46 | * I immediate |
| 47 | * Xx read/write |
| 48 | */ |
| 49 | |
| 50 | /* Template for instructions with one register operand */ |
| 51 | #define FUNC_x_OP_x(RESTYPE, SRCTYPE, NAME, INSN) \ |
| 52 | static RESTYPE NAME(SRCTYPE src, uint32_t *usr_result) \ |
| 53 | { \ |
| 54 | RESTYPE result; \ |
| 55 | uint32_t usr; \ |
| 56 | asm(CLEAR_USRBITS \ |
| 57 | INSN "\n\t" \ |
| 58 | "%1 = usr\n\t" \ |
| 59 | : "=r"(result), "=r"(usr) \ |
| 60 | : "r"(src) \ |
| 61 | : "r2", "usr"); \ |
| 62 | *usr_result = usr & 0x3f; \ |
| 63 | return result; \ |
| 64 | } |
| 65 | |
| 66 | #define FUNC_R_OP_R(NAME, INSN) \ |
| 67 | FUNC_x_OP_x(uint32_t, uint32_t, NAME, INSN) |
| 68 | |
| 69 | #define FUNC_R_OP_P(NAME, INSN) \ |
| 70 | FUNC_x_OP_x(uint32_t, uint64_t, NAME, INSN) |
| 71 | |
| 72 | #define FUNC_P_OP_P(NAME, INSN) \ |
| 73 | FUNC_x_OP_x(uint64_t, uint64_t, NAME, INSN) |
| 74 | |
| 75 | #define FUNC_P_OP_R(NAME, INSN) \ |
| 76 | FUNC_x_OP_x(uint64_t, uint32_t, NAME, INSN) |
| 77 | |
| 78 | /* |
| 79 | * Template for instructions with a register and predicate result |
| 80 | * and one register operand |
| 81 | */ |
| 82 | #define FUNC_xp_OP_x(RESTYPE, SRCTYPE, NAME, INSN) \ |
| 83 | static RESTYPE NAME(SRCTYPE src, uint8_t *pred_result, uint32_t *usr_result) \ |
| 84 | { \ |
| 85 | RESTYPE result; \ |
| 86 | uint8_t pred; \ |
| 87 | uint32_t usr; \ |
| 88 | asm(CLEAR_USRBITS \ |
| 89 | INSN "\n\t" \ |
| 90 | "%1 = p2\n\t" \ |
| 91 | "%2 = usr\n\t" \ |
| 92 | : "=r"(result), "=r"(pred), "=r"(usr) \ |
| 93 | : "r"(src) \ |
| 94 | : "r2", "p2", "usr"); \ |
| 95 | *pred_result = pred; \ |
| 96 | *usr_result = usr & 0x3f; \ |
| 97 | return result; \ |
| 98 | } |
| 99 | |
| 100 | #define FUNC_Rp_OP_R(NAME, INSN) \ |
| 101 | FUNC_xp_OP_x(uint32_t, uint32_t, NAME, INSN) |
| 102 | |
| 103 | /* Template for instructions with two register operands */ |
| 104 | #define FUNC_x_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \ |
| 105 | static RESTYPE NAME(SRC1TYPE src1, SRC2TYPE src2, uint32_t *usr_result) \ |
| 106 | { \ |
| 107 | RESTYPE result; \ |
| 108 | uint32_t usr; \ |
| 109 | asm(CLEAR_USRBITS \ |
| 110 | INSN "\n\t" \ |
| 111 | "%1 = usr\n\t" \ |
| 112 | : "=r"(result), "=r"(usr) \ |
| 113 | : "r"(src1), "r"(src2) \ |
| 114 | : "r2", "usr"); \ |
| 115 | *usr_result = usr & 0x3f; \ |
| 116 | return result; \ |
| 117 | } |
| 118 | |
| 119 | #define FUNC_P_OP_PP(NAME, INSN) \ |
| 120 | FUNC_x_OP_xx(uint64_t, uint64_t, uint64_t, NAME, INSN) |
| 121 | |
| 122 | #define FUNC_R_OP_PP(NAME, INSN) \ |
| 123 | FUNC_x_OP_xx(uint32_t, uint64_t, uint64_t, NAME, INSN) |
| 124 | |
| 125 | #define FUNC_P_OP_RR(NAME, INSN) \ |
| 126 | FUNC_x_OP_xx(uint64_t, uint32_t, uint32_t, NAME, INSN) |
| 127 | |
| 128 | #define FUNC_R_OP_RR(NAME, INSN) \ |
| 129 | FUNC_x_OP_xx(uint32_t, uint32_t, uint32_t, NAME, INSN) |
| 130 | |
| 131 | #define FUNC_R_OP_PR(NAME, INSN) \ |
| 132 | FUNC_x_OP_xx(uint32_t, uint64_t, uint32_t, NAME, INSN) |
| 133 | |
| 134 | #define FUNC_P_OP_PR(NAME, INSN) \ |
| 135 | FUNC_x_OP_xx(uint64_t, uint64_t, uint32_t, NAME, INSN) |
| 136 | |
| 137 | /* |
| 138 | * Template for instructions with a register and predicate result |
| 139 | * and two register operands |
| 140 | */ |
| 141 | #define FUNC_xp_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \ |
| 142 | static RESTYPE NAME(SRC1TYPE src1, SRC2TYPE src2, \ |
| 143 | uint8_t *pred_result, uint32_t *usr_result) \ |
| 144 | { \ |
| 145 | RESTYPE result; \ |
| 146 | uint8_t pred; \ |
| 147 | uint32_t usr; \ |
| 148 | asm(CLEAR_USRBITS \ |
| 149 | INSN "\n\t" \ |
| 150 | "%1 = p2\n\t" \ |
| 151 | "%2 = usr\n\t" \ |
| 152 | : "=r"(result), "=r"(pred), "=r"(usr) \ |
| 153 | : "r"(src1), "r"(src2) \ |
| 154 | : "r2", "p2", "usr"); \ |
| 155 | *pred_result = pred; \ |
| 156 | *usr_result = usr & 0x3f; \ |
| 157 | return result; \ |
| 158 | } |
| 159 | |
| 160 | #define FUNC_Rp_OP_RR(NAME, INSN) \ |
| 161 | FUNC_xp_OP_xx(uint32_t, uint32_t, uint32_t, NAME, INSN) |
| 162 | |
| 163 | /* Template for instructions with one register and one immediate */ |
| 164 | #define FUNC_x_OP_xI(RESTYPE, SRC1TYPE, NAME, INSN) \ |
| 165 | static RESTYPE NAME(SRC1TYPE src1, int32_t src2, uint32_t *usr_result) \ |
| 166 | { \ |
| 167 | RESTYPE result; \ |
| 168 | uint32_t usr; \ |
| 169 | asm(CLEAR_USRBITS \ |
| 170 | INSN "\n\t" \ |
| 171 | "%1 = usr\n\t" \ |
| 172 | : "=r"(result), "=r"(usr) \ |
| 173 | : "r"(src1), "i"(src2) \ |
| 174 | : "r2", "usr"); \ |
| 175 | *usr_result = usr & 0x3f; \ |
| 176 | return result; \ |
| 177 | } |
| 178 | |
| 179 | #define FUNC_R_OP_RI(NAME, INSN) \ |
| 180 | FUNC_x_OP_xI(uint32_t, uint32_t, NAME, INSN) |
| 181 | |
| 182 | #define FUNC_R_OP_PI(NAME, INSN) \ |
| 183 | FUNC_x_OP_xI(uint32_t, uint64_t, NAME, INSN) |
| 184 | |
| 185 | /* |
| 186 | * Template for instructions with a read/write result |
| 187 | * and two register operands |
| 188 | */ |
| 189 | #define FUNC_Xx_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \ |
| 190 | static RESTYPE NAME(RESTYPE result, SRC1TYPE src1, SRC2TYPE src2, \ |
| 191 | uint32_t *usr_result) \ |
| 192 | { \ |
| 193 | uint32_t usr; \ |
| 194 | asm(CLEAR_USRBITS \ |
| 195 | INSN "\n\t" \ |
| 196 | "%1 = usr\n\t" \ |
| 197 | : "+r"(result), "=r"(usr) \ |
| 198 | : "r"(src1), "r"(src2) \ |
| 199 | : "r2", "usr"); \ |
| 200 | *usr_result = usr & 0x3f; \ |
| 201 | return result; \ |
| 202 | } |
| 203 | |
| 204 | #define FUNC_XR_OP_RR(NAME, INSN) \ |
| 205 | FUNC_Xx_OP_xx(uint32_t, uint32_t, uint32_t, NAME, INSN) |
| 206 | |
| 207 | #define FUNC_XP_OP_PP(NAME, INSN) \ |
| 208 | FUNC_Xx_OP_xx(uint64_t, uint64_t, uint64_t, NAME, INSN) |
| 209 | |
| 210 | #define FUNC_XP_OP_RR(NAME, INSN) \ |
| 211 | FUNC_Xx_OP_xx(uint64_t, uint32_t, uint32_t, NAME, INSN) |
| 212 | |
| 213 | /* |
| 214 | * Template for instructions with a read/write result |
| 215 | * and two register operands |
| 216 | */ |
| 217 | #define FUNC_Xxp_OP_xx(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \ |
| 218 | static RESTYPE NAME(RESTYPE result, SRC1TYPE src1, SRC2TYPE src2, \ |
| 219 | uint8_t *pred_result, uint32_t *usr_result) \ |
| 220 | { \ |
| 221 | uint32_t usr; \ |
| 222 | uint8_t pred; \ |
| 223 | asm(CLEAR_USRBITS \ |
| 224 | INSN "\n\t" \ |
| 225 | "%1 = p2\n\t" \ |
| 226 | "%2 = usr\n\t" \ |
| 227 | : "+r"(result), "=r"(pred), "=r"(usr) \ |
| 228 | : "r"(src1), "r"(src2) \ |
| 229 | : "r2", "usr"); \ |
| 230 | *pred_result = pred; \ |
| 231 | *usr_result = usr & 0x3f; \ |
| 232 | return result; \ |
| 233 | } |
| 234 | |
| 235 | #define FUNC_XPp_OP_PP(NAME, INSN) \ |
| 236 | FUNC_Xxp_OP_xx(uint64_t, uint64_t, uint64_t, NAME, INSN) |
| 237 | |
| 238 | /* |
| 239 | * Template for instructions with a read/write result and |
| 240 | * two register and one predicate operands |
| 241 | */ |
| 242 | #define FUNC_Xx_OP_xxp(RESTYPE, SRC1TYPE, SRC2TYPE, NAME, INSN) \ |
| 243 | static RESTYPE NAME(RESTYPE result, SRC1TYPE src1, SRC2TYPE src2, uint8_t pred,\ |
| 244 | uint32_t *usr_result) \ |
| 245 | { \ |
| 246 | uint32_t usr; \ |
| 247 | asm(CLEAR_USRBITS \ |
| 248 | "p2 = %4\n\t" \ |
| 249 | INSN "\n\t" \ |
| 250 | "%1 = usr\n\t" \ |
| 251 | : "+r"(result), "=r"(usr) \ |
| 252 | : "r"(src1), "r"(src2), "r"(pred) \ |
| 253 | : "r2", "p2", "usr"); \ |
| 254 | *usr_result = usr & 0x3f; \ |
| 255 | return result; \ |
| 256 | } |
| 257 | |
| 258 | #define FUNC_XR_OP_RRp(NAME, INSN) \ |
| 259 | FUNC_Xx_OP_xxp(uint32_t, uint32_t, uint32_t, NAME, INSN) |
| 260 | |
| 261 | /* Template for compare instructions with two register operands */ |
| 262 | #define FUNC_CMP_xx(SRC1TYPE, SRC2TYPE, NAME, INSN) \ |
| 263 | static uint32_t NAME(SRC1TYPE src1, SRC2TYPE src2, uint32_t *usr_result) \ |
| 264 | { \ |
| 265 | uint32_t result; \ |
| 266 | uint32_t usr; \ |
| 267 | asm(CLEAR_USRBITS \ |
| 268 | INSN "\n\t" \ |
| 269 | "%0 = p1\n\t" \ |
| 270 | "%1 = usr\n\t" \ |
| 271 | : "=r"(result), "=r"(usr) \ |
| 272 | : "r"(src1), "r"(src2) \ |
| 273 | : "p1", "r2", "usr"); \ |
| 274 | *usr_result = usr & 0x3f; \ |
| 275 | return result; \ |
| 276 | } |
| 277 | |
| 278 | #define FUNC_CMP_RR(NAME, INSN) \ |
| 279 | FUNC_CMP_xx(uint32_t, uint32_t, NAME, INSN) |
| 280 | |
| 281 | #define FUNC_CMP_PP(NAME, INSN) \ |
| 282 | FUNC_CMP_xx(uint64_t, uint64_t, NAME, INSN) |
| 283 | |
| 284 | /* |
| 285 | * Function declarations using the templates |
| 286 | */ |
| 287 | FUNC_R_OP_R(satub, "%0 = satub(%2)") |
| 288 | FUNC_P_OP_PP(vaddubs, "%0 = vaddub(%2, %3):sat") |
| 289 | FUNC_P_OP_PP(vadduhs, "%0 = vadduh(%2, %3):sat") |
| 290 | FUNC_P_OP_PP(vsububs, "%0 = vsubub(%2, %3):sat") |
| 291 | FUNC_P_OP_PP(vsubuhs, "%0 = vsubuh(%2, %3):sat") |
| 292 | |
| 293 | /* Add vector of half integers with saturation and pack to unsigned bytes */ |
| 294 | FUNC_R_OP_PP(vaddhubs, "%0 = vaddhub(%2, %3):sat") |
| 295 | |
| 296 | /* Vector saturate half to unsigned byte */ |
| 297 | FUNC_R_OP_P(vsathub, "%0 = vsathub(%2)") |
| 298 | |
| 299 | /* Similar to above but takes a 32-bit argument */ |
| 300 | FUNC_R_OP_R(svsathub, "%0 = vsathub(%2)") |
| 301 | |
| 302 | /* Vector saturate word to unsigned half */ |
| 303 | FUNC_P_OP_P(vsatwuh_nopack, "%0 = vsatwuh(%2)") |
| 304 | |
| 305 | /* Similar to above but returns a 32-bit result */ |
| 306 | FUNC_R_OP_P(vsatwuh, "%0 = vsatwuh(%2)") |
| 307 | |
| 308 | /* Vector arithmetic shift halfwords with saturate and pack */ |
| 309 | FUNC_R_OP_PI(asrhub_sat, "%0 = vasrhub(%2, #%3):sat") |
| 310 | |
| 311 | /* Vector arithmetic shift halfwords with round, saturate and pack */ |
| 312 | FUNC_R_OP_PI(asrhub_rnd_sat, "%0 = vasrhub(%2, #%3):raw") |
| 313 | |
| 314 | FUNC_R_OP_RR(addsat, "%0 = add(%2, %3):sat") |
| 315 | /* Similar to above but with register pairs */ |
| 316 | FUNC_P_OP_PP(addpsat, "%0 = add(%2, %3):sat") |
| 317 | |
| 318 | FUNC_XR_OP_RR(mpy_acc_sat_hh_s0, "%0 += mpy(%2.H, %3.H):sat") |
| 319 | FUNC_R_OP_RR(mpy_sat_hh_s1, "%0 = mpy(%2.H, %3.H):<<1:sat") |
| 320 | FUNC_R_OP_RR(mpy_sat_rnd_hh_s1, "%0 = mpy(%2.H, %3.H):<<1:rnd:sat") |
| 321 | FUNC_R_OP_RR(mpy_up_s1_sat, "%0 = mpy(%2, %3):<<1:sat") |
| 322 | FUNC_P_OP_RR(vmpy2s_s1, "%0 = vmpyh(%2, %3):<<1:sat") |
| 323 | FUNC_P_OP_RR(vmpy2su_s1, "%0 = vmpyhsu(%2, %3):<<1:sat") |
| 324 | FUNC_R_OP_RR(vmpy2s_s1pack, "%0 = vmpyh(%2, %3):<<1:rnd:sat") |
| 325 | FUNC_P_OP_PP(vmpy2es_s1, "%0 = vmpyeh(%2, %3):<<1:sat") |
| 326 | FUNC_R_OP_PP(vdmpyrs_s1, "%0 = vdmpy(%2, %3):<<1:rnd:sat") |
| 327 | FUNC_XP_OP_PP(vdmacs_s0, "%0 += vdmpy(%2, %3):sat") |
| 328 | FUNC_R_OP_RR(cmpyrs_s0, "%0 = cmpy(%2, %3):rnd:sat") |
| 329 | FUNC_XP_OP_RR(cmacs_s0, "%0 += cmpy(%2, %3):sat") |
| 330 | FUNC_XP_OP_RR(cnacs_s0, "%0 -= cmpy(%2, %3):sat") |
| 331 | FUNC_P_OP_PP(vrcmpys_s1_h, "%0 = vrcmpys(%2, %3):<<1:sat:raw:hi") |
| 332 | FUNC_XP_OP_PP(mmacls_s0, "%0 += vmpyweh(%2, %3):sat") |
| 333 | FUNC_R_OP_RR(hmmpyl_rs1, "%0 = mpy(%2, %3.L):<<1:rnd:sat") |
| 334 | FUNC_XP_OP_PP(mmaculs_s0, "%0 += vmpyweuh(%2, %3):sat") |
| 335 | FUNC_R_OP_PR(cmpyi_wh, "%0 = cmpyiwh(%2, %3):<<1:rnd:sat") |
| 336 | FUNC_P_OP_PP(vcmpy_s0_sat_i, "%0 = vcmpyi(%2, %3):sat") |
| 337 | FUNC_P_OP_PR(vcrotate, "%0 = vcrotate(%2, %3)") |
| 338 | FUNC_P_OP_PR(vcnegh, "%0 = vcnegh(%2, %3)") |
| 339 | |
| 340 | #if CORE_HAS_AUDIO |
| 341 | FUNC_R_OP_PP(wcmpyrw, "%0 = cmpyrw(%2, %3):<<1:sat") |
| 342 | #endif |
| 343 | |
| 344 | FUNC_R_OP_RR(addh_l16_sat_ll, "%0 = add(%2.L, %3.L):sat") |
| 345 | FUNC_P_OP_P(vconj, "%0 = vconj(%2):sat") |
| 346 | FUNC_P_OP_PP(vxaddsubw, "%0 = vxaddsubw(%2, %3):sat") |
| 347 | FUNC_P_OP_P(vabshsat, "%0 = vabsh(%2):sat") |
| 348 | FUNC_P_OP_PP(vnavgwr, "%0 = vnavgw(%2, %3):rnd:sat") |
| 349 | FUNC_R_OP_RI(round_ri_sat, "%0 = round(%2, #%3):sat") |
| 350 | FUNC_R_OP_RR(asr_r_r_sat, "%0 = asr(%2, %3):sat") |
| 351 | FUNC_R_OP_RR(asl_r_r_sat, "%0 = asl(%2, %3):sat") |
| 352 | |
| 353 | FUNC_XPp_OP_PP(ACS, "%0, p2 = vacsh(%3, %4)") |
| 354 | |
| 355 | /* Floating point */ |
| 356 | FUNC_R_OP_RR(sfmin, "%0 = sfmin(%2, %3)") |
| 357 | FUNC_R_OP_RR(sfmax, "%0 = sfmax(%2, %3)") |
| 358 | FUNC_R_OP_RR(sfadd, "%0 = sfadd(%2, %3)") |
| 359 | FUNC_R_OP_RR(sfsub, "%0 = sfsub(%2, %3)") |
| 360 | FUNC_R_OP_RR(sfmpy, "%0 = sfmpy(%2, %3)") |
| 361 | FUNC_XR_OP_RR(sffma, "%0 += sfmpy(%2, %3)") |
| 362 | FUNC_XR_OP_RR(sffms, "%0 -= sfmpy(%2, %3)") |
| 363 | FUNC_CMP_RR(sfcmpuo, "p1 = sfcmp.uo(%2, %3)") |
| 364 | FUNC_CMP_RR(sfcmpeq, "p1 = sfcmp.eq(%2, %3)") |
| 365 | FUNC_CMP_RR(sfcmpgt, "p1 = sfcmp.gt(%2, %3)") |
| 366 | FUNC_CMP_RR(sfcmpge, "p1 = sfcmp.ge(%2, %3)") |
| 367 | |
| 368 | FUNC_P_OP_PP(dfadd, "%0 = dfadd(%2, %3)") |
| 369 | FUNC_P_OP_PP(dfsub, "%0 = dfsub(%2, %3)") |
| 370 | |
| 371 | #if CORE_IS_V67 |
| 372 | FUNC_P_OP_PP(dfmin, "%0 = dfmin(%2, %3)") |
| 373 | FUNC_P_OP_PP(dfmax, "%0 = dfmax(%2, %3)") |
| 374 | FUNC_XP_OP_PP(dfmpyhh, "%0 += dfmpyhh(%2, %3)") |
| 375 | #endif |
| 376 | |
| 377 | FUNC_CMP_PP(dfcmpuo, "p1 = dfcmp.uo(%2, %3)") |
| 378 | FUNC_CMP_PP(dfcmpeq, "p1 = dfcmp.eq(%2, %3)") |
| 379 | FUNC_CMP_PP(dfcmpgt, "p1 = dfcmp.gt(%2, %3)") |
| 380 | FUNC_CMP_PP(dfcmpge, "p1 = dfcmp.ge(%2, %3)") |
| 381 | |
| 382 | /* Conversions from sf */ |
| 383 | FUNC_P_OP_R(conv_sf2df, "%0 = convert_sf2df(%2)") |
| 384 | FUNC_R_OP_R(conv_sf2uw, "%0 = convert_sf2uw(%2)") |
| 385 | FUNC_R_OP_R(conv_sf2w, "%0 = convert_sf2w(%2)") |
| 386 | FUNC_P_OP_R(conv_sf2ud, "%0 = convert_sf2ud(%2)") |
| 387 | FUNC_P_OP_R(conv_sf2d, "%0 = convert_sf2d(%2)") |
| 388 | FUNC_R_OP_R(conv_sf2uw_chop, "%0 = convert_sf2uw(%2):chop") |
| 389 | FUNC_R_OP_R(conv_sf2w_chop, "%0 = convert_sf2w(%2):chop") |
| 390 | FUNC_P_OP_R(conv_sf2ud_chop, "%0 = convert_sf2ud(%2):chop") |
| 391 | FUNC_P_OP_R(conv_sf2d_chop, "%0 = convert_sf2d(%2):chop") |
| 392 | |
| 393 | /* Conversions from df */ |
| 394 | FUNC_R_OP_P(conv_df2sf, "%0 = convert_df2sf(%2)") |
| 395 | FUNC_R_OP_P(conv_df2uw, "%0 = convert_df2uw(%2)") |
| 396 | FUNC_R_OP_P(conv_df2w, "%0 = convert_df2w(%2)") |
| 397 | FUNC_P_OP_P(conv_df2ud, "%0 = convert_df2ud(%2)") |
| 398 | FUNC_P_OP_P(conv_df2d, "%0 = convert_df2d(%2)") |
| 399 | FUNC_R_OP_P(conv_df2uw_chop, "%0 = convert_df2uw(%2):chop") |
| 400 | FUNC_R_OP_P(conv_df2w_chop, "%0 = convert_df2w(%2):chop") |
| 401 | FUNC_P_OP_P(conv_df2ud_chop, "%0 = convert_df2ud(%2):chop") |
| 402 | FUNC_P_OP_P(conv_df2d_chop, "%0 = convert_df2d(%2):chop") |
| 403 | |
| 404 | /* Integer to float conversions */ |
| 405 | FUNC_R_OP_R(conv_uw2sf, "%0 = convert_uw2sf(%2)") |
| 406 | FUNC_R_OP_R(conv_w2sf, "%0 = convert_w2sf(%2)") |
| 407 | FUNC_R_OP_P(conv_ud2sf, "%0 = convert_ud2sf(%2)") |
| 408 | FUNC_R_OP_P(conv_d2sf, "%0 = convert_d2sf(%2)") |
| 409 | |
| 410 | /* Special purpose floating point instructions */ |
| 411 | FUNC_XR_OP_RRp(sffma_sc, "%0 += sfmpy(%2, %3, p2):scale") |
| 412 | FUNC_Rp_OP_RR(sfrecipa, "%0, p2 = sfrecipa(%3, %4)") |
| 413 | FUNC_R_OP_RR(sffixupn, "%0 = sffixupn(%2, %3)") |
| 414 | FUNC_R_OP_RR(sffixupd, "%0 = sffixupd(%2, %3)") |
| 415 | FUNC_R_OP_R(sffixupr, "%0 = sffixupr(%2)") |
| 416 | FUNC_Rp_OP_R(sfinvsqrta, "%0, p2 = sfinvsqrta(%3)") |
| 417 | |
| 418 | /* |
| 419 | * Templates for test cases |
| 420 | * |
| 421 | * Same naming convention as the function templates |
| 422 | */ |
| 423 | #define TEST_x_OP_x(RESTYPE, CHECKFN, SRCTYPE, FUNC, SRC, RES, USR_RES) \ |
| 424 | do { \ |
| 425 | RESTYPE result; \ |
| 426 | SRCTYPE src = SRC; \ |
| 427 | uint32_t usr_result; \ |
| 428 | result = FUNC(src, &usr_result); \ |
| 429 | CHECKFN(result, RES); \ |
| 430 | check32(usr_result, USR_RES); \ |
| 431 | } while (0) |
| 432 | |
| 433 | #define TEST_R_OP_R(FUNC, SRC, RES, USR_RES) \ |
| 434 | TEST_x_OP_x(uint32_t, check32, uint32_t, FUNC, SRC, RES, USR_RES) |
| 435 | |
| 436 | #define TEST_R_OP_P(FUNC, SRC, RES, USR_RES) \ |
| 437 | TEST_x_OP_x(uint32_t, check32, uint64_t, FUNC, SRC, RES, USR_RES) |
| 438 | |
| 439 | #define TEST_P_OP_P(FUNC, SRC, RES, USR_RES) \ |
| 440 | TEST_x_OP_x(uint64_t, check64, uint64_t, FUNC, SRC, RES, USR_RES) |
| 441 | |
| 442 | #define TEST_P_OP_R(FUNC, SRC, RES, USR_RES) \ |
| 443 | TEST_x_OP_x(uint64_t, check64, uint32_t, FUNC, SRC, RES, USR_RES) |
| 444 | |
| 445 | #define TEST_xp_OP_x(RESTYPE, CHECKFN, SRCTYPE, FUNC, SRC, \ |
| 446 | RES, PRED_RES, USR_RES) \ |
| 447 | do { \ |
| 448 | RESTYPE result; \ |
| 449 | SRCTYPE src = SRC; \ |
| 450 | uint8_t pred_result; \ |
| 451 | uint32_t usr_result; \ |
| 452 | result = FUNC(src, &pred_result, &usr_result); \ |
| 453 | CHECKFN(result, RES); \ |
| 454 | check32(pred_result, PRED_RES); \ |
| 455 | check32(usr_result, USR_RES); \ |
| 456 | } while (0) |
| 457 | |
| 458 | #define TEST_Rp_OP_R(FUNC, SRC, RES, PRED_RES, USR_RES) \ |
| 459 | TEST_xp_OP_x(uint32_t, check32, uint32_t, FUNC, SRC, RES, PRED_RES, USR_RES) |
| 460 | |
| 461 | #define TEST_x_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \ |
| 462 | FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 463 | do { \ |
| 464 | RESTYPE result; \ |
| 465 | SRC1TYPE src1 = SRC1; \ |
| 466 | SRC2TYPE src2 = SRC2; \ |
| 467 | uint32_t usr_result; \ |
| 468 | result = FUNC(src1, src2, &usr_result); \ |
| 469 | CHECKFN(result, RES); \ |
| 470 | check32(usr_result, USR_RES); \ |
| 471 | } while (0) |
| 472 | |
| 473 | #define TEST_P_OP_PP(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 474 | TEST_x_OP_xx(uint64_t, check64, uint64_t, uint64_t, \ |
| 475 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 476 | |
| 477 | #define TEST_R_OP_PP(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 478 | TEST_x_OP_xx(uint32_t, check32, uint64_t, uint64_t, \ |
| 479 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 480 | |
| 481 | #define TEST_P_OP_RR(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 482 | TEST_x_OP_xx(uint64_t, check64, uint32_t, uint32_t, \ |
| 483 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 484 | |
| 485 | #define TEST_R_OP_RR(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 486 | TEST_x_OP_xx(uint32_t, check32, uint32_t, uint32_t, \ |
| 487 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 488 | |
| 489 | #define TEST_R_OP_PR(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 490 | TEST_x_OP_xx(uint32_t, check32, uint64_t, uint32_t, \ |
| 491 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 492 | |
| 493 | #define TEST_P_OP_PR(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 494 | TEST_x_OP_xx(uint64_t, check64, uint64_t, uint32_t, \ |
| 495 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 496 | |
| 497 | #define TEST_xp_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, FUNC, SRC1, SRC2, \ |
| 498 | RES, PRED_RES, USR_RES) \ |
| 499 | do { \ |
| 500 | RESTYPE result; \ |
| 501 | SRC1TYPE src1 = SRC1; \ |
| 502 | SRC2TYPE src2 = SRC2; \ |
| 503 | uint8_t pred_result; \ |
| 504 | uint32_t usr_result; \ |
| 505 | result = FUNC(src1, src2, &pred_result, &usr_result); \ |
| 506 | CHECKFN(result, RES); \ |
| 507 | check32(pred_result, PRED_RES); \ |
| 508 | check32(usr_result, USR_RES); \ |
| 509 | } while (0) |
| 510 | |
| 511 | #define TEST_Rp_OP_RR(FUNC, SRC1, SRC2, RES, PRED_RES, USR_RES) \ |
| 512 | TEST_xp_OP_xx(uint32_t, check32, uint32_t, uint32_t, FUNC, SRC1, SRC2, \ |
| 513 | RES, PRED_RES, USR_RES) |
| 514 | |
| 515 | #define TEST_x_OP_xI(RESTYPE, CHECKFN, SRC1TYPE, \ |
| 516 | FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 517 | do { \ |
| 518 | RESTYPE result; \ |
| 519 | SRC1TYPE src1 = SRC1; \ |
| 520 | uint32_t src2 = SRC2; \ |
| 521 | uint32_t usr_result; \ |
| 522 | result = FUNC(src1, src2, &usr_result); \ |
| 523 | CHECKFN(result, RES); \ |
| 524 | check32(usr_result, USR_RES); \ |
| 525 | } while (0) |
| 526 | |
| 527 | #define TEST_R_OP_RI(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 528 | TEST_x_OP_xI(uint32_t, check32, uint32_t, \ |
| 529 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 530 | |
| 531 | #define TEST_R_OP_PI(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 532 | TEST_x_OP_xI(uint32_t, check64, uint64_t, \ |
| 533 | FUNC, SRC1, SRC2, RES, USR_RES) |
| 534 | |
| 535 | #define TEST_Xx_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \ |
| 536 | FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \ |
| 537 | do { \ |
| 538 | RESTYPE result = RESIN; \ |
| 539 | SRC1TYPE src1 = SRC1; \ |
| 540 | SRC2TYPE src2 = SRC2; \ |
| 541 | uint32_t usr_result; \ |
| 542 | result = FUNC(result, src1, src2, &usr_result); \ |
| 543 | CHECKFN(result, RES); \ |
| 544 | check32(usr_result, USR_RES); \ |
| 545 | } while (0) |
| 546 | |
| 547 | #define TEST_XR_OP_RR(FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \ |
| 548 | TEST_Xx_OP_xx(uint32_t, check32, uint32_t, uint32_t, \ |
| 549 | FUNC, RESIN, SRC1, SRC2, RES, USR_RES) |
| 550 | |
| 551 | #define TEST_XP_OP_PP(FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \ |
| 552 | TEST_Xx_OP_xx(uint64_t, check64, uint64_t, uint64_t, \ |
| 553 | FUNC, RESIN, SRC1, SRC2, RES, USR_RES) |
| 554 | |
| 555 | #define TEST_XP_OP_RR(FUNC, RESIN, SRC1, SRC2, RES, USR_RES) \ |
| 556 | TEST_Xx_OP_xx(uint64_t, check64, uint32_t, uint32_t, \ |
| 557 | FUNC, RESIN, SRC1, SRC2, RES, USR_RES) |
| 558 | |
| 559 | #define TEST_Xxp_OP_xx(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \ |
| 560 | FUNC, RESIN, SRC1, SRC2, RES, PRED_RES, USR_RES) \ |
| 561 | do { \ |
| 562 | RESTYPE result = RESIN; \ |
| 563 | SRC1TYPE src1 = SRC1; \ |
| 564 | SRC2TYPE src2 = SRC2; \ |
| 565 | uint8_t pred_res; \ |
| 566 | uint32_t usr_result; \ |
| 567 | result = FUNC(result, src1, src2, &pred_res, &usr_result); \ |
| 568 | CHECKFN(result, RES); \ |
| 569 | check32(usr_result, USR_RES); \ |
| 570 | } while (0) |
| 571 | |
| 572 | #define TEST_XPp_OP_PP(FUNC, RESIN, SRC1, SRC2, RES, PRED_RES, USR_RES) \ |
| 573 | TEST_Xxp_OP_xx(uint64_t, check64, uint64_t, uint64_t, FUNC, RESIN, SRC1, SRC2, \ |
| 574 | RES, PRED_RES, USR_RES) |
| 575 | |
| 576 | #define TEST_Xx_OP_xxp(RESTYPE, CHECKFN, SRC1TYPE, SRC2TYPE, \ |
| 577 | FUNC, RESIN, SRC1, SRC2, PRED, RES, USR_RES) \ |
| 578 | do { \ |
| 579 | RESTYPE result = RESIN; \ |
| 580 | SRC1TYPE src1 = SRC1; \ |
| 581 | SRC2TYPE src2 = SRC2; \ |
| 582 | uint8_t pred = PRED; \ |
| 583 | uint32_t usr_result; \ |
| 584 | result = FUNC(result, src1, src2, pred, &usr_result); \ |
| 585 | CHECKFN(result, RES); \ |
| 586 | check32(usr_result, USR_RES); \ |
| 587 | } while (0) |
| 588 | |
| 589 | #define TEST_XR_OP_RRp(FUNC, RESIN, SRC1, SRC2, PRED, RES, USR_RES) \ |
| 590 | TEST_Xx_OP_xxp(uint32_t, check32, uint32_t, uint32_t, \ |
| 591 | FUNC, RESIN, SRC1, SRC2, PRED, RES, USR_RES) |
| 592 | |
| 593 | #define TEST_CMP_xx(SRC1TYPE, SRC2TYPE, \ |
| 594 | FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 595 | do { \ |
| 596 | uint32_t result; \ |
| 597 | SRC1TYPE src1 = SRC1; \ |
| 598 | SRC2TYPE src2 = SRC2; \ |
| 599 | uint32_t usr_result; \ |
| 600 | result = FUNC(src1, src2, &usr_result); \ |
| 601 | check32(result, RES); \ |
| 602 | check32(usr_result, USR_RES); \ |
| 603 | } while (0) |
| 604 | |
| 605 | #define TEST_CMP_RR(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 606 | TEST_CMP_xx(uint32_t, uint32_t, FUNC, SRC1, SRC2, RES, USR_RES) |
| 607 | |
| 608 | #define TEST_CMP_PP(FUNC, SRC1, SRC2, RES, USR_RES) \ |
| 609 | TEST_CMP_xx(uint64_t, uint64_t, FUNC, SRC1, SRC2, RES, USR_RES) |
| 610 | |
| 611 | static void test_usr_packets(void) |
| 612 | { |
| 613 | uint32_t usr_out; |
| 614 | /* Test setting USR bits inside and outside packets */ |
| 615 | asm(CLEAR_USRBITS \ |
| 616 | "r10 = satub(%[val_0xfff]) /* Set usr.OVF */\n\t" |
| 617 | "{\n\t" |
| 618 | " r11 = convert_uw2sf(%[val_0x010020a5]) /* Set usr.FPINPF */\n\t" |
| 619 | " r10 = memw(%[err]) /* Force pkt commit */\n\t" |
| 620 | "}\n\t" |
| 621 | "{\n\t" |
| 622 | " r11 = sfadd(%[SF_one], %[SF_SNaN]) /* Set usr.FPINVF */\n\t" |
| 623 | " r10 = add(r10, #1) /* No pkt commit */\n\t" |
| 624 | "}\n\t" |
| 625 | "%[usr_out] = usr\n\t" |
| 626 | : [usr_out]"=r"(usr_out) |
| 627 | : [val_0xfff]"r"(0xfff), |
| 628 | [SF_one]"r"(SF_one), [SF_SNaN]"r"(SF_SNaN), |
| 629 | [val_0x010020a5]"r"(0x010020a5), |
| 630 | [err]"m"(err) |
| 631 | : "r2", "r10", "r11", "usr"); |
| 632 | check32(usr_out & 0x3f, USR_OVF | USR_FPINVF | USR_FPINPF); |
| 633 | |
| 634 | /* Test setting several USR bits in the same packet (no pkt commit) */ |
| 635 | asm(CLEAR_USRBITS \ |
| 636 | "{\n\t" |
| 637 | " r10 = satub(%[val_0xfff]) /* Set usr.OVF */\n\t" |
| 638 | " r12 = sfadd(%[SF_one], %[SF_SNaN]) /* Set usr.FPINVF */\n\t" |
| 639 | "}\n\t" |
| 640 | "%[usr_out] = usr\n\t" |
| 641 | : [usr_out]"=r"(usr_out) |
| 642 | : [val_0xfff]"r"(0xfff), |
| 643 | [SF_one]"r"(SF_one), [SF_SNaN]"r"(SF_SNaN) |
| 644 | : "r2", "r10", "r11", "r12", "usr"); |
| 645 | check32(usr_out & 0x3f, USR_OVF | USR_FPINVF); |
| 646 | |
| 647 | /* Test setting several USR bits in the same packet (with pkt commit) */ |
| 648 | asm(CLEAR_USRBITS \ |
| 649 | "{\n\t" |
| 650 | " r10 = satub(%[val_0xfff]) /* Set usr.OVF */\n\t" |
| 651 | " r11 = convert_uw2sf(%[val_0x010020a5]) /* Set usr.FPINPF */\n\t" |
| 652 | " r12 = memw(%[err]) /* Force pkt commit */\n\t" |
| 653 | "}\n\t" |
| 654 | "%[usr_out] = usr\n\t" |
| 655 | : [usr_out]"=r"(usr_out) |
| 656 | : [val_0xfff]"r"(0xfff), |
| 657 | [val_0x010020a5]"r"(0x010020a5), |
| 658 | [err]"m"(err) |
| 659 | : "r2", "r10", "r11", "r12", "usr"); |
| 660 | check32(usr_out & 0x3f, USR_OVF | USR_FPINPF); |
| 661 | } |
| 662 | |
| 663 | int main() |
| 664 | { |
| 665 | TEST_R_OP_R(satub, 0, 0, USR_CLEAR); |
| 666 | TEST_R_OP_R(satub, 0xff, 0xff, USR_CLEAR); |
| 667 | TEST_R_OP_R(satub, 0xfff, 0xff, USR_OVF); |
| 668 | TEST_R_OP_R(satub, -1, 0, USR_OVF); |
| 669 | |
| 670 | TEST_P_OP_PP(vaddubs, 0xfeLL, 0x01LL, 0xffLL, USR_CLEAR); |
| 671 | TEST_P_OP_PP(vaddubs, 0xffLL, 0xffLL, 0xffLL, USR_OVF); |
| 672 | |
| 673 | TEST_P_OP_PP(vadduhs, 0xfffeLL, 0x1LL, 0xffffLL, USR_CLEAR); |
| 674 | TEST_P_OP_PP(vadduhs, 0xffffLL, 0x1LL, 0xffffLL, USR_OVF); |
| 675 | |
| 676 | TEST_P_OP_PP(vsububs, 0x0807060504030201LL, 0x0101010101010101LL, |
| 677 | 0x0706050403020100LL, USR_CLEAR); |
| 678 | TEST_P_OP_PP(vsububs, 0x0807060504030201LL, 0x0202020202020202LL, |
| 679 | 0x0605040302010000LL, USR_OVF); |
| 680 | |
| 681 | TEST_P_OP_PP(vsubuhs, 0x0004000300020001LL, 0x0001000100010001LL, |
| 682 | 0x0003000200010000LL, USR_CLEAR); |
| 683 | TEST_P_OP_PP(vsubuhs, 0x0004000300020001LL, 0x0002000200020002LL, |
| 684 | 0x0002000100000000LL, USR_OVF); |
| 685 | |
| 686 | TEST_R_OP_PP(vaddhubs, 0x0004000300020001LL, 0x0001000100010001LL, |
| 687 | 0x05040302, USR_CLEAR); |
| 688 | TEST_R_OP_PP(vaddhubs, 0x7fff000300020001LL, 0x0002000200020002LL, |
| 689 | 0xff050403, USR_OVF); |
| 690 | |
| 691 | TEST_R_OP_P(vsathub, 0x0001000300020001LL, 0x01030201, USR_CLEAR); |
| 692 | TEST_R_OP_P(vsathub, 0x010000700080ffffLL, 0xff708000, USR_OVF); |
| 693 | |
| 694 | TEST_R_OP_P(vsatwuh, 0x0000ffff00000001LL, 0xffff0001, USR_CLEAR); |
| 695 | TEST_R_OP_P(vsatwuh, 0x800000000000ffffLL, 0x0000ffff, USR_OVF); |
| 696 | |
| 697 | TEST_P_OP_P(vsatwuh_nopack, 0x0000ffff00000001LL, 0x0000ffff00000001LL, |
| 698 | USR_CLEAR); |
| 699 | TEST_P_OP_P(vsatwuh_nopack, 0x800000000000ffffLL, 0x000000000000ffffLL, |
| 700 | USR_OVF); |
| 701 | |
| 702 | TEST_R_OP_R(svsathub, 0x00020001, 0x0201, USR_CLEAR); |
| 703 | TEST_R_OP_R(svsathub, 0x0080ffff, 0x8000, USR_OVF); |
| 704 | |
| 705 | TEST_R_OP_PI(asrhub_sat, 0x004f003f002f001fLL, 3, 0x09070503, |
| 706 | USR_CLEAR); |
| 707 | TEST_R_OP_PI(asrhub_sat, 0x004fffff8fff001fLL, 3, 0x09000003, |
| 708 | USR_OVF); |
| 709 | |
| 710 | TEST_R_OP_PI(asrhub_rnd_sat, 0x004f003f002f001fLL, 2, 0x0a080604, |
| 711 | USR_CLEAR); |
| 712 | TEST_R_OP_PI(asrhub_rnd_sat, 0x004fffff8fff001fLL, 2, 0x0a000004, |
| 713 | USR_OVF); |
| 714 | |
| 715 | TEST_R_OP_RR(addsat, 1, 2, 3, |
| 716 | USR_CLEAR); |
| 717 | TEST_R_OP_RR(addsat, 0x7fffffff, 0x00000010, 0x7fffffff, |
| 718 | USR_OVF); |
| 719 | TEST_R_OP_RR(addsat, 0x80000000, 0x80000006, 0x80000000, |
| 720 | USR_OVF); |
| 721 | |
| 722 | TEST_P_OP_PP(addpsat, 1LL, 2LL, 3LL, USR_CLEAR); |
| 723 | /* overflow to max positive */ |
| 724 | TEST_P_OP_PP(addpsat, 0x7ffffffffffffff0LL, 0x0000000000000010LL, |
| 725 | 0x7fffffffffffffffLL, USR_OVF); |
| 726 | /* overflow to min negative */ |
| 727 | TEST_P_OP_PP(addpsat, 0x8000000000000003LL, 0x8000000000000006LL, |
| 728 | 0x8000000000000000LL, USR_OVF); |
| 729 | |
| 730 | TEST_XR_OP_RR(mpy_acc_sat_hh_s0, 0x7fffffff, 0xffff0000, 0x11110000, |
| 731 | 0x7fffeeee, USR_CLEAR); |
| 732 | TEST_XR_OP_RR(mpy_acc_sat_hh_s0, 0x7fffffff, 0x7fff0000, 0x7fff0000, |
| 733 | 0x7fffffff, USR_OVF); |
| 734 | |
| 735 | TEST_R_OP_RR(mpy_sat_hh_s1, 0xffff0000, 0x11110000, 0xffffddde, |
| 736 | USR_CLEAR); |
| 737 | TEST_R_OP_RR(mpy_sat_hh_s1, 0x7fff0000, 0x7fff0000, 0x7ffe0002, |
| 738 | USR_CLEAR); |
| 739 | TEST_R_OP_RR(mpy_sat_hh_s1, 0x80000000, 0x80000000, 0x7fffffff, |
| 740 | USR_OVF); |
| 741 | |
| 742 | TEST_R_OP_RR(mpy_sat_rnd_hh_s1, 0xffff0000, 0x11110000, 0x00005dde, |
| 743 | USR_CLEAR); |
| 744 | TEST_R_OP_RR(mpy_sat_rnd_hh_s1, 0x7fff0000, 0x7fff0000, 0x7ffe8002, |
| 745 | USR_CLEAR); |
| 746 | TEST_R_OP_RR(mpy_sat_rnd_hh_s1, 0x80000000, 0x80000000, 0x7fffffff, |
| 747 | USR_OVF); |
| 748 | |
| 749 | TEST_R_OP_RR(mpy_up_s1_sat, 0xffff0000, 0x11110000, 0xffffddde, |
| 750 | USR_CLEAR); |
| 751 | TEST_R_OP_RR(mpy_up_s1_sat, 0x7fff0000, 0x7fff0000, 0x7ffe0002, |
| 752 | USR_CLEAR); |
| 753 | TEST_R_OP_RR(mpy_up_s1_sat, 0x80000000, 0x80000000, 0x7fffffff, |
| 754 | USR_OVF); |
| 755 | |
| 756 | TEST_P_OP_RR(vmpy2s_s1, 0x7fff0000, 0x7fff0000, 0x7ffe000200000000LL, |
| 757 | USR_CLEAR); |
| 758 | TEST_P_OP_RR(vmpy2s_s1, 0x80000000, 0x80000000, 0x7fffffff00000000LL, |
| 759 | USR_OVF); |
| 760 | |
| 761 | TEST_P_OP_RR(vmpy2su_s1, 0x7fff0000, 0x7fff0000, 0x7ffe000200000000LL, |
| 762 | USR_CLEAR); |
| 763 | TEST_P_OP_RR(vmpy2su_s1, 0xffffbd97, 0xffffffff, 0xfffe000280000000LL, |
| 764 | USR_OVF); |
| 765 | |
| 766 | TEST_R_OP_RR(vmpy2s_s1pack, 0x7fff0000, 0x7fff0000, 0x7ffe0000, |
| 767 | USR_CLEAR); |
| 768 | TEST_R_OP_RR(vmpy2s_s1pack, 0x80008000, 0x80008000, 0x7fff7fff, |
| 769 | USR_OVF); |
| 770 | |
| 771 | TEST_P_OP_PP(vmpy2es_s1, 0x7fff7fff7fff7fffLL, 0x1fff1fff1fff1fffLL, |
| 772 | 0x1ffec0021ffec002LL, USR_CLEAR); |
| 773 | TEST_P_OP_PP(vmpy2es_s1, 0x8000800080008000LL, 0x8000800080008000LL, |
| 774 | 0x7fffffff7fffffffLL, USR_OVF); |
| 775 | |
| 776 | TEST_R_OP_PP(vdmpyrs_s1, 0x7fff7fff7fff7fffLL, 0x1fff1fff1fff1fffLL, |
| 777 | 0x3ffe3ffe, USR_CLEAR); |
| 778 | TEST_R_OP_PP(vdmpyrs_s1, 0x8000800080008000LL, 0x8000800080008000LL, |
| 779 | 0x7fff7fffLL, USR_OVF); |
| 780 | |
| 781 | TEST_XP_OP_PP(vdmacs_s0, 0x0fffffffULL, 0x00ff00ff00ff00ffLL, |
| 782 | 0x00ff00ff00ff00ffLL, 0x0001fc021001fc01LL, USR_CLEAR); |
| 783 | TEST_XP_OP_PP(vdmacs_s0, 0x01111111ULL, 0x8000800080001000LL, |
| 784 | 0x8000800080008000LL, 0x7fffffff39111111LL, USR_OVF); |
| 785 | |
| 786 | TEST_R_OP_RR(cmpyrs_s0, 0x7fff0000, 0x7fff0000, 0x0000c001, |
| 787 | USR_CLEAR); |
| 788 | TEST_R_OP_RR(cmpyrs_s0, 0x80008000, 0x80008000, 0x7fff0000, |
| 789 | USR_OVF); |
| 790 | |
| 791 | TEST_XP_OP_RR(cmacs_s0, 0x0fffffff, 0x7fff0000, 0x7fff0000, |
| 792 | 0x00000000d000fffeLL, USR_CLEAR); |
| 793 | TEST_XP_OP_RR(cmacs_s0, 0x0fff1111, 0x80008000, 0x80008000, |
| 794 | 0x7fffffff0fff1111LL, USR_OVF); |
| 795 | |
| 796 | TEST_XP_OP_RR(cnacs_s0, 0x000000108fffffffULL, 0x7fff0000, 0x7fff0000, |
| 797 | 0x00000010cfff0000ULL, USR_CLEAR); |
| 798 | TEST_XP_OP_RR(cnacs_s0, 0x000000108ff1111fULL, 0x00002001, 0x00007ffd, |
| 799 | 0x0000001080000000ULL, USR_OVF); |
| 800 | |
| 801 | TEST_P_OP_PP(vrcmpys_s1_h, 0x00ff00ff00ff00ffLL, 0x00ff00ff00ff00ffLL, |
| 802 | 0x0003f8040003f804LL, USR_CLEAR); |
| 803 | TEST_P_OP_PP(vrcmpys_s1_h, 0x8000800080008000LL, 0x8000800080008000LL, |
| 804 | 0x7fffffff7fffffffLL, USR_OVF); |
| 805 | |
| 806 | TEST_XP_OP_PP(mmacls_s0, 0x6fffffff, 0x00ff00ff00ff00ffLL, |
| 807 | 0x00ff00ff00ff00ffLL, 0x0000fe017000fe00LL, USR_CLEAR); |
| 808 | TEST_XP_OP_PP(mmacls_s0, 0x6f1111ff, 0x8000800080008000LL, |
| 809 | 0x1000100080008000LL, 0xf80008007fffffffLL, USR_OVF); |
| 810 | |
| 811 | TEST_R_OP_RR(hmmpyl_rs1, 0x7fff0000, 0x7fff0001, 0x0000fffe, |
| 812 | USR_CLEAR); |
| 813 | TEST_R_OP_RR(hmmpyl_rs1, 0x80000000, 0x80008000, 0x7fffffff, |
| 814 | USR_OVF); |
| 815 | |
| 816 | TEST_XP_OP_PP(mmaculs_s0, 0x000000007fffffffULL, 0xffff800080008000LL, |
| 817 | 0xffff800080008000LL, 0xffffc00040003fffLL, USR_CLEAR); |
| 818 | TEST_XP_OP_PP(mmaculs_s0, 0x000011107fffffffULL, 0x00ff00ff00ff00ffLL, |
| 819 | 0x00ff00ff001100ffLL, 0x00010f117fffffffLL, USR_OVF); |
| 820 | |
| 821 | TEST_R_OP_PR(cmpyi_wh, 0x7fff000000000000LL, 0x7fff0001, 0x0000fffe, |
| 822 | USR_CLEAR); |
| 823 | TEST_R_OP_PR(cmpyi_wh, 0x8000000000000000LL, 0x80008000, 0x7fffffff, |
| 824 | USR_OVF); |
| 825 | |
| 826 | TEST_P_OP_PP(vcmpy_s0_sat_i, 0x00ff00ff00ff00ffLL, 0x00ff00ff00ff00ffLL, |
| 827 | 0x0001fc020001fc02LL, USR_CLEAR); |
| 828 | TEST_P_OP_PP(vcmpy_s0_sat_i, 0x8000800080008000LL, 0x8000800080008000LL, |
| 829 | 0x7fffffff7fffffffLL, USR_OVF); |
| 830 | |
| 831 | TEST_P_OP_PR(vcrotate, 0x8000000000000000LL, 0x00000002, |
| 832 | 0x8000000000000000LL, USR_CLEAR); |
| 833 | TEST_P_OP_PR(vcrotate, 0x7fff80007fff8000LL, 0x00000001, |
| 834 | 0x7fff80007fff7fffLL, USR_OVF); |
| 835 | |
| 836 | TEST_P_OP_PR(vcnegh, 0x8000000000000000LL, 0x00000002, |
| 837 | 0x8000000000000000LL, USR_CLEAR); |
| 838 | TEST_P_OP_PR(vcnegh, 0x7fff80007fff8000LL, 0x00000001, |
| 839 | 0x7fff80007fff7fffLL, USR_OVF); |
| 840 | |
| 841 | #if CORE_HAS_AUDIO |
| 842 | TEST_R_OP_PP(wcmpyrw, 0x8765432101234567LL, 0x00000002ffffffffLL, |
| 843 | 0x00000001, USR_CLEAR); |
| 844 | TEST_R_OP_PP(wcmpyrw, 0x800000007fffffffLL, 0x000000ff7fffffffLL, |
| 845 | 0x7fffffff, USR_OVF); |
| 846 | TEST_R_OP_PP(wcmpyrw, 0x7fffffff80000000LL, 0x7fffffff000000ffLL, |
| 847 | 0x80000000, USR_OVF); |
| 848 | #else |
| 849 | printf("Audio instructions skipped\n"); |
| 850 | #endif |
| 851 | |
| 852 | TEST_R_OP_RR(addh_l16_sat_ll, 0x0000ffff, 0x00000002, 0x00000001, |
| 853 | USR_CLEAR); |
| 854 | TEST_R_OP_RR(addh_l16_sat_ll, 0x00007fff, 0x00000005, 0x00007fff, |
| 855 | USR_OVF); |
| 856 | TEST_R_OP_RR(addh_l16_sat_ll, 0x00008000, 0x00008000, 0xffff8000, |
| 857 | USR_OVF); |
| 858 | |
| 859 | TEST_P_OP_P(vconj, 0x0000ffff00000001LL, 0x0000ffff00000001LL, USR_CLEAR); |
| 860 | TEST_P_OP_P(vconj, 0x800000000000ffffLL, 0x7fff00000000ffffLL, USR_OVF); |
| 861 | |
| 862 | TEST_P_OP_PP(vxaddsubw, 0x8765432101234567LL, 0x00000002ffffffffLL, |
| 863 | 0x8765432201234569LL, USR_CLEAR); |
| 864 | TEST_P_OP_PP(vxaddsubw, 0x7fffffff7fffffffLL, 0xffffffffffffffffLL, |
| 865 | 0x7fffffff7ffffffeLL, USR_OVF); |
| 866 | TEST_P_OP_PP(vxaddsubw, 0x800000000fffffffLL, 0x0000000a00000008LL, |
| 867 | 0x8000000010000009LL, USR_OVF); |
| 868 | |
| 869 | TEST_P_OP_P(vabshsat, 0x0001000afffff800LL, 0x0001000a00010800LL, |
| 870 | USR_CLEAR); |
| 871 | TEST_P_OP_P(vabshsat, 0x8000000b000c000aLL, 0x7fff000b000c000aLL, |
| 872 | USR_OVF); |
| 873 | |
| 874 | TEST_P_OP_PP(vnavgwr, 0x8765432101234567LL, 0x00000002ffffffffLL, |
| 875 | 0xc3b2a1900091a2b4LL, USR_CLEAR); |
| 876 | TEST_P_OP_PP(vnavgwr, 0x7fffffff8000000aLL, 0x80000000ffffffffLL, |
| 877 | 0x7fffffffc0000006LL, USR_OVF); |
| 878 | |
| 879 | TEST_R_OP_RI(round_ri_sat, 0x0000ffff, 2, 0x00004000, USR_CLEAR); |
| 880 | TEST_R_OP_RI(round_ri_sat, 0x7fffffff, 2, 0x1fffffff, USR_OVF); |
| 881 | |
| 882 | TEST_R_OP_RR(asr_r_r_sat, 0x0000ffff, 0x02, 0x00003fff, USR_CLEAR); |
| 883 | TEST_R_OP_RR(asr_r_r_sat, 0x80000000, 0x01, 0xc0000000, USR_CLEAR); |
| 884 | TEST_R_OP_RR(asr_r_r_sat, 0xffffffff, 0x01, 0xffffffff, USR_CLEAR); |
| 885 | TEST_R_OP_RR(asr_r_r_sat, 0x00ffffff, 0xf5, 0x7fffffff, USR_OVF); |
| 886 | TEST_R_OP_RR(asr_r_r_sat, 0x80000000, 0xf5, 0x80000000, USR_OVF); |
| 887 | TEST_R_OP_RR(asr_r_r_sat, 0x7fff0000, 0x42, 0x7fffffff, USR_OVF); |
| 888 | TEST_R_OP_RR(asr_r_r_sat, 0xff000000, 0x42, 0x80000000, USR_OVF); |
| 889 | TEST_R_OP_RR(asr_r_r_sat, 4096, 32, 0x00000000, USR_CLEAR); |
| 890 | TEST_R_OP_RR(asr_r_r_sat, 4096, -32, 0x7fffffff, USR_OVF); |
| 891 | TEST_R_OP_RR(asr_r_r_sat, -4096, 32, 0xffffffff, USR_CLEAR); |
| 892 | TEST_R_OP_RR(asr_r_r_sat, -4096, -32, 0x80000000, USR_OVF); |
| 893 | TEST_R_OP_RR(asr_r_r_sat, 0, -32, 0x00000000, USR_CLEAR); |
| 894 | TEST_R_OP_RR(asr_r_r_sat, 1, -32, 0x7fffffff, USR_OVF); |
| 895 | |
| 896 | TEST_R_OP_RR(asl_r_r_sat, 0x00000000, 0x40, 0x00000000, USR_CLEAR); |
| 897 | TEST_R_OP_RR(asl_r_r_sat, 0x80000000, 0xff, 0xc0000000, USR_CLEAR); |
| 898 | TEST_R_OP_RR(asl_r_r_sat, 0xffffffff, 0xff, 0xffffffff, USR_CLEAR); |
| 899 | TEST_R_OP_RR(asl_r_r_sat, 0x00ffffff, 0x0b, 0x7fffffff, USR_OVF); |
| 900 | TEST_R_OP_RR(asl_r_r_sat, 0x80000000, 0x0b, 0x80000000, USR_OVF); |
| 901 | TEST_R_OP_RR(asl_r_r_sat, 0x7fff0000, 0xbe, 0x7fffffff, USR_OVF); |
| 902 | TEST_R_OP_RR(asl_r_r_sat, 0xff000000, 0xbe, 0x80000000, USR_OVF); |
| 903 | TEST_R_OP_RR(asl_r_r_sat, 4096, 32, 0x7fffffff, USR_OVF); |
| 904 | TEST_R_OP_RR(asl_r_r_sat, 4096, -32, 0x00000000, USR_CLEAR); |
| 905 | TEST_R_OP_RR(asl_r_r_sat, -4096, 32, 0x80000000, USR_OVF); |
| 906 | TEST_R_OP_RR(asl_r_r_sat, -4096, -32, 0xffffffff, USR_CLEAR); |
| 907 | TEST_R_OP_RR(asl_r_r_sat, 0, 32, 0x00000000, USR_CLEAR); |
| 908 | TEST_R_OP_RR(asl_r_r_sat, 1, 32, 0x7fffffff, USR_OVF); |
| 909 | |
| 910 | TEST_XPp_OP_PP(ACS, 0x0004000300020001ULL, 0x0001000200030004ULL, |
| 911 | 0x0000000000000000ULL, 0x0004000300030004ULL, 0xf0, |
| 912 | USR_CLEAR); |
| 913 | TEST_XPp_OP_PP(ACS, 0x0004000300020001ULL, 0x0001000200030004ULL, |
| 914 | 0x000affff000d0000ULL, 0x000e0003000f0004ULL, 0xcc, |
| 915 | USR_CLEAR); |
| 916 | TEST_XPp_OP_PP(ACS, 0x00047fff00020001ULL, 0x00017fff00030004ULL, |
| 917 | 0x000a0fff000d0000ULL, 0x000e7fff000f0004ULL, 0xfc, |
| 918 | USR_OVF); |
| 919 | TEST_XPp_OP_PP(ACS, 0x00047fff00020001ULL, 0x00017fff00030004ULL, |
| 920 | 0x000a0fff000d0000ULL, 0x000e7fff000f0004ULL, 0xf0, |
| 921 | USR_OVF); |
| 922 | |
| 923 | /* Floating point */ |
| 924 | TEST_R_OP_RR(sfmin, SF_one, SF_small_neg, SF_small_neg, USR_CLEAR); |
| 925 | TEST_R_OP_RR(sfmin, SF_one, SF_SNaN, SF_one, USR_FPINVF); |
| 926 | TEST_R_OP_RR(sfmin, SF_SNaN, SF_one, SF_one, USR_FPINVF); |
| 927 | TEST_R_OP_RR(sfmin, SF_one, SF_QNaN, SF_one, USR_CLEAR); |
| 928 | TEST_R_OP_RR(sfmin, SF_QNaN, SF_one, SF_one, USR_CLEAR); |
| 929 | TEST_R_OP_RR(sfmin, SF_SNaN, SF_QNaN, SF_HEX_NaN, USR_FPINVF); |
| 930 | TEST_R_OP_RR(sfmin, SF_QNaN, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 931 | TEST_R_OP_RR(sfmin, SF_zero, SF_zero_neg, SF_zero_neg, USR_CLEAR); |
| 932 | TEST_R_OP_RR(sfmin, SF_zero_neg, SF_zero, SF_zero_neg, USR_CLEAR); |
| 933 | |
| 934 | TEST_R_OP_RR(sfmax, SF_one, SF_small_neg, SF_one, USR_CLEAR); |
| 935 | TEST_R_OP_RR(sfmax, SF_one, SF_SNaN, SF_one, USR_FPINVF); |
| 936 | TEST_R_OP_RR(sfmax, SF_SNaN, SF_one, SF_one, USR_FPINVF); |
| 937 | TEST_R_OP_RR(sfmax, SF_one, SF_QNaN, SF_one, USR_CLEAR); |
| 938 | TEST_R_OP_RR(sfmax, SF_QNaN, SF_one, SF_one, USR_CLEAR); |
| 939 | TEST_R_OP_RR(sfmax, SF_SNaN, SF_QNaN, SF_HEX_NaN, USR_FPINVF); |
| 940 | TEST_R_OP_RR(sfmax, SF_QNaN, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 941 | TEST_R_OP_RR(sfmax, SF_zero, SF_zero_neg, SF_zero, USR_CLEAR); |
| 942 | TEST_R_OP_RR(sfmax, SF_zero_neg, SF_zero, SF_zero, USR_CLEAR); |
| 943 | |
| 944 | TEST_R_OP_RR(sfadd, SF_one, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 945 | TEST_R_OP_RR(sfadd, SF_one, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 946 | TEST_R_OP_RR(sfadd, SF_QNaN, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 947 | TEST_R_OP_RR(sfadd, SF_SNaN, SF_QNaN, SF_HEX_NaN, USR_FPINVF); |
| 948 | |
| 949 | TEST_R_OP_RR(sfsub, SF_one, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 950 | TEST_R_OP_RR(sfsub, SF_one, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 951 | TEST_R_OP_RR(sfsub, SF_QNaN, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 952 | TEST_R_OP_RR(sfsub, SF_SNaN, SF_QNaN, SF_HEX_NaN, USR_FPINVF); |
| 953 | |
| 954 | TEST_R_OP_RR(sfmpy, SF_one, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 955 | TEST_R_OP_RR(sfmpy, SF_one, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 956 | TEST_R_OP_RR(sfmpy, SF_QNaN, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 957 | TEST_R_OP_RR(sfmpy, SF_SNaN, SF_QNaN, SF_HEX_NaN, USR_FPINVF); |
| 958 | |
| 959 | TEST_XR_OP_RR(sffma, SF_one, SF_one, SF_one, SF_two, USR_CLEAR); |
| 960 | TEST_XR_OP_RR(sffma, SF_zero, SF_one, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 961 | TEST_XR_OP_RR(sffma, SF_zero, SF_one, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 962 | TEST_XR_OP_RR(sffma, SF_zero, SF_QNaN, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 963 | TEST_XR_OP_RR(sffma, SF_zero, SF_SNaN, SF_QNaN, SF_HEX_NaN, USR_FPINVF); |
| 964 | |
| 965 | TEST_XR_OP_RR(sffms, SF_one, SF_one, SF_one, SF_zero, USR_CLEAR); |
| 966 | TEST_XR_OP_RR(sffms, SF_zero, SF_one, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 967 | TEST_XR_OP_RR(sffms, SF_zero, SF_one, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 968 | TEST_XR_OP_RR(sffms, SF_zero, SF_QNaN, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 969 | TEST_XR_OP_RR(sffms, SF_zero, SF_SNaN, SF_QNaN, SF_HEX_NaN, USR_FPINVF); |
| 970 | |
| 971 | TEST_CMP_RR(sfcmpuo, SF_one, SF_large_pos, 0x00, USR_CLEAR); |
| 972 | TEST_CMP_RR(sfcmpuo, SF_INF, SF_large_pos, 0x00, USR_CLEAR); |
| 973 | TEST_CMP_RR(sfcmpuo, SF_QNaN, SF_large_pos, 0xff, USR_CLEAR); |
| 974 | TEST_CMP_RR(sfcmpuo, SF_QNaN_neg, SF_large_pos, 0xff, USR_CLEAR); |
| 975 | TEST_CMP_RR(sfcmpuo, SF_SNaN, SF_large_pos, 0xff, USR_FPINVF); |
| 976 | TEST_CMP_RR(sfcmpuo, SF_SNaN_neg, SF_large_pos, 0xff, USR_FPINVF); |
| 977 | TEST_CMP_RR(sfcmpuo, SF_QNaN, SF_QNaN, 0xff, USR_CLEAR); |
| 978 | TEST_CMP_RR(sfcmpuo, SF_QNaN, SF_SNaN, 0xff, USR_FPINVF); |
| 979 | |
| 980 | TEST_CMP_RR(sfcmpeq, SF_one, SF_QNaN, 0x00, USR_CLEAR); |
| 981 | TEST_CMP_RR(sfcmpeq, SF_one, SF_SNaN, 0x00, USR_FPINVF); |
| 982 | TEST_CMP_RR(sfcmpgt, SF_one, SF_QNaN, 0x00, USR_CLEAR); |
| 983 | TEST_CMP_RR(sfcmpgt, SF_one, SF_SNaN, 0x00, USR_FPINVF); |
| 984 | TEST_CMP_RR(sfcmpge, SF_one, SF_QNaN, 0x00, USR_CLEAR); |
| 985 | TEST_CMP_RR(sfcmpge, SF_one, SF_SNaN, 0x00, USR_FPINVF); |
| 986 | |
| 987 | TEST_P_OP_PP(dfadd, DF_any, DF_QNaN, DF_HEX_NaN, USR_CLEAR); |
| 988 | TEST_P_OP_PP(dfadd, DF_any, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 989 | TEST_P_OP_PP(dfadd, DF_QNaN, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 990 | TEST_P_OP_PP(dfadd, DF_SNaN, DF_QNaN, DF_HEX_NaN, USR_FPINVF); |
| 991 | |
| 992 | TEST_P_OP_PP(dfsub, DF_any, DF_QNaN, DF_HEX_NaN, USR_CLEAR); |
| 993 | TEST_P_OP_PP(dfsub, DF_any, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 994 | TEST_P_OP_PP(dfsub, DF_QNaN, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 995 | TEST_P_OP_PP(dfsub, DF_SNaN, DF_QNaN, DF_HEX_NaN, USR_FPINVF); |
| 996 | |
| 997 | #if CORE_IS_V67 |
| 998 | TEST_P_OP_PP(dfmin, DF_any, DF_small_neg, DF_small_neg, USR_CLEAR); |
| 999 | TEST_P_OP_PP(dfmin, DF_any, DF_SNaN, DF_any, USR_FPINVF); |
| 1000 | TEST_P_OP_PP(dfmin, DF_SNaN, DF_any, DF_any, USR_FPINVF); |
| 1001 | TEST_P_OP_PP(dfmin, DF_any, DF_QNaN, DF_any, USR_CLEAR); |
| 1002 | TEST_P_OP_PP(dfmin, DF_QNaN, DF_any, DF_any, USR_CLEAR); |
| 1003 | TEST_P_OP_PP(dfmin, DF_SNaN, DF_QNaN, DF_HEX_NaN, USR_FPINVF); |
| 1004 | TEST_P_OP_PP(dfmin, DF_QNaN, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 1005 | TEST_P_OP_PP(dfmin, DF_zero, DF_zero_neg, DF_zero_neg, USR_CLEAR); |
| 1006 | TEST_P_OP_PP(dfmin, DF_zero_neg, DF_zero, DF_zero_neg, USR_CLEAR); |
| 1007 | |
| 1008 | TEST_P_OP_PP(dfmax, DF_any, DF_small_neg, DF_any, USR_CLEAR); |
| 1009 | TEST_P_OP_PP(dfmax, DF_any, DF_SNaN, DF_any, USR_FPINVF); |
| 1010 | TEST_P_OP_PP(dfmax, DF_SNaN, DF_any, DF_any, USR_FPINVF); |
| 1011 | TEST_P_OP_PP(dfmax, DF_any, DF_QNaN, DF_any, USR_CLEAR); |
| 1012 | TEST_P_OP_PP(dfmax, DF_QNaN, DF_any, DF_any, USR_CLEAR); |
| 1013 | TEST_P_OP_PP(dfmax, DF_SNaN, DF_QNaN, DF_HEX_NaN, USR_FPINVF); |
| 1014 | TEST_P_OP_PP(dfmax, DF_QNaN, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 1015 | TEST_P_OP_PP(dfmax, DF_zero, DF_zero_neg, DF_zero, USR_CLEAR); |
| 1016 | TEST_P_OP_PP(dfmax, DF_zero_neg, DF_zero, DF_zero, USR_CLEAR); |
| 1017 | |
| 1018 | TEST_XP_OP_PP(dfmpyhh, DF_one, DF_one, DF_one, DF_one_hh, USR_CLEAR); |
| 1019 | TEST_XP_OP_PP(dfmpyhh, DF_zero, DF_any, DF_QNaN, DF_HEX_NaN, USR_CLEAR); |
| 1020 | TEST_XP_OP_PP(dfmpyhh, DF_zero, DF_any, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 1021 | TEST_XP_OP_PP(dfmpyhh, DF_zero, DF_QNaN, DF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 1022 | TEST_XP_OP_PP(dfmpyhh, DF_zero, DF_SNaN, DF_QNaN, DF_HEX_NaN, USR_FPINVF); |
| 1023 | #else |
| 1024 | printf("v67 instructions skipped\n"); |
| 1025 | #endif |
| 1026 | |
| 1027 | TEST_CMP_PP(dfcmpuo, DF_small_neg, DF_any, 0x00, USR_CLEAR); |
| 1028 | TEST_CMP_PP(dfcmpuo, DF_large_pos, DF_any, 0x00, USR_CLEAR); |
| 1029 | TEST_CMP_PP(dfcmpuo, DF_QNaN, DF_any, 0xff, USR_CLEAR); |
| 1030 | TEST_CMP_PP(dfcmpuo, DF_QNaN_neg, DF_any, 0xff, USR_CLEAR); |
| 1031 | TEST_CMP_PP(dfcmpuo, DF_SNaN, DF_any, 0xff, USR_FPINVF); |
| 1032 | TEST_CMP_PP(dfcmpuo, DF_SNaN_neg, DF_any, 0xff, USR_FPINVF); |
| 1033 | TEST_CMP_PP(dfcmpuo, DF_QNaN, DF_QNaN, 0xff, USR_CLEAR); |
| 1034 | TEST_CMP_PP(dfcmpuo, DF_QNaN, DF_SNaN, 0xff, USR_FPINVF); |
| 1035 | |
| 1036 | TEST_CMP_PP(dfcmpeq, DF_any, DF_QNaN, 0x00, USR_CLEAR); |
| 1037 | TEST_CMP_PP(dfcmpeq, DF_any, DF_SNaN, 0x00, USR_FPINVF); |
| 1038 | TEST_CMP_PP(dfcmpgt, DF_any, DF_QNaN, 0x00, USR_CLEAR); |
| 1039 | TEST_CMP_PP(dfcmpgt, DF_any, DF_SNaN, 0x00, USR_FPINVF); |
| 1040 | TEST_CMP_PP(dfcmpge, DF_any, DF_QNaN, 0x00, USR_CLEAR); |
| 1041 | TEST_CMP_PP(dfcmpge, DF_any, DF_SNaN, 0x00, USR_FPINVF); |
| 1042 | |
| 1043 | TEST_P_OP_R(conv_sf2df, SF_QNaN, DF_HEX_NaN, USR_CLEAR); |
| 1044 | TEST_P_OP_R(conv_sf2df, SF_SNaN, DF_HEX_NaN, USR_FPINVF); |
| 1045 | TEST_R_OP_R(conv_sf2uw, SF_QNaN, 0xffffffff, USR_FPINVF); |
| 1046 | TEST_R_OP_R(conv_sf2uw, SF_SNaN, 0xffffffff, USR_FPINVF); |
| 1047 | TEST_R_OP_R(conv_sf2w, SF_QNaN, 0xffffffff, USR_FPINVF); |
| 1048 | TEST_R_OP_R(conv_sf2w, SF_SNaN, 0xffffffff, USR_FPINVF); |
| 1049 | TEST_P_OP_R(conv_sf2ud, SF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1050 | TEST_P_OP_R(conv_sf2ud, SF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1051 | TEST_P_OP_R(conv_sf2d, SF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1052 | TEST_P_OP_R(conv_sf2d, SF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1053 | TEST_R_OP_R(conv_sf2uw_chop, SF_QNaN, 0xffffffff, USR_FPINVF); |
| 1054 | TEST_R_OP_R(conv_sf2uw_chop, SF_SNaN, 0xffffffff, USR_FPINVF); |
| 1055 | TEST_R_OP_R(conv_sf2w_chop, SF_QNaN, 0xffffffff, USR_FPINVF); |
| 1056 | TEST_R_OP_R(conv_sf2w_chop, SF_SNaN, 0xffffffff, USR_FPINVF); |
| 1057 | TEST_P_OP_R(conv_sf2ud_chop, SF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1058 | TEST_P_OP_R(conv_sf2ud_chop, SF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1059 | TEST_P_OP_R(conv_sf2d_chop, SF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1060 | TEST_P_OP_R(conv_sf2d_chop, SF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1061 | |
| 1062 | TEST_R_OP_R(conv_sf2uw, SF_zero_neg, 0, USR_CLEAR); |
| 1063 | TEST_R_OP_R(conv_sf2uw_chop, SF_zero_neg, 0, USR_CLEAR); |
| 1064 | TEST_P_OP_R(conv_sf2ud, SF_zero_neg, 0, USR_CLEAR); |
| 1065 | TEST_P_OP_R(conv_sf2ud_chop, SF_zero_neg, 0, USR_CLEAR); |
| 1066 | |
| 1067 | TEST_R_OP_P(conv_df2sf, DF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 1068 | TEST_R_OP_P(conv_df2sf, DF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 1069 | TEST_R_OP_P(conv_df2uw, DF_QNaN, 0xffffffff, USR_FPINVF); |
| 1070 | TEST_R_OP_P(conv_df2uw, DF_SNaN, 0xffffffff, USR_FPINVF); |
| 1071 | TEST_R_OP_P(conv_df2w, DF_QNaN, 0xffffffff, USR_FPINVF); |
| 1072 | TEST_R_OP_P(conv_df2w, DF_SNaN, 0xffffffff, USR_FPINVF); |
| 1073 | TEST_P_OP_P(conv_df2ud, DF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1074 | TEST_P_OP_P(conv_df2ud, DF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1075 | TEST_P_OP_P(conv_df2d, DF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1076 | TEST_P_OP_P(conv_df2d, DF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1077 | TEST_R_OP_P(conv_df2uw_chop, DF_QNaN, 0xffffffff, USR_FPINVF); |
| 1078 | TEST_R_OP_P(conv_df2uw_chop, DF_SNaN, 0xffffffff, USR_FPINVF); |
| 1079 | |
| 1080 | TEST_R_OP_P(conv_df2uw, DF_zero_neg, 0, USR_CLEAR); |
| 1081 | TEST_R_OP_P(conv_df2uw_chop, DF_zero_neg, 0, USR_CLEAR); |
| 1082 | TEST_P_OP_P(conv_df2ud, DF_zero_neg, 0, USR_CLEAR); |
| 1083 | TEST_P_OP_P(conv_df2ud_chop, DF_zero_neg, 0, USR_CLEAR); |
| 1084 | |
| 1085 | /* Test for typo in HELPER(conv_df2uw_chop) */ |
| 1086 | TEST_R_OP_P(conv_df2uw_chop, 0xffffff7f00000001ULL, 0xffffffff, USR_FPINVF); |
| 1087 | |
| 1088 | TEST_R_OP_P(conv_df2w_chop, DF_QNaN, 0xffffffff, USR_FPINVF); |
| 1089 | TEST_R_OP_P(conv_df2w_chop, DF_SNaN, 0xffffffff, USR_FPINVF); |
| 1090 | TEST_P_OP_P(conv_df2ud_chop, DF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1091 | TEST_P_OP_P(conv_df2ud_chop, DF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1092 | TEST_P_OP_P(conv_df2d_chop, DF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1093 | TEST_P_OP_P(conv_df2d_chop, DF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); |
| 1094 | |
| 1095 | TEST_R_OP_R(conv_uw2sf, 0x00000001, SF_one, USR_CLEAR); |
| 1096 | TEST_R_OP_R(conv_uw2sf, 0x010020a5, 0x4b801052, USR_FPINPF); |
| 1097 | TEST_R_OP_R(conv_w2sf, 0x00000001, SF_one, USR_CLEAR); |
| 1098 | TEST_R_OP_R(conv_w2sf, 0x010020a5, 0x4b801052, USR_FPINPF); |
| 1099 | TEST_R_OP_P(conv_ud2sf, 0x0000000000000001ULL, SF_one, USR_CLEAR); |
| 1100 | TEST_R_OP_P(conv_ud2sf, 0x00000000010020a5ULL, 0x4b801052, USR_FPINPF); |
| 1101 | TEST_R_OP_P(conv_d2sf, 0x0000000000000001ULL, SF_one, USR_CLEAR); |
| 1102 | TEST_R_OP_P(conv_d2sf, 0x00000000010020a5ULL, 0x4b801052, USR_FPINPF); |
| 1103 | |
| 1104 | TEST_XR_OP_RRp(sffma_sc, SF_one, SF_one, SF_one, 1, SF_four, |
| 1105 | USR_CLEAR); |
| 1106 | TEST_XR_OP_RRp(sffma_sc, SF_QNaN, SF_one, SF_one, 1, SF_HEX_NaN, |
| 1107 | USR_CLEAR); |
| 1108 | TEST_XR_OP_RRp(sffma_sc, SF_one, SF_QNaN, SF_one, 1, SF_HEX_NaN, |
| 1109 | USR_CLEAR); |
| 1110 | TEST_XR_OP_RRp(sffma_sc, SF_one, SF_one, SF_QNaN, 1, SF_HEX_NaN, |
| 1111 | USR_CLEAR); |
| 1112 | TEST_XR_OP_RRp(sffma_sc, SF_SNaN, SF_one, SF_one, 1, SF_HEX_NaN, |
| 1113 | USR_FPINVF); |
| 1114 | TEST_XR_OP_RRp(sffma_sc, SF_one, SF_SNaN, SF_one, 1, SF_HEX_NaN, |
| 1115 | USR_FPINVF); |
| 1116 | TEST_XR_OP_RRp(sffma_sc, SF_one, SF_one, SF_SNaN, 1, SF_HEX_NaN, |
| 1117 | USR_FPINVF); |
| 1118 | |
| 1119 | TEST_Rp_OP_RR(sfrecipa, SF_one, SF_one, SF_one_recip, 0x00, |
| 1120 | USR_CLEAR); |
| 1121 | TEST_Rp_OP_RR(sfrecipa, SF_QNaN, SF_one, SF_HEX_NaN, 0x00, |
| 1122 | USR_CLEAR); |
| 1123 | TEST_Rp_OP_RR(sfrecipa, SF_one, SF_QNaN, SF_HEX_NaN, 0x00, |
| 1124 | USR_CLEAR); |
| 1125 | TEST_Rp_OP_RR(sfrecipa, SF_one, SF_SNaN, SF_HEX_NaN, 0x00, |
| 1126 | USR_FPINVF); |
| 1127 | TEST_Rp_OP_RR(sfrecipa, SF_SNaN, SF_one, SF_HEX_NaN, 0x00, |
| 1128 | USR_FPINVF); |
| 1129 | |
| 1130 | TEST_R_OP_RR(sffixupn, SF_one, SF_one, SF_one, USR_CLEAR); |
| 1131 | TEST_R_OP_RR(sffixupn, SF_QNaN, SF_one, SF_HEX_NaN, USR_CLEAR); |
| 1132 | TEST_R_OP_RR(sffixupn, SF_one, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 1133 | TEST_R_OP_RR(sffixupn, SF_SNaN, SF_one, SF_HEX_NaN, USR_FPINVF); |
| 1134 | TEST_R_OP_RR(sffixupn, SF_one, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 1135 | |
| 1136 | TEST_R_OP_RR(sffixupd, SF_one, SF_one, SF_one, USR_CLEAR); |
| 1137 | TEST_R_OP_RR(sffixupd, SF_QNaN, SF_one, SF_HEX_NaN, USR_CLEAR); |
| 1138 | TEST_R_OP_RR(sffixupd, SF_one, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 1139 | TEST_R_OP_RR(sffixupd, SF_SNaN, SF_one, SF_HEX_NaN, USR_FPINVF); |
| 1140 | TEST_R_OP_RR(sffixupd, SF_one, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 1141 | |
| 1142 | TEST_R_OP_R(sffixupr, SF_one, SF_one, USR_CLEAR); |
| 1143 | TEST_R_OP_R(sffixupr, SF_QNaN, SF_HEX_NaN, USR_CLEAR); |
| 1144 | TEST_R_OP_R(sffixupr, SF_SNaN, SF_HEX_NaN, USR_FPINVF); |
| 1145 | |
| 1146 | TEST_Rp_OP_R(sfinvsqrta, SF_one, SF_one_invsqrta, 0x00, USR_CLEAR); |
| 1147 | TEST_Rp_OP_R(sfinvsqrta, SF_zero, SF_one, 0x00, USR_CLEAR); |
| 1148 | TEST_Rp_OP_R(sfinvsqrta, SF_QNaN, SF_HEX_NaN, 0x00, USR_CLEAR); |
| 1149 | TEST_Rp_OP_R(sfinvsqrta, SF_small_neg, SF_HEX_NaN, 0x00, USR_FPINVF); |
| 1150 | TEST_Rp_OP_R(sfinvsqrta, SF_SNaN, SF_HEX_NaN, 0x00, USR_FPINVF); |
| 1151 | |
| 1152 | test_usr_packets(); |
| 1153 | |
| 1154 | puts(err ? "FAIL" : "PASS"); |
| 1155 | return err; |
| 1156 | } |