_mcount.S 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Machine-specific calling sequence for `mcount' profiling function. ia64
  2. Copyright (C) 2000-2019 Free Software Foundation, Inc.
  3. Contributed by David Mosberger <davidm@hpl.hp.com>
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. /* Assembly stub to invoke _mcount(). Compiler generated code calls
  17. this stub before executing a function's prologue and without saving
  18. any registers. It is therefore necessary to preserve the input
  19. registers as they may contain function arguments. To work
  20. correctly with frame-less functions, it is also necessary to
  21. preserve the return pointer (b0 aka rp).
  22. State upon entering _mcount:
  23. r8 address of return value structure (used only when called
  24. function returns a large structure)
  25. r15 static link (used only for nested functions)
  26. in0 ar.pfs to restore before returning to the function that
  27. called _mcount
  28. in1 gp value to restore before returning to the function that
  29. called _mcount
  30. in2 return address in the function that invoked the caller
  31. of _mcount (frompc)
  32. in3 address of the global-offset table entry that holds the
  33. profile count dword allocated by the compiler; to get
  34. the address of this dword, use "ld8 in2=[in2]; this
  35. dword can be used in any way by _mcount (including
  36. not at all, as is the case with the current implementation)
  37. b0 address to return to after _mcount is done
  38. */
  39. #include <sysdep.h>
  40. #undef ret
  41. LEAF(_mcount)
  42. .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(4)
  43. alloc loc1 = ar.pfs, 4, 4, 3, 0
  44. mov loc0 = rp
  45. .body
  46. mov loc2 = r8 // gcc uses r8 to pass pointer to return structure
  47. ;;
  48. mov loc3 = r15 // gcc uses r15 to pass the static link to nested functions
  49. mov out0 = in2
  50. mov out1 = rp
  51. br.call.sptk.few rp = __mcount
  52. ;;
  53. .here:
  54. {
  55. .mii
  56. mov gp = in1
  57. mov r2 = ip
  58. mov ar.pfs = loc1
  59. }
  60. ;;
  61. adds r2 = _mcount_ret_helper - .here, r2
  62. mov b7 = loc0
  63. mov rp = in2
  64. ;;
  65. mov r3 = in0
  66. mov r8 = loc2
  67. mov r15 = loc3
  68. mov b6 = r2
  69. br.ret.sptk.few b6
  70. END(_mcount)
  71. LOCAL_LEAF(_mcount_ret_helper)
  72. .prologue
  73. .altrp b7
  74. .save ar.pfs, r3
  75. .body
  76. alloc r2 = ar.pfs, 0, 0, 8, 0
  77. mov ar.pfs = r3
  78. br b7
  79. END(_mcount_ret_helper)
  80. weak_alias (_mcount, mcount)