Imported Upstream version 3.6
[debian/elilo] / ia64 / setjmp.S
1 /* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
2    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.
18
19    The layout of the jmp_buf is as follows.  This is subject to change
20    and user-code should never depend on the particular layout of
21    jmp_buf!
22
23
24         offset: description:
25         ------- ------------
26         0x000   stack pointer (r12)     ; unchangeable (see _JMPBUF_UNWINDS)
27         0x008   r1 (gp)
28         0x010   caller's unat
29         0x018   fpsr
30         0x020   r4
31         0x028   r5
32         0x030   r6
33         0x038   r7
34         0x040   rp (b0)
35         0x048   b1
36         0x050   b2
37         0x058   b3
38         0x060   b4
39         0x068   b5
40         0x070   ar.pfs
41         0x078   ar.lc
42         0x080   pr
43         0x088   ar.bsp                  ; unchangeable (see __longjmp.S)
44         0x090   ar.unat
45         0x098   &__jmp_buf      ; address of the jmpbuf (needed to locate NaT bits in unat)
46         0x0a0    f2
47         0x0b0    f3
48         0x0c0    f4
49         0x0d0    f5
50         0x0e0   f16
51         0x0f0   f17
52         0x100   f18
53         0x110   f19
54         0x120   f20
55         0x130   f21
56         0x130   f22
57         0x140   f23
58         0x150   f24
59         0x160   f25
60         0x170   f26
61         0x180   f27
62         0x190   f28
63         0x1a0   f29
64         0x1b0   f30
65         0x1c0   f31 */
66
67
68         /* The following two entry points are the traditional entry points: */
69
70         .text
71         .global setjmp
72         .proc setjmp
73 setjmp:
74         alloc r8=ar.pfs,2,0,0,0
75         mov in1=1
76         br.cond.sptk.many __sigsetjmp
77         .endp setjmp
78
79         /* __sigsetjmp(__jmp_buf buf, int savemask) */
80
81         .proc __sigsetjmp
82 __sigsetjmp:
83         //.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
84         alloc loc1=ar.pfs,2,2,2,0
85         mov r16=ar.unat
86         ;;
87         mov r17=ar.fpsr
88         mov r2=in0
89         add r3=8,in0
90         ;;
91         st8.spill.nta [r2]=sp,16        // r12 (sp)
92         st8.spill.nta [r3]=gp,16        // r1 (gp)
93         ;;
94         st8.nta [r2]=r16,16             // save caller's unat
95         st8.nta [r3]=r17,16             // save fpsr
96         add r8=0xa0,in0
97         ;;
98         st8.spill.nta [r2]=r4,16        // r4
99         st8.spill.nta [r3]=r5,16        // r5
100         add r9=0xb0,in0
101         ;;
102         stf.spill.nta [r8]=f2,32
103         stf.spill.nta [r9]=f3,32
104         mov loc0=rp
105         .body
106         ;;
107         stf.spill.nta [r8]=f4,32
108         stf.spill.nta [r9]=f5,32
109         mov r17=b1
110         ;;
111         stf.spill.nta [r8]=f16,32
112         stf.spill.nta [r9]=f17,32
113         mov r18=b2
114         ;;
115         stf.spill.nta [r8]=f18,32
116         stf.spill.nta [r9]=f19,32
117         mov r19=b3
118         ;;
119         stf.spill.nta [r8]=f20,32
120         stf.spill.nta [r9]=f21,32
121         mov r20=b4
122         ;;
123         stf.spill.nta [r8]=f22,32
124         stf.spill.nta [r9]=f23,32
125         mov r21=b5
126         ;;
127         stf.spill.nta [r8]=f24,32
128         stf.spill.nta [r9]=f25,32
129         mov r22=ar.lc
130         ;;
131         stf.spill.nta [r8]=f26,32
132         stf.spill.nta [r9]=f27,32
133         mov r24=pr
134         ;;
135         stf.spill.nta [r8]=f28,32
136         stf.spill.nta [r9]=f29,32
137         ;;
138         stf.spill.nta [r8]=f30
139         stf.spill.nta [r9]=f31
140
141         st8.spill.nta [r2]=r6,16        // r6
142         st8.spill.nta [r3]=r7,16        // r7
143         ;;
144         mov r23=ar.bsp
145         mov r25=ar.unat
146         mov out0=in0
147
148         st8.nta [r2]=loc0,16            // b0
149         st8.nta [r3]=r17,16             // b1
150         mov out1=in1
151         ;;
152         st8.nta [r2]=r18,16             // b2
153         st8.nta [r3]=r19,16             // b3
154         ;;
155         st8.nta [r2]=r20,16             // b4
156         st8.nta [r3]=r21,16             // b5
157         ;;
158         st8.nta [r2]=loc1,16            // ar.pfs
159         st8.nta [r3]=r22,16             // ar.lc
160         ;;
161         st8.nta [r2]=r24,16             // pr
162         st8.nta [r3]=r23,16             // ar.bsp
163         ;;
164         st8.nta [r2]=r25                // ar.unat
165         st8.nta [r3]=in0                // &__jmp_buf
166         mov r8=0
167         mov rp=loc0
168         mov ar.pfs=loc1
169         br.ret.sptk.many rp
170
171         .endp __sigsetjmp