Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / alpha / bb_init_func.S
blob77a05b021c74b37fdb3676f415c8a190b53f1e35
1 /* Copyright (C) 1996-2014 Free Software Foundation, Inc.
2    Contributed by David Mosberger (davidm@cs.arizona.edu).
3    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.
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.
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    <http://www.gnu.org/licenses/>.  */
19 /* __bb_init_func is invoked at the beginning of each function, before
20    any registers have been saved.  It is therefore safe to use any
21    caller-saved (call-used) registers (except for argument registers
22    a1-a5). */
24 #include <sysdep.h>
27  * These offsets should match with "struct bb" declared in gcc/libgcc2.c.
28  */
29 #define ZERO_WORD       0x00
30 #define NEXT            0x20
32         .set    noat
33         .set    noreorder
35 ENTRY(__bb_init_func)
36         .prologue 0
38         ldq     t0, ZERO_WORD(a0)       /* t0 <- blocks->zero_word */
39         beq     t0, init                /* not initialized yet -> */
40         ret
42 END(__bb_init_func)
44         .ent init
45 init:
46         .frame  sp, 0x38, ra, 0
47         subq    sp, 0x38, sp
48         .prologue 0
50         stq     pv, 0x30(sp)
51         br      pv, 1f
52 1:      ldgp    gp, 0(pv)
54         ldiq    t1, __bb_head
55         lda     t3, _gmonparam
56         ldq     t2, 0(t1)
57         ldl     t3, 0(t3)               /* t3 = _gmonparam.state */
58         lda     t0, 1
59         stq     t0, ZERO_WORD(a0)       /* blocks->zero_word = 1 */
60         stq     t2, NEXT(a0)            /* blocks->next = __bb_head */
61         stq     a0, 0(t1)
62         bne     t2, $leave
63         beq     t3, $leave              /* t3 == GMON_PROF_ON? yes -> */
65         /* also need to initialize destructor: */
66         stq     ra, 0x00(sp)
67         lda     a0, __bb_exit_func
68         stq     a1, 0x08(sp)
69         lda     pv, atexit
70         stq     a2, 0x10(sp)
71         stq     a3, 0x18(sp)
72         stq     a4, 0x20(sp)
73         stq     a5, 0x28(sp)
74         jsr     ra, (pv), atexit
75         ldq     ra, 0x00(sp)
76         ldq     a1, 0x08(sp)
77         ldq     a2, 0x10(sp)
78         ldq     a3, 0x18(sp)
79         ldq     a4, 0x20(sp)
80         ldq     a5, 0x28(sp)
82 $leave: ldq     pv, 0x30(sp)
83         addq    sp, 0x38, sp
84         ret
86         .end init