fpu_control.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* FPU control word bits. Nios2 version.
  2. Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _FPU_CONTROL_H
  16. #define _FPU_CONTROL_H
  17. /* MIPS FPU floating point control register bits.
  18. *
  19. * 31-25 -> floating point conditions code bits 7-1. These bits are only
  20. * available in MIPS IV.
  21. * 24 -> flush denormalized results to zero instead of
  22. * causing unimplemented operation exception. This bit is only
  23. * available for MIPS III and newer.
  24. * 23 -> Condition bit
  25. * 22-18 -> reserved (read as 0, write with 0)
  26. * 17 -> cause bit for unimplemented operation
  27. * 16 -> cause bit for invalid exception
  28. * 15 -> cause bit for division by zero exception
  29. * 14 -> cause bit for overflow exception
  30. * 13 -> cause bit for underflow exception
  31. * 12 -> cause bit for inexact exception
  32. * 11 -> enable exception for invalid exception
  33. * 10 -> enable exception for division by zero exception
  34. * 9 -> enable exception for overflow exception
  35. * 8 -> enable exception for underflow exception
  36. * 7 -> enable exception for inexact exception
  37. * 6 -> flag invalid exception
  38. * 5 -> flag division by zero exception
  39. * 4 -> flag overflow exception
  40. * 3 -> flag underflow exception
  41. * 2 -> flag inexact exception
  42. * 1-0 -> rounding control
  43. *
  44. *
  45. * Rounding Control:
  46. * 00 - rounding to nearest (RN)
  47. * 01 - rounding toward zero (RZ)
  48. * 10 - rounding (up) toward plus infinity (RP)
  49. * 11 - rounding (down)toward minus infinity (RM)
  50. */
  51. #include <features.h>
  52. /* masking of interrupts */
  53. #define _FPU_MASK_V 0x0800 /* Invalid operation */
  54. #define _FPU_MASK_Z 0x0400 /* Division by zero */
  55. #define _FPU_MASK_O 0x0200 /* Overflow */
  56. #define _FPU_MASK_U 0x0100 /* Underflow */
  57. #define _FPU_MASK_I 0x0080 /* Inexact operation */
  58. /* flush denormalized numbers to zero */
  59. #define _FPU_FLUSH_TZ 0x1000000
  60. /* rounding control */
  61. #define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
  62. #define _FPU_RC_ZERO 0x1
  63. #define _FPU_RC_UP 0x2
  64. #define _FPU_RC_DOWN 0x3
  65. #define _FPU_RESERVED 0xfe3c0000 /* Reserved bits in cw */
  66. /* The fdlibm code requires strict IEEE double precision arithmetic,
  67. and no interrupts for exceptions, rounding to nearest. */
  68. #define _FPU_DEFAULT 0x00000000
  69. /* IEEE: same as above, but exceptions */
  70. #define _FPU_IEEE 0x00000F80
  71. /* Type of the control word. */
  72. typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
  73. /* Macros for accessing the hardware control word. */
  74. #define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
  75. #define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
  76. #if 0
  77. /* Default control word set at startup. */
  78. extern fpu_control_t __fpu_control;
  79. #endif
  80. #endif /* fpu_control.h */