1 | /* -----------------------------------------------------------------------
|
---|
2 | ffi-mips.h - Copyright (c) 1996 Cygnus Support
|
---|
3 |
|
---|
4 | MIPS FFI Definitions
|
---|
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:
|
---|
13 |
|
---|
14 | The above copyright notice and this permission notice shall be included
|
---|
15 | in all copies or substantial portions of the Software.
|
---|
16 |
|
---|
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 SUPPORT 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 | ----------------------------------------------------------------------- */
|
---|
25 |
|
---|
26 | #ifndef FFI_MIPS_H
|
---|
27 |
|
---|
28 | #include <ffi.h>
|
---|
29 |
|
---|
30 | #if !defined(_MIPS_SIM)
|
---|
31 | -- something is very wrong --
|
---|
32 | #else
|
---|
33 | # if _MIPS_SIM==_ABIN32 && defined(_ABIN32)
|
---|
34 | # define FFI_MIPS_N32
|
---|
35 | # else
|
---|
36 | # if defined(__GNUC__)
|
---|
37 | # define FFI_MIPS_O32
|
---|
38 | # else
|
---|
39 | # if _MIPS_SIM==_ABIO32
|
---|
40 | # define FFI_MIPS_O32
|
---|
41 | # else
|
---|
42 | -- this is an unsupported platform --
|
---|
43 | # endif
|
---|
44 | # endif
|
---|
45 | # endif
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #define v0 $2
|
---|
49 | #define v1 $3
|
---|
50 | #define a0 $4
|
---|
51 | #define a1 $5
|
---|
52 | #define a2 $6
|
---|
53 | #define a3 $7
|
---|
54 | #define a4 $8
|
---|
55 | #define a5 $9
|
---|
56 | #define a6 $10
|
---|
57 | #define a7 $11
|
---|
58 | #define t0 $8
|
---|
59 | #define t1 $9
|
---|
60 | #define t2 $10
|
---|
61 | #define t3 $11
|
---|
62 | #define t4 $12
|
---|
63 | #define t5 $13
|
---|
64 | #define t6 $14
|
---|
65 | #define t7 $15
|
---|
66 | #define t8 $24
|
---|
67 | #define t9 $25
|
---|
68 | #define ra $31
|
---|
69 |
|
---|
70 | #if defined(FFI_MIPS_O32)
|
---|
71 |
|
---|
72 | #define FFI_DEFAULT_ABI FFI_O32
|
---|
73 |
|
---|
74 | /* O32 stack frames have 32bit integer args */
|
---|
75 | #define SLOT_TYPE_UNSIGNED UINT32
|
---|
76 | #define SLOT_TYPE_SIGNED SINT32
|
---|
77 | #define SIZEOF_ARG 4
|
---|
78 |
|
---|
79 | #define REG_L lw
|
---|
80 | #define REG_S sw
|
---|
81 | #define SUBU subu
|
---|
82 | #define ADDU addu
|
---|
83 | #define SRL srl
|
---|
84 | #define LI li
|
---|
85 |
|
---|
86 | #else
|
---|
87 |
|
---|
88 | #define FFI_DEFAULT_ABI FFI_N32
|
---|
89 |
|
---|
90 | /* N32 and N64 frames have 64bit integer args */
|
---|
91 | #define SLOT_TYPE_UNSIGNED UINT64
|
---|
92 | #define SLOT_TYPE_SIGNED SINT64
|
---|
93 | #define SIZEOF_ARG 8
|
---|
94 |
|
---|
95 | #define REG_L ld
|
---|
96 | #define REG_S sd
|
---|
97 | #define SUBU dsubu
|
---|
98 | #define ADDU daddu
|
---|
99 | #define SRL dsrl
|
---|
100 | #define LI dli
|
---|
101 |
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | #define FFI_FLAG_BITS 2
|
---|
105 |
|
---|
106 | /* SGI's strange assembler requires that we multiply by 4 rather
|
---|
107 | than shift left by FFI_FLAG_BITS */
|
---|
108 |
|
---|
109 | #define FFI_ARGS_D FFI_TYPE_DOUBLE
|
---|
110 | #define FFI_ARGS_F FFI_TYPE_FLOAT
|
---|
111 | #define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
|
---|
112 | #define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
|
---|
113 | #define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
|
---|
114 | #define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
|
---|
115 |
|
---|
116 | /* Needed for N32 structure returns */
|
---|
117 | #define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
|
---|
118 | #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
|
---|
119 |
|
---|
120 | #if 0
|
---|
121 |
|
---|
122 | /* The SGI assembler can't handle this.. */
|
---|
123 |
|
---|
124 | #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
|
---|
125 |
|
---|
126 | #else
|
---|
127 |
|
---|
128 | /* ...so we calculate these by hand! */
|
---|
129 |
|
---|
130 | #define FFI_TYPE_STRUCT_D 61
|
---|
131 | #define FFI_TYPE_STRUCT_F 45
|
---|
132 | #define FFI_TYPE_STRUCT_DD 253
|
---|
133 | #define FFI_TYPE_STRUCT_FF 173
|
---|
134 | #define FFI_TYPE_STRUCT_FD 237
|
---|
135 | #define FFI_TYPE_STRUCT_DF 189
|
---|
136 | #define FFI_TYPE_STRUCT_SMALL 93
|
---|
137 | #define FFI_TYPE_STRUCT_SMALL2 109
|
---|
138 |
|
---|
139 | #endif
|
---|
140 |
|
---|
141 | #endif
|
---|