OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / libffi / src / alpha / osf.S
1 /* -----------------------------------------------------------------------
2    osf.S - Copyright (c) 1998 Cygnus Solutions
3    
4    Alpha/OSF Foreign Function Interface 
5
6    $Id: osf.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 callback $16
32 #define ecifp    $17
33 #define bytes    $18
34 #define flags    $19
35 #define raddr    $20
36 #define fn       $21
37
38 #define flags_ofs       16
39 #define raddr_ofs       24
40 #define fn_ofs          32
41
42 #define SIZEOF_FRAME    (6*8)
43
44         .text
45         .align  4
46         .globl  ffi_call_osf
47         .ent    ffi_call_osf
48         
49 ffi_call_osf:
50         lda     $30, -SIZEOF_FRAME($30)
51         stq     $26, 0($30)
52         stq     $15, 8($30)
53         stq     flags, flags_ofs($30)
54         stq     raddr, raddr_ofs($30)
55         stq     fn, fn_ofs($30)
56         mov     $30, $15
57         .frame  $15, SIZEOF_FRAME, $26, 0
58         .mask   0x4008000, -SIZEOF_FRAME
59         .prologue 0
60
61         mov     callback, $27           # mov callback into place
62         subq    $30, bytes, $30         # allocate stack space
63         
64         # Call ffi_prep_args; ecif, bytes and flags are already in place.
65         mov     $30, $16                # push stack arg
66         jsr     $26, ($27), 0
67
68         # Load up all of the (potential) argument registers.
69         ldt     $f16, 0($30)
70         ldt     $f17, 8($30)
71         ldt     $f18, 16($30)
72         ldt     $f19, 24($30)
73         ldt     $f20, 32($30)
74         ldt     $f21, 40($30)
75         ldq     $16, 48($30)
76         ldq     $17, 56($30)
77         ldq     $18, 64($30)
78         ldq     $19, 72($30)
79         ldq     $20, 80($30)
80         ldq     $21, 88($30)
81
82         # Get rid of the arg reg temp space and call the function.
83         ldq     $27, fn_ofs($15)
84         lda     $30, 12*8($30)
85         jsr     $26, ($27), 0
86
87         # If the return value pointer is NULL, assume no return value.
88         ldq     raddr, raddr_ofs($15)
89         beq     raddr, $noretval
90
91         ldq     flags, flags_ofs($15)
92         cmpeq   flags, FFI_TYPE_INT, $1
93         bne     $1, $retint
94         cmpeq   flags, FFI_TYPE_FLOAT, $2
95         bne     $2, $retfloat
96         cmpeq   flags, FFI_TYPE_DOUBLE, $3
97         bne     $3, $retdouble
98         br      $retstruct
99         
100         .align 3
101 $retint:
102         stq     $0, 0(raddr)
103         br      $noretval
104 $retfloat:
105         sts     $f0, 0(raddr)
106         br      $noretval
107 $retdouble:
108         stt     $f0, 0(raddr)
109
110 $retstruct:
111 $noretval:
112         mov     $15, $30
113         ldq     $26, 0($15)
114         ldq     $15, 8($15)
115         lda     $30, SIZEOF_FRAME($30)
116         ret
117
118         .end    ffi_call_osf