1 /* -----------------------------------------------------------------*-C-*-
2 ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
3 Target configuration macros for MIPS.
5 Permission is hereby granted, free of charge, to any person obtaining
6 a copy of this software and associated documentation files (the
7 ``Software''), to deal in the Software without restriction, including
8 without limitation the rights to use, copy, modify, merge, publish,
9 distribute, sublicense, and/or sell copies of the Software, and to
10 permit persons to whom the Software is furnished to do so, subject to
11 the following conditions:
13 The above copyright notice and this permission notice shall be included
14 in all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 DEALINGS IN THE SOFTWARE.
25 ----------------------------------------------------------------------- */
27 #ifndef LIBFFI_TARGET_H
28 #define LIBFFI_TARGET_H
31 # include <asm/sgidefs.h>
36 # define _ABIN32 _MIPS_SIM_NABI32
39 # define _ABI64 _MIPS_SIM_ABI64
42 # define _ABIO32 _MIPS_SIM_ABI32
45 #if !defined(_MIPS_SIM)
46 -- something is very wrong
--
48 # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
51 # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
54 -- this is an unsupported platform
--
60 /* O32 stack frames have 32bit integer args */
61 # define FFI_SIZEOF_ARG 4
63 /* N32 and N64 frames have 64bit integer args */
64 # define FFI_SIZEOF_ARG 8
65 # if _MIPS_SIM == _ABIN32
66 # define FFI_SIZEOF_JAVA_RAW 4
70 #define FFI_FLAG_BITS 2
72 /* SGI's strange assembler requires that we multiply by 4 rather
73 than shift left by FFI_FLAG_BITS */
75 #define FFI_ARGS_D FFI_TYPE_DOUBLE
76 #define FFI_ARGS_F FFI_TYPE_FLOAT
77 #define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
78 #define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
79 #define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
80 #define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
82 /* Needed for N32 structure returns */
83 #define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
84 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
87 /* The SGI assembler can't handle this.. */
88 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
91 /* ...so we calculate these by hand! */
92 #define FFI_TYPE_STRUCT_D 61
93 #define FFI_TYPE_STRUCT_F 45
94 #define FFI_TYPE_STRUCT_DD 253
95 #define FFI_TYPE_STRUCT_FF 173
96 #define FFI_TYPE_STRUCT_FD 237
97 #define FFI_TYPE_STRUCT_DF 189
98 #define FFI_TYPE_STRUCT_SMALL 93
99 #define FFI_TYPE_STRUCT_SMALL2 109
101 /* and for n32 soft float, add 16 * 2^4 */
102 #define FFI_TYPE_STRUCT_D_SOFT 317
103 #define FFI_TYPE_STRUCT_F_SOFT 301
104 #define FFI_TYPE_STRUCT_DD_SOFT 509
105 #define FFI_TYPE_STRUCT_FF_SOFT 429
106 #define FFI_TYPE_STRUCT_FD_SOFT 493
107 #define FFI_TYPE_STRUCT_DF_SOFT 445
108 #define FFI_TYPE_STRUCT_SOFT 16
141 #else /* !FFI_MIPS_O32 */
148 # if (_MIPS_SIM==_ABI64)
150 # define EH_FRAME_ALIGN 3
151 # define FDE_ADDR_BYTES .8byte
154 # define EH_FRAME_ALIGN 2
155 # define FDE_ADDR_BYTES .4byte
156 # endif /* _MIPS_SIM==_ABI64 */
157 #endif /* !FFI_MIPS_O32 */
158 #else /* !LIBFFI_ASM */
161 /* O32 stack frames have 32bit integer args */
162 typedef unsigned int ffi_arg
__attribute__((__mode__(__SI__
)));
163 typedef signed int ffi_sarg
__attribute__((__mode__(__SI__
)));
165 /* N32 and N64 frames have 64bit integer args */
166 typedef unsigned int ffi_arg
__attribute__((__mode__(__DI__
)));
167 typedef signed int ffi_sarg
__attribute__((__mode__(__DI__
)));
171 /* O32 stack frames have 32bit integer args */
172 typedef __uint32_t ffi_arg
;
173 typedef __int32_t ffi_sarg
;
175 /* N32 and N64 frames have 64bit integer args */
176 typedef __uint64_t ffi_arg
;
177 typedef __int64_t ffi_sarg
;
179 # endif /* __GNUC__ */
181 typedef enum ffi_abi
{
191 #ifdef __mips_soft_float
192 FFI_DEFAULT_ABI
= FFI_O32_SOFT_FLOAT
,
194 FFI_DEFAULT_ABI
= FFI_O32
,
197 # if _MIPS_SIM==_ABI64
198 # ifdef __mips_soft_float
199 FFI_DEFAULT_ABI
= FFI_N64_SOFT_FLOAT
,
201 FFI_DEFAULT_ABI
= FFI_N64
,
204 # ifdef __mips_soft_float
205 FFI_DEFAULT_ABI
= FFI_N32_SOFT_FLOAT
,
207 FFI_DEFAULT_ABI
= FFI_N32
,
212 FFI_LAST_ABI
= FFI_DEFAULT_ABI
+ 1
215 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
216 #endif /* !LIBFFI_ASM */
218 /* ---- Definitions for closures ----------------------------------------- */
220 #if defined(FFI_MIPS_O32)
221 #define FFI_CLOSURES 1
222 #define FFI_TRAMPOLINE_SIZE 20
225 # define FFI_CLOSURES 1
226 #if _MIPS_SIM==_ABI64
227 #define FFI_TRAMPOLINE_SIZE 52
229 #define FFI_TRAMPOLINE_SIZE 20
231 #endif /* FFI_MIPS_O32 */
232 #define FFI_NATIVE_RAW_API 0