]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Tests for 16/32 bit byte reversed loads and stores.
authorJulian Seward <jseward@acm.org>
Mon, 8 May 2006 12:08:49 +0000 (12:08 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 8 May 2006 12:08:49 +0000 (12:08 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5887

none/tests/ppc32/Makefile.am
none/tests/ppc32/ldstrev.c [new file with mode: 0644]
none/tests/ppc32/ldstrev.stderr.exp [new file with mode: 0644]
none/tests/ppc32/ldstrev.stdout.exp [new file with mode: 0644]
none/tests/ppc32/ldstrev.vgtest [new file with mode: 0644]

index 3fcfdb24cb5f8598f5eac7a535a2bb450e3a0b8f..ba028f32e272e3950ac0a8f751edfc65fecc9c84 100644 (file)
@@ -2,6 +2,7 @@
 noinst_SCRIPTS = filter_stderr
 
 EXTRA_DIST = $(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 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        xlc_dbl_u32.stderr.exp xlc_dbl_u32.stdout.exp xlc_dbl_u32.vgtest
 
 check_PROGRAMS = \
-       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
 
 AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include \
                @FLAG_M32@
diff --git a/none/tests/ppc32/ldstrev.c b/none/tests/ppc32/ldstrev.c
new file mode 100644 (file)
index 0000000..b29ed6e
--- /dev/null
@@ -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
+    : "=b" (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
+    : "=b" (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
+    : "=b" (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
+    : "=b" (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" 
+  );
+}
+
+void write16le ( void* a, UInt data )
+{
+  __asm volatile(
+    "  sthbrx %0,0,%1\n"
+    :
+    : "b" (data), "b" (a)
+    : "memory" 
+  );
+}
+
+void write32be ( void* a, UInt data )
+{
+  __asm volatile(
+    "  stwx %0,0,%1\n"
+    :
+    : "b" (data), "b" (a)
+    : "memory" 
+  );
+}
+
+void write32le ( void* a, UInt data )
+{
+  __asm volatile(
+    "  stwbrx %0,0,%1\n"
+    :
+    : "b" (data), "b" (a)
+    : "memory" 
+  );
+}
+
+int main ( void )
+{
+   UInt foo = 0x12345678;  
+   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 = 0x12345678; write16be( &foo, 0xABCD );
+   printf("st be16 0x%08x\n", foo);
+
+   foo = 0x12345678; write16le( &foo, 0xABCD );
+   printf("st le16 0x%08x\n", foo);
+
+   foo = 0x12345678; write32be( &foo, 0xABCD1425 );
+   printf("st be32 0x%08x\n", foo);
+
+   foo = 0x12345678; write32le( &foo, 0xABCD1425 );
+   printf("st le32 0x%08x\n", foo);
+
+   return 0;
+}
diff --git a/none/tests/ppc32/ldstrev.stderr.exp b/none/tests/ppc32/ldstrev.stderr.exp
new file mode 100644 (file)
index 0000000..139597f
--- /dev/null
@@ -0,0 +1,2 @@
+
+
diff --git a/none/tests/ppc32/ldstrev.stdout.exp b/none/tests/ppc32/ldstrev.stdout.exp
new file mode 100644 (file)
index 0000000..2e07991
--- /dev/null
@@ -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
diff --git a/none/tests/ppc32/ldstrev.vgtest b/none/tests/ppc32/ldstrev.vgtest
new file mode 100644 (file)
index 0000000..0a2dff4
--- /dev/null
@@ -0,0 +1 @@
+prog: ldstrev