Add x prefix to v850e case for handling --with-cpu=v850e.
[official-gcc.git] / libffi / src / s390 / sysv.S
blobc28b14c8ce037144f7d5ab8d34caa1d3bfbbe134
1 /* -----------------------------------------------------------------------
2    sysv.S - Copyright (c) 2000 Software AG
3  
4    S390 Foreign Function Interface
5  
6    Permission is hereby granted, free of charge, to any person obtaining
7    a copy of this software and associated documentation files (the
8    ``Software''), to deal in the Software without restriction, including
9    without limitation the rights to use, copy, modify, merge, publish,
10    distribute, sublicense, and/or sell copies of the Software, and to
11    permit persons to whom the Software is furnished to do so, subject to
12    the following conditions:
14    The above copyright notice and this permission notice shall be included
15    in all copies or substantial portions of the Software.
17    THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20    IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23    OTHER DEALINGS IN THE SOFTWARE.
24    ----------------------------------------------------------------------- */
26 #define LIBFFI_ASM      
27 #include <ffi.h>
28 #ifdef HAVE_MACHINE_ASM_H
29 #include <machine/asm.h>
30 #endif
31         
32 .text
34         # r2:   ffi_prep_args
35         # r3:   &ecif
36         # r4:   cif->bytes
37         # r5:   fig->flags
38         # r6:   ecif.rvalue
39         # sp+0: fn
41         # This assumes we are using gas.
42         .globl  ffi_call_SYSV
43         .type   ffi_call_SYSV,%function
44 ffi_call_SYSV:
45 .LFB1:
46         # Save registers
47         stm     %r6,%r15,24(%r15)
48 .LCFI0:
49         l       %r7,96(%r15)           # Get A(fn)
50         lr      %r0,%r15
51         ahi     %r15,-128              # Make room for my args
52 .LCFI1:
53         st      %r0,0(%r15)            # Set backchain
54         lr      %r11,%r15              # Establish my stack register
55 .LCFI2:
56         sr      %r15,%r4               # Make room for fn args
57         ahi     %r15,-96               # Make room for new frame
58         lr      %r10,%r15              # Establish stack build area
59         ahi     %r15,-96               # Stack for next call
60         lr      %r1,%r7
61         stm     %r2,%r7,96(%r11)       # Save args on my stack
63 #------------------------------------------------------------------
64 #       move first 3 parameters in registers
65 #------------------------------------------------------------------
66         lr      %r9,%r2                # r9:     &ffi_prep_args
67         lr      %r2,%r10               # Parm 1: &stack Parm 2: &ecif
68         basr    %r14,%r9               # call ffi_prep_args
70 #------------------------------------------------------------------
71 #       load  first 5 parameter registers
72 #------------------------------------------------------------------
73         lm      %r2,%r6,24(%r10)
75 #------------------------------------------------------------------
76 #       load  fp parameter registers
77 #------------------------------------------------------------------
78         ld      %f0,48(%r10)
79         ld      %f2,56(%r10)
81 #------------------------------------------------------------------
82 #       call  function
83 #------------------------------------------------------------------
84         lr      %r15,%r10              # Set new stack
85         l       %r9,116(%r11)          # Get &fn
86         basr    %r14,%r9               # Call function
88 #------------------------------------------------------------------
89 #       On return:
90 #          r2: Return value (r3: Return value + 4 for long long)
91 #------------------------------------------------------------------
93 #------------------------------------------------------------------
94 #       If the return value pointer is NULL, assume no return value.
95 #------------------------------------------------------------------
96         icm     %r6,15,112(%r11)
97         jz      .Lepilogue
99         l       %r5,108(%r11)          # Get return type
100 #------------------------------------------------------------------
101 #       return INT
102 #------------------------------------------------------------------
103         chi     %r5,FFI_TYPE_INT
104         jne     .Lchk64
106         st      %r2,0(%r6)
107         j       .Lepilogue
109 .Lchk64:
110 #------------------------------------------------------------------
111 #       return LONG LONG (signed/unsigned)
112 #------------------------------------------------------------------
113         chi     %r5,FFI_TYPE_UINT64
114         je      .LdoLongLong
116         chi     %r5,FFI_TYPE_SINT64
117         jne     .LchkFloat
119 .LdoLongLong:
120         stm     %r2,%r3,0(%r6)
121         j       .Lepilogue
123 .LchkFloat:
124 #------------------------------------------------------------------
125 #       return FLOAT
126 #------------------------------------------------------------------
127         chi     %r5,FFI_TYPE_FLOAT
128         jne     .LchkDouble
130         std     %f0,0(%r6)
131         j       .Lepilogue
133 .LchkDouble:
134 #------------------------------------------------------------------
135 #       return DOUBLE or LONGDOUBLE
136 #------------------------------------------------------------------
137         chi     %r5,FFI_TYPE_DOUBLE
138         jne     .LchkStruct
140         std     %f0,0(%r6)
141         std     %f2,8(%r6)
142         j       .Lepilogue
144 .LchkStruct:
145 #------------------------------------------------------------------
146 # Structure - rvalue already set as sent as 1st parm to routine
147 #------------------------------------------------------------------
148         chi     %r5,FFI_TYPE_STRUCT
149         je      .Lepilogue
151 .Ldefault:
152 #------------------------------------------------------------------
153 #       return a pointer
154 #------------------------------------------------------------------
155         st      %r2,0(%r6)
156         j       .Lepilogue
158 .Lepilogue:
159         l       %r15,0(%r11)
160         l       %r4,56(%r15)
161         lm      %r6,%r15,24(%r15)
162         br      %r4
164 .LFE1: 
165 .ffi_call_SYSV_end:
166         .size    ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
169         .section        .eh_frame,"aw",@progbits
170 .Lframe1:
171         .4byte  .LECIE1-.LSCIE1 # Length of Common Information Entry
172 .LSCIE1:
173         .4byte  0x0     # CIE Identifier Tag
174         .byte   0x1     # CIE Version
175         .ascii "\0"     # CIE Augmentation
176         .uleb128 0x1    # CIE Code Alignment Factor
177         .sleb128 -4     # CIE Data Alignment Factor
178         .byte   0xe     # CIE RA Column
179         .byte   0xc     # DW_CFA_def_cfa
180         .uleb128 0xf
181         .uleb128 0x60
182         .align  4
183 .LECIE1:
184 .LSFDE1:
185         .4byte  .LEFDE1-.LASFDE1        # FDE Length
186 .LASFDE1:
187         .4byte  .LASFDE1-.Lframe1       # FDE CIE offset
188         .4byte  .LFB1   # FDE initial location
189         .4byte  .LFE1-.LFB1     # FDE address range
190         .uleb128 0x0    # Augmentation size
191         .byte   0x4     # DW_CFA_advance_loc4
192         .4byte  .LCFI0-.LFB1
193         .byte   0x8f    # DW_CFA_offset, column 0xf
194         .uleb128 0x9
195         .byte   0x8e    # DW_CFA_offset, column 0xe
196         .uleb128 0xa
197         .byte   0x8d    # DW_CFA_offset, column 0xd
198         .uleb128 0xb
199         .byte   0x8c    # DW_CFA_offset, column 0xc
200         .uleb128 0xc
201         .byte   0x8b    # DW_CFA_offset, column 0xb
202         .uleb128 0xd
203         .byte   0x8a    # DW_CFA_offset, column 0xa
204         .uleb128 0xe
205         .byte   0x89    # DW_CFA_offset, column 0x9
206         .uleb128 0xf
207         .byte   0x88    # DW_CFA_offset, column 0x8
208         .uleb128 0x10
209         .byte   0x87    # DW_CFA_offset, column 0x7
210         .uleb128 0x11
211         .byte   0x86    # DW_CFA_offset, column 0x6
212         .uleb128 0x12
213         .byte   0x4     # DW_CFA_advance_loc4
214         .4byte  .LCFI1-.LCFI0
215         .byte   0xe     # DW_CFA_def_cfa_offset
216         .uleb128 0xe0
217         .byte   0x4     # DW_CFA_advance_loc4
218         .4byte  .LCFI2-.LCFI1
219         .byte   0xd     # DW_CFA_def_cfa_register
220         .uleb128 0xb
221         .align  4
222 .LEFDE1: