2.9
[glibc/nacl-glibc.git] / sysdeps / alpha / bb_init_func.S
blobf711c8cb7425de5854fdb72e7a15b0f8f9092bdc
1 /* Copyright (C) 1996, 1997 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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 /* __bb_init_func is invoked at the beginning of each function, before
21    any registers have been saved.  It is therefore safe to use any
22    caller-saved (call-used) registers (except for argument registers
23    a1-a5). */
25 #include <sysdep.h>
28  * These offsets should match with "struct bb" declared in gcc/libgcc2.c.
29  */
30 #define ZERO_WORD       0x00
31 #define NEXT            0x20
33         .set    noat
34         .set    noreorder
36 ENTRY(__bb_init_func)
37         .prologue 0
39         ldq     t0, ZERO_WORD(a0)       /* t0 <- blocks->zero_word */
40         beq     t0, init                /* not initialized yet -> */
41         ret
43 END(__bb_init_func)
45         .ent init
46 init:
47         .frame  sp, 0x38, ra, 0
48         subq    sp, 0x38, sp
49         .prologue 0
51         stq     pv, 0x30(sp)
52         br      pv, 1f
53 1:      ldgp    gp, 0(pv)
55         ldiq    t1, __bb_head
56         lda     t3, _gmonparam
57         ldq     t2, 0(t1)
58         ldl     t3, 0(t3)               /* t3 = _gmonparam.state */
59         lda     t0, 1
60         stq     t0, ZERO_WORD(a0)       /* blocks->zero_word = 1 */
61         stq     t2, NEXT(a0)            /* blocks->next = __bb_head */
62         stq     a0, 0(t1)
63         bne     t2, $leave
64         beq     t3, $leave              /* t3 == GMON_PROF_ON? yes -> */
66         /* also need to initialize destructor: */
67         stq     ra, 0x00(sp)
68         lda     a0, __bb_exit_func
69         stq     a1, 0x08(sp)
70         lda     pv, atexit
71         stq     a2, 0x10(sp)
72         stq     a3, 0x18(sp)
73         stq     a4, 0x20(sp)
74         stq     a5, 0x28(sp)
75         jsr     ra, (pv), atexit
76         ldq     ra, 0x00(sp)
77         ldq     a1, 0x08(sp)
78         ldq     a2, 0x10(sp)
79         ldq     a3, 0x18(sp)
80         ldq     a4, 0x20(sp)
81         ldq     a5, 0x28(sp)
83 $leave: ldq     pv, 0x30(sp)
84         addq    sp, 0x38, sp
85         ret
87         .end init