OSDN Git Service

Port to sparc 32 and 64 Linux.
[pf3gnuchains/gcc-fork.git] / libffi / src / sparc / v8.S
1 /* -----------------------------------------------------------------------
2    v8.S - Copyright (c) 1996, 1997 Cygnus Solutions
3    
4    Sparc Foreign Function Interface 
5
6    $Id: v8.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 CYGNUS SOLUTIONS 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
31 #define STACKFRAME 96           /* Minimum stack framesize for SPARC */
32 #define ARGS (64+4)             /* Offset of register area in frame */
33
34 .text
35         .align 8
36 .globl ffi_call_V8
37 .globl _ffi_call_V8
38
39 ffi_call_V8:
40 _ffi_call_V8:
41         save    %sp, -STACKFRAME, %sp
42         
43         sub     %sp, %i2, %sp   ! alloca() space in stack for frame to set up
44         add     %sp, STACKFRAME, %l0    ! %l0 has start of 
45                                         ! frame to set up
46
47         mov     %l0, %o0        ! call routine to set up frame
48         call    %i0
49         mov     %i1, %o1        ! (delay)
50
51         ld      [%l0+ARGS], %o0 ! call foreign function
52         ld      [%l0+ARGS+4], %o1
53         ld      [%l0+ARGS+8], %o2
54         ld      [%l0+ARGS+12], %o3
55         ld      [%l0+ARGS+16], %o4
56         ld      [%l0+ARGS+20], %o5
57         call    %i5
58         mov     %l0, %sp        ! (delay) switch to frame
59         nop                     ! STRUCT returning functions skip 12 instead of 8 bytes
60
61         ! If the return value pointer is NULL, assume no return value.
62         tst     %i4
63         bz      done
64         nop
65
66         cmp     %i3, FFI_TYPE_INT
67         be,a    done
68         st      %o0, [%i4]      ! (delay)
69
70         cmp     %i3, FFI_TYPE_FLOAT
71         be,a    done
72         st      %f0, [%i4+0]    ! (delay)
73
74         cmp     %i3, FFI_TYPE_SINT64
75         be      longlong
76
77         cmp     %i3, FFI_TYPE_DOUBLE
78         bne     done
79         nop
80         st      %f0, [%i4+0]
81         st      %f1, [%i4+4]
82         
83 done:
84         ret
85         restore
86
87 longlong:
88         st      %o0, [%i4+0]
89         st      %o1, [%i4+4]
90         ret
91         restore
92
93 .ffi_call_V8_end:
94         .size    ffi_call_V8,.ffi_call_V8_end-ffi_call_V8
95