machine-gmon.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Machine-dependent definitions for profiling support. Nios II version.
  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 <sysdep.h>
  16. #define _MCOUNT_DECL(frompc, selfpc) \
  17. static void __attribute_used__ __mcount_internal (u_long frompc, u_long selfpc)
  18. /* This macro/func MUST save r4, r5, r6, r7 and r8 because the compiler inserts
  19. blind calls to mcount(), ignoring the fact that mcount may clobber
  20. registers; therefore, mcount may NOT clobber registers. */
  21. #if defined(__PIC__) || defined(PIC)
  22. #define NIOS2_MCOUNT_CALL \
  23. "nextpc r3\n\t" \
  24. "1: movhi r2, %hiadj(_gp_got - 1b)\n\t" \
  25. "addi r2, r2, %lo(_gp_got - 1b)\n\t" \
  26. "add r2, r2, r3\n\t" \
  27. "ldw r2, %call(__mcount_internal)(r2)\n\t" \
  28. "callr r2\n\t"
  29. #else
  30. #define NIOS2_MCOUNT_CALL \
  31. "call\t__mcount_internal\n\t"
  32. #endif
  33. #define MCOUNT \
  34. asm (".globl _mcount\n\t" \
  35. ".type _mcount,@function\n\t" \
  36. "_mcount:\n\t" \
  37. "subi sp, sp, 24\n\t" \
  38. "stw ra, 20(sp)\n\t" \
  39. "stw r8, 16(sp)\n\t" \
  40. "stw r7, 12(sp)\n\t" \
  41. "stw r6, 8(sp)\n\t" \
  42. "stw r5, 4(sp)\n\t" \
  43. "stw r4, 0(sp)\n\t" \
  44. "mov r4, r8\n\t" \
  45. "mov r5, ra\n\t" \
  46. NIOS2_MCOUNT_CALL \
  47. "ldw ra, 20(sp)\n\t" \
  48. "ldw r8, 16(sp)\n\t" \
  49. "ldw r7, 12(sp)\n\t" \
  50. "ldw r6, 8(sp)\n\t" \
  51. "ldw r5, 4(sp)\n\t" \
  52. "ldw r4, 0(sp)\n\t" \
  53. "addi sp, sp, 24\n\t" \
  54. "ret\n\t" \
  55. ".size _mcount, . - _mcount\n\t" \
  56. );