fpuctl.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * MacOSX/Darwin ppc fpu support
  3. * Mimic Plan9 floating point support
  4. */
  5. #include <architecture/ppc/fp_regs.h>
  6. static __inline__ ulong
  7. getfcr(void)
  8. {
  9. ppc_fp_scr_t fpscr = get_fp_scr();
  10. return ((ulong *)&fpscr)[1];
  11. }
  12. ulong
  13. getfsr(void)
  14. {
  15. ppc_fp_scr_t fpscr = get_fp_scr();
  16. return ((ulong *)&fpscr)[1];
  17. }
  18. void
  19. setfsr(ulong fsr)
  20. {
  21. ppc_fp_scr_t fpscr;
  22. // fpscr = get_fp_scr();
  23. (((ulong *)&fpscr)[1]) = fsr;
  24. set_fp_scr(fpscr);
  25. }
  26. void
  27. setfcr(ulong fcr)
  28. {
  29. ppc_fp_scr_t fpscr;
  30. // fpscr = get_fp_scr();
  31. (((ulong *)&fpscr)[1]) = fcr;
  32. set_fp_scr(fpscr);
  33. }
  34. /* FPSCR */
  35. #define FPSFX (1<<31) /* exception summary (sticky) */
  36. #define FPSEX (1<<30) /* enabled exception summary */
  37. #define FPSVX (1<<29) /* invalid operation exception summary */
  38. #define FPSOX (1<<28) /* overflow exception OX (sticky) */
  39. #define FPSUX (1<<27) /* underflow exception UX (sticky) */
  40. #define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
  41. #define FPSXX (1<<25) /* inexact exception XX (sticky) */
  42. #define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
  43. #define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
  44. #define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
  45. #define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
  46. #define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
  47. #define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
  48. #define FPSFR (1<<18) /* fraction rounded */
  49. #define FPSFI (1<<17) /* fraction inexact */
  50. #define FPSFPRF (1<<16) /* floating point result class */
  51. #define FPSFPCC (0xF<<12) /* <, >, =, unordered */
  52. #define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
  53. /* FCR */
  54. #define FPVE (1<<7) /* invalid operation exception enable */
  55. #define FPOVFL (1<<6) /* enable overflow exceptions */
  56. #define FPUNFL (1<<5) /* enable underflow */
  57. #define FPZDIV (1<<4) /* enable zero divide */
  58. #define FPINEX (1<<3) /* enable inexact exceptions */
  59. #define FPRMASK (3<<0) /* rounding mode */
  60. #define FPRNR (0<<0)
  61. #define FPRZ (1<<0)
  62. #define FPRPINF (2<<0)
  63. #define FPRNINF (3<<0)
  64. #define FPPEXT 0
  65. #define FPPSGL 0
  66. #define FPPDBL 0
  67. #define FPPMASK 0
  68. #define FPINVAL FPVE
  69. /* FSR */
  70. #define FPAOVFL FPSOX
  71. #define FPAINEX FPSXX
  72. #define FPAUNFL FPSUX
  73. #define FPAZDIV FPSZX
  74. #define FPAINVAL FPSVX