Fix floating point exception definitions for powerpcspe

These were incorrectly implemented in the original port.
This commit is contained in:
Justin Hibbits 2018-07-24 22:04:56 +00:00
parent 6ae00e306f
commit adc9dcf3e3
3 changed files with 11 additions and 3 deletions

View File

@ -44,6 +44,6 @@ fpgetmask()
uint32_t fpscr;
__asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
return ((fp_except_t)((fpscr >> 3) & 0x1f));
return ((fp_except_t)((fpscr >> 2) & 0x1f));
}
#endif

View File

@ -45,8 +45,8 @@ fpsetmask(fp_except_t mask)
fp_rnd_t old;
__asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
old = (fp_rnd_t)((fpscr >> 3) & 0x1f);
fpscr = (fpscr & 0xffffff07) | (mask << 3);
old = (fp_rnd_t)((fpscr >> 2) & 0x1f);
fpscr = (fpscr & 0xffffff83) | (mask << 2);
__asm__ __volatile("mtspr %1,%0" :: "r"(fpscr), "K"(SPR_SPEFSCR));
return (old);
}

View File

@ -11,11 +11,19 @@
/* Deprecated historical FPU control interface */
typedef int fp_except_t;
#ifdef __SPE__
#define FP_X_OFL 0x01 /* overflow exception */
#define FP_X_UFL 0x02 /* underflow exception */
#define FP_X_DZ 0x04 /* divide-by-zero exception */
#define FP_X_INV 0x08 /* invalid operation exception */
#define FP_X_IMP 0x10 /* imprecise (loss of precision) */
#else
#define FP_X_IMP 0x01 /* imprecise (loss of precision) */
#define FP_X_DZ 0x02 /* divide-by-zero exception */
#define FP_X_UFL 0x04 /* underflow exception */
#define FP_X_OFL 0x08 /* overflow exception */
#define FP_X_INV 0x10 /* invalid operation exception */
#endif
typedef enum {
FP_RN=0, /* round to nearest representable number */