utils-fpu.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # MIPS simulator testsuite FPU utility functions.
  2. # Copyright (C) 2004-2022 Free Software Foundation, Inc.
  3. # Contributed by Chris Demetriou of Broadcom Corporation.
  4. #
  5. # This file is part of the GNU simulators.
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>. */
  19. .macro enable_fpu fr
  20. mfc0 $20, $12
  21. or $20, $20, (1 << 29) | (\fr << 26)
  22. mtc0 $20, $20
  23. .endm
  24. ###
  25. ### Data movement macros
  26. ###
  27. .macro ld_fp_df r, v
  28. .data
  29. 1: .double \v
  30. .previous
  31. ldc1 \r, 1b
  32. .endm
  33. .macro ld_fp_di r, v
  34. .data
  35. 1: .dword \v
  36. .previous
  37. ldc1 \r, 1b
  38. .endm
  39. .macro ld_fp_sf r, v
  40. .data
  41. 1: .float \v
  42. .previous
  43. lwc1 \r, 1b
  44. .endm
  45. .macro ld_fp_si r, v
  46. .data
  47. 1: .word \v
  48. .previous
  49. lwc1 \r, 1b
  50. .endm
  51. ###
  52. ### FP condition code manipulation macros
  53. ###
  54. .macro clrset_fp_cc clr, set
  55. cfc1 $20, $31
  56. or $20, $20, (((\clr & 0xfe) << 24) | ((\clr & 0x01) << 23))
  57. xor $20, $20, (((\clr & 0xfe) << 24) | ((\clr & 0x01) << 23))
  58. or $20, $20, (((\set & 0xfe) << 24) | ((\set & 0x01) << 23))
  59. ctc1 $20, $31
  60. .endm
  61. .macro clr_fp_cc clr
  62. clrset_fp_cc \clr, 0
  63. .endm
  64. .macro set_fp_cc set
  65. clrset_fp_cc 0, \set
  66. .endm
  67. .macro get_fp_cc r
  68. .set push
  69. .set noat
  70. cfc1 $1, $31
  71. srl $1, $1, 23
  72. andi \r, $1, 0x1fc
  73. andi $1, $1, 0x1
  74. srl \r, \r, 1
  75. or \r, \r, $1
  76. .set pop
  77. .endm
  78. .macro ck_fp_cc v
  79. get_fp_cc $20
  80. xori $20, $20, \v
  81. bnez $20, _fail
  82. nop
  83. .endm
  84. .macro ckm_fp_cc v, mask
  85. get_fp_cc $20
  86. xori $20, $20, \v
  87. andi $20, $20, \mask
  88. bnez $20, _fail
  89. nop
  90. .endm