1457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique/* -----------------------------------------------------------------------
2457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   unix.S - Copyright (c) 1998, 2008 Red Hat, Inc.
3457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique            Copyright (c) 2000 Hewlett Packard Company
4457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
5457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   IA64/unix Foreign Function Interface
6457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
7457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   Primary author: Hans Boehm, HP Labs
8457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
9457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   Loosely modeled on Cygnus code for other platforms.
10457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
11457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   Permission is hereby granted, free of charge, to any person obtaining
12457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   a copy of this software and associated documentation files (the
13457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   ``Software''), to deal in the Software without restriction, including
14457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   without limitation the rights to use, copy, modify, merge, publish,
15457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   distribute, sublicense, and/or sell copies of the Software, and to
16457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   permit persons to whom the Software is furnished to do so, subject to
17457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   the following conditions:
18457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
19457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   The above copyright notice and this permission notice shall be included
20457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   in all copies or substantial portions of the Software.
21457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
22457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
23457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   DEALINGS IN THE SOFTWARE.
30457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique   ----------------------------------------------------------------------- */
31457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
32457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#define LIBFFI_ASM
33457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#include <fficonfig.h>
34457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#include <ffi.h>
35457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#include "ia64_flags.h"
36457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
37457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.pred.safe_across_calls p1-p5,p16-p63
38457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.text
39457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
40457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique/* int ffi_call_unix (struct ia64_args *stack, PTR64 rvalue,
41457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique		      void (*fn)(void), int flags);
42457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique */
43457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
44457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique        .align 16
45457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique        .global	ffi_call_unix
46457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique        .proc	ffi_call_unix
47457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Piqueffi_call_unix:
48457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.prologue
49457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Bit o trickiness.  We actually share a stack frame with ffi_call.
50457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	   Rely on the fact that ffi_call uses a vframe and don't bother
51457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	   tracking one here at all.  */
52457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.fframe	0
53457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.save	ar.pfs, r36 // loc0
54457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	alloc   loc0 = ar.pfs, 4, 3, 8, 0
55457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.save	rp, loc1
56457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov 	loc1 = b0
57457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
58457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r16 = 16, in0
59457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	loc2 = gp
60457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	r8 = in1
61457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
62457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
63457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Load up all of the argument registers.  */
64457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f8 = [in0], 32
65457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f9 = [r16], 32
66457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
67457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f10 = [in0], 32
68457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f11 = [r16], 32
69457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
70457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f12 = [in0], 32
71457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f13 = [r16], 32
72457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
73457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f14 = [in0], 32
74457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldf.fill f15 = [r16], 24
75457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
76457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out0 = [in0], 16
77457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out1 = [r16], 16
78457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
79457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out2 = [in0], 16
80457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out3 = [r16], 16
81457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
82457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out4 = [in0], 16
83457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out5 = [r16], 16
84457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
85457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out6 = [in0]
86457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	out7 = [r16]
87457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
88457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
89457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Deallocate the register save area from the stack frame.  */
90457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	sp = in0
91457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
92457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Call the target function.  */
93457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	r16 = [in2], 8
94457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
95457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	gp = [in2]
96457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	b6 = r16
97457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.call.sptk.many b0 = b6
98457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
99457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
100457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Dispatch to handle return value.  */
101457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	gp = loc2
102457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	zxt1	r16 = in3
103457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
104457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	ar.pfs = loc0
105457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	addl	r18 = @ltoffx(.Lst_table), gp
106457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
107457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8.mov	r18 = [r18], .Lst_table
108457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	b0 = loc1
109457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
110457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	shladd	r18 = r16, 3, r18
111457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
112457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	r17 = [r18]
113457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	shr	in3 = in3, 8
114457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
115457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = r17, r18
116457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
117457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	b6 = r17
118457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br	b6
119457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
120457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
121457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_void:
122457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
123457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
124457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_uint8:
125457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	zxt1	r8 = r8
126457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
127457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[in1] = r8
128457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
129457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
130457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_sint8:
131457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	sxt1	r8 = r8
132457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
133457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[in1] = r8
134457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
135457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
136457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_uint16:
137457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	zxt2	r8 = r8
138457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
139457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[in1] = r8
140457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
141457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
142457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_sint16:
143457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	sxt2	r8 = r8
144457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
145457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[in1] = r8
146457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
147457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
148457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_uint32:
149457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	zxt4	r8 = r8
150457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
151457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[in1] = r8
152457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
153457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
154457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_sint32:
155457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	sxt4	r8 = r8
156457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
157457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[in1] = r8
158457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
159457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
160457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_int64:
161457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[in1] = r8
162457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
163457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
164457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_float:
165457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stfs	[in1] = f8
166457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
167457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
168457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_double:
169457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stfd	[in1] = f8
170457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
171457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
172457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_ldouble:
173457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stfe	[in1] = f8
174457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
175457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
176457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
177457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_small_struct:
178457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = -16, sp
179457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 8, in3
180457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 16, in3
181457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 24, in3
182457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
183457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r16 = 8, sp
184457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = 16, sp
185457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r18 = 24, sp
186457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
187457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8	[sp] = r8
188457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	st8	[r16] = r9
189457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	out0 = in1
190457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	st8	[r17] = r10
191457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	st8	[r18] = r11
192457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	out1 = sp
193457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	out2 = in3
194457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.call.sptk.many b0 = memcpy#
195457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
196457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	ar.pfs = loc0
197457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	b0 = loc1
198457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	gp = loc2
199457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
200457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
201457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_hfa_float:
202457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r16 = 4, in1
203457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 4, in3
204457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
205457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stfs	[in1] = f8, 8
206457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	stfs	[r16] = f9, 8
207457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 8, in3
208457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 12, in3
209457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
210457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	stfs	[in1] = f10, 8
211457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	stfs	[r16] = f11, 8
212457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p9, p0 = 16, in3
213457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p10, p0 = 20, in3
214457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
215457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p9)	stfs	[in1] = f12, 8
216457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p10)	stfs	[r16] = f13, 8
217457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 24, in3
218457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 28, in3
219457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
220457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	stfs	[in1] = f14
221457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	stfs	[r16] = f15
222457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
223457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
224457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
225457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_hfa_double:
226457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r16 = 8, in1
227457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 8, in3
228457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
229457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stfd	[in1] = f8, 16
230457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	stfd	[r16] = f9, 16
231457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 16, in3
232457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 24, in3
233457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
234457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	stfd	[in1] = f10, 16
235457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	stfd	[r16] = f11, 16
236457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p9, p0 = 32, in3
237457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p10, p0 = 40, in3
238457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
239457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p9)	stfd	[in1] = f12, 16
240457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p10)	stfd	[r16] = f13, 16
241457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 48, in3
242457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 56, in3
243457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
244457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	stfd	[in1] = f14
245457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	stfd	[r16] = f15
246457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
247457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
248457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
249457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_hfa_ldouble:
250457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r16 = 16, in1
251457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 16, in3
252457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
253457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stfe	[in1] = f8, 32
254457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	stfe	[r16] = f9, 32
255457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 32, in3
256457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 48, in3
257457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
258457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	stfe	[in1] = f10, 32
259457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	stfe	[r16] = f11, 32
260457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p9, p0 = 64, in3
261457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p10, p0 = 80, in3
262457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
263457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p9)	stfe	[in1] = f12, 32
264457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p10)	stfe	[r16] = f13, 32
265457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 96, in3
266457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 112, in3
267457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
268457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	stfe	[in1] = f14
269457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	stfe	[r16] = f15
270457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
271457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
272457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
273457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique        .endp ffi_call_unix
274457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
275457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique        .align 16
276457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique        .global ffi_closure_unix
277457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique        .proc ffi_closure_unix
278457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
279457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#define FRAME_SIZE	(8*16 + 8*8 + 8*16)
280457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
281457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Piqueffi_closure_unix:
282457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.prologue
283457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.save	ar.pfs, r40 // loc0
284457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	alloc   loc0 = ar.pfs, 8, 4, 4, 0
285457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.fframe	FRAME_SIZE
286457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r12 = -FRAME_SIZE, r12
287457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.save	rp, loc1
288457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	loc1 = b0
289457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.save	ar.unat, loc2
290457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	loc2 = ar.unat
291457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
292457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
293457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Retrieve closure pointer and real gp.  */
294457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#ifdef _ILP32
295457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	addp4	out0 = 0, gp
296457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	addp4	gp = 16, gp
297457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#else
298457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	out0 = gp
299457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	gp = 16, gp
300457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#endif
301457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
302457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	gp = [gp]
303457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
304457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Spill all of the possible argument registers.  */
305457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r16 = 16 + 8*16, sp
306457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = 16 + 8*16 + 16, sp
307457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
308457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r16] = f8, 32
309457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r17] = f9, 32
310457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	loc3 = gp
311457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
312457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r16] = f10, 32
313457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r17] = f11, 32
314457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
315457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r16] = f12, 32
316457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r17] = f13, 32
317457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
318457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r16] = f14, 32
319457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	stf.spill [r17] = f15, 24
320457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
321457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 0, 0
322457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r16] = in0, 16
323457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 8, 0
324457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r17] = in1, 16
325457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	out1 = 16 + 8*16, sp
326457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
327457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 0, 0
328457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r16] = in2, 16
329457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 8, 0
330457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r17] = in3, 16
331457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	out2 = 16, sp
332457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
333457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 0, 0
334457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r16] = in4, 16
335457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 8, 0
336457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r17] = in5, 16
337457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	out3 = r8
338457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
339457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 0, 0
340457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r16] = in6
341457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.mem.offset 8, 0
342457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	st8.spill [r17] = in7
343457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
344457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Invoke ffi_closure_unix_inner for the hard work.  */
345457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.call.sptk.many b0 = ffi_closure_unix_inner
346457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
347457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
348457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	/* Dispatch to handle return value.  */
349457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	gp = loc3
350457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	zxt1	r16 = r8
351457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
352457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	addl	r18 = @ltoffx(.Lld_table), gp
353457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	ar.pfs = loc0
354457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
355457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8.mov	r18 = [r18], .Lld_table
356457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	b0 = loc1
357457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
358457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	shladd	r18 = r16, 3, r18
359457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	ar.unat = loc2
360457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
361457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	r17 = [r18]
362457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	shr	r8 = r8, 8
363457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
364457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = r17, r18
365457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r16 = 16, sp
366457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
367457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	mov	b6 = r17
368457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br	b6
369457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
370457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.label_state 1
371457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
372457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_void:
373457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
374457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
375457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
376457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
377457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_int:
378457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
379457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
380457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	r8 = [r16]
381457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
382457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
383457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
384457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
385457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_float:
386457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
387457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
388457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldfs	f8 = [r16]
389457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
390457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
391457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
392457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
393457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_double:
394457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
395457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
396457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldfd	f8 = [r16]
397457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
398457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
399457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
400457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
401457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_ldouble:
402457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
403457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
404457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldfe	f8 = [r16]
405457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
406457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
407457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
408457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
409457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
410457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_small_struct:
411457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
412457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
413457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = 8, r16
414457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 8, r8
415457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 16, r8
416457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 24, r8
417457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
418457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ld8	r8 = [r16], 16
419457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	ld8	r9 = [r17], 16
420457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
421457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	ld8	r10 = [r16]
422457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	ld8	r11 = [r17]
423457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
424457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
425457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
426457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
427457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
428457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_hfa_float:
429457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
430457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
431457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = 4, r16
432457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 4, r8
433457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
434457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldfs	f8 = [r16], 8
435457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	ldfs	f9 = [r17], 8
436457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 8, r8
437457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 12, r8
438457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
439457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	ldfs	f10 = [r16], 8
440457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	ldfs	f11 = [r17], 8
441457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p9, p0 = 16, r8
442457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p10, p0 = 20, r8
443457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
444457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p9)	ldfs	f12 = [r16], 8
445457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p10)	ldfs	f13 = [r17], 8
446457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 24, r8
447457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 28, r8
448457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
449457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	ldfs	f14 = [r16]
450457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	ldfs	f15 = [r17]
451457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
452457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
453457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
454457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
455457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
456457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_hfa_double:
457457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
458457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
459457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = 8, r16
460457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 8, r8
461457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
462457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldfd	f8 = [r16], 16
463457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	ldfd	f9 = [r17], 16
464457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 16, r8
465457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 24, r8
466457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
467457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	ldfd	f10 = [r16], 16
468457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	ldfd	f11 = [r17], 16
469457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p9, p0 = 32, r8
470457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p10, p0 = 40, r8
471457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
472457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p9)	ldfd	f12 = [r16], 16
473457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p10)	ldfd	f13 = [r17], 16
474457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 48, r8
475457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 56, r8
476457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
477457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	ldfd	f14 = [r16]
478457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	ldfd	f15 = [r17]
479457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
480457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
481457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
482457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
483457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
484457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_hfa_ldouble:
485457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.body
486457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.copy_state 1
487457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	r17 = 16, r16
488457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 16, r8
489457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
490457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	ldfe	f8 = [r16], 32
491457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	ldfe	f9 = [r17], 32
492457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 32, r8
493457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p8, p0 = 48, r8
494457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
495457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	ldfe	f10 = [r16], 32
496457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p8)	ldfe	f11 = [r17], 32
497457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p9, p0 = 64, r8
498457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p10, p0 = 80, r8
499457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
500457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p9)	ldfe	f12 = [r16], 32
501457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p10)	ldfe	f13 = [r17], 32
502457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p6, p0 = 96, r8
503457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	cmp.lt	p7, p0 = 112, r8
504457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
505457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p6)	ldfe	f14 = [r16]
506457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique(p7)	ldfe	f15 = [r17]
507457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.restore sp
508457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	add	sp = FRAME_SIZE, sp
509457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	br.ret.sptk.many b0
510457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	;;
511457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
512457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.endp	ffi_closure_unix
513457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
514457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.section .rodata
515457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.align	8
516457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lst_table:
517457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_void)		// FFI_TYPE_VOID
518457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_sint32)		// FFI_TYPE_INT
519457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_float)		// FFI_TYPE_FLOAT
520457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_double)		// FFI_TYPE_DOUBLE
521457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_ldouble)		// FFI_TYPE_LONGDOUBLE
522457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_uint8)		// FFI_TYPE_UINT8
523457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_sint8)		// FFI_TYPE_SINT8
524457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_uint16)		// FFI_TYPE_UINT16
525457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_sint16)		// FFI_TYPE_SINT16
526457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_uint32)		// FFI_TYPE_UINT32
527457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_sint32)		// FFI_TYPE_SINT32
528457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_int64)		// FFI_TYPE_UINT64
529457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_int64)		// FFI_TYPE_SINT64
530457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_void)		// FFI_TYPE_STRUCT
531457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_int64)		// FFI_TYPE_POINTER
532457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8 	@pcrel(.Lst_small_struct)	// FFI_IA64_TYPE_SMALL_STRUCT
533457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_hfa_float)		// FFI_IA64_TYPE_HFA_FLOAT
534457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_hfa_double)		// FFI_IA64_TYPE_HFA_DOUBLE
535457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lst_hfa_ldouble)	// FFI_IA64_TYPE_HFA_LDOUBLE
536457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
537457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique.Lld_table:
538457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_void)		// FFI_TYPE_VOID
539457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_INT
540457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_float)		// FFI_TYPE_FLOAT
541457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_double)		// FFI_TYPE_DOUBLE
542457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_ldouble)		// FFI_TYPE_LONGDOUBLE
543457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT8
544457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT8
545457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT16
546457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT16
547457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT32
548457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT32
549457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_UINT64
550457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_SINT64
551457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_void)		// FFI_TYPE_STRUCT
552457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_int)		// FFI_TYPE_POINTER
553457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8 	@pcrel(.Lld_small_struct)	// FFI_IA64_TYPE_SMALL_STRUCT
554457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_hfa_float)		// FFI_IA64_TYPE_HFA_FLOAT
555457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_hfa_double)		// FFI_IA64_TYPE_HFA_DOUBLE
556457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	data8	@pcrel(.Lld_hfa_ldouble)	// FFI_IA64_TYPE_HFA_LDOUBLE
557457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique
558457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#if defined __ELF__ && defined __linux__
559457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique	.section	.note.GNU-stack,"",@progbits
560457ba79995d512b9e8c07061fe10d4cd88273b2Lloyd Pique#endif
561