Commit 48d6c64311ddb6417b901639530ccbc47bdc7635

Authored by Kumar Gala
1 parent 40d3057ac0

math-emu: Add support for reporting exact invalid exception

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 <galak@kernel.crashing.org>
Acked-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 27 additions and 4 deletions Side-by-side Diff

include/math-emu/op-common.h
... ... @@ -73,7 +73,7 @@
73 73 X##_c = FP_CLS_NAN; \
74 74 /* Check for signaling NaN */ \
75 75 if (!(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
76   - FP_SET_EXCEPTION(FP_EX_INVALID); \
  76 + FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_SNAN); \
77 77 } \
78 78 break; \
79 79 } \
... ... @@ -324,7 +324,7 @@
324 324 _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
325 325 R##_s = _FP_NANSIGN_##fs; \
326 326 R##_c = FP_CLS_NAN; \
327   - FP_SET_EXCEPTION(FP_EX_INVALID); \
  327 + FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_ISI); \
328 328 break; \
329 329 } \
330 330 /* FALLTHRU */ \
... ... @@ -431,7 +431,7 @@
431 431 R##_s = _FP_NANSIGN_##fs; \
432 432 R##_c = FP_CLS_NAN; \
433 433 _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
434   - FP_SET_EXCEPTION(FP_EX_INVALID); \
  434 + FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_IMZ);\
435 435 break; \
436 436 \
437 437 default: \
438 438  
... ... @@ -490,11 +490,15 @@
490 490 break; \
491 491 \
492 492 case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF): \
  493 + R##_s = _FP_NANSIGN_##fs; \
  494 + R##_c = FP_CLS_NAN; \
  495 + _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
  496 + FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_IDI);\
493 497 case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_ZERO): \
494 498 R##_s = _FP_NANSIGN_##fs; \
495 499 R##_c = FP_CLS_NAN; \
496 500 _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
497   - FP_SET_EXCEPTION(FP_EX_INVALID); \
  501 + FP_SET_EXCEPTION(FP_EX_INVALID | FP_EX_INVALID_ZDZ);\
498 502 break; \
499 503 \
500 504 default: \
include/math-emu/soft-fp.h
... ... @@ -51,6 +51,25 @@
51 51 #ifndef FP_EX_INVALID
52 52 #define FP_EX_INVALID 0
53 53 #endif
  54 +#ifndef FP_EX_INVALID_SNAN
  55 +#define FP_EX_INVALID_SNAN 0
  56 +#endif
  57 +/* inf - inf */
  58 +#ifndef FP_EX_INVALID_ISI
  59 +#define FP_EX_INVALID_ISI 0
  60 +#endif
  61 +/* inf / inf */
  62 +#ifndef FP_EX_INVALID_IDI
  63 +#define FP_EX_INVALID_IDI 0
  64 +#endif
  65 +/* 0 / 0 */
  66 +#ifndef FP_EX_INVALID_ZDZ
  67 +#define FP_EX_INVALID_ZDZ 0
  68 +#endif
  69 +/* inf * 0 */
  70 +#ifndef FP_EX_INVALID_IMZ
  71 +#define FP_EX_INVALID_IMZ 0
  72 +#endif
54 73 #ifndef FP_EX_OVERFLOW
55 74 #define FP_EX_OVERFLOW 0
56 75 #endif