2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / config / i860 / varargs.asm
blobff58d7325b0fca5acf012c6b80defd9a054c0df7
1 /* Special varargs support for i860.
2 Copyright (C) 2001, 2003 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file. (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
18 executable.)
20 GCC is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with GCC; see the file COPYING. If not, write to
27 the Free Software Foundation, 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. */
30 #if defined(__svr4__) || defined(__alliant__)
31 .text
32 .align 4
34 /* The Alliant needs the added underscore. */
35 .globl __builtin_saveregs
36 __builtin_saveregs:
37 .globl ___builtin_saveregs
38 ___builtin_saveregs:
40 andnot 0x0f,%sp,%sp /* round down to 16-byte boundary */
41 #if 0
42 adds -96,%sp,%sp /* allocate stack space for reg save
43 area and also for a new va_list
44 structure */
45 #else
46 adds -80,%sp,%sp /* allocate stack space for reg save area */
47 #endif
48 /* Save all argument registers in the arg reg save area. The
49 arg reg save area must have the following layout (according
50 to the svr4 ABI):
52 struct {
53 union {
54 float freg[8];
55 double dreg[4];
56 } float_regs;
57 long ireg[12];
61 fst.q %f8, 0(%sp) /* save floating regs (f8-f15) */
62 fst.q %f12,16(%sp)
64 st.l %r16,32(%sp) /* save integer regs (r16-r27) */
65 st.l %r17,36(%sp)
66 st.l %r18,40(%sp)
67 st.l %r19,44(%sp)
68 st.l %r20,48(%sp)
69 st.l %r21,52(%sp)
70 st.l %r22,56(%sp)
71 st.l %r23,60(%sp)
72 st.l %r24,64(%sp)
73 st.l %r25,68(%sp)
74 st.l %r26,72(%sp)
75 st.l %r27,76(%sp)
77 #if 0
78 adds 80,%sp,%r16 /* compute the address of the new
79 va_list structure. Put in into
80 r16 so that it will be returned
81 to the caller. */
82 #endif
84 /* Initialize all fields of the new va_list structure. This
85 structure looks like:
87 typedef struct {
88 unsigned long ireg_used;
89 unsigned long freg_used;
90 long *reg_base;
91 long *mem_ptr;
92 } va_list;
95 #if 0
96 st.l %r0, 0(%r16) /* nfixed */
97 st.l %r0, 4(%r16) /* nfloating */
98 st.l %sp, 8(%r16) /* __va_ctl points to __va_struct. */
99 bri %r1 /* delayed return */
100 st.l %r28,12(%r16) /* pointer to overflow args */
101 #else
102 bri %r1 /* delayed return */
103 or %sp,%r0,%r16 /* Return the address of the reg save area. */
104 #endif
106 #else /* not __svr4__ */
107 #if defined(__PARAGON__)
109 * we'll use SVR4-ish varargs but need SVR3.2 assembler syntax,
110 * and we stand a better chance of hooking into libraries
111 * compiled by PGI. [andyp@ssd.intel.com]
113 .text
114 .align 4
115 .globl __builtin_saveregs
116 __builtin_saveregs:
117 .globl ___builtin_saveregs
118 ___builtin_saveregs:
120 andnot 0x0f,sp,sp /* round down to 16-byte boundary */
121 adds -96,sp,sp /* allocate stack space for reg save
122 area and also for a new va_list
123 structure */
124 /* Save all argument registers in the arg reg save area. The
125 arg reg save area must have the following layout (according
126 to the svr4 ABI):
128 struct {
129 union {
130 float freg[8];
131 double dreg[4];
132 } float_regs;
133 long ireg[12];
137 fst.q f8, 0(sp)
138 fst.q f12,16(sp)
139 st.l r16,32(sp)
140 st.l r17,36(sp)
141 st.l r18,40(sp)
142 st.l r19,44(sp)
143 st.l r20,48(sp)
144 st.l r21,52(sp)
145 st.l r22,56(sp)
146 st.l r23,60(sp)
147 st.l r24,64(sp)
148 st.l r25,68(sp)
149 st.l r26,72(sp)
150 st.l r27,76(sp)
152 adds 80,sp,r16 /* compute the address of the new
153 va_list structure. Put in into
154 r16 so that it will be returned
155 to the caller. */
157 /* Initialize all fields of the new va_list structure. This
158 structure looks like:
160 typedef struct {
161 unsigned long ireg_used;
162 unsigned long freg_used;
163 long *reg_base;
164 long *mem_ptr;
165 } va_list;
168 st.l r0, 0(r16) /* nfixed */
169 st.l r0, 4(r16) /* nfloating */
170 st.l sp, 8(r16) /* __va_ctl points to __va_struct. */
171 bri r1 /* delayed return */
172 st.l r28,12(r16) /* pointer to overflow args */
173 #else /* not __PARAGON__ */
174 .text
175 .align 4
177 .globl ___builtin_saveregs
178 ___builtin_saveregs:
179 mov sp,r30
180 andnot 0x0f,sp,sp
181 adds -96,sp,sp /* allocate sufficient space on the stack */
183 /* Fill in the __va_struct. */
184 st.l r16, 0(sp) /* save integer regs (r16-r27) */
185 st.l r17, 4(sp) /* int fixed[12] */
186 st.l r18, 8(sp)
187 st.l r19,12(sp)
188 st.l r20,16(sp)
189 st.l r21,20(sp)
190 st.l r22,24(sp)
191 st.l r23,28(sp)
192 st.l r24,32(sp)
193 st.l r25,36(sp)
194 st.l r26,40(sp)
195 st.l r27,44(sp)
197 fst.q f8, 48(sp) /* save floating regs (f8-f15) */
198 fst.q f12,64(sp) /* int floating[8] */
200 /* Fill in the __va_ctl. */
201 st.l sp, 80(sp) /* __va_ctl points to __va_struct. */
202 st.l r28,84(sp) /* pointer to more args */
203 st.l r0, 88(sp) /* nfixed */
204 st.l r0, 92(sp) /* nfloating */
206 adds 80,sp,r16 /* return address of the __va_ctl. */
207 bri r1
208 mov r30,sp
209 /* recover stack and pass address to start
210 of data. */
211 #endif /* not __PARAGON__ */
212 #endif /* not __svr4__ */