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, EXPRESS
17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 OTHER DEALINGS IN THE SOFTWARE.
24 ----------------------------------------------------------------------- */
26 #ifndef LIBFFI_TARGET_H
27 #define LIBFFI_TARGET_H
29 #if !defined(_MIPS_SIM)
30 -- something is very wrong --
32 # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
35 # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
38 -- this is an unsupported platform --
44 /* O32 stack frames have 32bit integer args */
45 # define FFI_SIZEOF_ARG 4
47 /* N32 and N64 frames have 64bit integer args */
48 # define FFI_SIZEOF_ARG 8
49 # if _MIPS_SIM == _ABIN32
50 # define FFI_SIZEOF_JAVA_RAW 4
54 #define FFI_FLAG_BITS 2
56 /* SGI's strange assembler requires that we multiply by 4 rather
57 than shift left by FFI_FLAG_BITS */
59 #define FFI_ARGS_D FFI_TYPE_DOUBLE
60 #define FFI_ARGS_F FFI_TYPE_FLOAT
61 #define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
62 #define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
63 #define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
64 #define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
66 /* Needed for N32 structure returns */
67 #define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
68 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
71 /* The SGI assembler can't handle this.. */
72 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
75 /* ...so we calculate these by hand! */
76 #define FFI_TYPE_STRUCT_D 61
77 #define FFI_TYPE_STRUCT_F 45
78 #define FFI_TYPE_STRUCT_DD 253
79 #define FFI_TYPE_STRUCT_FF 173
80 #define FFI_TYPE_STRUCT_FD 237
81 #define FFI_TYPE_STRUCT_DF 189
82 #define FFI_TYPE_STRUCT_SMALL 93
83 #define FFI_TYPE_STRUCT_SMALL2 109
116 #else /* !FFI_MIPS_O32 */
123 # if (_MIPS_SIM==_ABI64)
125 # define EH_FRAME_ALIGN 3
126 # define FDE_ADDR_BYTES .8byte
129 # define EH_FRAME_ALIGN 2
130 # define FDE_ADDR_BYTES .4byte
131 # endif /* _MIPS_SIM==_ABI64 */
132 #endif /* !FFI_MIPS_O32 */
133 #else /* !LIBFFI_ASM */
135 /* O32 stack frames have 32bit integer args */
136 typedef unsigned int ffi_arg __attribute__((__mode__(__SI__)));
137 typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
139 /* N32 and N64 frames have 64bit integer args */
140 typedef unsigned int ffi_arg __attribute__((__mode__(__DI__)));
141 typedef signed int ffi_sarg __attribute__((__mode__(__DI__)));
144 typedef enum ffi_abi {
152 #ifdef __mips_soft_float
153 FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT,
155 FFI_DEFAULT_ABI = FFI_O32,
158 # if _MIPS_SIM==_ABI64
159 FFI_DEFAULT_ABI = FFI_N64,
161 FFI_DEFAULT_ABI = FFI_N32,
165 FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
168 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
169 #endif /* !LIBFFI_ASM */
171 /* ---- Definitions for closures ----------------------------------------- */
173 #if defined(FFI_MIPS_O32)
174 #define FFI_CLOSURES 1
175 #define FFI_TRAMPOLINE_SIZE 20
178 # define FFI_CLOSURES 1
179 #if _MIPS_SIM==_ABI64
180 #define FFI_TRAMPOLINE_SIZE 52
182 #define FFI_TRAMPOLINE_SIZE 20
184 #endif /* FFI_MIPS_O32 */
185 #define FFI_NATIVE_RAW_API 0