Commit a4682cc20a68c59939552492590559e94b00a984

Authored by bellard
1 parent 839fa988

fxsr test


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1216 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 63 additions and 0 deletions
tests/test-i386.c
... ... @@ -1872,6 +1872,67 @@ void test_sse_comi(double a1, double b1)
1872 1872 r.l[0]);\
1873 1873 }
1874 1874  
  1875 +struct fpxstate {
  1876 + uint16_t fpuc;
  1877 + uint16_t fpus;
  1878 + uint16_t fptag;
  1879 + uint16_t fop;
  1880 + uint32_t fpuip;
  1881 + uint16_t cs_sel;
  1882 + uint16_t dummy0;
  1883 + uint32_t fpudp;
  1884 + uint16_t ds_sel;
  1885 + uint16_t dummy1;
  1886 + uint32_t mxcsr;
  1887 + uint32_t mxcsr_mask;
  1888 + uint8_t fpregs1[8 * 16];
  1889 + uint8_t xmm_regs[8 * 16];
  1890 + uint8_t dummy2[224];
  1891 +};
  1892 +
  1893 +static struct fpxstate fpx_state __attribute__((aligned(16)));
  1894 +static struct fpxstate fpx_state2 __attribute__((aligned(16)));
  1895 +
  1896 +void test_fxsave(void)
  1897 +{
  1898 + struct fpxstate *fp = &fpx_state;
  1899 + struct fpxstate *fp2 = &fpx_state2;
  1900 + int i;
  1901 + XMMReg a, b;
  1902 + a.q[0] = test_values[0][0];
  1903 + a.q[1] = test_values[0][1];
  1904 + b.q[0] = test_values[1][0];
  1905 + b.q[1] = test_values[1][1];
  1906 +
  1907 + asm("movdqa %2, %%xmm0\n"
  1908 + "movdqa %3, %%xmm7\n"
  1909 + " fld1\n"
  1910 + " fldpi\n"
  1911 + " fldln2\n"
  1912 + " fxsave %0\n"
  1913 + " fxrstor %0\n"
  1914 + " fxsave %1\n"
  1915 + " fninit\n"
  1916 + : "=m" (*(uint32_t *)fp2), "=m" (*(uint32_t *)fp)
  1917 + : "m" (a), "m" (b));
  1918 + printf("fpuc=%04x\n", fp->fpuc);
  1919 + printf("fpus=%04x\n", fp->fpus);
  1920 + printf("fptag=%04x\n", fp->fptag);
  1921 + for(i = 0; i < 3; i++) {
  1922 + printf("ST%d: %016llx %04x\n",
  1923 + i,
  1924 + *(uint64_t *)&fp->fpregs1[i * 16],
  1925 + *(uint16_t *)&fp->fpregs1[i * 16 + 8]);
  1926 + }
  1927 + printf("mxcsr=%08x\n", fp->mxcsr & 0x1f80);
  1928 + for(i = 0; i < 8; i++) {
  1929 + printf("xmm%d: %016llx%016llx\n",
  1930 + i,
  1931 + *(uint64_t *)&fp->xmm_regs[i * 16],
  1932 + *(uint64_t *)&fp->xmm_regs[i * 16 + 8]);
  1933 + }
  1934 +}
  1935 +
1875 1936 void test_sse(void)
1876 1937 {
1877 1938 XMMReg r, a, b;
... ... @@ -2098,6 +2159,7 @@ void test_sse(void)
2098 2159 #if 0
2099 2160 SSE_OP2(movshdup);
2100 2161 #endif
  2162 + asm volatile ("emms");
2101 2163 }
2102 2164  
2103 2165 #endif
... ... @@ -2134,6 +2196,7 @@ int main(int argc, char **argv)
2134 2196 test_enter();
2135 2197 #ifdef TEST_SSE
2136 2198 test_sse();
  2199 + test_fxsave();
2137 2200 #endif
2138 2201 return 0;
2139 2202 }
... ...