Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/arch/x86_64/gen Attempt to juggle the 2 seperarate ...



details:   https://anonhg.NetBSD.org/src/rev/8a0c8c17ccdb
branches:  trunk
changeset: 532675:8a0c8c17ccdb
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Wed Jun 12 19:17:22 2002 +0000

description:
Attempt to juggle the 2 seperarate status/mask bit sets for plain FP
and XMM to provide a consistent interface.

diffstat:

 lib/libc/arch/x86_64/gen/fpgetmask.S   |   8 +++++-
 lib/libc/arch/x86_64/gen/fpgetround.S  |   7 ++++-
 lib/libc/arch/x86_64/gen/fpgetsticky.S |  18 +++++++++---
 lib/libc/arch/x86_64/gen/fpsetmask.S   |  37 ++++++++++++++++++---------
 lib/libc/arch/x86_64/gen/fpsetround.S  |  45 ++++++++++++++++++++++++---------
 lib/libc/arch/x86_64/gen/fpsetsticky.S |  37 +++++++++++++++++++--------
 6 files changed, 109 insertions(+), 43 deletions(-)

diffs (258 lines):

diff -r 6c44605a950c -r 8a0c8c17ccdb lib/libc/arch/x86_64/gen/fpgetmask.S
--- a/lib/libc/arch/x86_64/gen/fpgetmask.S      Wed Jun 12 19:13:27 2002 +0000
+++ b/lib/libc/arch/x86_64/gen/fpgetmask.S      Wed Jun 12 19:17:22 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpgetmask.S,v 1.2 2002/01/13 21:45:51 thorpej Exp $    */
+/*     $NetBSD: fpgetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $       */
 
 /*
  * Written by J.T. Conklin, Apr 4, 1995
@@ -7,6 +7,12 @@
 
 #include <machine/asm.h>
 
+/*
+ * XXX only read x87 control word here. If an application only
+ * uses the fp* interface to manipulate FP bits, it should
+ * always remain in sync with the SSE mxcsr register.
+ */
+
 #ifdef WEAK_ALIAS
 WEAK_ALIAS(fpgetmask, _fpgetmask)
 ENTRY(_fpgetmask)
diff -r 6c44605a950c -r 8a0c8c17ccdb lib/libc/arch/x86_64/gen/fpgetround.S
--- a/lib/libc/arch/x86_64/gen/fpgetround.S     Wed Jun 12 19:13:27 2002 +0000
+++ b/lib/libc/arch/x86_64/gen/fpgetround.S     Wed Jun 12 19:17:22 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpgetround.S,v 1.2 2002/01/13 21:45:51 thorpej Exp $   */
+/*     $NetBSD: fpgetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $      */
 
 /*
  * Written by J.T. Conklin, Apr 4, 1995
@@ -7,6 +7,11 @@
 
 #include <machine/asm.h>
 
+/*
+ * XXX store only x87 state. If an application only uses the fp*
+ * interface, this should be in sync with the SSE mxcsr register.
+ */
+
 #ifdef WEAK_ALIAS
 WEAK_ALIAS(fpgetround, _fpgetround)
 ENTRY(_fpgetround)
diff -r 6c44605a950c -r 8a0c8c17ccdb lib/libc/arch/x86_64/gen/fpgetsticky.S
--- a/lib/libc/arch/x86_64/gen/fpgetsticky.S    Wed Jun 12 19:13:27 2002 +0000
+++ b/lib/libc/arch/x86_64/gen/fpgetsticky.S    Wed Jun 12 19:17:22 2002 +0000
@@ -1,19 +1,27 @@
-/*     $NetBSD: fpgetsticky.S,v 1.2 2002/01/13 21:45:51 thorpej Exp $  */
+/*     $NetBSD: fpgetsticky.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $     */
 
 /*
- * Written by J.T. Conklin, Apr 4, 1995
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD.
  * Public domain.
+ *
  */
 
 #include <machine/asm.h>
 
+/*
+ * XXX read both the x87 and SSE status words here, and OR
+ * them to get a complete picture of exceptions.
+ */
+
 #ifdef WEAK_ALIAS
 WEAK_ALIAS(fpgetsticky, _fpgetsticky)
 ENTRY(_fpgetsticky)
 #else
 ENTRY(fpgetsticky)
 #endif
-       fnstsw -4(%rsp)
-       movl -4(%rsp),%eax
-       andl $63,%eax
+       fnstsw  -4(%rsp)
+       stmxcsr -8(%rsp)
+       movl    -4(%rsp),%eax
+       orl     -8(%rsp),%eax
+       andl    $63,%eax
        ret
diff -r 6c44605a950c -r 8a0c8c17ccdb lib/libc/arch/x86_64/gen/fpsetmask.S
--- a/lib/libc/arch/x86_64/gen/fpsetmask.S      Wed Jun 12 19:13:27 2002 +0000
+++ b/lib/libc/arch/x86_64/gen/fpsetmask.S      Wed Jun 12 19:17:22 2002 +0000
@@ -1,28 +1,41 @@
-/*     $NetBSD: fpsetmask.S,v 1.2 2002/01/13 21:45:51 thorpej Exp $    */
+/*     $NetBSD: fpsetmask.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $       */
 
 /*
- * Written by Charles M. Hannum, Apr 9, 1995
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD.
  * Public domain.
  */
 
 #include <machine/asm.h>
 
+/*
+ * XXX set both the x87 control word and the SSE mxcsr register.
+ * Applications should only set exception and round flags
+ * via the fp*() interface, otherwise the status words
+ * will get our of sync.
+ */
+
 #ifdef WEAK_ALIAS
 WEAK_ALIAS(fpsetmask, _fpsetmask)
 ENTRY(_fpsetmask)
 #else
 ENTRY(fpsetmask)
 #endif
-       fnstcw -4(%rsp)
-       movl -4(%rsp),%eax
-       movl %eax,%edx
+       fnstcw  -4(%rsp)
+       stmxcsr -8(%rsp)
+       andl    $63,%edi
+       notl    %edi
 
-       notl %eax
-       andl $63,%eax
+       movl    -4(%rsp),%edx
+       movl    %edx,%eax
+       andl    %edi,%edx
+       movl    %edx,-4(%rsp)
 
-       addl %eax,%edx
-       andl $63,%edi
-       subl %edi,%edx
-       movl %edx,-4(%rsp)
-       fldcw -4(%rsp)
+       movl    -8(%rsp),%edx
+       roll    $7,%edi
+       andl    %edi,%edx
+       movl    %edx,-8(%rsp)
+
+       fldcw   -4(%rsp)
+       ldmxcsr -8(%rsp)
+       andl    $63,%eax
        ret
diff -r 6c44605a950c -r 8a0c8c17ccdb lib/libc/arch/x86_64/gen/fpsetround.S
--- a/lib/libc/arch/x86_64/gen/fpsetround.S     Wed Jun 12 19:13:27 2002 +0000
+++ b/lib/libc/arch/x86_64/gen/fpsetround.S     Wed Jun 12 19:17:22 2002 +0000
@@ -1,29 +1,48 @@
-/*     $NetBSD: fpsetround.S,v 1.2 2002/01/13 21:45:52 thorpej Exp $   */
+/*     $NetBSD: fpsetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $      */
 
 /*
- * Written by Charles M. Hannum, Apr 9, 1995
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD.
  * Public domain.
  */
 
 #include <machine/asm.h>
 
+/*
+ * XXX set both the x87 control word and the SSE mxcsr register.
+ * Applications should only set exception and round flags
+ * via the fp*() interface, otherwise the status words
+ * will get our of sync.
+ */ 
+
+
 #ifdef WEAK_ALIAS
 WEAK_ALIAS(fpsetround, _fpsetround)
 ENTRY(_fpsetround)
 #else
 ENTRY(fpsetround)
 #endif
-       fnstcw -4(%rsp)
-       movl -4(%rsp),%eax
+       fnstcw  -4(%rsp)
+       stmxcsr -8(%rsp)
+
+       andl    $3,%edi
 
-       rorl $10,%eax
-       movl %eax,%edx
-       andl $3,%eax
+       movl    -4(%rsp),%edx
+       rorl    $10,%edx
+       movl    %edx,%eax
+       andl    $3,%eax
 
-       subl %eax,%edx
-       andl $3,%edi
-       orl %edi,%edx
-       roll $10,%edx
-       movl %edx,-4(%rsp)
-       fldcw -4(%rsp)
+       andl    $~3,%edx
+       orl     %edi,%edx
+       roll    $10,%edx
+       movl    %edx,-4(%rsp)
+
+       movl    -8(%rsp),%edx
+       rorl    $13,%edx
+       andl    $~3,%edx
+       orl     %edi,%edx
+       roll    $13,%edx
+       movl    %edx,-8(%rsp)
+
+       ldmxcsr -8(%rsp)
+       fldcw   -4(%rsp)
        ret
diff -r 6c44605a950c -r 8a0c8c17ccdb lib/libc/arch/x86_64/gen/fpsetsticky.S
--- a/lib/libc/arch/x86_64/gen/fpsetsticky.S    Wed Jun 12 19:13:27 2002 +0000
+++ b/lib/libc/arch/x86_64/gen/fpsetsticky.S    Wed Jun 12 19:17:22 2002 +0000
@@ -1,27 +1,42 @@
-/*     $NetBSD: fpsetsticky.S,v 1.2 2002/01/13 21:45:52 thorpej Exp $  */
+/*     $NetBSD: fpsetsticky.S,v 1.3 2002/06/12 19:17:23 fvdl Exp $     */
 
 /*
- * Written by Charles M. Hannum, Apr 9, 1995
+ * Written by Frank van der Linden at Wasabi Systems for NetBSD
  * Public domain.
  */
 
 #include <machine/asm.h>
 
+/*
+ * XXX set both the x87 status word and the SSE mxcsr register.
+ * Applications should only set exception and round flags
+ * via the fp*() interface, otherwise the status words
+ * will get our of sync.
+ */ 
+
+
 #ifdef WEAK_ALIAS
 WEAK_ALIAS(fpsetsticky, _fpsetsticky)
 ENTRY(_fpsetsticky)
 #else
 ENTRY(fpsetsticky)
 #endif
-       fnstenv -28(%rsp)
-       movl -24(%rsp),%eax
-       movl %eax,%edx
+       fnstenv -28(%rsp)
+       stmxcsr -32(%rsp)
 
-       andl $63,%eax
+       andl    $63,%edi
+
+       movl    -24(%rsp),%eax
+       movl    %eax,%edx
+       andl    $63,%eax
 
-       subl %eax,%edx
-       andl $63,%edi
-       addl %edi,%edx
-       movl %edx,-24(%rsp)
-       fldenv -28(%rsp)
+       orl     %edi,%edx
+       movl    %edx,-24(%rsp)
+
+       movl    -32(%rsp),%edx
+       orl     %edi,%edx
+       movl    %edx,-32(%rsp)
+
+       ldmxcsr -32(%rsp)
+       fldenv  -28(%rsp)
        ret



Home | Main Index | Thread Index | Old Index