machine-gmon.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* Machine-specific calling sequence for `mcount' profiling function. MIPS
  2. Copyright (C) 1996-2019 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. #include <sgidefs.h>
  16. #define _MCOUNT_DECL(frompc,selfpc) \
  17. static void __attribute_used__ __mcount (u_long frompc, u_long selfpc)
  18. /* Call __mcount with the return PC for our caller,
  19. and the return PC our caller will return to. */
  20. #if _MIPS_SIM == _ABIO32
  21. #ifdef __PIC__
  22. # define CPLOAD ".cpload $25;"
  23. # define CPRESTORE ".cprestore 44\n\t"
  24. #else
  25. # define CPLOAD
  26. # define CPRESTORE
  27. #endif
  28. #define MCOUNT asm(\
  29. ".globl _mcount;\n\t" \
  30. ".align 2;\n\t" \
  31. ".set push;\n\t" \
  32. ".set nomips16;\n\t" \
  33. ".type _mcount,@function;\n\t" \
  34. ".ent _mcount\n\t" \
  35. "_mcount:\n\t" \
  36. ".frame $sp,44,$31\n\t" \
  37. ".set noreorder;\n\t" \
  38. ".set noat;\n\t" \
  39. CPLOAD \
  40. "subu $29,$29,48;\n\t" \
  41. CPRESTORE \
  42. "sw $4,24($29);\n\t" \
  43. "sw $5,28($29);\n\t" \
  44. "sw $6,32($29);\n\t" \
  45. "sw $7,36($29);\n\t" \
  46. "sw $2,40($29);\n\t" \
  47. "sw $1,16($29);\n\t" \
  48. "sw $31,20($29);\n\t" \
  49. "move $5,$31;\n\t" \
  50. "move $4,$1;\n\t" \
  51. "jal __mcount;\n\t" \
  52. "nop;\n\t" \
  53. "lw $4,24($29);\n\t" \
  54. "lw $5,28($29);\n\t" \
  55. "lw $6,32($29);\n\t" \
  56. "lw $7,36($29);\n\t" \
  57. "lw $2,40($29);\n\t" \
  58. "lw $31,20($29);\n\t" \
  59. "lw $1,16($29);\n\t" \
  60. "addu $29,$29,56;\n\t" \
  61. "j $31;\n\t" \
  62. "move $31,$1;\n\t" \
  63. ".end _mcount;\n\t" \
  64. ".set pop");
  65. #else
  66. #ifdef __PIC__
  67. # define CPSETUP ".cpsetup $25, 88, _mcount;"
  68. # define CPRETURN ".cpreturn;"
  69. #else
  70. # define CPSETUP
  71. # define CPRETURN
  72. #endif
  73. #if _MIPS_SIM == _ABIN32
  74. # if !defined __mips_isa_rev || __mips_isa_rev < 6
  75. # define PTR_ADDU_STRING "add" /* no u */
  76. # define PTR_SUBU_STRING "sub" /* no u */
  77. # else
  78. # define PTR_ADDU_STRING "addu"
  79. # define PTR_SUBU_STRING "subu"
  80. # endif
  81. #elif _MIPS_SIM == _ABI64
  82. # define PTR_ADDU_STRING "daddu"
  83. # define PTR_SUBU_STRING "dsubu"
  84. #else
  85. # error "Unknown ABI"
  86. #endif
  87. #define MCOUNT asm(\
  88. ".globl _mcount;\n\t" \
  89. ".align 3;\n\t" \
  90. ".set push;\n\t" \
  91. ".set nomips16;\n\t" \
  92. ".type _mcount,@function;\n\t" \
  93. ".ent _mcount\n\t" \
  94. "_mcount:\n\t" \
  95. ".frame $sp,88,$31\n\t" \
  96. ".set noreorder;\n\t" \
  97. ".set noat;\n\t" \
  98. PTR_SUBU_STRING " $29,$29,96;\n\t" \
  99. CPSETUP \
  100. "sd $4,24($29);\n\t" \
  101. "sd $5,32($29);\n\t" \
  102. "sd $6,40($29);\n\t" \
  103. "sd $7,48($29);\n\t" \
  104. "sd $8,56($29);\n\t" \
  105. "sd $9,64($29);\n\t" \
  106. "sd $10,72($29);\n\t" \
  107. "sd $11,80($29);\n\t" \
  108. "sd $2,16($29);\n\t" \
  109. "sd $1,0($29);\n\t" \
  110. "sd $31,8($29);\n\t" \
  111. "move $5,$31;\n\t" \
  112. "move $4,$1;\n\t" \
  113. "jal __mcount;\n\t" \
  114. "nop;\n\t" \
  115. "ld $4,24($29);\n\t" \
  116. "ld $5,32($29);\n\t" \
  117. "ld $6,40($29);\n\t" \
  118. "ld $7,48($29);\n\t" \
  119. "ld $8,56($29);\n\t" \
  120. "ld $9,64($29);\n\t" \
  121. "ld $10,72($29);\n\t" \
  122. "ld $11,80($29);\n\t" \
  123. "ld $2,16($29);\n\t" \
  124. "ld $31,8($29);\n\t" \
  125. "ld $1,0($29);\n\t" \
  126. CPRETURN \
  127. PTR_ADDU_STRING " $29,$29,96;\n\t" \
  128. "j $31;\n\t" \
  129. "move $31,$1;\n\t" \
  130. ".end _mcount;\n\t" \
  131. ".set pop");
  132. #endif