|
From: <sv...@va...> - 2006-03-01 22:36:54
|
Author: sewardj
Date: 2006-03-01 22:36:49 +0000 (Wed, 01 Mar 2006)
New Revision: 5705
Log:
A simple test of m{f,t}ocrf.
Added:
trunk/none/tests/ppc32/mftocrf.c
trunk/none/tests/ppc32/mftocrf.stderr.exp
trunk/none/tests/ppc32/mftocrf.stdout.exp
trunk/none/tests/ppc32/mftocrf.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-02-28 13:12:04 UTC (rev 5704)
+++ trunk/none/tests/ppc32/Makefile.am 2006-03-01 22:36:49 UTC (rev 5705)
@@ -6,6 +6,7 @@
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 \
+ mftocrf.stderr.exp mftocrf.stdout.exp mftocrf.vgtest \
test_fx.stderr.exp test_fx.stdout.exp test_fx.vgtest \
test_gx.stderr.exp test_gx.stdout.exp test_gx.vgtest \
testVMX.stderr.exp testVMX.stdout.exp testVMX.vgtest \
@@ -13,7 +14,7 @@
xlc_dbl_u32.stderr.exp xlc_dbl_u32.stdout.exp xlc_dbl_u32.vgtest
=20
check_PROGRAMS =3D \
- lsw jm-insns test_fx test_gx testVMX twi xlc_dbl_u32
+ lsw jm-insns mftocrf 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/mftocrf.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/mftocrf.c (rev 0)
+++ trunk/none/tests/ppc32/mftocrf.c 2006-03-01 22:36:49 UTC (rev 5705)
@@ -0,0 +1,66 @@
+
+#include <stdio.h>
+
+static
+int try_mtocrf ( int x )
+{
+ int base =3D 0x31415927;
+ int res;
+
+ /* pre-set CR */
+ __asm__ __volatile__(
+ "mtcr %0"
+ : /*w*/ : /*r*/ "b"(base) : /*trash*/"cc" );
+
+ /* do it */
+ __asm__ __volatile__(
+ "mtocrf 4, %0"
+ : /*w*/ : /*r*/ "b"(x) : /*trash*/"cc" );
+
+ /* get CR */
+ __asm__ __volatile__(
+ "mfcr %0"
+ : /*w*/"=3Db"(res) : /*r*/ );
+
+ return res;
+}
+
+static
+int try_mfocrf ( int x )=20
+{
+ int res;
+ /* CR =3D x */
+ __asm__ __volatile__(
+ "mtcr %0"
+ : /*w*/ : /*r*/ "b"(x) : /*trash*/"cc" );
+
+ /* do it */
+ __asm__ __volatile__(
+ "li %0,0\n\t"
+ "mfocrf %0,64"
+ : /*w*/"=3Db"(res) : /*r*/ );
+
+ return res;
+}
+
+/* This is a bit of a kludge since mfocrf reads the spec'd CR field,
+ but the remaining returned bits are undefined. It seems like on
+ MPC7447A (Apple Mac Mini) mfocrf just reads the entire CR, which is
+ an acceptable implementation, but is not necessarily what other
+ implementations are going to do. */
+
+int main ( void )
+{
+ int i, j;
+ for (i =3D 0; i < 32; i++) {
+ printf("0x%08x\n", try_mtocrf( 1<<i ));
+ }
+ printf("\n");
+ j =3D 1;
+ for (i =3D 0; i < 32; i++) {
+ printf("0x%08x\n", try_mfocrf( j ));
+ j *=3D 3;
+ }
+
+ return 0;
+}
Added: trunk/none/tests/ppc32/mftocrf.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/mftocrf.stderr.exp (re=
v 0)
+++ trunk/none/tests/ppc32/mftocrf.stderr.exp 2006-03-01 22:36:49 UTC (re=
v 5705)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/ppc32/mftocrf.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/mftocrf.stdout.exp (re=
v 0)
+++ trunk/none/tests/ppc32/mftocrf.stdout.exp 2006-03-01 22:36:49 UTC (re=
v 5705)
@@ -0,0 +1,65 @@
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415127
+0x31415227
+0x31415427
+0x31415827
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+0x31415027
+
+0x00000001
+0x00000003
+0x00000009
+0x0000001b
+0x00000051
+0x000000f3
+0x000002d9
+0x0000088b
+0x000019a1
+0x00004ce3
+0x0000e6a9
+0x0002b3fb
+0x00081bf1
+0x001853d3
+0x0048fb79
+0x00daf26b
+0x0290d741
+0x07b285c3
+0x17179149
+0x4546b3db
+0xcfd41b91
+0x6f7c52b3
+0x4e74f819
+0xeb5ee84b
+0xc21cb8e1
+0x46562aa3
+0xd3027fe9
+0x79077fbb
+0x6b167f31
+0x41437d93
+0xc3ca78b9
+0x4b5f6a2b
Added: trunk/none/tests/ppc32/mftocrf.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/mftocrf.vgtest (rev 0)
+++ trunk/none/tests/ppc32/mftocrf.vgtest 2006-03-01 22:36:49 UTC (rev 57=
05)
@@ -0,0 +1 @@
+prog: mftocrf
|