Skip to content

Commit

Permalink
math-emu: Add support for reporting exact invalid exception
Browse files Browse the repository at this point in the history
Some architectures (like powerpc) provide status information on the exact
type of invalid exception.  This is pretty straight forward as we already
report invalid exceptions via FP_SET_EXCEPTION.

We add new flags (FP_EX_INVALID_*) the architecture code can define if it
wants the exact invalid exception reported.

We had to split out the INF/INF and 0/0 cases for divide to allow reporting
the two invalid forms properly.

Signed-off-by: Kumar Gala <[email protected]>
Acked-by: David S. Miller <[email protected]>
  • Loading branch information
kumargala committed Sep 16, 2008
1 parent 40d3057 commit 48d6c64
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
12 changes: 8 additions & 4 deletions include/math-emu/op-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ do { \
X##_c = FP_CLS_NAN; \
/* Check for signaling NaN */ \
if (!(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
FP_SET_EXCEPTION(FP_EX_INVALID); \
FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_SNAN); \
} \
break; \
} \
Expand Down Expand Up @@ -324,7 +324,7 @@ do { \
_FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
R##_s = _FP_NANSIGN_##fs; \
R##_c = FP_CLS_NAN; \
FP_SET_EXCEPTION(FP_EX_INVALID); \
FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_ISI); \
break; \
} \
/* FALLTHRU */ \
Expand Down Expand Up @@ -431,7 +431,7 @@ do { \
R##_s = _FP_NANSIGN_##fs; \
R##_c = FP_CLS_NAN; \
_FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
FP_SET_EXCEPTION(FP_EX_INVALID); \
FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_IMZ);\
break; \
\
default: \
Expand Down Expand Up @@ -490,11 +490,15 @@ do { \
break; \
\
case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF): \
R##_s = _FP_NANSIGN_##fs; \
R##_c = FP_CLS_NAN; \
_FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_IDI);\
case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_ZERO): \
R##_s = _FP_NANSIGN_##fs; \
R##_c = FP_CLS_NAN; \
_FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
FP_SET_EXCEPTION(FP_EX_INVALID); \
FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_ZDZ);\
break; \
\
default: \
Expand Down
19 changes: 19 additions & 0 deletions include/math-emu/soft-fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@
#ifndef FP_EX_INVALID
#define FP_EX_INVALID 0
#endif
#ifndef FP_EX_INVALID_SNAN
#define FP_EX_INVALID_SNAN 0
#endif
/* inf - inf */
#ifndef FP_EX_INVALID_ISI
#define FP_EX_INVALID_ISI 0
#endif
/* inf / inf */
#ifndef FP_EX_INVALID_IDI
#define FP_EX_INVALID_IDI 0
#endif
/* 0 / 0 */
#ifndef FP_EX_INVALID_ZDZ
#define FP_EX_INVALID_ZDZ 0
#endif
/* inf * 0 */
#ifndef FP_EX_INVALID_IMZ
#define FP_EX_INVALID_IMZ 0
#endif
#ifndef FP_EX_OVERFLOW
#define FP_EX_OVERFLOW 0
#endif
Expand Down

0 comments on commit 48d6c64

Please sign in to comment.