1 /* -----------------------------------------------------------------------
2 sysv.S - Copyright (c) 1998 Geoffrey Keating
3 Copyright (C) 2007 Free Software Foundation, Inc
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 ``Software''), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
25 ----------------------------------------------------------------------- */
28 #include <fficonfig.h>
30 #include <powerpc/asm.h>
33 .globl ffi_prep_args_SYSV
36 /* Save the old stack pointer as AP. */
40 /* Allocate the stack space we need. */
42 /* Save registers we use. */
55 /* Save arguments over call... */
56 mr %r31,%r5 /* flags, */
57 mr %r30,%r6 /* rvalue, */
58 mr %r29,%r7 /* function address, */
59 mr %r28,%r8 /* our AP. */
62 /* Call ffi_prep_args_SYSV. */
64 bl ffi_prep_args_SYSV@local
66 /* Now do the call. */
67 /* Set up cr1 with bits 4-7 of the flags. */
69 /* Get the address to call into CTR. */
71 /* Load all those argument registers. */
72 lwz %r3,-16-(8*4)(%r28)
73 lwz %r4,-16-(7*4)(%r28)
74 lwz %r5,-16-(6*4)(%r28)
75 lwz %r6,-16-(5*4)(%r28)
78 lwz %r7,-16-(4*4)(%r28)
79 lwz %r8,-16-(3*4)(%r28)
80 lwz %r9,-16-(2*4)(%r28)
81 lwz %r10,-16-(1*4)(%r28)
85 /* Load all the FP registers. */
87 lfd %f1,-16-(8*4)-(8*8)(%r28)
88 lfd %f2,-16-(8*4)-(7*8)(%r28)
89 lfd %f3,-16-(8*4)-(6*8)(%r28)
90 lfd %f4,-16-(8*4)-(5*8)(%r28)
92 lfd %f5,-16-(8*4)-(4*8)(%r28)
93 lfd %f6,-16-(8*4)-(3*8)(%r28)
94 lfd %f7,-16-(8*4)-(2*8)(%r28)
95 lfd %f8,-16-(8*4)-(1*8)(%r28)
101 /* Now, deal with the return value. */
102 mtcrf 0x01,%r31 /* cr7 */
103 bt- 31,L(small_struct_return_value)
104 bt- 30,L(done_return_value)
105 bt- 29,L(fp_return_value)
107 bf+ 28,L(done_return_value)
109 mtcrf 0x02,%r31 /* cr6 */
110 bf 27,L(done_return_value)
113 /* Fall through... */
115 L(done_return_value):
116 /* Restore the registers we used and return. */
127 bf 28,L(float_return_value)
129 mtcrf 0x02,%r31 /* cr6 */
130 bf 27,L(done_return_value)
132 b L(done_return_value)
133 L(float_return_value):
135 b L(done_return_value)
137 L(small_struct_return_value):
138 mtcrf 0x10,%r31 /* cr3 */
139 bt- 15,L(smst_one_register)
140 mtcrf 0x08,%r31 /* cr4 */
141 bt- 16,L(smst_two_register)
142 b L(done_return_value)
144 L(smst_one_register):
145 rlwinm %r5,%r31,5+23,32-5,31 /* Extract the value to shift. */
148 b L(done_return_value)
149 L(smst_two_register):
150 rlwinm %r5,%r31,5+23,32-5,31 /* Extract the value to shift. */
161 b L(done_return_value)
166 .section ".eh_frame",EH_FRAME_FLAGS,@progbits
168 .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
170 .4byte 0x0 /* CIE Identifier Tag */
171 .byte 0x1 /* CIE Version */
172 #if defined _RELOCATABLE || defined __PIC__
173 .ascii "zR\0" /* CIE Augmentation */
175 .ascii "\0" /* CIE Augmentation */
177 .uleb128 0x1 /* CIE Code Alignment Factor */
178 .sleb128 -4 /* CIE Data Alignment Factor */
179 .byte 0x41 /* CIE RA Column */
180 #if defined _RELOCATABLE || defined __PIC__
181 .uleb128 0x1 /* Augmentation size */
182 .byte 0x1b /* FDE Encoding (pcrel sdata4) */
184 .byte 0xc /* DW_CFA_def_cfa */
190 .4byte .LEFDE1-.LASFDE1 /* FDE Length */
192 .4byte .LASFDE1-.Lframe1 /* FDE CIE offset */
193 #if defined _RELOCATABLE || defined __PIC__
194 .4byte .LFB1-. /* FDE initial location */
196 .4byte .LFB1 /* FDE initial location */
198 .4byte .LFE1-.LFB1 /* FDE address range */
199 #if defined _RELOCATABLE || defined __PIC__
200 .uleb128 0x0 /* Augmentation size */
202 .byte 0x4 /* DW_CFA_advance_loc4 */
204 .byte 0xd /* DW_CFA_def_cfa_register */
206 .byte 0x4 /* DW_CFA_advance_loc4 */
208 .byte 0x11 /* DW_CFA_offset_extended_sf */
211 .byte 0x9f /* DW_CFA_offset, column 0x1f */
213 .byte 0x9e /* DW_CFA_offset, column 0x1e */
215 .byte 0x9d /* DW_CFA_offset, column 0x1d */
217 .byte 0x9c /* DW_CFA_offset, column 0x1c */
219 .byte 0x4 /* DW_CFA_advance_loc4 */
221 .byte 0xd /* DW_CFA_def_cfa_register */