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>
32 #elif defined(__rtems__)
34 * Subprogram calling convention - copied from sgidefs.h
36 #define _MIPS_SIM_ABI32 1
37 #define _MIPS_SIM_NABI32 2
38 #define _MIPS_SIM_ABI64 3
44 # define _ABIN32 _MIPS_SIM_NABI32
47 # define _ABI64 _MIPS_SIM_ABI64
50 # define _ABIO32 _MIPS_SIM_ABI32
53 #if !defined(_MIPS_SIM)
54 -- something is very wrong
--
56 # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
59 # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
62 -- this is an unsupported platform
--
68 /* O32 stack frames have 32bit integer args */
69 # define FFI_SIZEOF_ARG 4
71 /* N32 and N64 frames have 64bit integer args */
72 # define FFI_SIZEOF_ARG 8
73 # if _MIPS_SIM == _ABIN32
74 # define FFI_SIZEOF_JAVA_RAW 4
78 #define FFI_FLAG_BITS 2
80 /* SGI's strange assembler requires that we multiply by 4 rather
81 than shift left by FFI_FLAG_BITS */
83 #define FFI_ARGS_D FFI_TYPE_DOUBLE
84 #define FFI_ARGS_F FFI_TYPE_FLOAT
85 #define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
86 #define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
87 #define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
88 #define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
90 /* Needed for N32 structure returns */
91 #define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
92 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
95 /* The SGI assembler can't handle this.. */
96 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
99 /* ...so we calculate these by hand! */
100 #define FFI_TYPE_STRUCT_D 61
101 #define FFI_TYPE_STRUCT_F 45
102 #define FFI_TYPE_STRUCT_DD 253
103 #define FFI_TYPE_STRUCT_FF 173
104 #define FFI_TYPE_STRUCT_FD 237
105 #define FFI_TYPE_STRUCT_DF 189
106 #define FFI_TYPE_STRUCT_SMALL 93
107 #define FFI_TYPE_STRUCT_SMALL2 109
109 /* and for n32 soft float, add 16 * 2^4 */
110 #define FFI_TYPE_STRUCT_D_SOFT 317
111 #define FFI_TYPE_STRUCT_F_SOFT 301
112 #define FFI_TYPE_STRUCT_DD_SOFT 509
113 #define FFI_TYPE_STRUCT_FF_SOFT 429
114 #define FFI_TYPE_STRUCT_FD_SOFT 493
115 #define FFI_TYPE_STRUCT_DF_SOFT 445
116 #define FFI_TYPE_STRUCT_SOFT 16
149 #else /* !FFI_MIPS_O32 */
156 # if (_MIPS_SIM==_ABI64)
158 # define EH_FRAME_ALIGN 3
159 # define FDE_ADDR_BYTES .8byte
162 # define EH_FRAME_ALIGN 2
163 # define FDE_ADDR_BYTES .4byte
164 # endif /* _MIPS_SIM==_ABI64 */
165 #endif /* !FFI_MIPS_O32 */
166 #else /* !LIBFFI_ASM */
169 /* O32 stack frames have 32bit integer args */
170 typedef unsigned int ffi_arg
__attribute__((__mode__(__SI__
)));
171 typedef signed int ffi_sarg
__attribute__((__mode__(__SI__
)));
173 /* N32 and N64 frames have 64bit integer args */
174 typedef unsigned int ffi_arg
__attribute__((__mode__(__DI__
)));
175 typedef signed int ffi_sarg
__attribute__((__mode__(__DI__
)));
179 /* O32 stack frames have 32bit integer args */
180 typedef __uint32_t ffi_arg
;
181 typedef __int32_t ffi_sarg
;
183 /* N32 and N64 frames have 64bit integer args */
184 typedef __uint64_t ffi_arg
;
185 typedef __int64_t ffi_sarg
;
187 # endif /* __GNUC__ */
189 typedef enum ffi_abi
{
199 #ifdef __mips_soft_float
200 FFI_DEFAULT_ABI
= FFI_O32_SOFT_FLOAT
,
202 FFI_DEFAULT_ABI
= FFI_O32
,
205 # if _MIPS_SIM==_ABI64
206 # ifdef __mips_soft_float
207 FFI_DEFAULT_ABI
= FFI_N64_SOFT_FLOAT
,
209 FFI_DEFAULT_ABI
= FFI_N64
,
212 # ifdef __mips_soft_float
213 FFI_DEFAULT_ABI
= FFI_N32_SOFT_FLOAT
,
215 FFI_DEFAULT_ABI
= FFI_N32
,
220 FFI_LAST_ABI
= FFI_DEFAULT_ABI
+ 1
223 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
224 #endif /* !LIBFFI_ASM */
226 /* ---- Definitions for closures ----------------------------------------- */
228 #if defined(FFI_MIPS_O32)
229 #define FFI_CLOSURES 1
230 #define FFI_TRAMPOLINE_SIZE 20
233 # define FFI_CLOSURES 1
234 #if _MIPS_SIM==_ABI64
235 #define FFI_TRAMPOLINE_SIZE 52
237 #define FFI_TRAMPOLINE_SIZE 20
239 #endif /* FFI_MIPS_O32 */
240 #define FFI_NATIVE_RAW_API 0