Changeset 103050 in vbox
- Timestamp:
- Jan 25, 2024 12:42:30 AM (10 months ago)
- Location:
- trunk/src/VBox/VMM/testcase
- Files:
-
- 240 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/tstIEMAImpl.cpp
r103049 r103050 71 71 g_aTests_ ## a_Name, &g_cTests_ ## a_Name, \ 72 72 a_uExtra, IEMTARGETCPU_EFL_BEHAVIOR_NATIVE /* means same for all here */, \ 73 RT_ELEMENTS(g_aFixedTests_ ## a_Name), false, false, g_aFixedTests_ ## a_Name }73 false, false, RT_ELEMENTS(g_aFixedTests_ ## a_Name), g_aFixedTests_ ## a_Name } 74 74 #else 75 75 # define ENTRY_FIX_EX(a_Name, a_uExtra) ENTRY_EX(a_Name, a_uExtra) … … 1001 1001 1002 1002 1003 static bool GenerateBinaryOpen(PIEMBINARYOUTPUT pBinOut, const char *pszFilenameFmt, const char *pszName, 1004 const char *pszCpuType = NULL) 1003 static bool GenerateBinaryOpen(PIEMBINARYOUTPUT pBinOut, const char *pszFilenameFmt, const char *pszName) 1005 1004 { 1006 1005 pBinOut->hVfsFile = NIL_RTVFSFILE; … … 1009 1008 { 1010 1009 pBinOut->fNull = false; 1011 if (RTStrPrintf2(pBinOut->szFilename, sizeof(pBinOut->szFilename), pszFilenameFmt, pszName , pszCpuType) > 0)1010 if (RTStrPrintf2(pBinOut->szFilename, sizeof(pBinOut->szFilename), pszFilenameFmt, pszName) > 0) 1012 1011 { 1013 1012 RTMsgInfo("GenerateBinaryOpen: %s...\n", pBinOut->szFilename); … … 1043 1042 else 1044 1043 { 1045 RTMsgError("filename too long: %s + %s + %s", pszFilenameFmt, pszName, pszCpuType);1044 RTMsgError("filename too long: %s + %s", pszFilenameFmt, pszName); 1046 1045 pBinOut->rcWrite = VERR_BUFFER_OVERFLOW; 1047 1046 } … … 1220 1219 return rc; 1221 1220 } 1221 1222 #define DECOMPRESS_TESTS(a_Entry) \ 1223 RT_SUCCESS(DecompressBinaryTest(&(a_Entry).fCompressed, (void **)&(a_Entry).paTests, &(a_Entry).pcTests, \ 1224 sizeof((a_Entry).paTests[0]), (a_Entry).fBinary)) 1222 1225 1223 1226 … … 1563 1566 #ifdef TSTIEMAIMPL_WITH_GENERATOR 1564 1567 # define GEN_BINARY_TESTS(a_cBits, a_Fmt, a_TestType) \ 1565 static void BinU ## a_cBits ## Generate(PRTSTREAM pOut, PRTSTREAM pOutCpu, uint32_t cTests) \1568 static RTEXITCODE BinU ## a_cBits ## Generate(uint32_t cTests, const char * const * papszNameFmts) \ 1566 1569 { \ 1567 1570 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aBinU ## a_cBits); iFn++) \ … … 1569 1572 PFNIEMAIMPLBINU ## a_cBits const pfn = g_aBinU ## a_cBits[iFn].pfnNative \ 1570 1573 ? g_aBinU ## a_cBits[iFn].pfnNative : g_aBinU ## a_cBits[iFn].pfn; \ 1571 PRTSTREAM pOutFn = pOut; \ 1572 if (g_aBinU ## a_cBits[iFn].idxCpuEflFlavour != IEMTARGETCPU_EFL_BEHAVIOR_NATIVE) \ 1573 { \ 1574 if (g_aBinU ## a_cBits[iFn].idxCpuEflFlavour != g_idxCpuEflFlavour) \ 1575 continue; \ 1576 pOutFn = pOutCpu; \ 1577 } \ 1578 \ 1579 GenerateArrayStart(pOutFn, g_aBinU ## a_cBits[iFn].pszName, #a_TestType); \ 1574 IEMBINARYOUTPUT BinOut; \ 1575 if ( g_aBinU ## a_cBits[iFn].idxCpuEflFlavour != IEMTARGETCPU_EFL_BEHAVIOR_NATIVE \ 1576 && g_aBinU ## a_cBits[iFn].idxCpuEflFlavour != g_idxCpuEflFlavour) \ 1577 continue; \ 1578 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[g_aBinU ## a_cBits[iFn].idxCpuEflFlavour], \ 1579 g_aBinU ## a_cBits[iFn].pszName), RTEXITCODE_FAILURE); \ 1580 1580 for (uint32_t iTest = 0; iTest < cTests; iTest++ ) \ 1581 1581 { \ … … 1590 1590 Test.uMisc = 0; \ 1591 1591 pfn(&Test.uDstOut, Test.uSrcIn, &Test.fEflOut); \ 1592 RTStrmPrintf(pOutFn, " { %#08x, %#08x, " a_Fmt ", " a_Fmt ", " a_Fmt ", %#x }, /* #%u */\n", \ 1593 Test.fEflIn, Test.fEflOut, Test.uDstIn, Test.uDstOut, Test.uSrcIn, Test.uMisc, iTest); \ 1592 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); \ 1594 1593 } \ 1595 1594 for (uint32_t iTest = 0; iTest < g_aBinU ## a_cBits[iFn].cFixedTests; iTest++ ) \ … … 1604 1603 Test.uMisc = g_aBinU ## a_cBits[iFn].paFixedTests[iTest].uMisc; \ 1605 1604 pfn(&Test.uDstOut, Test.uSrcIn, &Test.fEflOut); \ 1606 RTStrmPrintf(pOutFn, " { %#08x, %#08x, " a_Fmt ", " a_Fmt ", " a_Fmt ", %#x }, /* fixed #%u */\n", \ 1607 Test.fEflIn, Test.fEflOut, Test.uDstIn, Test.uDstOut, Test.uSrcIn, Test.uMisc, iTest); \ 1605 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); \ 1608 1606 } \ 1609 GenerateArrayEnd(pOutFn, g_aBinU ## a_cBits[iFn].pszName); \1607 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 1610 1608 } \ 1611 } 1609 return RTEXITCODE_SUCCESS; \ 1610 } \ 1611 /* Temp for conversion. */ \ 1612 static RTEXITCODE BinU ## a_cBits ## DumpAll(const char * const * papszNameFmts) \ 1613 { \ 1614 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aBinU ## a_cBits); iFn++) \ 1615 { \ 1616 AssertReturn(DECOMPRESS_TESTS(g_aBinU ## a_cBits[iFn]), RTEXITCODE_FAILURE); \ 1617 IEMBINARYOUTPUT BinOut; \ 1618 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[g_aBinU ## a_cBits[iFn].idxCpuEflFlavour], \ 1619 g_aBinU ## a_cBits[iFn].pszName), RTEXITCODE_FAILURE); \ 1620 size_t cbTests = g_aBinU ## a_cBits[iFn].pcTests[0]; \ 1621 if (!g_aBinU ## a_cBits[iFn].fBinary) \ 1622 cbTests *= sizeof(g_aBinU ## a_cBits[iFn].paTests[0]); \ 1623 GenerateBinaryWrite(&BinOut, g_aBinU ## a_cBits[iFn].paTests, cbTests); \ 1624 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 1625 } \ 1626 return RTEXITCODE_SUCCESS; \ 1627 } 1628 1612 1629 #else 1613 1630 # define GEN_BINARY_TESTS(a_cBits, a_Fmt, a_TestType) … … 2208 2225 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2209 2226 # define GEN_SHIFT_DBL(a_cBits, a_Fmt, a_TestType, a_aSubTests) \ 2210 static void ShiftDblU ## a_cBits ## Generate(PRTSTREAM pOut, uint32_t cTests) \2227 static RTEXITCODE ShiftDblU ## a_cBits ## Generate(uint32_t cTests, const char * const * papszNameFmts) \ 2211 2228 { \ 2212 2229 for (size_t iFn = 0; iFn < RT_ELEMENTS(a_aSubTests); iFn++) \ … … 2215 2232 && a_aSubTests[iFn].idxCpuEflFlavour != g_idxCpuEflFlavour) \ 2216 2233 continue; \ 2217 GenerateArrayStart(pOut, a_aSubTests[iFn].pszName, #a_TestType); \ 2234 IEMBINARYOUTPUT BinOut; \ 2235 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[a_aSubTests[iFn].idxCpuEflFlavour], a_aSubTests[iFn].pszName), \ 2236 RTEXITCODE_FAILURE); \ 2218 2237 for (uint32_t iTest = 0; iTest < cTests; iTest++ ) \ 2219 2238 { \ … … 2226 2245 Test.uMisc = RandU8() & (a_cBits * 4 - 1); /* need to go way beyond the a_cBits limit */ \ 2227 2246 a_aSubTests[iFn].pfnNative(&Test.uDstOut, Test.uSrcIn, Test.uMisc, &Test.fEflOut); \ 2228 RTStrmPrintf(pOut, " { %#08x, %#08x, " a_Fmt ", " a_Fmt ", " a_Fmt ", %2u }, /* #%u */\n", \ 2229 Test.fEflIn, Test.fEflOut, Test.uDstIn, Test.uDstOut, Test.uSrcIn, Test.uMisc, iTest); \ 2247 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); \ 2230 2248 } \ 2231 GenerateArrayEnd(pOut, a_aSubTests[iFn].pszName); \2249 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2232 2250 } \ 2233 } 2251 return RTEXITCODE_SUCCESS; \ 2252 } \ 2253 static RTEXITCODE ShiftDblU ## a_cBits ## DumpAll(const char * const * papszNameFmts) \ 2254 { \ 2255 for (size_t iFn = 0; iFn < RT_ELEMENTS(a_aSubTests); iFn++) \ 2256 { \ 2257 AssertReturn(DECOMPRESS_TESTS(a_aSubTests[iFn]), RTEXITCODE_FAILURE); \ 2258 IEMBINARYOUTPUT BinOut; \ 2259 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[a_aSubTests[iFn].idxCpuEflFlavour], a_aSubTests[iFn].pszName), \ 2260 RTEXITCODE_FAILURE); \ 2261 size_t cbTests = a_aSubTests[iFn].pcTests[0]; \ 2262 if (!a_aSubTests[iFn].fBinary) \ 2263 cbTests *= sizeof(a_aSubTests[iFn].paTests[0]); \ 2264 GenerateBinaryWrite(&BinOut, a_aSubTests[iFn].paTests, cbTests); \ 2265 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2266 } \ 2267 return RTEXITCODE_SUCCESS; \ 2268 } 2269 2234 2270 #else 2235 2271 # define GEN_SHIFT_DBL(a_cBits, a_Fmt, a_TestType, a_aSubTests) … … 2292 2328 2293 2329 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2294 static void ShiftDblGenerate(PRTSTREAM pOut, uint32_t cTests) 2295 { 2296 ShiftDblU16Generate(pOut, cTests); 2297 ShiftDblU32Generate(pOut, cTests); 2298 ShiftDblU64Generate(pOut, cTests); 2330 static RTEXITCODE ShiftDblGenerate(uint32_t cTests, const char * const * papszNameFmts) 2331 { 2332 RTEXITCODE rcExit = ShiftDblU16Generate(cTests, papszNameFmts); 2333 if (rcExit == RTEXITCODE_SUCCESS) 2334 rcExit = ShiftDblU32Generate(cTests, papszNameFmts); 2335 if (rcExit == RTEXITCODE_SUCCESS) 2336 rcExit = ShiftDblU64Generate(cTests, papszNameFmts); 2337 return rcExit; 2338 } 2339 2340 static RTEXITCODE ShiftDblDumpAll(const char * const * papszNameFmts) 2341 { 2342 RTEXITCODE rcExit = ShiftDblU16DumpAll(papszNameFmts); 2343 if (rcExit == RTEXITCODE_SUCCESS) 2344 rcExit = ShiftDblU32DumpAll(papszNameFmts); 2345 if (rcExit == RTEXITCODE_SUCCESS) 2346 rcExit = ShiftDblU64DumpAll(papszNameFmts); 2347 return rcExit; 2299 2348 } 2300 2349 #endif … … 2315 2364 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2316 2365 # define GEN_UNARY(a_cBits, a_Type, a_Fmt, a_TestType, a_SubTestType) \ 2317 static void UnaryU ## a_cBits ## Generate(PRTSTREAM pOut, uint32_t cTests) \2366 static RTEXITCODE UnaryU ## a_cBits ## Generate(uint32_t cTests, const char * const * papszNameFmts) \ 2318 2367 { \ 2319 2368 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aUnaryU ## a_cBits); iFn++) \ 2320 2369 { \ 2321 GenerateArrayStart(pOut, g_aUnaryU ## a_cBits[iFn].pszName, #a_TestType); \ 2370 IEMBINARYOUTPUT BinOut; \ 2371 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[0], g_aUnaryU ## a_cBits[iFn].pszName), RTEXITCODE_FAILURE); \ 2322 2372 for (uint32_t iTest = 0; iTest < cTests; iTest++ ) \ 2323 2373 { \ … … 2330 2380 Test.uMisc = 0; \ 2331 2381 g_aUnaryU ## a_cBits[iFn].pfn(&Test.uDstOut, &Test.fEflOut); \ 2332 RTStrmPrintf(pOut, " { %#08x, %#08x, " a_Fmt ", " a_Fmt ", 0, 0 }, /* #%u */\n", \ 2333 Test.fEflIn, Test.fEflOut, Test.uDstIn, Test.uDstOut, iTest); \ 2382 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); \ 2334 2383 } \ 2335 GenerateArrayEnd(pOut, g_aUnaryU ## a_cBits[iFn].pszName); \2384 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2336 2385 } \ 2386 return RTEXITCODE_SUCCESS; \ 2387 } \ 2388 static RTEXITCODE UnaryU ## a_cBits ## DumpAll(const char * const * papszNameFmts) \ 2389 { \ 2390 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aUnaryU ## a_cBits); iFn++) \ 2391 { \ 2392 AssertReturn(DECOMPRESS_TESTS(g_aUnaryU ## a_cBits[iFn]), RTEXITCODE_FAILURE); \ 2393 IEMBINARYOUTPUT BinOut; \ 2394 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[0], g_aUnaryU ## a_cBits[iFn].pszName), RTEXITCODE_FAILURE); \ 2395 uint32_t cbTests = g_aUnaryU ## a_cBits[iFn].pcTests[0]; \ 2396 if (!g_aUnaryU ## a_cBits[iFn].fBinary) \ 2397 cbTests *= sizeof(g_aUnaryU ## a_cBits[iFn].paTests[0]); \ 2398 GenerateBinaryWrite(&BinOut, g_aUnaryU ## a_cBits[iFn].paTests, cbTests); \ 2399 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2400 } \ 2401 return RTEXITCODE_SUCCESS; \ 2337 2402 } 2338 2403 #else … … 2393 2458 2394 2459 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2395 static void UnaryGenerate(PRTSTREAM pOut, uint32_t cTests) 2396 { 2397 UnaryU8Generate(pOut, cTests); 2398 UnaryU16Generate(pOut, cTests); 2399 UnaryU32Generate(pOut, cTests); 2400 UnaryU64Generate(pOut, cTests); 2460 static RTEXITCODE UnaryGenerate(uint32_t cTests, const char * const * papszNameFmts) 2461 { 2462 RTEXITCODE rcExit = UnaryU8Generate(cTests, papszNameFmts); 2463 if (rcExit == RTEXITCODE_SUCCESS) 2464 rcExit = UnaryU16Generate(cTests, papszNameFmts); 2465 if (rcExit == RTEXITCODE_SUCCESS) 2466 rcExit = UnaryU32Generate(cTests, papszNameFmts); 2467 if (rcExit == RTEXITCODE_SUCCESS) 2468 rcExit = UnaryU64Generate(cTests, papszNameFmts); 2469 return rcExit; 2470 } 2471 2472 static RTEXITCODE UnaryDumpAll(const char * const * papszNameFmts) 2473 { 2474 RTEXITCODE rcExit = UnaryU8DumpAll(papszNameFmts); 2475 if (rcExit == RTEXITCODE_SUCCESS) 2476 rcExit = UnaryU16DumpAll(papszNameFmts); 2477 if (rcExit == RTEXITCODE_SUCCESS) 2478 rcExit = UnaryU32DumpAll(papszNameFmts); 2479 if (rcExit == RTEXITCODE_SUCCESS) 2480 rcExit = UnaryU64DumpAll(papszNameFmts); 2481 return rcExit; 2401 2482 } 2402 2483 #endif … … 2418 2499 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2419 2500 # define GEN_SHIFT(a_cBits, a_Fmt, a_TestType, a_aSubTests) \ 2420 static void ShiftU ## a_cBits ## Generate(PRTSTREAM pOut, uint32_t cTests) \2501 static RTEXITCODE ShiftU ## a_cBits ## Generate(uint32_t cTests, const char * const * papszNameFmts) \ 2421 2502 { \ 2422 2503 for (size_t iFn = 0; iFn < RT_ELEMENTS(a_aSubTests); iFn++) \ … … 2425 2506 && a_aSubTests[iFn].idxCpuEflFlavour != g_idxCpuEflFlavour) \ 2426 2507 continue; \ 2427 GenerateArrayStart(pOut, a_aSubTests[iFn].pszName, #a_TestType); \ 2508 IEMBINARYOUTPUT BinOut; \ 2509 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[a_aSubTests[iFn].idxCpuEflFlavour], a_aSubTests[iFn].pszName), \ 2510 RTEXITCODE_FAILURE); \ 2428 2511 for (uint32_t iTest = 0; iTest < cTests; iTest++ ) \ 2429 2512 { \ … … 2436 2519 Test.uMisc = RandU8() & (a_cBits * 4 - 1); /* need to go way beyond the a_cBits limit */ \ 2437 2520 a_aSubTests[iFn].pfnNative(&Test.uDstOut, Test.uMisc, &Test.fEflOut); \ 2438 RTStrmPrintf(pOut, " { %#08x, %#08x, " a_Fmt ", " a_Fmt ", 0, %-2u }, /* #%u */\n", \ 2439 Test.fEflIn, Test.fEflOut, Test.uDstIn, Test.uDstOut, Test.uMisc, iTest); \ 2521 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); \ 2440 2522 \ 2441 2523 Test.fEflIn = (~Test.fEflIn & X86_EFL_LIVE_MASK) | X86_EFL_RA1_MASK; \ … … 2443 2525 Test.uDstOut = Test.uDstIn; \ 2444 2526 a_aSubTests[iFn].pfnNative(&Test.uDstOut, Test.uMisc, &Test.fEflOut); \ 2445 RTStrmPrintf(pOut, " { %#08x, %#08x, " a_Fmt ", " a_Fmt ", 0, %-2u }, /* #%u b */\n", \ 2446 Test.fEflIn, Test.fEflOut, Test.uDstIn, Test.uDstOut, Test.uMisc, iTest); \ 2527 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); \ 2447 2528 } \ 2448 GenerateArrayEnd(pOut, a_aSubTests[iFn].pszName); \2529 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2449 2530 } \ 2531 return RTEXITCODE_SUCCESS; \ 2532 } \ 2533 static RTEXITCODE ShiftU ## a_cBits ## DumpAll(const char * const * papszNameFmts) \ 2534 { \ 2535 for (size_t iFn = 0; iFn < RT_ELEMENTS(a_aSubTests); iFn++) \ 2536 { \ 2537 AssertReturn(DECOMPRESS_TESTS(a_aSubTests[iFn]), RTEXITCODE_FAILURE); \ 2538 IEMBINARYOUTPUT BinOut; \ 2539 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[a_aSubTests[iFn].idxCpuEflFlavour], a_aSubTests[iFn].pszName), \ 2540 RTEXITCODE_FAILURE); \ 2541 uint32_t cbTests = a_aSubTests[iFn].pcTests[0]; \ 2542 if (!a_aSubTests[iFn].fBinary) \ 2543 cbTests *= sizeof(a_aSubTests[iFn].paTests[0]); \ 2544 GenerateBinaryWrite(&BinOut, a_aSubTests[iFn].paTests, cbTests); \ 2545 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2546 } \ 2547 return RTEXITCODE_SUCCESS; \ 2450 2548 } 2451 2549 #else … … 2519 2617 2520 2618 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2521 static void ShiftGenerate(PRTSTREAM pOut, uint32_t cTests) 2522 { 2523 ShiftU8Generate(pOut, cTests); 2524 ShiftU16Generate(pOut, cTests); 2525 ShiftU32Generate(pOut, cTests); 2526 ShiftU64Generate(pOut, cTests); 2619 static RTEXITCODE ShiftGenerate(uint32_t cTests, const char * const * papszNameFmts) 2620 { 2621 RTEXITCODE rcExit = ShiftU8Generate(cTests, papszNameFmts); 2622 if (rcExit == RTEXITCODE_SUCCESS) 2623 rcExit = ShiftU16Generate(cTests, papszNameFmts); 2624 if (rcExit == RTEXITCODE_SUCCESS) 2625 rcExit = ShiftU32Generate(cTests, papszNameFmts); 2626 if (rcExit == RTEXITCODE_SUCCESS) 2627 rcExit = ShiftU64Generate(cTests, papszNameFmts); 2628 return rcExit; 2629 } 2630 2631 static RTEXITCODE ShiftDumpAll(const char * const * papszNameFmts) 2632 { 2633 RTEXITCODE rcExit = ShiftU8DumpAll(papszNameFmts); 2634 if (rcExit == RTEXITCODE_SUCCESS) 2635 rcExit = ShiftU16DumpAll(papszNameFmts); 2636 if (rcExit == RTEXITCODE_SUCCESS) 2637 rcExit = ShiftU32DumpAll(papszNameFmts); 2638 if (rcExit == RTEXITCODE_SUCCESS) 2639 rcExit = ShiftU64DumpAll(papszNameFmts); 2640 return rcExit; 2527 2641 } 2528 2642 #endif … … 2561 2675 2562 2676 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2563 static void MulDivU8Generate(PRTSTREAM pOut, uint32_t cTests)2677 static RTEXITCODE MulDivU8Generate(uint32_t cTests, const char * const * papszNameFmts) 2564 2678 { 2565 2679 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aMulDivU8); iFn++) … … 2568 2682 && g_aMulDivU8[iFn].idxCpuEflFlavour != g_idxCpuEflFlavour) 2569 2683 continue; 2570 GenerateArrayStart(pOut, g_aMulDivU8[iFn].pszName, "MULDIVU8_TEST_T"); \ 2684 IEMBINARYOUTPUT BinOut; \ 2685 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[g_aMulDivU8[iFn].idxCpuEflFlavour], g_aMulDivU8[iFn].pszName), 2686 RTEXITCODE_FAILURE); 2571 2687 for (uint32_t iTest = 0; iTest < cTests; iTest++ ) 2572 2688 { … … 2578 2694 Test.uSrcIn = RandU8Src(iTest); 2579 2695 Test.rc = g_aMulDivU8[iFn].pfnNative(&Test.uDstOut, Test.uSrcIn, &Test.fEflOut); 2580 RTStrmPrintf(pOut, " { %#08x, %#08x, %#06RX16, %#06RX16, %#04RX8, %d }, /* #%u */\n", 2581 Test.fEflIn, Test.fEflOut, Test.uDstIn, Test.uDstOut, Test.uSrcIn, Test.rc, iTest); 2582 } 2583 GenerateArrayEnd(pOut, g_aMulDivU8[iFn].pszName); 2584 } 2696 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); 2697 } 2698 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); 2699 } 2700 return RTEXITCODE_SUCCESS; 2701 } 2702 static RTEXITCODE MulDivU8DumpAll(const char * const * papszNameFmts) 2703 { 2704 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aMulDivU8); iFn++) 2705 { 2706 AssertReturn(DECOMPRESS_TESTS(g_aMulDivU8[iFn]), RTEXITCODE_FAILURE); 2707 IEMBINARYOUTPUT BinOut; 2708 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[g_aMulDivU8[iFn].idxCpuEflFlavour], g_aMulDivU8[iFn].pszName), 2709 RTEXITCODE_FAILURE); 2710 uint32_t cbTests = g_aMulDivU8[iFn].pcTests[0]; 2711 if (!g_aMulDivU8[iFn].fBinary) 2712 cbTests *= sizeof(g_aMulDivU8[iFn].paTests[0]); 2713 GenerateBinaryWrite(&BinOut, g_aMulDivU8[iFn].paTests, cbTests); 2714 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); 2715 } 2716 return RTEXITCODE_SUCCESS; 2585 2717 } 2586 2718 #endif … … 2632 2764 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2633 2765 # define GEN_MULDIV(a_cBits, a_Fmt, a_TestType, a_aSubTests) \ 2634 void MulDivU ## a_cBits ## Generate(PRTSTREAM pOut, uint32_t cTests) \2766 static RTEXITCODE MulDivU ## a_cBits ## Generate(uint32_t cTests, const char * const * papszNameFmts) \ 2635 2767 { \ 2636 2768 for (size_t iFn = 0; iFn < RT_ELEMENTS(a_aSubTests); iFn++) \ … … 2639 2771 && a_aSubTests[iFn].idxCpuEflFlavour != g_idxCpuEflFlavour) \ 2640 2772 continue; \ 2641 GenerateArrayStart(pOut, a_aSubTests[iFn].pszName, #a_TestType); \ 2773 IEMBINARYOUTPUT BinOut; \ 2774 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[a_aSubTests[iFn].idxCpuEflFlavour], a_aSubTests[iFn].pszName), \ 2775 RTEXITCODE_FAILURE); \ 2642 2776 for (uint32_t iTest = 0; iTest < cTests; iTest++ ) \ 2643 2777 { \ … … 2651 2785 Test.uSrcIn = RandU ## a_cBits ## Src(iTest); \ 2652 2786 Test.rc = a_aSubTests[iFn].pfnNative(&Test.uDst1Out, &Test.uDst2Out, Test.uSrcIn, &Test.fEflOut); \ 2653 RTStrmPrintf(pOut, " { %#08x, %#08x, " a_Fmt ", " a_Fmt ", " a_Fmt ", " a_Fmt ", " a_Fmt ", %d }, /* #%u */\n", \ 2654 Test.fEflIn, Test.fEflOut, Test.uDst1In, Test.uDst1Out, Test.uDst2In, Test.uDst2Out, Test.uSrcIn, \ 2655 Test.rc, iTest); \ 2787 GenerateBinaryWrite(&BinOut, &Test, sizeof(Test)); \ 2656 2788 } \ 2657 GenerateArrayEnd(pOut, a_aSubTests[iFn].pszName); \2789 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2658 2790 } \ 2791 return RTEXITCODE_SUCCESS; \ 2792 } \ 2793 static RTEXITCODE MulDivU ## a_cBits ## DumpAll(const char * const * papszNameFmts) \ 2794 { \ 2795 for (size_t iFn = 0; iFn < RT_ELEMENTS(a_aSubTests); iFn++) \ 2796 { \ 2797 AssertReturn(DECOMPRESS_TESTS(a_aSubTests[iFn]), RTEXITCODE_FAILURE); \ 2798 IEMBINARYOUTPUT BinOut; \ 2799 AssertReturn(GenerateBinaryOpen(&BinOut, papszNameFmts[a_aSubTests[iFn].idxCpuEflFlavour], a_aSubTests[iFn].pszName), \ 2800 RTEXITCODE_FAILURE); \ 2801 uint32_t cbTests = a_aSubTests[iFn].pcTests[0]; \ 2802 if (!a_aSubTests[iFn].fBinary) \ 2803 cbTests *= sizeof(a_aSubTests[iFn].paTests[0]); \ 2804 GenerateBinaryWrite(&BinOut, a_aSubTests[iFn].paTests, cbTests); \ 2805 AssertReturn(GenerateBinaryClose(&BinOut), RTEXITCODE_FAILURE); \ 2806 } \ 2807 return RTEXITCODE_SUCCESS; \ 2659 2808 } 2660 2809 #else … … 2733 2882 2734 2883 #ifdef TSTIEMAIMPL_WITH_GENERATOR 2735 static void MulDivGenerate(PRTSTREAM pOut, uint32_t cTests) 2736 { 2737 MulDivU8Generate(pOut, cTests); 2738 MulDivU16Generate(pOut, cTests); 2739 MulDivU32Generate(pOut, cTests); 2740 MulDivU64Generate(pOut, cTests); 2884 static RTEXITCODE MulDivGenerate(uint32_t cTests, const char * const * papszNameFmts) 2885 { 2886 RTEXITCODE rcExit = MulDivU8Generate(cTests, papszNameFmts); 2887 if (rcExit == RTEXITCODE_SUCCESS) 2888 rcExit = MulDivU16Generate(cTests, papszNameFmts); 2889 if (rcExit == RTEXITCODE_SUCCESS) 2890 rcExit = MulDivU32Generate(cTests, papszNameFmts); 2891 if (rcExit == RTEXITCODE_SUCCESS) 2892 rcExit = MulDivU64Generate(cTests, papszNameFmts); 2893 return rcExit; 2894 } 2895 2896 static RTEXITCODE MulDivDumpAll(const char * const * papszNameFmts) 2897 { 2898 RTEXITCODE rcExit = MulDivU8DumpAll(papszNameFmts); 2899 if (rcExit == RTEXITCODE_SUCCESS) 2900 rcExit = MulDivU16DumpAll(papszNameFmts); 2901 if (rcExit == RTEXITCODE_SUCCESS) 2902 rcExit = MulDivU32DumpAll(papszNameFmts); 2903 if (rcExit == RTEXITCODE_SUCCESS) 2904 rcExit = MulDivU64DumpAll(papszNameFmts); 2905 return rcExit; 2741 2906 } 2742 2907 #endif … … 9391 9556 * Parse arguments. 9392 9557 */ 9393 enum { kModeNotSet, kModeTest, kModeGenerate }9558 enum { kModeNotSet, kModeTest, kModeGenerate, kModeDump } 9394 9559 enmMode = kModeNotSet; 9395 9560 bool fInt = true; … … 9409 9574 // mode: 9410 9575 { "--generate", 'g', RTGETOPT_REQ_NOTHING }, 9576 { "--dump", 'G', RTGETOPT_REQ_NOTHING }, 9411 9577 { "--test", 't', RTGETOPT_REQ_NOTHING }, 9412 9578 { "--benchmark", 'b', RTGETOPT_REQ_NOTHING }, … … 9445 9611 case 'g': 9446 9612 enmMode = kModeGenerate; 9613 g_cPicoSecBenchmark = 0; 9614 break; 9615 case 'G': 9616 enmMode = kModeDump; 9447 9617 g_cPicoSecBenchmark = 0; 9448 9618 break; … … 9615 9785 if (fInt) 9616 9786 { 9617 const char *pszDataFile = fCommonData ? "tstIEMAImplDataInt.cpp" : pszBitBucket; 9618 PRTSTREAM pStrmData = GenerateOpenWithHdr(pszDataFile, szCpuDesc, NULL); 9619 const char *pszDataCpuFile = !fCpuData ? pszBitBucket : g_idxCpuEflFlavour == IEMTARGETCPU_EFL_BEHAVIOR_AMD 9620 ? "tstIEMAImplDataInt-Amd.cpp" : "tstIEMAImplDataInt-Intel.cpp"; 9621 PRTSTREAM pStrmDataCpu = GenerateOpenWithHdr(pszDataCpuFile, szCpuDesc, pszCpuType); 9622 if (!pStrmData || !pStrmDataCpu) 9623 return RTEXITCODE_FAILURE; 9624 9625 BinU8Generate( pStrmData, pStrmDataCpu, cTests); 9626 BinU16Generate(pStrmData, pStrmDataCpu, cTests); 9627 BinU32Generate(pStrmData, pStrmDataCpu, cTests); 9628 BinU64Generate(pStrmData, pStrmDataCpu, cTests); 9629 ShiftDblGenerate(pStrmDataCpu, RT_MAX(cTests, 128)); 9630 UnaryGenerate(pStrmData, cTests); 9631 ShiftGenerate(pStrmDataCpu, cTests); 9632 MulDivGenerate(pStrmDataCpu, cTests); 9633 9634 RTEXITCODE rcExit = GenerateFooterAndClose(pStrmDataCpu, pszDataCpuFile, 9635 GenerateFooterAndClose(pStrmData, pszDataFile, RTEXITCODE_SUCCESS)); 9787 const char * const apszNameFmts[] = 9788 { 9789 /*[IEMTARGETCPU_EFL_BEHAVIOR_NATIVE] =*/ fCommonData ? "tstIEMAImplDataInt-%s.bin.gz" : NULL, 9790 /*[IEMTARGETCPU_EFL_BEHAVIOR_INTEL] =*/ fCpuData ? "tstIEMAImplDataInt-%s-Intel.bin.gz" : NULL, 9791 /*[IEMTARGETCPU_EFL_BEHAVIOR_AMD] =*/ fCpuData ? "tstIEMAImplDataInt-%s-Amd.bin.gz" : NULL, 9792 }; 9793 RTEXITCODE rcExit = BinU8Generate(cTests, apszNameFmts); 9794 if (rcExit == RTEXITCODE_SUCCESS) 9795 rcExit = BinU16Generate(cTests, apszNameFmts); 9796 if (rcExit == RTEXITCODE_SUCCESS) 9797 rcExit = BinU32Generate(cTests, apszNameFmts); 9798 if (rcExit == RTEXITCODE_SUCCESS) 9799 rcExit = BinU64Generate(cTests, apszNameFmts); 9800 if (rcExit == RTEXITCODE_SUCCESS) 9801 rcExit = ShiftDblGenerate(RT_MAX(cTests, 128), apszNameFmts); 9802 if (rcExit == RTEXITCODE_SUCCESS) 9803 rcExit = UnaryGenerate(cTests, apszNameFmts); 9804 if (rcExit == RTEXITCODE_SUCCESS) 9805 rcExit = ShiftGenerate(cTests, apszNameFmts); 9806 if (rcExit == RTEXITCODE_SUCCESS) 9807 rcExit = MulDivGenerate(cTests, apszNameFmts); 9636 9808 if (rcExit != RTEXITCODE_SUCCESS) 9637 9809 return rcExit; … … 9815 9987 9816 9988 /* 9989 * Dump tables. 9990 */ 9991 if (enmMode == kModeDump) 9992 { 9993 #ifdef TSTIEMAIMPL_WITH_GENERATOR 9994 if (fInt) 9995 { 9996 const char * const apszNameFmts[] = 9997 { 9998 /*[IEMTARGETCPU_EFL_BEHAVIOR_NATIVE] =*/ fCommonData ? "tstIEMAImplDataInt-%s.bin.gz" : NULL, 9999 /*[IEMTARGETCPU_EFL_BEHAVIOR_INTEL] =*/ fCpuData ? "tstIEMAImplDataInt-%s-Intel.bin.gz" : NULL, 10000 /*[IEMTARGETCPU_EFL_BEHAVIOR_AMD] =*/ fCpuData ? "tstIEMAImplDataInt-%s-Amd.bin.gz" : NULL, 10001 }; 10002 RTEXITCODE rcExit = BinU8DumpAll(apszNameFmts); 10003 if (rcExit == RTEXITCODE_SUCCESS) 10004 rcExit = BinU16DumpAll(apszNameFmts); 10005 if (rcExit == RTEXITCODE_SUCCESS) 10006 rcExit = BinU32DumpAll(apszNameFmts); 10007 if (rcExit == RTEXITCODE_SUCCESS) 10008 rcExit = BinU64DumpAll(apszNameFmts); 10009 if (rcExit == RTEXITCODE_SUCCESS) 10010 rcExit = ShiftDblDumpAll(apszNameFmts); 10011 if (rcExit == RTEXITCODE_SUCCESS) 10012 rcExit = UnaryDumpAll(apszNameFmts); 10013 if (rcExit == RTEXITCODE_SUCCESS) 10014 rcExit = ShiftDumpAll(apszNameFmts); 10015 if (rcExit == RTEXITCODE_SUCCESS) 10016 rcExit = MulDivDumpAll(apszNameFmts); 10017 if (rcExit != RTEXITCODE_SUCCESS) 10018 return rcExit; 10019 } 10020 10021 return RTEXITCODE_SUCCESS; 10022 #else 10023 return RTMsgErrorExitFailure("Test data generator not compiled in!"); 10024 #endif 10025 } 10026 10027 10028 /* 9817 10029 * Do testing. Currrently disabled by default as data needs to be checked 9818 10030 * on both intel and AMD systems first.
Note:
See TracChangeset
for help on using the changeset viewer.