aboutsummaryrefslogtreecommitdiff
path: root/target/ppc
diff options
context:
space:
mode:
authorJohn Arbuckle <programmingkidx@gmail.com>2018-06-18 11:50:24 -0400
committerDavid Gibson <david@gibson.dropbear.id.au>2018-06-21 21:22:53 +1000
commit88d8d5555d0257a31b5891a328d957cc9b579eb2 (patch)
tree8c6e7927504bef7d40185e3c35e288f14c12fde5 /target/ppc
parent71b5c8d26e35549db4b83d907b2886623d8dd99a (diff)
downloadqemu-88d8d5555d0257a31b5891a328d957cc9b579eb2.zip
qemu-88d8d5555d0257a31b5891a328d957cc9b579eb2.tar.gz
qemu-88d8d5555d0257a31b5891a328d957cc9b579eb2.tar.bz2
fpu_helper.c: fix helper_fpscr_clrbit() function
Fix the helper_fpscr_clrbit() function so it correctly sets the FEX and VX bits. Determining the value for the Floating Point Status and Control Register's (FPSCR) FEX bit is suppose to be done like this: FEX = (VX & VE) | (OX & OE) | (UX & UE) | (ZX & ZE) | (XX & XE)) It is described as "the logical OR of all the floating-point exception bits masked by their respective enable bits". It was not implemented correctly. The value of FEX would stay on even when all other bits were set to off. The VX bit is described as "the logical OR of all of the invalid operation exceptions". This bit was also not implemented correctly. It too would stay on when all the other bits were set to off. My main source of information is an IBM document called: PowerPC Microprocessor Family: The Programming Environments for 32-Bit Microprocessors Page 62 is where the FPSCR information is located. This is an older copy than the one I use but it is still very useful: https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-environments-for-32-e3087633.html I use a G3 and G5 iMac to compare bit values with QEMU. This patch fixed all the problems I was having with these bits. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> [dwg: Re-wrapped commit message] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target/ppc')
-rw-r--r--target/ppc/fpu_helper.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index d31a933..7714bfe 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -325,6 +325,34 @@ void helper_fpscr_clrbit(CPUPPCState *env, uint32_t bit)
case FPSCR_RN:
fpscr_set_rounding_mode(env);
break;
+ case FPSCR_VXSNAN:
+ case FPSCR_VXISI:
+ case FPSCR_VXIDI:
+ case FPSCR_VXZDZ:
+ case FPSCR_VXIMZ:
+ case FPSCR_VXVC:
+ case FPSCR_VXSOFT:
+ case FPSCR_VXSQRT:
+ case FPSCR_VXCVI:
+ if (!fpscr_ix) {
+ /* Set VX bit to zero */
+ env->fpscr &= ~(1 << FPSCR_VX);
+ }
+ break;
+ case FPSCR_OX:
+ case FPSCR_UX:
+ case FPSCR_ZX:
+ case FPSCR_XX:
+ case FPSCR_VE:
+ case FPSCR_OE:
+ case FPSCR_UE:
+ case FPSCR_ZE:
+ case FPSCR_XE:
+ if (!fpscr_eex) {
+ /* Set the FEX bit */
+ env->fpscr &= ~(1 << FPSCR_FEX);
+ }
+ break;
default:
break;
}