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