|
From: <sv...@va...> - 2006-05-09 01:24:26
|
Author: sewardj
Date: 2006-05-08 13:08:49 +0100 (Mon, 08 May 2006)
New Revision: 5887
Log:
Tests for 16/32 bit byte reversed loads and stores.
Added:
trunk/none/tests/ppc32/ldstrev.c
trunk/none/tests/ppc32/ldstrev.stderr.exp
trunk/none/tests/ppc32/ldstrev.stdout.exp
trunk/none/tests/ppc32/ldstrev.vgtest
Modified:
trunk/none/tests/ppc32/Makefile.am
Modified: trunk/none/tests/ppc32/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ppc32/Makefile.am 2006-05-08 11:58:06 UTC (rev 5886)
+++ trunk/none/tests/ppc32/Makefile.am 2006-05-08 12:08:49 UTC (rev 5887)
@@ -2,6 +2,7 @@
noinst_SCRIPTS =3D filter_stderr
=20
EXTRA_DIST =3D $(noinst_SCRIPTS) \
+ ldstrev.stderr.exp ldstrev.stdout.exp ldstrev.vgtest \
lsw.stderr.exp lsw.stdout.exp lsw.vgtest \
jm-int.stderr.exp jm-int.stdout.exp jm-int.vgtest \
jm-fp.stderr.exp jm-fp.stdout.exp jm-fp.vgtest \
@@ -15,7 +16,8 @@
xlc_dbl_u32.stderr.exp xlc_dbl_u32.stdout.exp xlc_dbl_u32.vgtest
=20
check_PROGRAMS =3D \
- lsw jm-insns mftocrf round test_fx test_gx testVMX twi xlc_dbl_u32
+ ldstrev lsw jm-insns mftocrf round test_fx test_gx testVMX \
+ twi xlc_dbl_u32
=20
AM_CFLAGS =3D $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/inc=
lude \
@FLAG_M32@
Added: trunk/none/tests/ppc32/ldstrev.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ppc32/ldstrev.c (rev 0)
+++ trunk/none/tests/ppc32/ldstrev.c 2006-05-08 12:08:49 UTC (rev 5887)
@@ -0,0 +1,116 @@
+
+#include <stdio.h>
+
+typedef unsigned int UInt;
+typedef unsigned short UShort;
+
+UInt read16le ( void* a )
+{
+ UInt res;
+ __asm volatile(
+ " lhbrx %0,0,%1 \n" // Get half word and reverse the=
bytes
+ : "=3Db" (res) // %0 - Output operand
+ : "b" (a) // %1 - Input operand
+ : "memory" // Consider memory clobberred for aliasing
+ );
+ return res;
+}
+
+UInt read16be ( void* a )
+{
+ UInt res;
+ __asm volatile(
+ " lhzx %0,0,%1 \n" // Get half word and reverse the =
bytes
+ : "=3Db" (res) // %0 - Output operand
+ : "b" (a) // %1 - Input operand
+ : "memory" // Consider memory clobberred for aliasing
+ );
+ return res;
+}
+
+UInt read32le ( void* a )
+{
+ UInt res;
+ __asm volatile(
+ " lwbrx %0,0,%1 \n" // Get half word and reverse the=
bytes
+ : "=3Db" (res) // %0 - Output operand
+ : "b" (a) // %1 - Input operand
+ : "memory" // Consider memory clobberred for aliasing
+ );
+ return res;
+}
+
+UInt read32be ( void* a )
+{
+ UInt res;
+ __asm volatile(
+ " lwzx %0,0,%1 \n" // Get half word and reverse the =
bytes
+ : "=3Db" (res) // %0 - Output operand
+ : "b" (a) // %1 - Input operand
+ : "memory" // Consider memory clobberred for aliasing
+ );
+ return res;
+}
+
+void write16be ( void* a, UInt data )
+{
+ __asm volatile(
+ " sthx %0,0,%1\n"
+ :
+ : "b" (data), "b" (a)
+ : "memory"=20
+ );
+}
+
+void write16le ( void* a, UInt data )
+{
+ __asm volatile(
+ " sthbrx %0,0,%1\n"
+ :
+ : "b" (data), "b" (a)
+ : "memory"=20
+ );
+}
+
+void write32be ( void* a, UInt data )
+{
+ __asm volatile(
+ " stwx %0,0,%1\n"
+ :
+ : "b" (data), "b" (a)
+ : "memory"=20
+ );
+}
+
+void write32le ( void* a, UInt data )
+{
+ __asm volatile(
+ " stwbrx %0,0,%1\n"
+ :
+ : "b" (data), "b" (a)
+ : "memory"=20
+ );
+}
+
+int main ( void )
+{
+ UInt foo =3D 0x12345678; =20
+ printf("ld be16 0x%08x\n", read16be( &foo ));
+ printf("ld le16 0x%08x\n", read16le( &foo ));
+ printf("ld be32 0x%08x\n", read32be( &foo ));
+ printf("ld le32 0x%08x\n", read32le( &foo ));
+
+ foo =3D 0x12345678; write16be( &foo, 0xABCD );
+ printf("st be16 0x%08x\n", foo);
+
+ foo =3D 0x12345678; write16le( &foo, 0xABCD );
+ printf("st le16 0x%08x\n", foo);
+
+ foo =3D 0x12345678; write32be( &foo, 0xABCD1425 );
+ printf("st be32 0x%08x\n", foo);
+
+ foo =3D 0x12345678; write32le( &foo, 0xABCD1425 );
+ printf("st le32 0x%08x\n", foo);
+
+ return 0;
+}
Added: trunk/none/tests/ppc32/ldstrev.stderr.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ppc32/ldstrev.stderr.exp (re=
v 0)
+++ trunk/none/tests/ppc32/ldstrev.stderr.exp 2006-05-08 12:08:49 UTC (re=
v 5887)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/ppc32/ldstrev.stdout.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ppc32/ldstrev.stdout.exp (re=
v 0)
+++ trunk/none/tests/ppc32/ldstrev.stdout.exp 2006-05-08 12:08:49 UTC (re=
v 5887)
@@ -0,0 +1,8 @@
+ld be16 0x00001234
+ld le16 0x00003412
+ld be32 0x12345678
+ld le32 0x78563412
+st be16 0xabcd5678
+st le16 0xcdab5678
+st be32 0xabcd1425
+st le32 0x2514cdab
Added: trunk/none/tests/ppc32/ldstrev.vgtest
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ppc32/ldstrev.vgtest (rev 0)
+++ trunk/none/tests/ppc32/ldstrev.vgtest 2006-05-08 12:08:49 UTC (rev 58=
87)
@@ -0,0 +1 @@
+prog: ldstrev
|