source: trunk/gcc/libffi/src/powerpc/sysv.S

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.1 KB
Line 
1/* -----------------------------------------------------------------------
2 sysv.h - Copyright (c) 1998 Geoffrey Keating
3
4 PowerPC Assembly glue.
5
6 $Id: sysv.S,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
7
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 ``Software''), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
15
16 The above copyright notice and this permission notice shall be included
17 in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 OTHER DEALINGS IN THE SOFTWARE.
26 ----------------------------------------------------------------------- */
27
28#define LIBFFI_ASM
29#include <ffi.h>
30#include <powerpc/asm.h>
31
32 .globl ffi_prep_args
33ENTRY(ffi_call_SYSV)
34.LFB1:
35 /* Save the old stack pointer as AP. */
36 mr %r8,%r1
37
38.LCFI0:
39 /* Allocate the stack space we need. */
40 stwux %r1,%r1,%r4
41 /* Save registers we use. */
42 mflr %r9
43 stw %r28,-16(%r8)
44.LCFI1:
45 stw %r29,-12(%r8)
46.LCFI2:
47 stw %r30, -8(%r8)
48.LCFI3:
49 stw %r31, -4(%r8)
50.LCFI4:
51 stw %r9, 4(%r8)
52.LCFI5:
53
54 /* Save arguments over call... */
55 mr %r31,%r5 /* flags, */
56 mr %r30,%r6 /* rvalue, */
57 mr %r29,%r7 /* function address, */
58 mr %r28,%r8 /* our AP. */
59.LCFI6:
60
61 /* Call ffi_prep_args. */
62 mr %r4,%r1
63 bl JUMPTARGET(ffi_prep_args)
64
65 /* Now do the call. */
66 /* Set up cr1 with bits 4-7 of the flags. */
67 mtcrf 0x40,%r31
68 /* Get the address to call into CTR. */
69 mtctr %r29
70 /* Load all those argument registers. */
71 lwz %r3,-16-(8*4)(%r28)
72 lwz %r4,-16-(7*4)(%r28)
73 lwz %r5,-16-(6*4)(%r28)
74 lwz %r6,-16-(5*4)(%r28)
75 bf- 5,1f
76 nop
77 lwz %r7,-16-(4*4)(%r28)
78 lwz %r8,-16-(3*4)(%r28)
79 lwz %r9,-16-(2*4)(%r28)
80 lwz %r10,-16-(1*4)(%r28)
81 nop
821:
83
84 /* Load all the FP registers. */
85 bf- 6,2f
86 lfd %f1,-16-(8*4)-(8*8)(%r28)
87 lfd %f2,-16-(8*4)-(7*8)(%r28)
88 lfd %f3,-16-(8*4)-(6*8)(%r28)
89 lfd %f4,-16-(8*4)-(5*8)(%r28)
90 nop
91 lfd %f5,-16-(8*4)-(4*8)(%r28)
92 lfd %f6,-16-(8*4)-(3*8)(%r28)
93 lfd %f7,-16-(8*4)-(2*8)(%r28)
94 lfd %f8,-16-(8*4)-(1*8)(%r28)
952:
96
97 /* Make the call. */
98 bctrl
99
100 /* Now, deal with the return value. */
101 mtcrf 0x01,%r31
102 bt- 30,L(done_return_value)
103 bt- 29,L(fp_return_value)
104 stw %r3,0(%r30)
105 bf+ 28,L(done_return_value)
106 stw %r4,4(%r30)
107 /* Fall through... */
108
109L(done_return_value):
110 /* Restore the registers we used and return. */
111 lwz %r9, 4(%r28)
112 lwz %r31, -4(%r28)
113 mtlr %r9
114 lwz %r30, -8(%r28)
115 lwz %r29,-12(%r28)
116 lwz %r28,-16(%r28)
117 lwz %r1,0(%r1)
118 blr
119
120L(fp_return_value):
121 bf 28,L(float_return_value)
122 stfd %f1,0(%r30)
123 b L(done_return_value)
124L(float_return_value):
125 stfs %f1,0(%r30)
126 b L(done_return_value)
127.LFE1:
128END(ffi_call_SYSV)
129
130 .section ".eh_frame","aw"
131__FRAME_BEGIN__:
132 .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
133.LSCIE1:
134 .4byte 0x0 /* CIE Identifier Tag */
135 .byte 0x1 /* CIE Version */
136 .ascii "\0" /* CIE Augmentation */
137 .byte 0x1 /* uleb128 0x1; CIE Code Alignment Factor */
138 .byte 0x7c /* sleb128 -4; CIE Data Alignment Factor */
139 .byte 0x41 /* CIE RA Column */
140 .byte 0xc /* DW_CFA_def_cfa */
141 .byte 0x1 /* uleb128 0x1 */
142 .byte 0x0 /* uleb128 0x0 */
143 .align 2
144.LECIE1:
145.LSFDE1:
146 .4byte .LEFDE1-.LASFDE1 /* FDE Length */
147.LASFDE1:
148 .4byte .LASFDE1-__FRAME_BEGIN__ /* FDE CIE offset */
149 .4byte .LFB1 /* FDE initial location */
150 .4byte .LFE1-.LFB1 /* FDE address range */
151 .byte 0x4 /* DW_CFA_advance_loc4 */
152 .4byte .LCFI0-.LFB1
153 .byte 0xd /* DW_CFA_def_cfa_register */
154 .byte 0x08 /* uleb128 0x08 */
155 .byte 0x4 /* DW_CFA_advance_loc4 */
156 .4byte .LCFI5-.LCFI0
157 .byte 0x2f /* DW_CFA_GNU_negative_offset_extended */
158 .byte 0x41 /* uleb128 0x41 */
159 .byte 0x1 /* uleb128 0x1 */
160 .byte 0x9f /* DW_CFA_offset, column 0x1f */
161 .byte 0x1 /* uleb128 0x1 */
162 .byte 0x9e /* DW_CFA_offset, column 0x1e */
163 .byte 0x2 /* uleb128 0x2 */
164 .byte 0x9d /* DW_CFA_offset, column 0x1d */
165 .byte 0x3 /* uleb128 0x3 */
166 .byte 0x9c /* DW_CFA_offset, column 0x1c */
167 .byte 0x4 /* uleb128 0x4 */
168 .byte 0x4 /* DW_CFA_advance_loc4 */
169 .4byte .LCFI6-.LCFI5
170 .byte 0xd /* DW_CFA_def_cfa_register */
171 .byte 0x1c /* uleb128 0x1c */
172 .align 2
173.LEFDE1:
Note: See TracBrowser for help on using the repository browser.