stackframe_fpu.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * ls1c FPU's stackframe
  3. * 最开始本想,将代码加入到stackframe.h中的SAVE_ALL, RESTORE_ALL和RESTORE_ALL_AND_RET中,
  4. * 但考虑到源文件"stackframe.h"位于目录"libcpu\mips\common"内,怕影响到其它mips cpu
  5. * 所以,另外新建本源文件
  6. */
  7. #ifndef __OPENLOONGSON_STACKFRAME_FPU_H
  8. #define __OPENLOONGSON_STACKFRAME_FPU_H
  9. #include "../common/asm.h"
  10. #include "../common/mipsregs.h"
  11. #include "../common/stackframe.h"
  12. #define PT_FPU_R0 (0)
  13. #define PT_FPU_R2 ((PT_FPU_R0) + 2*LONGSIZE)
  14. #define PT_FPU_R4 ((PT_FPU_R2) + 2*LONGSIZE)
  15. #define PT_FPU_R6 ((PT_FPU_R4) + 2*LONGSIZE)
  16. #define PT_FPU_R8 ((PT_FPU_R6) + 2*LONGSIZE)
  17. #define PT_FPU_R10 ((PT_FPU_R8) + 2*LONGSIZE)
  18. #define PT_FPU_R12 ((PT_FPU_R10) + 2*LONGSIZE)
  19. #define PT_FPU_R14 ((PT_FPU_R12) + 2*LONGSIZE)
  20. #define PT_FPU_R16 ((PT_FPU_R14) + 2*LONGSIZE)
  21. #define PT_FPU_R18 ((PT_FPU_R16) + 2*LONGSIZE)
  22. #define PT_FPU_R20 ((PT_FPU_R18) + 2*LONGSIZE)
  23. #define PT_FPU_R22 ((PT_FPU_R20) + 2*LONGSIZE)
  24. #define PT_FPU_R24 ((PT_FPU_R22) + 2*LONGSIZE)
  25. #define PT_FPU_R26 ((PT_FPU_R24) + 2*LONGSIZE)
  26. #define PT_FPU_R28 ((PT_FPU_R26) + 2*LONGSIZE)
  27. #define PT_FPU_R30 ((PT_FPU_R28) + 2*LONGSIZE)
  28. #define PT_FPU_SIZE ((((PT_FPU_R30) + 2*LONGSIZE) + (2*PTRSIZE-1)) & ~(2*PTRSIZE-1))
  29. .macro SAVE_FPU
  30. .set push
  31. .set noreorder
  32. #ifdef RT_USING_FPU
  33. move k1, sp /* 保存现场 */
  34. and k0, k1, 0xFFFFFFF8 /* 8字节对齐 */
  35. PTR_SUBU sp, k0, PT_FPU_SIZE /* 计算栈底 */
  36. s.d $f0, PT_FPU_R0(sp)
  37. s.d $f2, PT_FPU_R2(sp)
  38. s.d $f4, PT_FPU_R4(sp)
  39. s.d $f6, PT_FPU_R6(sp)
  40. s.d $f8, PT_FPU_R8(sp)
  41. s.d $f10, PT_FPU_R10(sp)
  42. s.d $f12, PT_FPU_R12(sp)
  43. s.d $f14, PT_FPU_R14(sp)
  44. s.d $f16, PT_FPU_R16(sp)
  45. s.d $f18, PT_FPU_R18(sp)
  46. s.d $f20, PT_FPU_R20(sp)
  47. s.d $f22, PT_FPU_R22(sp)
  48. s.d $f24, PT_FPU_R24(sp)
  49. s.d $f26, PT_FPU_R26(sp)
  50. s.d $f28, PT_FPU_R28(sp)
  51. s.d $f30, PT_FPU_R30(sp)
  52. move sp, k1 /* 恢复现场 */
  53. #endif
  54. .set reorder
  55. .set pop
  56. .endm
  57. .macro RESTORE_FPU
  58. .set push
  59. .set noreorder
  60. #ifdef RT_USING_FPU
  61. move k1, sp /* 保存现场 */
  62. and k0, k1, 0xFFFFFFF8 /* 8字节对齐 */
  63. PTR_SUBU sp, k0, PT_FPU_SIZE /* 计算栈底*/
  64. l.d $f0, PT_FPU_R0(sp)
  65. l.d $f2, PT_FPU_R2(sp)
  66. l.d $f4, PT_FPU_R4(sp)
  67. l.d $f6, PT_FPU_R6(sp)
  68. l.d $f8, PT_FPU_R8(sp)
  69. l.d $f10, PT_FPU_R10(sp)
  70. l.d $f12, PT_FPU_R12(sp)
  71. l.d $f14, PT_FPU_R14(sp)
  72. l.d $f16, PT_FPU_R16(sp)
  73. l.d $f18, PT_FPU_R18(sp)
  74. l.d $f20, PT_FPU_R20(sp)
  75. l.d $f22, PT_FPU_R22(sp)
  76. l.d $f24, PT_FPU_R24(sp)
  77. l.d $f26, PT_FPU_R26(sp)
  78. l.d $f28, PT_FPU_R28(sp)
  79. l.d $f30, PT_FPU_R30(sp)
  80. move sp, k1 /* 恢复现场 */
  81. #endif
  82. .set reorder
  83. .set pop
  84. .endm
  85. #endif