From: Carlos O'Donell <carlos@baldric.uwo.ca>
To: John David Anglin <dave@hiauly3.hia.nrc.ca>
Cc: parisc-linux@lists.parisc-linux.org, dave.anglin@nrc-cnrc.gc.ca,
Matthew Wilcox <willy@debian.org>
Subject: Re: [parisc-linux] Re: [glibc] fixing delayed exceptions in hppa
Date: Sat, 30 Aug 2003 12:37:33 -0400 [thread overview]
Message-ID: <20030830163732.GG5194@systemhalted> (raw)
In-Reply-To: <200308231612.MAA21233@hiauly3.hia.nrc.ca>
>
> Yes. If you follow the thread that I sent you, Jim Hull comments on
> this and offers a rewrite of the sentence that you quoted. I believe
> that referencing memory is important as this makes the operation visible
> to another processor. A register->register operation doesn't do this.
>
I implemented and tested 3 versions, fcpy doesn't work on my c3k, but
the fstd and fldd does. Any recommendations on which to take. I'm
tempted to leave all this in and send the patch like this upstream, so I
don't forget what the other versions looked like :)
Comments welcome.
c.
diff -u -p -r1.4 fraiseexcpt.c
--- libc/sysdeps/hppa/fpu/fraiseexcpt.c 10 Sep 2002 01:26:37 -0000 1.4
+++ libc/sysdeps/hppa/fpu/fraiseexcpt.c 30 Aug 2003 16:35:48 -0000
@@ -22,9 +22,27 @@
#include <float.h>
#include <math.h>
+/* We implement three methods for flushing delayed exceptions. The first
+ is an interlocked register copy with the destination register of the
+ trapping insn. This method is not recommended, and may not work in all
+ situations. The last two, either loading or storing a value from memory
+ into the destination register of the trapping insn will work, here we
+ choose to store the value to memory.
+
+ Please see section 10,
+ page 10-5 "Delayed Trapping" in the PA-RISC 2.0 Architecture manual */
+
+#undef BARRIER_FCPY
+#define BARRIER_FSTD
+#undef BARRIER_FLDD
+
int
feraiseexcept (int excepts)
{
+ /* Provides a place to fake our write for flushing the delayed trap */
+ double dmem = 0;
+ double * pmem = &dmem;
+
/* Raise exceptions represented by EXCEPTS. But we must raise only one
signal at a time. It is important that if the overflow/underflow
exception and the divide by zero exception are given at the same
@@ -33,26 +51,49 @@ feraiseexcept (int excepts)
/* We do these bits in assembly to be certain GCC doesn't optimize
away something important, and so we can force delayed traps to
- occur. */
-
- /* FIXME: These all need verification! */
+ occur. */
/* First: invalid exception. */
if (excepts & FE_INVALID)
{
/* One example of a invalid operation is 0 * Infinity. */
double d = HUGE_VAL;
- __asm__ __volatile__ ("fmpy,dbl %1,%%fr0,%0\n\t"
- /* FIXME: is this a proper trap barrier? */
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d));
+ __asm__ __volatile__ (
+ " fmpy,dbl %0,%%fr0,%0\n"
+#ifdef BARRIER_FCPY
+ " fcpy,dbl %0,%1"
+ : "+f" (d), "=f" (dmem)
+#endif
+#ifdef BARRIER_FSTD
+ " fstd,dbl %0,%1"
+ : "+f" (d), "=m" (*pmem)
+#endif
+#ifdef BARRIER_FLDD
+ " fldd,dbl 0(%%sr0,%%sp),%0"
+ : "+f" (d)
+#endif
+ );
}
/* Next: division by zero. */
if (excepts & FE_DIVBYZERO)
{
double d = 1.0;
- __asm__ __volatile__ ("fdiv,dbl %1,%%fr0,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d));
+ __asm__ __volatile__ (
+ " fdiv,dbl %0,%%fr0,%0\n"
+#ifdef BARRIER_FCPY
+ " fcpy,dbl %0,%1"
+ : "+f" (d), "=f" (dmem)
+#endif
+#ifdef BARRIER_FSTD
+ " fstd,dbl %0,%1"
+ : "+f" (d), "=m" (*pmem)
+#endif
+#ifdef BARRIER_FLDD
+ " fldd,dbl 0(%%sr0,%%sp),%0"
+ : "+f" (d)
+#endif
+ );
}
/* Next: overflow. */
@@ -61,8 +102,21 @@ feraiseexcept (int excepts)
{
double d = DBL_MAX;
- __asm__ __volatile__ ("fmpy,dbl %1,%1,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d));
+ __asm__ __volatile__ (
+ " fmpy,dbl %0,%0,%0\n"
+#ifdef BARRIER_FCPY
+ " fcpy,dbl %0,%1"
+ : "+f" (d), "=f" (dmem)
+#endif
+#ifdef BARRIER_FSTD
+ " fstd,dbl %0,%1"
+ : "+f" (d), "=m" (*pmem)
+#endif
+#ifdef BARRIER_FLDD
+ " fldd,dbl 0(%%sr0,%%sp),%0"
+ : "+f" (d)
+#endif
+ );
}
/* Next: underflow. */
@@ -71,8 +125,23 @@ feraiseexcept (int excepts)
double d = DBL_MIN;
double e = 69.69;
- __asm__ __volatile__ ("fdiv,dbl %1,%2,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d), "f" (e));
+ __asm__ __volatile__ (
+#ifdef BARRIER_FCPY
+ " fdiv,dbl %0,%2,%0\n"
+ " fcpy,dbl %0,%1"
+ : "+f" (d), "=f" (dmem) : "f" (e)
+#endif
+#ifdef BARRIER_FSTD
+ " fdiv,dbl %0,%2,%0\n"
+ " fstd,dbl %0,%1"
+ : "+f" (d), "=m" (*pmem) : "f" (e)
+#endif
+#ifdef BARRIER_FLDD
+ " fdiv,dbl %0,%1,%0\n"
+ " fldd,dbl 0(%%sr0,%%sp),%0"
+ : "+f" (d) : "f" (e)
+#endif
+ );
}
/* Last: inexact. */
@@ -81,8 +150,23 @@ feraiseexcept (int excepts)
double d = 1.0;
double e = M_PI;
- __asm__ __volatile__ ("fdiv,dbl %1,%2,%0\n\t"
- "fcpy,dbl %%fr0,%%fr0" : "=f" (d) : "0" (d), "f" (e));
+ __asm__ __volatile__ (
+#ifdef BARRIER_FCPY
+ " fdiv,dbl %0,%2,%0\n"
+ " fcpy,dbl %0,%1"
+ : "+f" (d), "=f" (dmem) : "f" (e)
+#endif
+#ifdef BARRIER_FSTD
+ " fdiv,dbl %0,%2,%0\n"
+ " fstd,dbl %0,%1"
+ : "+f" (d), "=m" (*pmem) : "f" (e)
+#endif
+#ifdef BARRIER_FLDD
+ " fdiv,dbl %0,%1,%0\n"
+ " fldd,dbl 0(%%sr0,%%sp),%0"
+ : "+f" (d) : "f" (e)
+#endif
+ );
}
/* Success. */
next prev parent reply other threads:[~2003-08-30 16:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-22 1:39 [parisc-linux] [glibc] fixing delayed exceptions in hppa Carlos O'Donell
2003-08-22 2:42 ` Matthew Wilcox
2003-08-22 3:04 ` [parisc-linux] " John David Anglin
2003-08-22 14:46 ` Carlos O'Donell
2003-08-22 20:24 ` John David Anglin
2003-08-23 5:55 ` Carlos O'Donell
2003-08-23 16:12 ` John David Anglin
2003-08-30 16:37 ` Carlos O'Donell [this message]
2003-08-30 22:54 ` John David Anglin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030830163732.GG5194@systemhalted \
--to=carlos@baldric.uwo.ca \
--cc=dave.anglin@nrc-cnrc.gc.ca \
--cc=dave@hiauly3.hia.nrc.ca \
--cc=parisc-linux@lists.parisc-linux.org \
--cc=willy@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.