/* This file is part of the program psim.
- Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
+ Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
if (OE) { \
if ((((unsigned64)(alu_overflow_val & BIT64(0))) \
>> 32) \
- == (alu_overflow_val & BIT32(0))) \
+ == (alu_overflow_val & BIT64(32))) \
XER &= (~xer_overflow); \
else \
XER |= (xer_summary_overflow | xer_overflow); \
: cr_i_zero))
#define CR_SET(REG, VAL) MBLIT32(CR, REG*4, REG*4+3, VAL)
+#define CR_FIELD(REG) EXTRACTED32(CR, REG*4, REG*4+3)
#define CR_SET_XER_SO(REG, VAL) \
do { \
creg new_bits = ((XER & xer_summary_overflow) \
} while (0)
-/* some FPSCR update macros */
+
+/* some FPSCR update macros. */
#define FPSCR_BEGIN \
-FPSCR &= ~fpscr_reserved_20; \
{ \
- fpscreg old_fpscr __attribute__((__unused__)) = FPSCR
+ fpscreg old_fpscr UNUSED = FPSCR
#define FPSCR_END(Rc) { \
+ /* always update VX */ \
+ if ((FPSCR & fpscr_vx_bits)) \
+ FPSCR |= fpscr_vx; \
+ else \
+ FPSCR &= ~fpscr_vx; \
+ /* always update FEX */ \
+ if (((FPSCR & fpscr_vx) && (FPSCR & fpscr_ve)) \
+ || ((FPSCR & fpscr_ox) && (FPSCR & fpscr_oe)) \
+ || ((FPSCR & fpscr_ux) && (FPSCR & fpscr_ue)) \
+ || ((FPSCR & fpscr_zx) && (FPSCR & fpscr_ze)) \
+ || ((FPSCR & fpscr_xx) && (FPSCR & fpscr_xe))) \
+ FPSCR |= fpscr_fex; \
+ else \
+ FPSCR &= ~fpscr_fex; \
CR1_UPDATE(Rc); \
- if (FPSCR & fpscr_reserved_20) { \
- FPSCR &= ~fpscr_reserved_20; \
+ /* interrupt enabled? */ \
+ if ((MSR & (msr_floating_point_exception_mode_0 \
+ | msr_floating_point_exception_mode_1)) \
+ && (FPSCR & fpscr_fex)) \
program_interrupt(processor, cia, \
floating_point_enabled_program_interrupt); \
- } \
}}
+#define FPSCR_SET(REG, VAL) MBLIT32(FPSCR, REG*4, REG*4+3, VAL)
+#define FPSCR_FIELD(REG) EXTRACTED32(FPSCR, REG*4, REG*4+3)
+
#define FPSCR_SET_FPCC(VAL) MBLIT32(FPSCR, fpscr_fpcc_bit, fpscr_fpcc_bit+3, VAL)
/* Handle various exceptions */
#define FPSCR_OR_VX(VAL) \
do { \
+ /* NOTE: VAL != 0 */ \
FPSCR |= (VAL); \
FPSCR |= fpscr_fx; \
- if (FPSCR & fpscr_ve) \
- FPSCR |= fpscr_fex | fpscr_reserved_20; \
- FPSCR |= fpscr_vx; \
} while (0)
#define FPSCR_SET_OX(COND) \
if (COND) { \
FPSCR |= fpscr_ox; \
FPSCR |= fpscr_fx; \
- if (FPSCR & fpscr_oe) \
- FPSCR |= fpscr_fex | fpscr_reserved_20; \
} \
else \
FPSCR &= ~fpscr_ox; \
if (COND) { \
FPSCR |= fpscr_ux; \
FPSCR |= fpscr_fx; \
- if (FPSCR & fpscr_ue) \
- FPSCR |= fpscr_fex | fpscr_reserved_20; \
} \
else \
FPSCR &= ~fpscr_ux; \
if (COND) { \
FPSCR |= fpscr_zx; \
FPSCR |= fpscr_fx; \
- if (FPSCR & fpscr_ze) \
- FPSCR |= fpscr_fex | fpscr_reserved_20; \
} \
else \
FPSCR &= ~fpscr_zx; \
if (COND) { \
FPSCR |= fpscr_xx; \
FPSCR |= fpscr_fx; \
- if (FPSCR & fpscr_xe) \
- FPSCR |= fpscr_fex | fpscr_reserved_20; \
} \
} while (0)
-#define FPSCR_SET_FR(COND) \
-do { \
+/* Note: code using SET_FI must also explicitly call SET_XX */
+
+#define FPSCR_SET_FR(COND) do { \
if (COND) \
FPSCR |= fpscr_fr; \
else \
#define FPSCR_SET_FI(COND) \
do { \
- if (COND) \
+ if (COND) { \
FPSCR |= fpscr_fi; \
+ } \
else \
FPSCR &= ~fpscr_fi; \
} while (0)