fpuctl.h 2.3 KB

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