machine-gmon.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Machine-dependent definitions for profiling support. SH version.
  2. *
  3. * Copyright (C) 2003 Stefan Allius <allius@atecom.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public
  16. * License along with this program; if not, write to the Free
  17. * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  18. * 02111-1307 USA
  19. */
  20. #define mcount_internal __mcount_internal
  21. #define _MCOUNT_DECL(frompc, selfpc) \
  22. static void __attribute__((unused)) mcount_internal (u_long frompc, u_long selfpc)
  23. /*
  24. * This mcount implementation expect the 'frompc' return address on
  25. * the stack and the 'selfpc' return address in register pr.
  26. *
  27. * Your compiler should include some stuff like this at each function
  28. * entry:
  29. *
  30. * mov.l 1f,r1
  31. * sts.l pr,@-r15
  32. * mova 2f,r0
  33. * jmp @r1
  34. * lds r0,pr
  35. * .align 2
  36. * 1: .long mcount
  37. * 2: lds.l @r15+,pr
  38. *
  39. * or for PIC:
  40. *
  41. * mov.l 3f,r1
  42. * mova 3f,r0
  43. * add r1,r0
  44. * mov.l 1f,r1
  45. * mov.l @(r0,r1),r1
  46. * sts.l pr,@-r15
  47. * mova 2f,r0
  48. * jmp @r1
  49. * lds r0,pr
  50. * .align 2
  51. * 1: .long mcount@GOT
  52. * 3: .long _GLOBAL_OFFSET_TABLE_
  53. * 2: lds.l @r15+,pr
  54. *
  55. *
  56. * This ABI will be supported by GCC version 3.3 or newer!
  57. */
  58. #define MCOUNT asm(\
  59. ".align 4\n\t" \
  60. ".globl _mcount\n\t" \
  61. ".type _mcount,@function\n" \
  62. "_mcount:\n\t" \
  63. "mov.l r4, @-r15\n\t" \
  64. "mov.l r5, @-r15\n\t" \
  65. "mov.l r6, @-r15\n\t" \
  66. "mov.l r7, @-r15\n\t" \
  67. "sts.l pr, @-r15\n\t" \
  68. "sts pr, r5\n\t" \
  69. "bsr __mcount_internal\n\t" \
  70. " mov.l @(5*4,r15), r4\n\t" \
  71. "lds.l @r15+, pr\n\t" \
  72. "mov.l @r15+, r7\n\t" \
  73. "mov.l @r15+, r6\n\t" \
  74. "mov.l @r15+, r5\n\t" \
  75. "rts\n\t" \
  76. " mov.l @r15+, r4\n\t" \
  77. ".size _mcount,.-_mcount;\n\t" \
  78. ".weak mcount;\n\t" \
  79. " mcount = _mcount;");