2.9
[glibc/nacl-glibc.git] / sysdeps / alpha / _mcount.S
blobc4c921b4f798b3614c95d251e1598f13e9c1533f
1 /* Machine-specific calling sequence for `mcount' profiling function.  alpha
2    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
3    Contributed by David Mosberger (davidm@cs.arizona.edu).
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 after executing a function's prologue and without saving any
23    registers.  It is therefore necessary to preserve a0..a5 as they may
24    contain function arguments.  To work correctly with frame- less
25    functions, it is also necessary to preserve ra.  Finally, division
26    routines are invoked with a special calling convention and the
27    compiler treats those calls as if they were instructions.  In
28    particular, it doesn't save any of the temporary registers (caller
29    saved registers).  It is therefore necessary to preserve all
30    caller-saved registers as well.
32    Upon entering _mcount, register $at holds the return address and ra
33    holds the return address of the function's caller (selfpc and frompc,
34    respectively in gmon.c language...). */
36 #include <sysdep.h>
38         .set    noat
39         .set    noreorder
41 LEAF(_mcount, 0xb0)
42         .prologue 0
44         subq     sp, 0xb0, sp
45         stq      a0, 0x00(sp)
46         mov      ra, a0         # a0 = caller-pc
47         stq      a1, 0x08(sp)
48         mov     $at, a1         # a1 = self-pc
49         stq     $at, 0x10(sp)
51         stq      a2, 0x18(sp)
52         stq      a3, 0x20(sp)
53         stq      a4, 0x28(sp)
54         stq      a5, 0x30(sp)
55         stq      ra, 0x38(sp)
56         stq      gp, 0x40(sp)
58         br      gp, 1f
59 1:      ldgp    gp, 0(gp)
61         stq      t0, 0x48(sp)
62         stq      t1, 0x50(sp)
63         stq      t2, 0x58(sp)
64         stq      t3, 0x60(sp)
65         stq      t4, 0x68(sp)
66         stq      t5, 0x70(sp)
67         stq      t6, 0x78(sp)
69         stq      t7, 0x80(sp)
70         stq      t8, 0x88(sp)
71         stq      t9, 0x90(sp)
72         stq     t10, 0x98(sp)
73         stq     t11, 0xa0(sp)
74         stq      v0, 0xa8(sp)
76         jsr     ra, __mcount
78         ldq      a0, 0x00(sp)
79         ldq      a1, 0x08(sp)
80         ldq     $at, 0x10(sp)   # restore self-pc
81         ldq      a2, 0x18(sp)
82         ldq      a3, 0x20(sp)
83         ldq      a4, 0x28(sp)
84         ldq      a5, 0x30(sp)
85         ldq      ra, 0x38(sp)
86         ldq      gp, 0x40(sp)
87         mov     $at, pv         # make pv point to return address
88         ldq      t0, 0x48(sp)   # this is important under OSF/1 to
89         ldq      t1, 0x50(sp)   # ensure that the code that we return
90         ldq      t2, 0x58(sp)   # can correctly compute its gp
91         ldq      t3, 0x60(sp)
92         ldq      t4, 0x68(sp)
93         ldq      t5, 0x70(sp)
94         ldq      t6, 0x78(sp)
95         ldq      t7, 0x80(sp)
96         ldq      t8, 0x88(sp)
97         ldq      t9, 0x90(sp)
98         ldq     t10, 0x98(sp)
99         ldq     t11, 0xa0(sp)
100         ldq      v0, 0xa8(sp)
102         addq    sp, 0xb0, sp
103         ret     zero,($at),1
105         END(_mcount)
107 weak_alias (_mcount, mcount)