|
From: <sv...@va...> - 2006-01-29 17:09:04
|
Author: sewardj
Date: 2006-01-29 17:08:58 +0000 (Sun, 29 Jan 2006)
New Revision: 5601
Log:
Add test cases for soem FX (general-purpose) and GX (graphics) optional i=
nsns.
Added:
trunk/none/tests/ppc32/test_fx.c
trunk/none/tests/ppc32/test_gx.c
Added: trunk/none/tests/ppc32/test_fx.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/test_fx.c (rev 0)
+++ trunk/none/tests/ppc32/test_fx.c 2006-01-29 17:08:58 UTC (rev 5601)
@@ -0,0 +1,86 @@
+
+#include <stdio.h>
+#include <malloc.h>
+
+double do_fsqrt ( double x )
+{
+ double block[2];
+ block[0] =3D x;
+ __asm__ __volatile__(
+ "lfd %%f1, 0(%0)\n\t"
+ "fsqrt %%f1,%%f1\n\t"
+ "stfd %%f1, 8(%0)"
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/ "memory", "fr1"
+ );
+ return block[1];
+}
+
+double do_fsqrts ( double x )
+{
+ double block[2];
+ block[0] =3D x;
+ __asm__ __volatile__(
+ "lfd %%f1, 0(%0)\n\t"
+ "fsqrts %%f1,%%f1\n\t"
+ "stfd %%f1, 8(%0)"
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/ "memory", "fr1"
+ );
+ return block[1];
+}
+
+////////////////////////////////////////////////////////////
+
+void do_one ( char* name,=20
+ double(*f)(double),=20
+ double* args, int nargs,=20
+ char* argfmt, char* resfmt )
+{
+ int i;
+ double a, r;
+ printf("\n");
+
+ for (i =3D 0; i < nargs; i++) {
+ a =3D args[i];
+ r =3D f(a);
+ printf("%s ", name);
+ printf(argfmt, a);
+ printf(" -> ");
+ printf(resfmt, r);
+ printf("\n");
+ }
+}
+
+int main ( void )
+{
+ int nargs =3D 19;
+ double* args =3D malloc(nargs * sizeof(double));
+ args[0] =3D 0.0;
+ args[1] =3D 1.0 / 0.0; // inf
+ args[2] =3D -args[1]; // -inf
+ args[3] =3D args[2]/args[2]; // nan
+ args[4] =3D -args[3]; // -nan
+ args[5] =3D -5e100;
+ args[6] =3D -5e20;
+ args[7] =3D -501.0;
+ args[8] =3D -6.0;
+ args[9] =3D -1.0;
+ args[10] =3D -2e-20;
+ args[11] =3D -2e-200;
+ args[12] =3D 2e-200;
+ args[13] =3D 2e-20;
+ args[14] =3D 1.0;
+ args[15] =3D 6.0;
+ args[16] =3D 501.0;
+ args[17] =3D 5e20;
+ args[18] =3D 5e100;
+
+ do_one( "fsqrt", do_fsqrt, args, nargs, "%e", "%20.14e");
+ do_one( "fsqrts", do_fsqrts, args, nargs, "%e", "%e");
+
+ free(args);
+ return 0;
+}
Added: trunk/none/tests/ppc32/test_gx.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/test_gx.c (rev 0)
+++ trunk/none/tests/ppc32/test_gx.c 2006-01-29 17:08:58 UTC (rev 5601)
@@ -0,0 +1,124 @@
+
+#include <stdio.h>
+#include <malloc.h>
+
+/* This is a Marie Celeste instruction. Some IBM documents think it
+ exists, others don't. The same appears to be true for
+ implementations - ppc970 doesn't think it exists, but POWER5
+ does. */
+double do_fre ( double x )
+{
+ double block[2];
+ block[0] =3D x;
+ __asm__ __volatile__(
+ "lfd %%f1, 0(%0)\n\t"
+ ".long 0xfc200830\n\t" /* =3D=3D fre %%f1,%%f1 */
+ "stfd %%f1, 8(%0)"
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/ "memory", "fr1"
+ );
+ return block[1];
+}
+
+double do_fres ( double x )
+{
+ double block[2];
+ block[0] =3D x;
+ __asm__ __volatile__(
+ "lfd %%f1, 0(%0)\n\t"
+ "fres %%f1,%%f1\n\t"
+ "stfd %%f1, 8(%0)"
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/ "memory", "fr1"
+ );
+ return block[1];
+}
+
+double do_frsqrte ( double x )
+{
+ double block[2];
+ block[0] =3D x;
+ __asm__ __volatile__(
+ "lfd %%f1, 0(%0)\n\t"
+ "frsqrte %%f1,%%f1\n\t"
+ "stfd %%f1, 8(%0)"
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/ "memory", "fr1"
+ );
+ return block[1];
+}
+
+/* Another Marie Celeste insn. */
+double do_frsqrtes ( double x )
+{
+ double block[2];
+ block[0] =3D x;
+ __asm__ __volatile__(
+ "lfd %%f1, 0(%0)\n\t"
+ ".long 0xec200834\n\t" /* =3D=3D frsqrtes %%f1,%%f1 */
+ "stfd %%f1, 8(%0)"
+ : /*out*/
+ : /*in*/ "b" (&block[0])
+ : /*trash*/ "memory", "fr1"
+ );
+ return block[1];
+}
+
+////////////////////////////////////////////////////////////
+
+void do_one ( char* name,=20
+ double(*f)(double),=20
+ double* args, int nargs,=20
+ char* argfmt, char* resfmt )
+{
+ int i;
+ double a, r;
+ printf("\n");
+
+ for (i =3D 0; i < nargs; i++) {
+ a =3D args[i];
+ r =3D f(a);
+ printf("%s ", name);
+ printf(argfmt, a);
+ printf(" -> ");
+ printf(resfmt, r);
+ printf("\n");
+ }
+}
+
+int main ( void )
+{
+ int nargs =3D 19;
+ double* args =3D malloc(nargs * sizeof(double));
+ args[0] =3D 0.0;
+ args[1] =3D 1.0 / 0.0; // inf
+ args[2] =3D -args[1]; // -inf
+ args[3] =3D args[2]/args[2]; // nan
+ args[4] =3D -args[3]; // -nan
+ args[5] =3D -5e100;
+ args[6] =3D -5e20;
+ args[7] =3D -501.0;
+ args[8] =3D -6.0;
+ args[9] =3D -1.0;
+ args[10] =3D -2e-20;
+ args[11] =3D -2e-200;
+ args[12] =3D 2e-200;
+ args[13] =3D 2e-20;
+ args[14] =3D 1.0;
+ args[15] =3D 6.0;
+ args[16] =3D 501.0;
+ args[17] =3D 5e20;
+ args[18] =3D 5e100;
+
+ do_one( "fre", do_fre, args, nargs, "%e", "%e");
+ do_one( "fres", do_fres, args, nargs, "%e", "%e");
+
+ do_one( "frsqrte", do_frsqrte, args, nargs, "%e", "%e");
+ do_one( "frsqrtes", do_frsqrtes, args, nargs, "%e", "%e");
+
+ free(args);
+ return 0;
+}
|