Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / alpha / _mcount.S
blobf61287557b13ccdbe722fdddab8546fef0739c0b
1 /* Machine-specific calling sequence for `mcount' profiling function.  alpha
2    Copyright (C) 1995-2014 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, see
18    <http://www.gnu.org/licenses/>.  */
20 /* Assembly stub to invoke _mcount().  Compiler generated code calls
21    this stub after executing a function's prologue and without saving any
22    registers.  It is therefore necessary to preserve a0..a5 as they may
23    contain function arguments.  To work correctly with frame- less
24    functions, it is also necessary to preserve ra.  Finally, division
25    routines are invoked with a special calling convention and the
26    compiler treats those calls as if they were instructions.  In
27    particular, it doesn't save any of the temporary registers (caller
28    saved registers).  It is therefore necessary to preserve all
29    caller-saved registers as well.
31    Upon entering _mcount, register $at holds the return address and ra
32    holds the return address of the function's caller (selfpc and frompc,
33    respectively in gmon.c language...). */
35 #include <sysdep.h>
37         .set    noat
38         .set    noreorder
40 LEAF(_mcount, 0xb0)
41         subq     sp, 0xb0, sp
42         .prologue 0
43         stq      a0, 0x00(sp)
44         mov      ra, a0         # a0 = caller-pc
45         stq      a1, 0x08(sp)
46         mov     $at, a1         # a1 = self-pc
47         stq     $at, 0x10(sp)
49         stq      a2, 0x18(sp)
50         stq      a3, 0x20(sp)
51         stq      a4, 0x28(sp)
52         stq      a5, 0x30(sp)
53         stq      ra, 0x38(sp)
54         stq      gp, 0x40(sp)
56         br      gp, 1f
57 1:      ldgp    gp, 0(gp)
59         stq      t0, 0x48(sp)
60         stq      t1, 0x50(sp)
61         stq      t2, 0x58(sp)
62         stq      t3, 0x60(sp)
63         stq      t4, 0x68(sp)
64         stq      t5, 0x70(sp)
65         stq      t6, 0x78(sp)
67         stq      t7, 0x80(sp)
68         stq      t8, 0x88(sp)
69         stq      t9, 0x90(sp)
70         stq     t10, 0x98(sp)
71         stq     t11, 0xa0(sp)
72         stq      v0, 0xa8(sp)
74         jsr     ra, __mcount
76         ldq      a0, 0x00(sp)
77         ldq      a1, 0x08(sp)
78         ldq     $at, 0x10(sp)   # restore self-pc
79         ldq      a2, 0x18(sp)
80         ldq      a3, 0x20(sp)
81         ldq      a4, 0x28(sp)
82         ldq      a5, 0x30(sp)
83         ldq      ra, 0x38(sp)
84         ldq      gp, 0x40(sp)
85         mov     $at, pv         # make pv point to return address
86         ldq      t0, 0x48(sp)   # this is important under OSF/1 to
87         ldq      t1, 0x50(sp)   # ensure that the code that we return
88         ldq      t2, 0x58(sp)   # can correctly compute its gp
89         ldq      t3, 0x60(sp)
90         ldq      t4, 0x68(sp)
91         ldq      t5, 0x70(sp)
92         ldq      t6, 0x78(sp)
93         ldq      t7, 0x80(sp)
94         ldq      t8, 0x88(sp)
95         ldq      t9, 0x90(sp)
96         ldq     t10, 0x98(sp)
97         ldq     t11, 0xa0(sp)
98         ldq      v0, 0xa8(sp)
100         addq    sp, 0xb0, sp
101         ret     zero,($at),1
103         END(_mcount)
105 weak_alias (_mcount, mcount)