Changeset 98822 in vbox
- Timestamp:
- Mar 2, 2023 3:02:03 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156142
- Location:
- trunk/src/VBox/VMM/testcase
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/Makefile.kmk
r98437 r98822 316 316 tstIEMAImplDataSseConvert-cvtpi2pd_u128.bin \ 317 317 tstIEMAImplDataSseConvert-cvtps2pi_u128.bin \ 318 tstIEMAImplDataSseConvert-cvttps2pi_u128.bin 318 tstIEMAImplDataSseConvert-cvttps2pi_u128.bin \ 319 tstIEMAImplDataSsePcmpxstrx-pcmpistri_u128.bin \ 320 tstIEMAImplDataSsePcmpxstrx-pcmpistrm_u128.bin \ 321 tstIEMAImplDataSsePcmpxstrx-pcmpestri_u128.bin \ 322 tstIEMAImplDataSsePcmpxstrx-pcmpestrm_u128.bin 319 323 320 324 tstIEMAImpl_TEMPLATE = VBoxR3TstExe -
trunk/src/VBox/VMM/testcase/tstIEMAImpl.cpp
r98106 r98822 72 72 #else 73 73 # define ENTRY_BIN_AVX_EX(a_Name, a_uExtra) \ 74 { RT_XSTR(a_Name), iemAImpl_ ## a_Name ## _fallback, NULL, \ 75 g_aTests_ ## a_Name, &g_cbTests_ ## a_Name, \ 76 a_uExtra, IEMTARGETCPU_EFL_BEHAVIOR_NATIVE /* means same for all here */ } 77 #endif 78 79 #define ENTRY_BIN_SSE_OPT(a_Name) ENTRY_BIN_SSE_OPT_EX(a_Name, 0) 80 #ifndef IEM_WITHOUT_ASSEMBLY 81 # define ENTRY_BIN_SSE_OPT_EX(a_Name, a_uExtra) \ 82 { RT_XSTR(a_Name), iemAImpl_ ## a_Name, NULL, \ 83 g_aTests_ ## a_Name, &g_cbTests_ ## a_Name, \ 84 a_uExtra, IEMTARGETCPU_EFL_BEHAVIOR_NATIVE /* means same for all here */ } 85 #else 86 # define ENTRY_BIN_SSE_OPT_EX(a_Name, a_uExtra) \ 74 87 { RT_XSTR(a_Name), iemAImpl_ ## a_Name ## _fallback, NULL, \ 75 88 g_aTests_ ## a_Name, &g_cbTests_ ## a_Name, \ … … 1276 1289 char *pszBuf = g_aszBuf[g_idxBuf++ % RT_ELEMENTS(g_aszBuf)]; 1277 1290 RTStrFormatU16(pszBuf, sizeof(g_aszBuf[0]), *piVal, 16, 0, 0, RTSTR_F_SPECIAL | RTSTR_F_VALSIGNED); 1291 return pszBuf; 1292 } 1293 1294 1295 static const char *FormatU128(PCRTUINT128U puVal) 1296 { 1297 char *pszBuf = g_aszBuf[g_idxBuf++ % RT_ELEMENTS(g_aszBuf)]; 1298 RTStrFormatU128(pszBuf, sizeof(g_aszBuf[0]), puVal, 16, 0, 0, RTSTR_F_SPECIAL); 1278 1299 return pszBuf; 1279 1300 } … … 8749 8770 8750 8771 8772 /* 8773 * SSE 4.2 pcmpxstrx instructions. 8774 */ 8775 TYPEDEF_SUBTEST_TYPE(SSE_PCMPISTRI_T, SSE_PCMPISTRI_TEST_T, PFNIEMAIMPLPCMPISTRIU128IMM8); 8776 8777 static const SSE_PCMPISTRI_T g_aSsePcmpistri[] = 8778 { 8779 ENTRY_BIN_SSE_OPT(pcmpistri_u128), 8780 }; 8781 8782 #ifdef TSTIEMAIMPL_WITH_GENERATOR 8783 static RTEXITCODE SseComparePcmpistriGenerate(const char *pszDataFileFmt, uint32_t cTests) 8784 { 8785 cTests = RT_MAX(192, cTests); /* there are 144 standard input variations */ 8786 8787 static struct { RTUINT128U uSrc1; RTUINT128U uSrc2; } const s_aSpecials[] = 8788 { 8789 { RTUINT128_INIT_C(0, 0), RTUINT128_INIT_C(0, 0) }, 8790 /** @todo More specials. */ 8791 }; 8792 8793 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpistri); iFn++) 8794 { 8795 PFNIEMAIMPLPCMPISTRIU128IMM8 const pfn = g_aSsePcmpistri[iFn].pfnNative ? g_aSsePcmpistri[iFn].pfnNative : g_aSsePcmpistri[iFn].pfn; 8796 8797 PRTSTREAM pStrmOut = NULL; 8798 int rc = RTStrmOpenF("wb", &pStrmOut, pszDataFileFmt, g_aSsePcmpistri[iFn].pszName); 8799 if (RT_FAILURE(rc)) 8800 { 8801 RTMsgError("Failed to open data file for %s for writing: %Rrc", g_aSsePcmpistri[iFn].pszName, rc); 8802 return RTEXITCODE_FAILURE; 8803 } 8804 8805 for (uint32_t iTest = 0; iTest < cTests + RT_ELEMENTS(s_aSpecials); iTest += 1) 8806 { 8807 SSE_PCMPISTRI_TEST_T TestData; RT_ZERO(TestData); 8808 8809 TestData.InVal1.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc1; 8810 TestData.InVal2.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc2; 8811 8812 IEMPCMPISTRXSRC TestVal; 8813 TestVal.uSrc1 = TestData.InVal1.uXmm; 8814 TestVal.uSrc2 = TestData.InVal2.uXmm; 8815 8816 uint32_t const fEFlagsIn = RandEFlags(); 8817 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 8818 { 8819 uint32_t fEFlagsOut = fEFlagsIn; 8820 pfn(&TestData.u32EcxOut, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 8821 TestData.fEFlagsIn = fEFlagsIn; 8822 TestData.fEFlagsOut = fEFlagsOut; 8823 TestData.bImm = (uint8_t)u16Imm; 8824 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 8825 } 8826 8827 /* Repeat the test with the input value being the same. */ 8828 TestData.InVal2.uXmm = TestData.InVal1.uXmm; 8829 TestVal.uSrc1 = TestData.InVal1.uXmm; 8830 TestVal.uSrc2 = TestData.InVal2.uXmm; 8831 8832 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 8833 { 8834 uint32_t fEFlagsOut = fEFlagsIn; 8835 pfn(&TestData.u32EcxOut, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 8836 TestData.fEFlagsIn = fEFlagsIn; 8837 TestData.fEFlagsOut = fEFlagsOut; 8838 TestData.bImm = (uint8_t)u16Imm; 8839 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 8840 } 8841 } 8842 rc = RTStrmClose(pStrmOut); 8843 if (RT_FAILURE(rc)) 8844 { 8845 RTMsgError("Failed to close data file for %s: %Rrc", g_aSsePcmpistri[iFn].pszName, rc); 8846 return RTEXITCODE_FAILURE; 8847 } 8848 } 8849 8850 return RTEXITCODE_SUCCESS; 8851 } 8852 #endif 8853 8854 static void SseComparePcmpistriTest(void) 8855 { 8856 X86FXSTATE State; 8857 RT_ZERO(State); 8858 8859 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpistri); iFn++) 8860 { 8861 if (!SubTestAndCheckIfEnabled(g_aSsePcmpistri[iFn].pszName)) 8862 continue; 8863 8864 uint32_t const cTests = *g_aSsePcmpistri[iFn].pcTests; 8865 SSE_PCMPISTRI_TEST_T const * const paTests = g_aSsePcmpistri[iFn].paTests; 8866 PFNIEMAIMPLPCMPISTRIU128IMM8 pfn = g_aSsePcmpistri[iFn].pfn; 8867 uint32_t const cVars = COUNT_VARIATIONS(g_aSsePcmpistri[iFn]); 8868 if (!cTests) RTTestSkipped(g_hTest, "no tests"); 8869 for (uint32_t iVar = 0; iVar < cVars; iVar++) 8870 { 8871 for (uint32_t iTest = 0; iTest < cTests / sizeof(*paTests); iTest++) 8872 { 8873 IEMPCMPISTRXSRC TestVal; 8874 TestVal.uSrc1 = paTests[iTest].InVal1.uXmm; 8875 TestVal.uSrc2 = paTests[iTest].InVal2.uXmm; 8876 8877 uint32_t fEFlags = paTests[iTest].fEFlagsIn; 8878 uint32_t u32EcxOut = 0; 8879 pfn(&u32EcxOut, &fEFlags, &TestVal, paTests[iTest].bImm); 8880 if ( fEFlags != paTests[iTest].fEFlagsOut 8881 || u32EcxOut != paTests[iTest].u32EcxOut) 8882 RTTestFailed(g_hTest, "#%04u%s: efl=%#08x in1=%s in2=%s bImm=%#x\n" 8883 "%s -> efl=%#08x %RU32\n" 8884 "%s expected %#08x %RU32%s%s\n", 8885 iTest, iVar ? "/n" : "", paTests[iTest].fEFlagsIn, 8886 FormatU128(&paTests[iTest].InVal1.uXmm), FormatU128(&paTests[iTest].InVal2.uXmm), paTests[iTest].bImm, 8887 iVar ? " " : "", fEFlags, u32EcxOut, 8888 iVar ? " " : "", paTests[iTest].fEFlagsOut, paTests[iTest].u32EcxOut, 8889 EFlagsDiff(fEFlags, paTests[iTest].fEFlagsOut), 8890 (u32EcxOut != paTests[iTest].u32EcxOut) ? " - val" : ""); 8891 } 8892 } 8893 } 8894 } 8895 8896 8897 TYPEDEF_SUBTEST_TYPE(SSE_PCMPISTRM_T, SSE_PCMPISTRM_TEST_T, PFNIEMAIMPLPCMPISTRMU128IMM8); 8898 8899 static const SSE_PCMPISTRM_T g_aSsePcmpistrm[] = 8900 { 8901 ENTRY_BIN_SSE_OPT(pcmpistrm_u128), 8902 }; 8903 8904 #ifdef TSTIEMAIMPL_WITH_GENERATOR 8905 static RTEXITCODE SseComparePcmpistrmGenerate(const char *pszDataFileFmt, uint32_t cTests) 8906 { 8907 cTests = RT_MAX(192, cTests); /* there are 144 standard input variations */ 8908 8909 static struct { RTUINT128U uSrc1; RTUINT128U uSrc2; } const s_aSpecials[] = 8910 { 8911 { RTUINT128_INIT_C(0, 0), RTUINT128_INIT_C(0, 0) }, 8912 /** @todo More specials. */ 8913 }; 8914 8915 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpistrm); iFn++) 8916 { 8917 PFNIEMAIMPLPCMPISTRMU128IMM8 const pfn = g_aSsePcmpistrm[iFn].pfnNative ? g_aSsePcmpistrm[iFn].pfnNative : g_aSsePcmpistrm[iFn].pfn; 8918 8919 PRTSTREAM pStrmOut = NULL; 8920 int rc = RTStrmOpenF("wb", &pStrmOut, pszDataFileFmt, g_aSsePcmpistrm[iFn].pszName); 8921 if (RT_FAILURE(rc)) 8922 { 8923 RTMsgError("Failed to open data file for %s for writing: %Rrc", g_aSsePcmpistrm[iFn].pszName, rc); 8924 return RTEXITCODE_FAILURE; 8925 } 8926 8927 for (uint32_t iTest = 0; iTest < cTests + RT_ELEMENTS(s_aSpecials); iTest += 1) 8928 { 8929 SSE_PCMPISTRM_TEST_T TestData; RT_ZERO(TestData); 8930 8931 TestData.InVal1.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc1; 8932 TestData.InVal2.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc2; 8933 8934 IEMPCMPISTRXSRC TestVal; 8935 TestVal.uSrc1 = TestData.InVal1.uXmm; 8936 TestVal.uSrc2 = TestData.InVal2.uXmm; 8937 8938 uint32_t const fEFlagsIn = RandEFlags(); 8939 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 8940 { 8941 uint32_t fEFlagsOut = fEFlagsIn; 8942 pfn(&TestData.OutVal.uXmm, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 8943 TestData.fEFlagsIn = fEFlagsIn; 8944 TestData.fEFlagsOut = fEFlagsOut; 8945 TestData.bImm = (uint8_t)u16Imm; 8946 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 8947 } 8948 8949 /* Repeat the test with the input value being the same. */ 8950 TestData.InVal2.uXmm = TestData.InVal1.uXmm; 8951 TestVal.uSrc1 = TestData.InVal1.uXmm; 8952 TestVal.uSrc2 = TestData.InVal2.uXmm; 8953 8954 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 8955 { 8956 uint32_t fEFlagsOut = fEFlagsIn; 8957 pfn(&TestData.OutVal.uXmm, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 8958 TestData.fEFlagsIn = fEFlagsIn; 8959 TestData.fEFlagsOut = fEFlagsOut; 8960 TestData.bImm = (uint8_t)u16Imm; 8961 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 8962 } 8963 } 8964 rc = RTStrmClose(pStrmOut); 8965 if (RT_FAILURE(rc)) 8966 { 8967 RTMsgError("Failed to close data file for %s: %Rrc", g_aSsePcmpistrm[iFn].pszName, rc); 8968 return RTEXITCODE_FAILURE; 8969 } 8970 } 8971 8972 return RTEXITCODE_SUCCESS; 8973 } 8974 #endif 8975 8976 static void SseComparePcmpistrmTest(void) 8977 { 8978 X86FXSTATE State; 8979 RT_ZERO(State); 8980 8981 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpistrm); iFn++) 8982 { 8983 if (!SubTestAndCheckIfEnabled(g_aSsePcmpistrm[iFn].pszName)) 8984 continue; 8985 8986 uint32_t const cTests = *g_aSsePcmpistrm[iFn].pcTests; 8987 SSE_PCMPISTRM_TEST_T const * const paTests = g_aSsePcmpistrm[iFn].paTests; 8988 PFNIEMAIMPLPCMPISTRMU128IMM8 pfn = g_aSsePcmpistrm[iFn].pfn; 8989 uint32_t const cVars = COUNT_VARIATIONS(g_aSsePcmpistrm[iFn]); 8990 if (!cTests) RTTestSkipped(g_hTest, "no tests"); 8991 for (uint32_t iVar = 0; iVar < cVars; iVar++) 8992 { 8993 for (uint32_t iTest = 0; iTest < cTests / sizeof(*paTests); iTest++) 8994 { 8995 IEMPCMPISTRXSRC TestVal; 8996 TestVal.uSrc1 = paTests[iTest].InVal1.uXmm; 8997 TestVal.uSrc2 = paTests[iTest].InVal2.uXmm; 8998 8999 uint32_t fEFlags = paTests[iTest].fEFlagsIn; 9000 RTUINT128U OutVal; 9001 pfn(&OutVal, &fEFlags, &TestVal, paTests[iTest].bImm); 9002 if ( fEFlags != paTests[iTest].fEFlagsOut 9003 || OutVal.s.Hi != paTests[iTest].OutVal.uXmm.s.Hi 9004 || OutVal.s.Lo != paTests[iTest].OutVal.uXmm.s.Lo) 9005 RTTestFailed(g_hTest, "#%04u%s: efl=%#08x in1=%s in2=%s bImm=%#x\n" 9006 "%s -> efl=%#08x %s\n" 9007 "%s expected %#08x %s%s%s\n", 9008 iTest, iVar ? "/n" : "", paTests[iTest].fEFlagsIn, 9009 FormatU128(&paTests[iTest].InVal1.uXmm), FormatU128(&paTests[iTest].InVal2.uXmm), paTests[iTest].bImm, 9010 iVar ? " " : "", fEFlags, FormatU128(&OutVal), 9011 iVar ? " " : "", paTests[iTest].fEFlagsOut, FormatU128(&paTests[iTest].OutVal.uXmm), 9012 EFlagsDiff(fEFlags, paTests[iTest].fEFlagsOut), 9013 ( OutVal.s.Hi != paTests[iTest].OutVal.uXmm.s.Hi 9014 || OutVal.s.Lo != paTests[iTest].OutVal.uXmm.s.Lo) ? " - val" : ""); 9015 } 9016 } 9017 } 9018 } 9019 9020 9021 TYPEDEF_SUBTEST_TYPE(SSE_PCMPESTRI_T, SSE_PCMPESTRI_TEST_T, PFNIEMAIMPLPCMPESTRIU128IMM8); 9022 9023 static const SSE_PCMPESTRI_T g_aSsePcmpestri[] = 9024 { 9025 ENTRY_BIN_SSE_OPT(pcmpestri_u128), 9026 }; 9027 9028 #ifdef TSTIEMAIMPL_WITH_GENERATOR 9029 static RTEXITCODE SseComparePcmpestriGenerate(const char *pszDataFileFmt, uint32_t cTests) 9030 { 9031 cTests = RT_MAX(192, cTests); /* there are 144 standard input variations */ 9032 9033 static struct { RTUINT128U uSrc1; RTUINT128U uSrc2; } const s_aSpecials[] = 9034 { 9035 { RTUINT128_INIT_C(0, 0), RTUINT128_INIT_C(0, 0) }, 9036 /** @todo More specials. */ 9037 }; 9038 9039 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpestri); iFn++) 9040 { 9041 PFNIEMAIMPLPCMPESTRIU128IMM8 const pfn = g_aSsePcmpestri[iFn].pfnNative ? g_aSsePcmpestri[iFn].pfnNative : g_aSsePcmpestri[iFn].pfn; 9042 9043 PRTSTREAM pStrmOut = NULL; 9044 int rc = RTStrmOpenF("wb", &pStrmOut, pszDataFileFmt, g_aSsePcmpestri[iFn].pszName); 9045 if (RT_FAILURE(rc)) 9046 { 9047 RTMsgError("Failed to open data file for %s for writing: %Rrc", g_aSsePcmpestri[iFn].pszName, rc); 9048 return RTEXITCODE_FAILURE; 9049 } 9050 9051 for (uint32_t iTest = 0; iTest < cTests + RT_ELEMENTS(s_aSpecials); iTest += 1) 9052 { 9053 SSE_PCMPESTRI_TEST_T TestData; RT_ZERO(TestData); 9054 9055 TestData.InVal1.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc1; 9056 TestData.InVal2.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc2; 9057 9058 for (int64_t i64Rax = -20; i64Rax < 20; i64Rax += 20) 9059 for (int64_t i64Rdx = -20; i64Rdx < 20; i64Rdx += 20) 9060 { 9061 TestData.u64Rax = (uint64_t)i64Rax; 9062 TestData.u64Rdx = (uint64_t)i64Rdx; 9063 9064 IEMPCMPESTRXSRC TestVal; 9065 TestVal.uSrc1 = TestData.InVal1.uXmm; 9066 TestVal.uSrc2 = TestData.InVal2.uXmm; 9067 TestVal.u64Rax = TestData.u64Rax; 9068 TestVal.u64Rdx = TestData.u64Rdx; 9069 9070 uint32_t const fEFlagsIn = RandEFlags(); 9071 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 9072 { 9073 uint32_t fEFlagsOut = fEFlagsIn; 9074 pfn(&TestData.u32EcxOut, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 9075 TestData.fEFlagsIn = fEFlagsIn; 9076 TestData.fEFlagsOut = fEFlagsOut; 9077 TestData.bImm = (uint8_t)u16Imm; 9078 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 9079 } 9080 9081 /* Repeat the test with the input value being the same. */ 9082 TestData.InVal2.uXmm = TestData.InVal1.uXmm; 9083 TestVal.uSrc1 = TestData.InVal1.uXmm; 9084 TestVal.uSrc2 = TestData.InVal2.uXmm; 9085 9086 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 9087 { 9088 uint32_t fEFlagsOut = fEFlagsIn; 9089 pfn(&TestData.u32EcxOut, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 9090 TestData.fEFlagsIn = fEFlagsIn; 9091 TestData.fEFlagsOut = fEFlagsOut; 9092 TestData.bImm = (uint8_t)u16Imm; 9093 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 9094 } 9095 } 9096 } 9097 rc = RTStrmClose(pStrmOut); 9098 if (RT_FAILURE(rc)) 9099 { 9100 RTMsgError("Failed to close data file for %s: %Rrc", g_aSsePcmpestri[iFn].pszName, rc); 9101 return RTEXITCODE_FAILURE; 9102 } 9103 } 9104 9105 return RTEXITCODE_SUCCESS; 9106 } 9107 #endif 9108 9109 static void SseComparePcmpestriTest(void) 9110 { 9111 X86FXSTATE State; 9112 RT_ZERO(State); 9113 9114 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpestri); iFn++) 9115 { 9116 if (!SubTestAndCheckIfEnabled(g_aSsePcmpestri[iFn].pszName)) 9117 continue; 9118 9119 uint32_t const cTests = *g_aSsePcmpestri[iFn].pcTests; 9120 SSE_PCMPESTRI_TEST_T const * const paTests = g_aSsePcmpestri[iFn].paTests; 9121 PFNIEMAIMPLPCMPESTRIU128IMM8 pfn = g_aSsePcmpestri[iFn].pfn; 9122 uint32_t const cVars = COUNT_VARIATIONS(g_aSsePcmpestri[iFn]); 9123 if (!cTests) RTTestSkipped(g_hTest, "no tests"); 9124 for (uint32_t iVar = 0; iVar < cVars; iVar++) 9125 { 9126 for (uint32_t iTest = 0; iTest < cTests / sizeof(*paTests); iTest++) 9127 { 9128 IEMPCMPESTRXSRC TestVal; 9129 TestVal.uSrc1 = paTests[iTest].InVal1.uXmm; 9130 TestVal.uSrc2 = paTests[iTest].InVal2.uXmm; 9131 TestVal.u64Rax = paTests[iTest].u64Rax; 9132 TestVal.u64Rdx = paTests[iTest].u64Rdx; 9133 9134 uint32_t fEFlags = paTests[iTest].fEFlagsIn; 9135 uint32_t u32EcxOut = 0; 9136 pfn(&u32EcxOut, &fEFlags, &TestVal, paTests[iTest].bImm); 9137 if ( fEFlags != paTests[iTest].fEFlagsOut 9138 || u32EcxOut != paTests[iTest].u32EcxOut) 9139 RTTestFailed(g_hTest, "#%04u%s: efl=%#08x in1=%s rax1=%RI64 in2=%s rdx2=%RI64 bImm=%#x\n" 9140 "%s -> efl=%#08x %RU32\n" 9141 "%s expected %#08x %RU32%s%s\n", 9142 iTest, iVar ? "/n" : "", paTests[iTest].fEFlagsIn, 9143 FormatU128(&paTests[iTest].InVal1.uXmm), paTests[iTest].u64Rax, 9144 FormatU128(&paTests[iTest].InVal2.uXmm), paTests[iTest].u64Rdx, 9145 paTests[iTest].bImm, 9146 iVar ? " " : "", fEFlags, u32EcxOut, 9147 iVar ? " " : "", paTests[iTest].fEFlagsOut, paTests[iTest].u32EcxOut, 9148 EFlagsDiff(fEFlags, paTests[iTest].fEFlagsOut), 9149 (u32EcxOut != paTests[iTest].u32EcxOut) ? " - val" : ""); 9150 } 9151 } 9152 } 9153 } 9154 9155 9156 TYPEDEF_SUBTEST_TYPE(SSE_PCMPESTRM_T, SSE_PCMPESTRM_TEST_T, PFNIEMAIMPLPCMPESTRMU128IMM8); 9157 9158 static const SSE_PCMPESTRM_T g_aSsePcmpestrm[] = 9159 { 9160 ENTRY_BIN_SSE_OPT(pcmpestrm_u128), 9161 }; 9162 9163 #ifdef TSTIEMAIMPL_WITH_GENERATOR 9164 static RTEXITCODE SseComparePcmpestrmGenerate(const char *pszDataFileFmt, uint32_t cTests) 9165 { 9166 cTests = RT_MAX(192, cTests); /* there are 144 standard input variations */ 9167 9168 static struct { RTUINT128U uSrc1; RTUINT128U uSrc2; } const s_aSpecials[] = 9169 { 9170 { RTUINT128_INIT_C(0, 0), RTUINT128_INIT_C(0, 0) }, 9171 /** @todo More specials. */ 9172 }; 9173 9174 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpestrm); iFn++) 9175 { 9176 PFNIEMAIMPLPCMPESTRMU128IMM8 const pfn = g_aSsePcmpestrm[iFn].pfnNative ? g_aSsePcmpestrm[iFn].pfnNative : g_aSsePcmpestrm[iFn].pfn; 9177 9178 PRTSTREAM pStrmOut = NULL; 9179 int rc = RTStrmOpenF("wb", &pStrmOut, pszDataFileFmt, g_aSsePcmpestrm[iFn].pszName); 9180 if (RT_FAILURE(rc)) 9181 { 9182 RTMsgError("Failed to open data file for %s for writing: %Rrc", g_aSsePcmpestrm[iFn].pszName, rc); 9183 return RTEXITCODE_FAILURE; 9184 } 9185 9186 for (uint32_t iTest = 0; iTest < cTests + RT_ELEMENTS(s_aSpecials); iTest += 1) 9187 { 9188 SSE_PCMPESTRM_TEST_T TestData; RT_ZERO(TestData); 9189 9190 TestData.InVal1.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc1; 9191 TestData.InVal2.uXmm = iTest < cTests ? RandU128() : s_aSpecials[iTest - cTests].uSrc2; 9192 9193 for (int64_t i64Rax = -20; i64Rax < 20; i64Rax += 20) 9194 for (int64_t i64Rdx = -20; i64Rdx < 20; i64Rdx += 20) 9195 { 9196 TestData.u64Rax = (uint64_t)i64Rax; 9197 TestData.u64Rdx = (uint64_t)i64Rdx; 9198 9199 IEMPCMPESTRXSRC TestVal; 9200 TestVal.uSrc1 = TestData.InVal1.uXmm; 9201 TestVal.uSrc2 = TestData.InVal2.uXmm; 9202 TestVal.u64Rax = TestData.u64Rax; 9203 TestVal.u64Rdx = TestData.u64Rdx; 9204 9205 uint32_t const fEFlagsIn = RandEFlags(); 9206 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 9207 { 9208 uint32_t fEFlagsOut = fEFlagsIn; 9209 pfn(&TestData.OutVal.uXmm, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 9210 TestData.fEFlagsIn = fEFlagsIn; 9211 TestData.fEFlagsOut = fEFlagsOut; 9212 TestData.bImm = (uint8_t)u16Imm; 9213 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 9214 } 9215 9216 /* Repeat the test with the input value being the same. */ 9217 TestData.InVal2.uXmm = TestData.InVal1.uXmm; 9218 TestVal.uSrc1 = TestData.InVal1.uXmm; 9219 TestVal.uSrc2 = TestData.InVal2.uXmm; 9220 9221 for (uint16_t u16Imm = 0; u16Imm < 256; u16Imm++) 9222 { 9223 uint32_t fEFlagsOut = fEFlagsIn; 9224 pfn(&TestData.OutVal.uXmm, &fEFlagsOut, &TestVal, (uint8_t)u16Imm); 9225 TestData.fEFlagsIn = fEFlagsIn; 9226 TestData.fEFlagsOut = fEFlagsOut; 9227 TestData.bImm = (uint8_t)u16Imm; 9228 RTStrmWrite(pStrmOut, &TestData, sizeof(TestData)); 9229 } 9230 } 9231 } 9232 rc = RTStrmClose(pStrmOut); 9233 if (RT_FAILURE(rc)) 9234 { 9235 RTMsgError("Failed to close data file for %s: %Rrc", g_aSsePcmpestrm[iFn].pszName, rc); 9236 return RTEXITCODE_FAILURE; 9237 } 9238 } 9239 9240 return RTEXITCODE_SUCCESS; 9241 } 9242 #endif 9243 9244 static void SseComparePcmpestrmTest(void) 9245 { 9246 X86FXSTATE State; 9247 RT_ZERO(State); 9248 9249 for (size_t iFn = 0; iFn < RT_ELEMENTS(g_aSsePcmpestrm); iFn++) 9250 { 9251 if (!SubTestAndCheckIfEnabled(g_aSsePcmpestrm[iFn].pszName)) 9252 continue; 9253 9254 uint32_t const cTests = *g_aSsePcmpestrm[iFn].pcTests; 9255 SSE_PCMPESTRM_TEST_T const * const paTests = g_aSsePcmpestrm[iFn].paTests; 9256 PFNIEMAIMPLPCMPESTRMU128IMM8 pfn = g_aSsePcmpestrm[iFn].pfn; 9257 uint32_t const cVars = COUNT_VARIATIONS(g_aSsePcmpestrm[iFn]); 9258 if (!cTests) RTTestSkipped(g_hTest, "no tests"); 9259 for (uint32_t iVar = 0; iVar < cVars; iVar++) 9260 { 9261 for (uint32_t iTest = 0; iTest < cTests / sizeof(*paTests); iTest++) 9262 { 9263 IEMPCMPESTRXSRC TestVal; 9264 TestVal.uSrc1 = paTests[iTest].InVal1.uXmm; 9265 TestVal.uSrc2 = paTests[iTest].InVal2.uXmm; 9266 TestVal.u64Rax = paTests[iTest].u64Rax; 9267 TestVal.u64Rdx = paTests[iTest].u64Rdx; 9268 9269 uint32_t fEFlags = paTests[iTest].fEFlagsIn; 9270 RTUINT128U OutVal; 9271 pfn(&OutVal, &fEFlags, &TestVal, paTests[iTest].bImm); 9272 if ( fEFlags != paTests[iTest].fEFlagsOut 9273 || OutVal.s.Hi != paTests[iTest].OutVal.uXmm.s.Hi 9274 || OutVal.s.Lo != paTests[iTest].OutVal.uXmm.s.Lo) 9275 RTTestFailed(g_hTest, "#%04u%s: efl=%#08x in1=%s rax1=%RI64 in2=%s rdx2=%RI64 bImm=%#x\n" 9276 "%s -> efl=%#08x %s\n" 9277 "%s expected %#08x %s%s%s\n", 9278 iTest, iVar ? "/n" : "", paTests[iTest].fEFlagsIn, 9279 FormatU128(&paTests[iTest].InVal1.uXmm), paTests[iTest].u64Rax, 9280 FormatU128(&paTests[iTest].InVal2.uXmm), paTests[iTest].u64Rdx, 9281 paTests[iTest].bImm, 9282 iVar ? " " : "", fEFlags, FormatU128(&OutVal), 9283 iVar ? " " : "", paTests[iTest].fEFlagsOut, FormatU128(&paTests[iTest].OutVal.uXmm), 9284 EFlagsDiff(fEFlags, paTests[iTest].fEFlagsOut), 9285 ( OutVal.s.Hi != paTests[iTest].OutVal.uXmm.s.Hi 9286 || OutVal.s.Lo != paTests[iTest].OutVal.uXmm.s.Lo) ? " - val" : ""); 9287 } 9288 } 9289 } 9290 } 9291 9292 8751 9293 8752 9294 int main(int argc, char **argv) … … 8782 9324 bool fSseFpBinary = true; 8783 9325 bool fSseFpOther = true; 9326 bool fSsePcmpxstrx = true; 8784 9327 uint32_t const cDefaultTests = 96; 8785 9328 uint32_t cTests = cDefaultTests; … … 8800 9343 { "--sse-fp-binary", 'S', RTGETOPT_REQ_NOTHING }, 8801 9344 { "--sse-fp-other", 'T', RTGETOPT_REQ_NOTHING }, 9345 { "--sse-pcmpxstrx", 'C', RTGETOPT_REQ_NOTHING }, 8802 9346 { "--int", 'i', RTGETOPT_REQ_NOTHING }, 8803 9347 { "--include", 'I', RTGETOPT_REQ_STRING }, … … 8837 9381 fSseFpBinary = true; 8838 9382 fSseFpOther = true; 9383 fSsePcmpxstrx = true; 8839 9384 break; 8840 9385 case 'z': … … 8848 9393 fSseFpBinary = false; 8849 9394 fSseFpOther = false; 9395 fSsePcmpxstrx = false; 8850 9396 break; 8851 9397 … … 8867 9413 case 'T': 8868 9414 fSseFpOther = true; 9415 break; 9416 case 'C': 9417 fSsePcmpxstrx = true; 8869 9418 break; 8870 9419 case 'i': … … 8930 9479 " -T, --sse-fp-other\n" 8931 9480 " Enable misc SSE 64- and 32-bit FP tests.\n" 9481 " -C, --sse-pcmpxstrx\n" 9482 " Enable SSE pcmpxstrx tests.\n" 8932 9483 " -I,--include=<test-patter>\n" 8933 9484 " Enable tests matching the given pattern.\n" … … 9154 9705 } 9155 9706 9707 if (fSsePcmpxstrx) 9708 { 9709 const char *pszDataFileFmtCmp = fCommonData ? "tstIEMAImplDataSsePcmpxstrx-%s.bin" : pszBitBucket; 9710 9711 RTEXITCODE rcExit = SseComparePcmpistriGenerate(pszDataFileFmtCmp, cTests); 9712 if (rcExit == RTEXITCODE_SUCCESS) 9713 rcExit = SseComparePcmpistrmGenerate(pszDataFileFmtCmp, cTests); 9714 if (rcExit == RTEXITCODE_SUCCESS) 9715 rcExit = SseComparePcmpestriGenerate(pszDataFileFmtCmp, cTests); 9716 if (rcExit == RTEXITCODE_SUCCESS) 9717 rcExit = SseComparePcmpestrmGenerate(pszDataFileFmtCmp, cTests); 9718 if (rcExit != RTEXITCODE_SUCCESS) 9719 return rcExit; 9720 } 9721 9156 9722 return RTEXITCODE_SUCCESS; 9157 9723 #else … … 9277 9843 SseConvertMmI32XmmR32Test(); 9278 9844 } 9845 9846 if (fSsePcmpxstrx) 9847 { 9848 SseComparePcmpistriTest(); 9849 SseComparePcmpistrmTest(); 9850 SseComparePcmpestriTest(); 9851 SseComparePcmpestrmTest(); 9852 } 9279 9853 } 9280 9854 return RTTestSummaryAndDestroy(g_hTest); -
trunk/src/VBox/VMM/testcase/tstIEMAImpl.h
r98103 r98822 517 517 RTUINT64U OutVal; 518 518 } SSE_CONVERT_MM_R32_TEST_T; 519 520 typedef struct SSE_PCMPISTRI_TEST_T 521 { 522 X86XMMREG InVal1; 523 X86XMMREG InVal2; 524 uint32_t u32EcxOut; 525 uint32_t fEFlagsIn; 526 uint32_t fEFlagsOut; 527 uint8_t bImm; 528 } SSE_PCMPISTRI_TEST_T; 529 530 typedef struct SSE_PCMPESTRI_TEST_T 531 { 532 X86XMMREG InVal1; 533 X86XMMREG InVal2; 534 uint64_t u64Rax; 535 uint64_t u64Rdx; 536 uint32_t u32EcxOut; 537 uint32_t fEFlagsIn; 538 uint32_t fEFlagsOut; 539 uint8_t bImm; 540 } SSE_PCMPESTRI_TEST_T; 541 542 typedef struct SSE_PCMPISTRM_TEST_T 543 { 544 X86XMMREG InVal1; 545 X86XMMREG InVal2; 546 X86XMMREG OutVal; 547 uint32_t fEFlagsIn; 548 uint32_t fEFlagsOut; 549 uint8_t bImm; 550 } SSE_PCMPISTRM_TEST_T; 551 552 typedef struct SSE_PCMPESTRM_TEST_T 553 { 554 X86XMMREG InVal1; 555 X86XMMREG InVal2; 556 X86XMMREG OutVal; 557 uint64_t u64Rax; 558 uint64_t u64Rdx; 559 uint32_t fEFlagsIn; 560 uint32_t fEFlagsOut; 561 uint8_t bImm; 562 } SSE_PCMPESTRM_TEST_T; 519 563 520 564 /** @} */ … … 986 1030 TSTIEM_DECLARE_TEST_ARRAY_BIN(SseConvert, SSE_CONVERT_MM_R32_TEST_T, cvttps2pi_u128 ); 987 1031 1032 TSTIEM_DECLARE_TEST_ARRAY_BIN(SsePcmpxstrx, SSE_PCMPISTRI_TEST_T, pcmpistri_u128 ); 1033 TSTIEM_DECLARE_TEST_ARRAY_BIN(SsePcmpxstrx, SSE_PCMPESTRI_TEST_T, pcmpestri_u128 ); 1034 TSTIEM_DECLARE_TEST_ARRAY_BIN(SsePcmpxstrx, SSE_PCMPISTRM_TEST_T, pcmpistrm_u128 ); 1035 TSTIEM_DECLARE_TEST_ARRAY_BIN(SsePcmpxstrx, SSE_PCMPESTRM_TEST_T, pcmpestrm_u128 ); 1036 988 1037 RT_C_DECLS_END 989 1038 -
trunk/src/VBox/VMM/testcase/tstIEMAImplDataSseBinary.S
r98103 r98822 151 151 IEM_TEST_DATA cvtps2pi_u128, "tstIEMAImplDataSseConvert-cvtps2pi_u128.bin" 152 152 IEM_TEST_DATA cvttps2pi_u128, "tstIEMAImplDataSseConvert-cvttps2pi_u128.bin" 153 154 IEM_TEST_DATA pcmpistri_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpistri_u128.bin" 155 IEM_TEST_DATA pcmpistrm_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpistrm_u128.bin" 156 IEM_TEST_DATA pcmpestri_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpestri_u128.bin" 157 IEM_TEST_DATA pcmpestrm_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpestrm_u128.bin" -
trunk/src/VBox/VMM/testcase/tstIEMAImplDataSseBinary.asm
r98103 r98822 149 149 IEM_TEST_DATA cvtps2pi_u128, "tstIEMAImplDataSseConvert-cvtps2pi_u128.bin" 150 150 IEM_TEST_DATA cvttps2pi_u128, "tstIEMAImplDataSseConvert-cvttps2pi_u128.bin" 151 152 IEM_TEST_DATA pcmpistri_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpistri_u128.bin" 153 IEM_TEST_DATA pcmpistrm_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpistrm_u128.bin" 154 IEM_TEST_DATA pcmpestri_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpestri_u128.bin" 155 IEM_TEST_DATA pcmpestrm_u128, "tstIEMAImplDataSsePcmpxstrx-pcmpestrm_u128.bin"
Note:
See TracChangeset
for help on using the changeset viewer.