]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libffi/src/mips/ffitarget.h
1 /* -----------------------------------------------------------------*-C-*-
2 ffitarget.h - Copyright (c) 2012 Anthony Green
3 Copyright (c) 1996-2003 Red Hat, Inc.
4 Target configuration macros for MIPS.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 ``Software''), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE.
26 ----------------------------------------------------------------------- */
28 #ifndef LIBFFI_TARGET_H
29 #define LIBFFI_TARGET_H
32 #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
36 # include <asm/sgidefs.h>
37 #elif defined(__rtems__)
39 * Subprogram calling convention - copied from sgidefs.h
41 #define _MIPS_SIM_ABI32 1
42 #define _MIPS_SIM_NABI32 2
43 #define _MIPS_SIM_ABI64 3
44 #elif !defined(__OpenBSD__) && !defined(__FreeBSD__)
49 # define _ABIN32 _MIPS_SIM_NABI32
52 # define _ABI64 _MIPS_SIM_ABI64
55 # define _ABIO32 _MIPS_SIM_ABI32
58 #if !defined(_MIPS_SIM)
59 # error -- something is very wrong --
61 # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
64 # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
67 # error -- this is an unsupported platform --
73 /* O32 stack frames have 32bit integer args */
74 # define FFI_SIZEOF_ARG 4
76 /* N32 and N64 frames have 64bit integer args */
77 # define FFI_SIZEOF_ARG 8
78 # if _MIPS_SIM == _ABIN32
79 # define FFI_SIZEOF_JAVA_RAW 4
83 #define FFI_FLAG_BITS 2
85 /* SGI's strange assembler requires that we multiply by 4 rather
86 than shift left by FFI_FLAG_BITS */
88 #define FFI_ARGS_D FFI_TYPE_DOUBLE
89 #define FFI_ARGS_F FFI_TYPE_FLOAT
90 #define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
91 #define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
92 #define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
93 #define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
95 /* Needed for N32 structure returns */
96 #define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
97 #define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
100 /* The SGI assembler can't handle this.. */
101 #define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
104 /* ...so we calculate these by hand! */
105 #define FFI_TYPE_STRUCT_D 61
106 #define FFI_TYPE_STRUCT_F 45
107 #define FFI_TYPE_STRUCT_DD 253
108 #define FFI_TYPE_STRUCT_FF 173
109 #define FFI_TYPE_STRUCT_FD 237
110 #define FFI_TYPE_STRUCT_DF 189
111 #define FFI_TYPE_STRUCT_SMALL 93
112 #define FFI_TYPE_STRUCT_SMALL2 109
114 /* and for n32 soft float, add 16 * 2^4 */
115 #define FFI_TYPE_STRUCT_D_SOFT 317
116 #define FFI_TYPE_STRUCT_F_SOFT 301
117 #define FFI_TYPE_STRUCT_DD_SOFT 509
118 #define FFI_TYPE_STRUCT_FF_SOFT 429
119 #define FFI_TYPE_STRUCT_FD_SOFT 493
120 #define FFI_TYPE_STRUCT_DF_SOFT 445
121 #define FFI_TYPE_STRUCT_SOFT 16
154 #else /* !FFI_MIPS_O32 */
161 # if (_MIPS_SIM==_ABI64)
163 # define EH_FRAME_ALIGN 3
164 # define FDE_ADDR_BYTES .8byte
167 # define EH_FRAME_ALIGN 2
168 # define FDE_ADDR_BYTES .4byte
169 # endif /* _MIPS_SIM==_ABI64 */
170 #endif /* !FFI_MIPS_O32 */
171 #else /* !LIBFFI_ASM */
174 /* O32 stack frames have 32bit integer args */
175 typedef unsigned int ffi_arg
__attribute__((__mode__(__SI__
)));
176 typedef signed int ffi_sarg
__attribute__((__mode__(__SI__
)));
178 /* N32 and N64 frames have 64bit integer args */
179 typedef unsigned int ffi_arg
__attribute__((__mode__(__DI__
)));
180 typedef signed int ffi_sarg
__attribute__((__mode__(__DI__
)));
184 /* O32 stack frames have 32bit integer args */
185 typedef __uint32_t ffi_arg
;
186 typedef __int32_t ffi_sarg
;
188 /* N32 and N64 frames have 64bit integer args */
189 typedef __uint64_t ffi_arg
;
190 typedef __int64_t ffi_sarg
;
192 # endif /* __GNUC__ */
194 typedef enum ffi_abi
{
205 #ifdef __mips_soft_float
206 FFI_DEFAULT_ABI
= FFI_O32_SOFT_FLOAT
208 FFI_DEFAULT_ABI
= FFI_O32
211 # if _MIPS_SIM==_ABI64
212 # ifdef __mips_soft_float
213 FFI_DEFAULT_ABI
= FFI_N64_SOFT_FLOAT
215 FFI_DEFAULT_ABI
= FFI_N64
218 # ifdef __mips_soft_float
219 FFI_DEFAULT_ABI
= FFI_N32_SOFT_FLOAT
221 FFI_DEFAULT_ABI
= FFI_N32
227 #define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag; unsigned mips_nfixedargs
228 #define FFI_TARGET_SPECIFIC_VARIADIC
229 #endif /* !LIBFFI_ASM */
231 /* ---- Definitions for closures ----------------------------------------- */
233 #define FFI_CLOSURES 1
234 #define FFI_GO_CLOSURES 1
235 #define FFI_NATIVE_RAW_API 0
237 #if defined(FFI_MIPS_O32) || (_MIPS_SIM ==_ABIN32)
238 # define FFI_TRAMPOLINE_SIZE 20
240 # define FFI_TRAMPOLINE_SIZE 56