Attempt to juggle the 2 seperarate status/mask bit sets for plain FP

and XMM to provide a consistent interface.
This commit is contained in:
fvdl 2002-06-12 19:17:22 +00:00
parent c7647a1294
commit 4f2f06c917
6 changed files with 109 additions and 43 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)
rorl $10,%eax
movl %eax,%edx
andl $3,%eax
andl $3,%edi
subl %eax,%edx
andl $3,%edi
orl %edi,%edx
roll $10,%edx
movl %edx,-4(%rsp)
fldcw -4(%rsp)
movl -4(%rsp),%edx
rorl $10,%edx
movl %edx,%eax
andl $3,%eax
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

View File

@ -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
subl %eax,%edx
andl $63,%edi
addl %edi,%edx
movl %edx,-24(%rsp)
fldenv -28(%rsp)
movl -24(%rsp),%eax
movl %eax,%edx
andl $63,%eax
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