annotate libffi/src/mips/ffitarget.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* -----------------------------------------------------------------*-C-*-
kono
parents:
diff changeset
2 ffitarget.h - Copyright (c) 2012 Anthony Green
kono
parents:
diff changeset
3 Copyright (c) 1996-2003 Red Hat, Inc.
kono
parents:
diff changeset
4 Target configuration macros for MIPS.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 Permission is hereby granted, free of charge, to any person obtaining
kono
parents:
diff changeset
7 a copy of this software and associated documentation files (the
kono
parents:
diff changeset
8 ``Software''), to deal in the Software without restriction, including
kono
parents:
diff changeset
9 without limitation the rights to use, copy, modify, merge, publish,
kono
parents:
diff changeset
10 distribute, sublicense, and/or sell copies of the Software, and to
kono
parents:
diff changeset
11 permit persons to whom the Software is furnished to do so, subject to
kono
parents:
diff changeset
12 the following conditions:
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 The above copyright notice and this permission notice shall be included
kono
parents:
diff changeset
15 in all copies or substantial portions of the Software.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
kono
parents:
diff changeset
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
kono
parents:
diff changeset
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
kono
parents:
diff changeset
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
kono
parents:
diff changeset
21 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
kono
parents:
diff changeset
22 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
kono
parents:
diff changeset
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
kono
parents:
diff changeset
24 DEALINGS IN THE SOFTWARE.
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 ----------------------------------------------------------------------- */
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 #ifndef LIBFFI_TARGET_H
kono
parents:
diff changeset
29 #define LIBFFI_TARGET_H
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 #ifndef LIBFFI_H
kono
parents:
diff changeset
32 #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
kono
parents:
diff changeset
33 #endif
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 #ifdef linux
kono
parents:
diff changeset
36 # include <asm/sgidefs.h>
kono
parents:
diff changeset
37 #elif defined(__rtems__)
kono
parents:
diff changeset
38 /*
kono
parents:
diff changeset
39 * Subprogram calling convention - copied from sgidefs.h
kono
parents:
diff changeset
40 */
kono
parents:
diff changeset
41 #define _MIPS_SIM_ABI32 1
kono
parents:
diff changeset
42 #define _MIPS_SIM_NABI32 2
kono
parents:
diff changeset
43 #define _MIPS_SIM_ABI64 3
kono
parents:
diff changeset
44 #elif !defined(__OpenBSD__)
kono
parents:
diff changeset
45 # include <sgidefs.h>
kono
parents:
diff changeset
46 #endif
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 # ifndef _ABIN32
kono
parents:
diff changeset
49 # define _ABIN32 _MIPS_SIM_NABI32
kono
parents:
diff changeset
50 # endif
kono
parents:
diff changeset
51 # ifndef _ABI64
kono
parents:
diff changeset
52 # define _ABI64 _MIPS_SIM_ABI64
kono
parents:
diff changeset
53 # endif
kono
parents:
diff changeset
54 # ifndef _ABIO32
kono
parents:
diff changeset
55 # define _ABIO32 _MIPS_SIM_ABI32
kono
parents:
diff changeset
56 # endif
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 #if !defined(_MIPS_SIM)
kono
parents:
diff changeset
59 # error -- something is very wrong --
kono
parents:
diff changeset
60 #else
kono
parents:
diff changeset
61 # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
kono
parents:
diff changeset
62 # define FFI_MIPS_N32
kono
parents:
diff changeset
63 # else
kono
parents:
diff changeset
64 # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
kono
parents:
diff changeset
65 # define FFI_MIPS_O32
kono
parents:
diff changeset
66 # else
kono
parents:
diff changeset
67 # error -- this is an unsupported platform --
kono
parents:
diff changeset
68 # endif
kono
parents:
diff changeset
69 # endif
kono
parents:
diff changeset
70 #endif
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 #ifdef FFI_MIPS_O32
kono
parents:
diff changeset
73 /* O32 stack frames have 32bit integer args */
kono
parents:
diff changeset
74 # define FFI_SIZEOF_ARG 4
kono
parents:
diff changeset
75 #else
kono
parents:
diff changeset
76 /* N32 and N64 frames have 64bit integer args */
kono
parents:
diff changeset
77 # define FFI_SIZEOF_ARG 8
kono
parents:
diff changeset
78 # if _MIPS_SIM == _ABIN32
kono
parents:
diff changeset
79 # define FFI_SIZEOF_JAVA_RAW 4
kono
parents:
diff changeset
80 # endif
kono
parents:
diff changeset
81 #endif
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 #define FFI_FLAG_BITS 2
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 /* SGI's strange assembler requires that we multiply by 4 rather
kono
parents:
diff changeset
86 than shift left by FFI_FLAG_BITS */
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 #define FFI_ARGS_D FFI_TYPE_DOUBLE
kono
parents:
diff changeset
89 #define FFI_ARGS_F FFI_TYPE_FLOAT
kono
parents:
diff changeset
90 #define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
kono
parents:
diff changeset
91 #define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
kono
parents:
diff changeset
92 #define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
kono
parents:
diff changeset
93 #define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 /* Needed for N32 structure returns */
kono
parents:
diff changeset
96 #define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
kono
parents:
diff changeset
97 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 #if 0
kono
parents:
diff changeset
100 /* The SGI assembler can't handle this.. */
kono
parents:
diff changeset
101 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
kono
parents:
diff changeset
102 /* (and so on) */
kono
parents:
diff changeset
103 #else
kono
parents:
diff changeset
104 /* ...so we calculate these by hand! */
kono
parents:
diff changeset
105 #define FFI_TYPE_STRUCT_D 61
kono
parents:
diff changeset
106 #define FFI_TYPE_STRUCT_F 45
kono
parents:
diff changeset
107 #define FFI_TYPE_STRUCT_DD 253
kono
parents:
diff changeset
108 #define FFI_TYPE_STRUCT_FF 173
kono
parents:
diff changeset
109 #define FFI_TYPE_STRUCT_FD 237
kono
parents:
diff changeset
110 #define FFI_TYPE_STRUCT_DF 189
kono
parents:
diff changeset
111 #define FFI_TYPE_STRUCT_SMALL 93
kono
parents:
diff changeset
112 #define FFI_TYPE_STRUCT_SMALL2 109
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 /* and for n32 soft float, add 16 * 2^4 */
kono
parents:
diff changeset
115 #define FFI_TYPE_STRUCT_D_SOFT 317
kono
parents:
diff changeset
116 #define FFI_TYPE_STRUCT_F_SOFT 301
kono
parents:
diff changeset
117 #define FFI_TYPE_STRUCT_DD_SOFT 509
kono
parents:
diff changeset
118 #define FFI_TYPE_STRUCT_FF_SOFT 429
kono
parents:
diff changeset
119 #define FFI_TYPE_STRUCT_FD_SOFT 493
kono
parents:
diff changeset
120 #define FFI_TYPE_STRUCT_DF_SOFT 445
kono
parents:
diff changeset
121 #define FFI_TYPE_STRUCT_SOFT 16
kono
parents:
diff changeset
122 #endif
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 #ifdef LIBFFI_ASM
kono
parents:
diff changeset
125 #define v0 $2
kono
parents:
diff changeset
126 #define v1 $3
kono
parents:
diff changeset
127 #define a0 $4
kono
parents:
diff changeset
128 #define a1 $5
kono
parents:
diff changeset
129 #define a2 $6
kono
parents:
diff changeset
130 #define a3 $7
kono
parents:
diff changeset
131 #define a4 $8
kono
parents:
diff changeset
132 #define a5 $9
kono
parents:
diff changeset
133 #define a6 $10
kono
parents:
diff changeset
134 #define a7 $11
kono
parents:
diff changeset
135 #define t0 $8
kono
parents:
diff changeset
136 #define t1 $9
kono
parents:
diff changeset
137 #define t2 $10
kono
parents:
diff changeset
138 #define t3 $11
kono
parents:
diff changeset
139 #define t4 $12
kono
parents:
diff changeset
140 #define t5 $13
kono
parents:
diff changeset
141 #define t6 $14
kono
parents:
diff changeset
142 #define t7 $15
kono
parents:
diff changeset
143 #define t8 $24
kono
parents:
diff changeset
144 #define t9 $25
kono
parents:
diff changeset
145 #define ra $31
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 #ifdef FFI_MIPS_O32
kono
parents:
diff changeset
148 # define REG_L lw
kono
parents:
diff changeset
149 # define REG_S sw
kono
parents:
diff changeset
150 # define SUBU subu
kono
parents:
diff changeset
151 # define ADDU addu
kono
parents:
diff changeset
152 # define SRL srl
kono
parents:
diff changeset
153 # define LI li
kono
parents:
diff changeset
154 #else /* !FFI_MIPS_O32 */
kono
parents:
diff changeset
155 # define REG_L ld
kono
parents:
diff changeset
156 # define REG_S sd
kono
parents:
diff changeset
157 # define SUBU dsubu
kono
parents:
diff changeset
158 # define ADDU daddu
kono
parents:
diff changeset
159 # define SRL dsrl
kono
parents:
diff changeset
160 # define LI dli
kono
parents:
diff changeset
161 # if (_MIPS_SIM==_ABI64)
kono
parents:
diff changeset
162 # define LA dla
kono
parents:
diff changeset
163 # define EH_FRAME_ALIGN 3
kono
parents:
diff changeset
164 # define FDE_ADDR_BYTES .8byte
kono
parents:
diff changeset
165 # else
kono
parents:
diff changeset
166 # define LA la
kono
parents:
diff changeset
167 # define EH_FRAME_ALIGN 2
kono
parents:
diff changeset
168 # define FDE_ADDR_BYTES .4byte
kono
parents:
diff changeset
169 # endif /* _MIPS_SIM==_ABI64 */
kono
parents:
diff changeset
170 #endif /* !FFI_MIPS_O32 */
kono
parents:
diff changeset
171 #else /* !LIBFFI_ASM */
kono
parents:
diff changeset
172 # ifdef __GNUC__
kono
parents:
diff changeset
173 # ifdef FFI_MIPS_O32
kono
parents:
diff changeset
174 /* O32 stack frames have 32bit integer args */
kono
parents:
diff changeset
175 typedef unsigned int ffi_arg __attribute__((__mode__(__SI__)));
kono
parents:
diff changeset
176 typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
kono
parents:
diff changeset
177 #else
kono
parents:
diff changeset
178 /* N32 and N64 frames have 64bit integer args */
kono
parents:
diff changeset
179 typedef unsigned int ffi_arg __attribute__((__mode__(__DI__)));
kono
parents:
diff changeset
180 typedef signed int ffi_sarg __attribute__((__mode__(__DI__)));
kono
parents:
diff changeset
181 # endif
kono
parents:
diff changeset
182 # else
kono
parents:
diff changeset
183 # ifdef FFI_MIPS_O32
kono
parents:
diff changeset
184 /* O32 stack frames have 32bit integer args */
kono
parents:
diff changeset
185 typedef __uint32_t ffi_arg;
kono
parents:
diff changeset
186 typedef __int32_t ffi_sarg;
kono
parents:
diff changeset
187 # else
kono
parents:
diff changeset
188 /* N32 and N64 frames have 64bit integer args */
kono
parents:
diff changeset
189 typedef __uint64_t ffi_arg;
kono
parents:
diff changeset
190 typedef __int64_t ffi_sarg;
kono
parents:
diff changeset
191 # endif
kono
parents:
diff changeset
192 # endif /* __GNUC__ */
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 typedef enum ffi_abi {
kono
parents:
diff changeset
195 FFI_FIRST_ABI = 0,
kono
parents:
diff changeset
196 FFI_O32,
kono
parents:
diff changeset
197 FFI_N32,
kono
parents:
diff changeset
198 FFI_N64,
kono
parents:
diff changeset
199 FFI_O32_SOFT_FLOAT,
kono
parents:
diff changeset
200 FFI_N32_SOFT_FLOAT,
kono
parents:
diff changeset
201 FFI_N64_SOFT_FLOAT,
kono
parents:
diff changeset
202 FFI_LAST_ABI,
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 #ifdef FFI_MIPS_O32
kono
parents:
diff changeset
205 #ifdef __mips_soft_float
kono
parents:
diff changeset
206 FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT
kono
parents:
diff changeset
207 #else
kono
parents:
diff changeset
208 FFI_DEFAULT_ABI = FFI_O32
kono
parents:
diff changeset
209 #endif
kono
parents:
diff changeset
210 #else
kono
parents:
diff changeset
211 # if _MIPS_SIM==_ABI64
kono
parents:
diff changeset
212 # ifdef __mips_soft_float
kono
parents:
diff changeset
213 FFI_DEFAULT_ABI = FFI_N64_SOFT_FLOAT
kono
parents:
diff changeset
214 # else
kono
parents:
diff changeset
215 FFI_DEFAULT_ABI = FFI_N64
kono
parents:
diff changeset
216 # endif
kono
parents:
diff changeset
217 # else
kono
parents:
diff changeset
218 # ifdef __mips_soft_float
kono
parents:
diff changeset
219 FFI_DEFAULT_ABI = FFI_N32_SOFT_FLOAT
kono
parents:
diff changeset
220 # else
kono
parents:
diff changeset
221 FFI_DEFAULT_ABI = FFI_N32
kono
parents:
diff changeset
222 # endif
kono
parents:
diff changeset
223 # endif
kono
parents:
diff changeset
224 #endif
kono
parents:
diff changeset
225 } ffi_abi;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
kono
parents:
diff changeset
228 #endif /* !LIBFFI_ASM */
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 /* ---- Definitions for closures ----------------------------------------- */
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 #if defined(FFI_MIPS_O32)
kono
parents:
diff changeset
233 #define FFI_CLOSURES 1
kono
parents:
diff changeset
234 #define FFI_TRAMPOLINE_SIZE 20
kono
parents:
diff changeset
235 #else
kono
parents:
diff changeset
236 /* N32/N64. */
kono
parents:
diff changeset
237 # define FFI_CLOSURES 1
kono
parents:
diff changeset
238 #if _MIPS_SIM==_ABI64
kono
parents:
diff changeset
239 #define FFI_TRAMPOLINE_SIZE 52
kono
parents:
diff changeset
240 #else
kono
parents:
diff changeset
241 #define FFI_TRAMPOLINE_SIZE 20
kono
parents:
diff changeset
242 #endif
kono
parents:
diff changeset
243 #endif /* FFI_MIPS_O32 */
kono
parents:
diff changeset
244 #define FFI_NATIVE_RAW_API 0
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 #endif
kono
parents:
diff changeset
247