PR bootstrap/82916
[official-gcc.git] / libffi / src / powerpc / ffitarget.h
blob90aa36b0fce48ec827c2eafae94ee68f7dcf2afd
1 /* -----------------------------------------------------------------*-C-*-
2 ffitarget.h - Copyright (c) 2012 Anthony Green
3 Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc
4 Copyright (c) 1996-2003 Red Hat, Inc.
6 Target configuration macros for PowerPC.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 ``Software''), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice shall be included
17 in all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 DEALINGS IN THE SOFTWARE.
28 ----------------------------------------------------------------------- */
30 #ifndef LIBFFI_TARGET_H
31 #define LIBFFI_TARGET_H
33 #ifndef LIBFFI_H
34 #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
35 #endif
37 /* ---- System specific configurations ----------------------------------- */
39 #if defined (POWERPC) && defined (__powerpc64__) /* linux64 */
40 #ifndef POWERPC64
41 #define POWERPC64
42 #endif
43 #elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin64 */
44 #ifndef POWERPC64
45 #define POWERPC64
46 #endif
47 #ifndef POWERPC_DARWIN64
48 #define POWERPC_DARWIN64
49 #endif
50 #elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */
51 #ifndef POWERPC64
52 #define POWERPC64
53 #endif
54 #endif
56 #ifndef LIBFFI_ASM
57 typedef unsigned long ffi_arg;
58 typedef signed long ffi_sarg;
60 typedef enum ffi_abi {
61 FFI_FIRST_ABI = 0,
63 #if defined (POWERPC_AIX)
64 FFI_AIX,
65 FFI_DARWIN,
66 FFI_DEFAULT_ABI = FFI_AIX,
67 FFI_LAST_ABI
69 #elif defined (POWERPC_DARWIN)
70 FFI_AIX,
71 FFI_DARWIN,
72 FFI_DEFAULT_ABI = FFI_DARWIN,
73 FFI_LAST_ABI
75 #else
76 /* The FFI_COMPAT values are used by old code. Since libffi may be
77 a shared library we have to support old values for backwards
78 compatibility. */
79 FFI_COMPAT_SYSV,
80 FFI_COMPAT_GCC_SYSV,
81 FFI_COMPAT_LINUX64,
82 FFI_COMPAT_LINUX,
83 FFI_COMPAT_LINUX_SOFT_FLOAT,
85 # if defined (POWERPC64)
86 /* This bit, always set in new code, must not be set in any of the
87 old FFI_COMPAT values that might be used for 64-bit linux. We
88 only need worry about FFI_COMPAT_LINUX64, but to be safe avoid
89 all old values. */
90 FFI_LINUX = 8,
91 /* This and following bits can reuse FFI_COMPAT values. */
92 FFI_LINUX_STRUCT_ALIGN = 1,
93 FFI_LINUX_LONG_DOUBLE_128 = 2,
94 FFI_DEFAULT_ABI = (FFI_LINUX
95 # ifdef __STRUCT_PARM_ALIGN__
96 | FFI_LINUX_STRUCT_ALIGN
97 # endif
98 # ifdef __LONG_DOUBLE_128__
99 | FFI_LINUX_LONG_DOUBLE_128
100 # endif
102 FFI_LAST_ABI = 12
104 # else
105 /* This bit, always set in new code, must not be set in any of the
106 old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd. */
107 FFI_SYSV = 8,
108 /* This and following bits can reuse FFI_COMPAT values. */
109 FFI_SYSV_SOFT_FLOAT = 1,
110 FFI_SYSV_STRUCT_RET = 2,
111 FFI_SYSV_IBM_LONG_DOUBLE = 4,
112 FFI_SYSV_LONG_DOUBLE_128 = 16,
114 FFI_DEFAULT_ABI = (FFI_SYSV
115 # ifdef __NO_FPRS__
116 | FFI_SYSV_SOFT_FLOAT
117 # endif
118 # if (defined (__SVR4_STRUCT_RETURN) \
119 || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
120 | FFI_SYSV_STRUCT_RET
121 # endif
122 # if __LDBL_MANT_DIG__ == 106
123 | FFI_SYSV_IBM_LONG_DOUBLE
124 # endif
125 # ifdef __LONG_DOUBLE_128__
126 | FFI_SYSV_LONG_DOUBLE_128
127 # endif
129 FFI_LAST_ABI = 32
130 # endif
131 #endif
133 } ffi_abi;
134 #endif
136 /* ---- Definitions for closures ----------------------------------------- */
138 #define FFI_CLOSURES 1
139 #define FFI_NATIVE_RAW_API 0
140 #if defined (POWERPC) || defined (POWERPC_FREEBSD)
141 # define FFI_GO_CLOSURES 1
142 # define FFI_TARGET_SPECIFIC_VARIADIC 1
143 # define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs
144 #endif
145 #if defined (POWERPC_AIX)
146 # define FFI_GO_CLOSURES 1
147 #endif
149 /* ppc_closure.S and linux64_closure.S expect this. */
150 #define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER
152 /* We define additional types below. If generic types are added that
153 must be supported by powerpc libffi then it is likely that
154 FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in
155 ppc_closure.S and linux64_closure.S be extended. */
157 #if !(FFI_TYPE_LAST == FFI_PPC_TYPE_LAST \
158 || (FFI_TYPE_LAST == FFI_TYPE_COMPLEX \
159 && !defined FFI_TARGET_HAS_COMPLEX_TYPE))
160 # error "You likely have a broken powerpc libffi"
161 #endif
163 /* Needed for soft-float long-double-128 support. */
164 #define FFI_TYPE_UINT128 (FFI_PPC_TYPE_LAST + 1)
166 /* Needed for FFI_SYSV small structure returns. */
167 #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2)
169 /* Used by ELFv2 for homogenous structure returns. */
170 #define FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 1)
171 #define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 2)
172 #define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 3)
174 #if _CALL_ELF == 2
175 # define FFI_TRAMPOLINE_SIZE 32
176 #else
177 # if defined(POWERPC64) || defined(POWERPC_AIX)
178 # if defined(POWERPC_DARWIN64)
179 # define FFI_TRAMPOLINE_SIZE 48
180 # else
181 # define FFI_TRAMPOLINE_SIZE 24
182 # endif
183 # else /* POWERPC || POWERPC_AIX */
184 # define FFI_TRAMPOLINE_SIZE 40
185 # endif
186 #endif
188 #ifndef LIBFFI_ASM
189 #if defined(POWERPC_DARWIN) || defined(POWERPC_AIX)
190 struct ffi_aix_trampoline_struct {
191 void * code_pointer; /* Pointer to ffi_closure_ASM */
192 void * toc; /* TOC */
193 void * static_chain; /* Pointer to closure */
195 #endif
196 #endif
198 #endif