From 0e343fea865adf6575fbca5aa1ee2926abff0e6e Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Wed, 10 Jan 2007 04:57:27 +0000 Subject: [PATCH] Regtest for FXSAVE on amd64. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6499 --- memcheck/tests/amd64/Makefile.am | 3 +- memcheck/tests/amd64/fxsave-amd64.c | 79 ++++++++++++++++++++ memcheck/tests/amd64/fxsave-amd64.stderr.exp | 0 memcheck/tests/amd64/fxsave-amd64.stdout.exp | 32 ++++++++ memcheck/tests/amd64/fxsave-amd64.vgtest | 2 + 5 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 memcheck/tests/amd64/fxsave-amd64.c create mode 100644 memcheck/tests/amd64/fxsave-amd64.stderr.exp create mode 100644 memcheck/tests/amd64/fxsave-amd64.stdout.exp create mode 100644 memcheck/tests/amd64/fxsave-amd64.vgtest diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am index a8bf7047c3..b8452b12ff 100644 --- a/memcheck/tests/amd64/Makefile.am +++ b/memcheck/tests/amd64/Makefile.am @@ -11,10 +11,11 @@ EXTRA_DIST = $(noinst_SCRIPTS) \ bt_everything.stderr.exp bt_everything.stdout.exp \ bt_everything.vgtest \ bug132146.vgtest bug132146.stderr.exp bug132146.stdout.exp \ + fxsave-amd64.vgtest fxsave-amd64.stdout.exp fxsave-amd64.stderr.exp \ more_x87_fp.stderr.exp more_x87_fp.stdout.exp more_x87_fp.vgtest \ sse_memory.stderr.exp sse_memory.stdout.exp sse_memory.vgtest -check_PROGRAMS = bt_everything bug132146 more_x87_fp sse_memory +check_PROGRAMS = bt_everything bug132146 fxsave-amd64 more_x87_fp sse_memory AM_CPPFLAGS = -I$(top_srcdir)/include AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include diff --git a/memcheck/tests/amd64/fxsave-amd64.c b/memcheck/tests/amd64/fxsave-amd64.c new file mode 100644 index 0000000000..b83efe8d8a --- /dev/null +++ b/memcheck/tests/amd64/fxsave-amd64.c @@ -0,0 +1,79 @@ + +#include +#include + +const unsigned int vec0[4] + = { 0x12345678, 0x11223344, 0x55667788, 0x87654321 }; + +const unsigned int vec1[4] + = { 0xABCDEF01, 0xAABBCCDD, 0xEEFF0011, 0x10FEDCBA }; + +/* set up the FP and SSE state, and then dump it. */ +void do_fxsave ( void* p ) +{ + asm __volatile__("finit"); + asm __volatile__("fldpi"); + asm __volatile__("fld1"); + asm __volatile__("fldln2"); + asm __volatile__("fldlg2"); + asm __volatile__("fld %st(3)"); + asm __volatile__("fld %st(3)"); + asm __volatile__("fld1"); + asm __volatile__("movups (%0), %%xmm0" : : "r"(&vec0[0]) : "xmm0" ); + asm __volatile__("movups (%0), %%xmm1" : : "r"(&vec1[0]) : "xmm1" ); + asm __volatile__("xorps %xmm2, %xmm2"); + asm __volatile__("movaps %xmm0, %xmm3"); + asm __volatile__("movaps %xmm1, %xmm4"); + asm __volatile__("movaps %xmm2, %xmm5"); + asm __volatile__("movaps %xmm0, %xmm6"); + asm __volatile__("movaps %xmm1, %xmm7"); + asm __volatile__("movaps %xmm1, %xmm8"); + asm __volatile__("movaps %xmm2, %xmm9"); + asm __volatile__("movaps %xmm0, %xmm10"); + asm __volatile__("movaps %xmm1, %xmm11"); + asm __volatile__("movaps %xmm1, %xmm12"); + asm __volatile__("movaps %xmm2, %xmm13"); + asm __volatile__("movaps %xmm0, %xmm14"); + asm __volatile__("movaps %xmm1, %xmm15"); + asm __volatile__("fxsave (%0)" : : "r" (p) : "memory" ); +} + +int isFPLsbs ( int i ) +{ + int q; + q = 32; if (i == q || i == q+1) return 1; + q = 48; if (i == q || i == q+1) return 1; + q = 64; if (i == q || i == q+1) return 1; + q = 80; if (i == q || i == q+1) return 1; + q = 96; if (i == q || i == q+1) return 1; + q = 112; if (i == q || i == q+1) return 1; + q = 128; if (i == q || i == q+1) return 1; + q = 144; if (i == q || i == q+1) return 1; + return 0; +} + +int main ( int argc, char** argv ) +{ + int i, j; + unsigned char* buf = malloc(512); + int xx = 1; /* argc > 1; + printf("Re-run with any arg to suppress least-significant\n" + " 16 bits of FP numbers\n"); + */ + for (i = 0; i < 512; i++) + buf[i] = 0x55; + + do_fxsave(buf); + for (j = 0; j < 512; j++) { + i = (j & 0xFFF0) + (15 - (j & 0xF)); + if ((j % 16) == 0) + printf("%3d ", j); + if (xx && isFPLsbs(i)) + printf("xx "); + else + printf("%02x ", buf[i]); + if (j > 0 && ((j % 16) == 15)) + printf("\n"); + } + return 0; +} diff --git a/memcheck/tests/amd64/fxsave-amd64.stderr.exp b/memcheck/tests/amd64/fxsave-amd64.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/amd64/fxsave-amd64.stdout.exp b/memcheck/tests/amd64/fxsave-amd64.stdout.exp new file mode 100644 index 0000000000..1796d5b8ba --- /dev/null +++ b/memcheck/tests/amd64/fxsave-amd64.stdout.exp @@ -0,0 +1,32 @@ + 0 00 00 00 00 00 00 00 00 00 00 00 fe 08 00 03 7f + 16 00 00 ff ff 00 00 1f 80 00 00 00 00 00 00 00 00 + 32 00 00 00 00 00 00 3f ff 80 00 00 00 00 00 xx xx + 48 00 00 00 00 00 00 3f ff 80 00 00 00 00 00 xx xx + 64 00 00 00 00 00 00 40 00 c9 0f da a2 21 68 xx xx + 80 00 00 00 00 00 00 3f fd 9a 20 9a 84 fb cf xx xx + 96 00 00 00 00 00 00 3f fe b1 72 17 f7 d1 cf xx xx +112 00 00 00 00 00 00 3f ff 80 00 00 00 00 00 xx xx +128 00 00 00 00 00 00 40 00 c9 0f da a2 21 68 xx xx +144 00 00 00 00 00 00 00 00 00 00 00 00 00 00 xx xx +160 87 65 43 21 55 66 77 88 11 22 33 44 12 34 56 78 +176 10 fe dc ba ee ff 00 11 aa bb cc dd ab cd ef 01 +192 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +208 87 65 43 21 55 66 77 88 11 22 33 44 12 34 56 78 +224 10 fe dc ba ee ff 00 11 aa bb cc dd ab cd ef 01 +240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +256 87 65 43 21 55 66 77 88 11 22 33 44 12 34 56 78 +272 10 fe dc ba ee ff 00 11 aa bb cc dd ab cd ef 01 +288 10 fe dc ba ee ff 00 11 aa bb cc dd ab cd ef 01 +304 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +320 87 65 43 21 55 66 77 88 11 22 33 44 12 34 56 78 +336 10 fe dc ba ee ff 00 11 aa bb cc dd ab cd ef 01 +352 10 fe dc ba ee ff 00 11 aa bb cc dd ab cd ef 01 +368 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +384 87 65 43 21 55 66 77 88 11 22 33 44 12 34 56 78 +400 10 fe dc ba ee ff 00 11 aa bb cc dd ab cd ef 01 +416 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 +432 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 +448 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 +464 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 +480 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 +496 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 diff --git a/memcheck/tests/amd64/fxsave-amd64.vgtest b/memcheck/tests/amd64/fxsave-amd64.vgtest new file mode 100644 index 0000000000..19f13f09fa --- /dev/null +++ b/memcheck/tests/amd64/fxsave-amd64.vgtest @@ -0,0 +1,2 @@ +prog: fxsave-amd64 +vgopts: -q -- 2.47.2