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
30 #if !defined(_MIPS_SIM)
31 -- something is very wrong
--
33 # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
36 # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
39 -- this is an unsupported platform
--
45 /* O32 stack frames have 32bit integer args */
46 # define FFI_SIZEOF_ARG 4
48 /* N32 and N64 frames have 64bit integer args */
49 # define FFI_SIZEOF_ARG 8
50 # if _MIPS_SIM == _ABIN32
51 # define FFI_SIZEOF_JAVA_RAW 4
55 #define FFI_FLAG_BITS 2
57 /* SGI's strange assembler requires that we multiply by 4 rather
58 than shift left by FFI_FLAG_BITS */
60 #define FFI_ARGS_D FFI_TYPE_DOUBLE
61 #define FFI_ARGS_F FFI_TYPE_FLOAT
62 #define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
63 #define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
64 #define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
65 #define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
67 /* Needed for N32 structure returns */
68 #define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
69 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
72 /* The SGI assembler can't handle this.. */
73 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
76 /* ...so we calculate these by hand! */
77 #define FFI_TYPE_STRUCT_D 61
78 #define FFI_TYPE_STRUCT_F 45
79 #define FFI_TYPE_STRUCT_DD 253
80 #define FFI_TYPE_STRUCT_FF 173
81 #define FFI_TYPE_STRUCT_FD 237
82 #define FFI_TYPE_STRUCT_DF 189
83 #define FFI_TYPE_STRUCT_SMALL 93
84 #define FFI_TYPE_STRUCT_SMALL2 109
117 #else /* !FFI_MIPS_O32 */
124 # if (_MIPS_SIM==_ABI64)
126 # define EH_FRAME_ALIGN 3
127 # define FDE_ADDR_BYTES .8byte
130 # define EH_FRAME_ALIGN 2
131 # define FDE_ADDR_BYTES .4byte
132 # endif /* _MIPS_SIM==_ABI64 */
133 #endif /* !FFI_MIPS_O32 */
134 #else /* !LIBFFI_ASM */
136 /* O32 stack frames have 32bit integer args */
137 typedef unsigned int ffi_arg
__attribute__((__mode__(__SI__
)));
138 typedef signed int ffi_sarg
__attribute__((__mode__(__SI__
)));
140 /* N32 and N64 frames have 64bit integer args */
141 typedef unsigned int ffi_arg
__attribute__((__mode__(__DI__
)));
142 typedef signed int ffi_sarg
__attribute__((__mode__(__DI__
)));
145 typedef enum ffi_abi
{
153 #ifdef __mips_soft_float
154 FFI_DEFAULT_ABI
= FFI_O32_SOFT_FLOAT
,
156 FFI_DEFAULT_ABI
= FFI_O32
,
159 # if _MIPS_SIM==_ABI64
160 FFI_DEFAULT_ABI
= FFI_N64
,
162 FFI_DEFAULT_ABI
= FFI_N32
,
166 FFI_LAST_ABI
= FFI_DEFAULT_ABI
+ 1
169 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
170 #endif /* !LIBFFI_ASM */
172 /* ---- Definitions for closures ----------------------------------------- */
174 #if defined(FFI_MIPS_O32)
175 #define FFI_CLOSURES 1
176 #define FFI_TRAMPOLINE_SIZE 20
179 # define FFI_CLOSURES 1
180 #if _MIPS_SIM==_ABI64
181 #define FFI_TRAMPOLINE_SIZE 52
183 #define FFI_TRAMPOLINE_SIZE 20
185 #endif /* FFI_MIPS_O32 */
186 #define FFI_NATIVE_RAW_API 0