summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1998-12-04 10:52:48 +0000
committerdfr <dfr@FreeBSD.org>1998-12-04 10:52:48 +0000
commit8f01fff32f94dc39467983f7207be602213d0730 (patch)
tree008714999f57f4465bc9805f8d58777620fd1a81 /sys/powerpc
parent20107e8f4764aa3175f409771cda14a671f81324 (diff)
downloadFreeBSD-src-8f01fff32f94dc39467983f7207be602213d0730.zip
FreeBSD-src-8f01fff32f94dc39467983f7207be602213d0730.tar.gz
Implement 'software completion' for floating point arithmetic. On the
alpha, operations involving non-finite numbers or denormalised numbers or operations which should generate such numbers will cause an arithmetic exception. For programs which follow some strict code generation rules, the kernel trap handler can then 'complete' the operation by emulating the faulting instruction. To use software completion, a program must be compiled with the arguments '-mtrap-precision=i' and '-mfp-trap-mode=su' or '-mfp-trap-mode=sui'. Programs compiled in this way can use non-finite and denormalised numbers at the expense of slightly less efficient code generation of floating point instructions. Programs not compiled with these options will receive a SIGFPE signal when non-finite or denormalised numbers are used or generated. Reviewed by: John Polstra <jdp@polstra.com>
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/aim/vm_machdep.c14
-rw-r--r--sys/powerpc/powerpc/vm_machdep.c14
2 files changed, 26 insertions, 2 deletions
diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c
index 95a41d8..600819c 100644
--- a/sys/powerpc/aim/vm_machdep.c
+++ b/sys/powerpc/aim/vm_machdep.c
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $Id: vm_machdep.c,v 1.3 1998/07/12 16:30:58 dfr Exp $
+ * $Id: vm_machdep.c,v 1.4 1998/10/15 09:53:27 dfr Exp $
*/
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -79,6 +79,7 @@
#include <machine/clock.h>
#include <machine/cpu.h>
+#include <machine/fpu.h>
#include <machine/md_var.h>
#include <machine/prom.h>
@@ -147,6 +148,17 @@ cpu_fork(p1, p2)
p2->p_addr->u_pcb.pcb_hw.apcb_usp = alpha_pal_rdusp();
/*
+ * Set the floating point state.
+ */
+ if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) {
+ p2->p_addr->u_pcb.pcb_fp_control = (IEEE_TRAP_ENABLE_INV
+ | IEEE_TRAP_ENABLE_DZE
+ | IEEE_TRAP_ENABLE_OVF);
+ p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
+ | FPCR_INED | FPCR_UNFD);
+ }
+
+ /*
* Arrange for a non-local goto when the new process
* is started, to resume here, returning nonzero from setjmp.
*/
diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c
index 95a41d8..600819c 100644
--- a/sys/powerpc/powerpc/vm_machdep.c
+++ b/sys/powerpc/powerpc/vm_machdep.c
@@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $Id: vm_machdep.c,v 1.3 1998/07/12 16:30:58 dfr Exp $
+ * $Id: vm_machdep.c,v 1.4 1998/10/15 09:53:27 dfr Exp $
*/
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -79,6 +79,7 @@
#include <machine/clock.h>
#include <machine/cpu.h>
+#include <machine/fpu.h>
#include <machine/md_var.h>
#include <machine/prom.h>
@@ -147,6 +148,17 @@ cpu_fork(p1, p2)
p2->p_addr->u_pcb.pcb_hw.apcb_usp = alpha_pal_rdusp();
/*
+ * Set the floating point state.
+ */
+ if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) {
+ p2->p_addr->u_pcb.pcb_fp_control = (IEEE_TRAP_ENABLE_INV
+ | IEEE_TRAP_ENABLE_DZE
+ | IEEE_TRAP_ENABLE_OVF);
+ p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
+ | FPCR_INED | FPCR_UNFD);
+ }
+
+ /*
* Arrange for a non-local goto when the new process
* is started, to resume here, returning nonzero from setjmp.
*/
OpenPOWER on IntegriCloud