darwin-fpsave.S 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* This file contains the floating-point save and restore routines.
  2. *
  3. * Copyright (C) 2004-2022 Free Software Foundation, Inc.
  4. *
  5. * This file is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 3, or (at your option) any
  8. * later version.
  9. *
  10. * This file is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * Under Section 7 of GPL version 3, you are granted additional
  16. * permissions described in the GCC Runtime Library Exception, version
  17. * 3.1, as published by the Free Software Foundation.
  18. *
  19. * You should have received a copy of the GNU General Public License and
  20. * a copy of the GCC Runtime Library Exception along with this program;
  21. * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  22. * <http://www.gnu.org/licenses/>.
  23. */
  24. /* THE SAVE AND RESTORE ROUTINES CAN HAVE ONLY ONE GLOBALLY VISIBLE
  25. ENTRY POINT - callers have to jump to "saveFP+60" to save f29..f31,
  26. for example. For FP reg saves/restores, it takes one instruction
  27. (4 bytes) to do the operation; for Vector regs, 2 instructions are
  28. required (8 bytes.)
  29. MORAL: DO NOT MESS AROUND WITH THESE FUNCTIONS! */
  30. #include "darwin-asm.h"
  31. .text
  32. .align 2
  33. /* saveFP saves R0 -- assumed to be the callers LR -- to 8/16(R1). */
  34. .private_extern saveFP
  35. saveFP:
  36. stfd f14,-144(r1)
  37. stfd f15,-136(r1)
  38. stfd f16,-128(r1)
  39. stfd f17,-120(r1)
  40. stfd f18,-112(r1)
  41. stfd f19,-104(r1)
  42. stfd f20,-96(r1)
  43. stfd f21,-88(r1)
  44. stfd f22,-80(r1)
  45. stfd f23,-72(r1)
  46. stfd f24,-64(r1)
  47. stfd f25,-56(r1)
  48. stfd f26,-48(r1)
  49. stfd f27,-40(r1)
  50. stfd f28,-32(r1)
  51. stfd f29,-24(r1)
  52. stfd f30,-16(r1)
  53. stfd f31,-8(r1)
  54. stg r0,SAVED_LR_OFFSET(r1)
  55. blr
  56. /* restFP restores the caller`s LR from 8/16(R1). Note that the code for
  57. this starts at the offset of F30 restoration, so calling this
  58. routine in an attempt to restore only F31 WILL NOT WORK (it would
  59. be a stupid thing to do, anyway.) */
  60. .private_extern restFP
  61. restFP:
  62. lfd f14,-144(r1)
  63. lfd f15,-136(r1)
  64. lfd f16,-128(r1)
  65. lfd f17,-120(r1)
  66. lfd f18,-112(r1)
  67. lfd f19,-104(r1)
  68. lfd f20,-96(r1)
  69. lfd f21,-88(r1)
  70. lfd f22,-80(r1)
  71. lfd f23,-72(r1)
  72. lfd f24,-64(r1)
  73. lfd f25,-56(r1)
  74. lfd f26,-48(r1)
  75. lfd f27,-40(r1)
  76. lfd f28,-32(r1)
  77. lfd f29,-24(r1)
  78. /* <OFFSET OF F30 RESTORE> restore callers LR */
  79. lg r0,SAVED_LR_OFFSET(r1)
  80. lfd f30,-16(r1)
  81. /* and prepare for return to caller */
  82. mtlr r0
  83. lfd f31,-8(r1)
  84. blr