]> git.proxmox.com Git - mirror_qemu.git/commit - target/i386/ops_sse.h
target/i386: fix IEEE SSE floating-point exception raising
authorJoseph Myers <joseph@codesourcery.com>
Thu, 25 Jun 2020 23:58:31 +0000 (23:58 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 10 Jul 2020 22:02:17 +0000 (18:02 -0400)
commit418b0f93d12a1589d5031405de857844f32e9ccc
tree2684d445b3b701c9cd347b9f9ca0eec01bea393f
parent3ddc0eca2229846bfecc3485648a6cb85a466dc7
target/i386: fix IEEE SSE floating-point exception raising

The SSE instruction implementations all fail to raise the expected
IEEE floating-point exceptions because they do nothing to convert the
exception state from the softfloat machinery into the exception flags
in MXCSR.

Fix this by adding such conversions.  Unlike for x87, emulated SSE
floating-point operations might be optimized using hardware floating
point on the host, and so a different approach is taken that is
compatible with such optimizations.  The required invariant is that
all exceptions set in env->sse_status (other than "denormal operand",
for which the SSE semantics are different from those in the softfloat
code) are ones that are set in the MXCSR; the emulated MXCSR is
updated lazily when code reads MXCSR, while when code sets MXCSR, the
exceptions in env->sse_status are set accordingly.

A few instructions do not raise all the exceptions that would be
raised by the softfloat code, and those instructions are made to save
and restore the softfloat exception state accordingly.

Nothing is done about "denormal operand"; setting that (only for the
case when input denormals are *not* flushed to zero, the opposite of
the logic in the softfloat code for such an exception) will require
custom code for relevant instructions, or else architecture-specific
conditionals in the softfloat code for when to set such an exception
together with custom code for various SSE conversion and rounding
instructions that do not set that exception.

Nothing is done about trapping exceptions (for which there is minimal
and largely broken support in QEMU's emulation in the x87 case and no
support at all in the SSE case).

Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Message-Id: <alpine.DEB.2.21.2006252358000.3832@digraph.polyomino.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/Makefile.objs
target/i386/cpu.h
target/i386/fpu_helper.c
target/i386/gdbstub.c
target/i386/helper.c
target/i386/helper.h
target/i386/ops_sse.h
target/i386/tcg-stub.c [new file with mode: 0644]
target/i386/translate.c
tests/tcg/i386/Makefile.target
tests/tcg/i386/test-i386-sse-exceptions.c [new file with mode: 0644]