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

source code of glibc/sysdeps/ia64/_mcount.S