From 1e0aac8d52be23c76c9cc4a1b82474ad4d91e8dc Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Sat, 28 Jan 2006 17:08:23 +0000 Subject: [PATCH] Check lsw/stsw insns in 64-bit mode. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5599 --- none/tests/ppc64/Makefile.am | 5 +- none/tests/ppc64/lsw.c | 102 ++++++++++++++++++++++++++++++++ none/tests/ppc64/lsw.stderr.exp | 2 + none/tests/ppc64/lsw.stdout.exp | 54 +++++++++++++++++ none/tests/ppc64/lsw.vgtest | 1 + 5 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 none/tests/ppc64/lsw.c create mode 100644 none/tests/ppc64/lsw.stderr.exp create mode 100644 none/tests/ppc64/lsw.stdout.exp create mode 100644 none/tests/ppc64/lsw.vgtest diff --git a/none/tests/ppc64/Makefile.am b/none/tests/ppc64/Makefile.am index 792a1afe81..3b654a7784 100644 --- a/none/tests/ppc64/Makefile.am +++ b/none/tests/ppc64/Makefile.am @@ -4,10 +4,11 @@ noinst_SCRIPTS = filter_stderr EXTRA_DIST = $(noinst_SCRIPTS) \ jm-int.stderr.exp jm-int.stdout.exp jm-int.vgtest \ jm-fp.stderr.exp jm-fp.stdout.exp jm-fp.vgtest \ - jm-vmx.stderr.exp jm-vmx.stdout.exp jm-vmx.vgtest + jm-vmx.stderr.exp jm-vmx.stdout.exp jm-vmx.vgtest \ + lsw.stderr.exp lsw.stdout.exp lsw.vgtest check_PROGRAMS = \ - jm-insns + jm-insns lsw AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include \ @FLAG_M64@ diff --git a/none/tests/ppc64/lsw.c b/none/tests/ppc64/lsw.c new file mode 100644 index 0000000000..a0496dbefd --- /dev/null +++ b/none/tests/ppc64/lsw.c @@ -0,0 +1,102 @@ + +#include +#include +#include + +/* Apparently the "b" register constraint is like "r" except that it + disallows the use of r0, which means it is safe to use in places + where the appearance of r0 would cause a problem due to it being + read as zero. */ + +static void announce ( char* str ) +{ + printf("------ %s ------\n", str); +} + +int main ( void ) +{ + int i; + char* a1 = malloc(100); + char* a2 = malloc(100); + strcpy(a1,"here is a stringHERE IS A STRING"); + + announce("lswi n == 8 (fe special cased)"); + asm volatile("li 5,0\n\t" + "lswi 3,%0, 8\n\t" + "stw 3,0(%1)\n\t" + "stw 4,4(%1)\n\t" + "stw 5,8(%1)\n\t" + : : "b"(a1), "b"(a2) : "r3", "r4", "r5", + "cc", "memory" ); + printf("%s\n", a2); + for (i = 0; i < 12; i++) + printf("%d = 0x%2x\n", i, a2[i]); + printf("\n"); + + + announce("lswi n /= 8"); + asm volatile("lswi 3,%0, 9\n\t" + "stw 3,0(%1)\n\t" + "stw 4,4(%1)\n\t" + "stw 5,8(%1)\n\t" + : : "b"(a1), "b"(a2) : "r3", "r4", "r5", + "cc", "memory" ); + printf("%s\n", a2); + for (i = 0; i < 12; i++) + printf("%d = 0x%2x\n", i, a2[i]); + printf("\n"); + + + announce("lswx"); + free(a2); + a2 = malloc(100); + asm volatile("li 8, 11\n\t" + "mtxer 8\n\t" + "lswx 3,%0,%2\n\t" + "stw 3,0(%1)\n\t" + "stw 4,4(%1)\n\t" + "stw 5,8(%1)\n\t" + : : "b"(a1), "b"(a2), "b"(16) : "r3", "r4", "r5", "r8", + "cc", "memory" ); + printf("%s\n", a2); + for (i = 0; i < 12; i++) + printf("%d = 0x%2x\n", i, a2[i]); + printf("\n"); + + + announce("stswi n == 8 (fe special cased)"); + free(a2); + a2 = calloc(100,1); + asm volatile("lswi 3,%0, 19\n\t" + "stswi 3,%1, 8\n" + : : "b"(a1), "b"(a2) : "r3","r4","r5","r6","r7", + "cc", "memory" ); + printf("%s\n", a2); + printf("\n"); + + + announce("stswi n /= 8"); + free(a2); + a2 = calloc(100,1); + asm volatile("lswi 3,%0, 19\n\t" + "stswi 3,%1, 17\n" + : : "b"(a1), "b"(a2) : "r3","r4","r5","r6","r7", + "cc", "memory" ); + printf("%s\n", a2); + printf("\n"); + + + announce("stswx"); + free(a2); + a2 = calloc(100,1); + asm volatile("li 8, 11\n\t" + "mtxer 8\n\t" + "lswx 3,%0,%2\n\t" + "stswx 3,%1,%2\n\t" + : : "b"(a1), "b"(a2), "b"(16) : "r3", "r4", "r5", "r8", + "cc", "memory" ); + printf("%s\n", a2+16); + printf("\n"); + + return 0; +} diff --git a/none/tests/ppc64/lsw.stderr.exp b/none/tests/ppc64/lsw.stderr.exp new file mode 100644 index 0000000000..139597f9cb --- /dev/null +++ b/none/tests/ppc64/lsw.stderr.exp @@ -0,0 +1,2 @@ + + diff --git a/none/tests/ppc64/lsw.stdout.exp b/none/tests/ppc64/lsw.stdout.exp new file mode 100644 index 0000000000..1ecd857cef --- /dev/null +++ b/none/tests/ppc64/lsw.stdout.exp @@ -0,0 +1,54 @@ +------ lswi n == 8 (fe special cased) ------ +here is +0 = 0x68 +1 = 0x65 +2 = 0x72 +3 = 0x65 +4 = 0x20 +5 = 0x69 +6 = 0x73 +7 = 0x20 +8 = 0x 0 +9 = 0x 0 +10 = 0x 0 +11 = 0x 0 + +------ lswi n /= 8 ------ +here is a +0 = 0x68 +1 = 0x65 +2 = 0x72 +3 = 0x65 +4 = 0x20 +5 = 0x69 +6 = 0x73 +7 = 0x20 +8 = 0x61 +9 = 0x 0 +10 = 0x 0 +11 = 0x 0 + +------ lswx ------ +HERE IS A S +0 = 0x48 +1 = 0x45 +2 = 0x52 +3 = 0x45 +4 = 0x20 +5 = 0x49 +6 = 0x53 +7 = 0x20 +8 = 0x41 +9 = 0x20 +10 = 0x53 +11 = 0x 0 + +------ stswi n == 8 (fe special cased) ------ +here is + +------ stswi n /= 8 ------ +here is a stringH + +------ stswx ------ +HERE IS A S + diff --git a/none/tests/ppc64/lsw.vgtest b/none/tests/ppc64/lsw.vgtest new file mode 100644 index 0000000000..8039094961 --- /dev/null +++ b/none/tests/ppc64/lsw.vgtest @@ -0,0 +1 @@ +prog: lsw -- 2.47.3