1 /* Definitions of target machine for GNU compiler. Vxworks PowerPC version. 2 Copyright (C) 1996-2022 Free Software Foundation, Inc. 3 Contributed by CodeSourcery, LLC. 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it under 8 the terms of the GNU General Public License as published by the Free 9 Software Foundation; either version 3, or (at your option) any later 10 version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13 WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 /* The port comes in two very different flavors at this stage: 22 23 - For 653 (AE) and regular versions prior to VxWorks 7, the port 24 comes with its own set of definitions, matching a system compiler 25 configured this way as well as the corresponding run-time 26 environment. This is essentially an eabi system, so changes to 27 eabi.h should usually be reflected here. 28 29 - Starting with VxWorks 7 (post SR600), the system environment 30 was made extremely similar to GNU/Linux and this toolchain is 31 built on top of the corresponding header files. */ 32 33 /*-------------------------------------------------------------*/ 34 /* Common definitions first. */ 35 /*-------------------------------------------------------------*/ 36 37 /* CPP predefined macros. */ 38 39 #undef TARGET_OS_CPP_BUILTINS 40 #define TARGET_OS_CPP_BUILTINS() \ 41 do \ 42 { \ 43 builtin_define ("__ELF__"); \ 44 if (!TARGET_VXWORKS7) \ 45 builtin_define ("__EABI__"); \ 46 \ 47 /* CPU macros, based on what the system compilers do. */ \ 48 if (!TARGET_VXWORKS7) \ 49 { \ 50 builtin_define ("__ppc"); \ 51 /* Namespace violation below, but the system headers \ 52 really depend heavily on this. */ \ 53 builtin_define ("CPU_FAMILY=PPC"); \ 54 \ 55 /* __PPC__ isn't actually emitted by the system compiler \ 56 prior to vx7 but has been advertised by us for ages. */ \ 57 builtin_define ("__PPC__"); \ 58 } \ 59 else \ 60 { \ 61 builtin_define ("__PPC__"); \ 62 builtin_define ("__powerpc__"); \ 63 if (TARGET_64BIT) \ 64 { \ 65 builtin_define ("__PPC64__"); \ 66 builtin_define ("__powerpc64__"); \ 67 } \ 68 else \ 69 { \ 70 builtin_define ("__PPC"); \ 71 builtin_define ("__powerpc"); \ 72 } \ 73 \ 74 /* __ppc isn't emitted by the system compiler \ 75 any more but a few system headers still depend \ 76 on it, as well as on __ppc__. */ \ 77 builtin_define ("__ppc"); \ 78 builtin_define ("__ppc__"); \ 79 } \ 80 \ 81 /* Asserts for #cpu and #machine. */ \ 82 if (TARGET_64BIT) \ 83 { \ 84 builtin_assert ("cpu=powerpc64"); \ 85 builtin_assert ("machine=powerpc64"); \ 86 } \ 87 else \ 88 { \ 89 builtin_assert ("cpu=powerpc"); \ 90 builtin_assert ("machine=powerpc"); \ 91 } \ 92 \ 93 /* PowerPC VxWorks specificities. */ \ 94 if (!TARGET_SOFT_FLOAT) \ 95 { \ 96 builtin_define ("__hardfp"); \ 97 builtin_define ("_WRS_HARDWARE_FP"); \ 98 } \ 99 \ 100 /* Common VxWorks and port items. */ \ 101 VXWORKS_OS_CPP_BUILTINS (); \ 102 TARGET_OS_SYSV_CPP_BUILTINS (); \ 103 } \ 104 while (0) 105 106 107 #define VX_CPUDEF(CPUID) \ 108 ":-D" VX_CPU_PREFIX "CPU=" VX_CPU_PREFIX #CPUID 109 110 #define VX_MCPU(CPU,CPUID) \ 111 "mcpu=" #CPU VX_CPUDEF(CPUID) 112 113 #undef CPP_SPEC 114 #define CPP_SPEC \ 115 "%{!D" VX_CPU_PREFIX "CPU=*:%{" \ 116 VX_MCPU(403, PPC403) ";" \ 117 VX_MCPU(405, PPC405) ";" \ 118 VX_MCPU(440, PPC440) ";" \ 119 VX_MCPU(464, PPC464) ";" \ 120 VX_MCPU(476, PPC476) ";" \ 121 VX_MCPU(603, PPC603) ";" \ 122 VX_MCPU(604, PPC604) ";" \ 123 VX_MCPU(860, PPC860) ";" \ 124 VX_MCPU(e6500, PPCE6500) ";" \ 125 VX_MCPU(8540, PPC85XX) ";" \ 126 VX_MCPU(8548, PPC85XX) ";" \ 127 VX_CPUDEF(PPC604) \ 128 "}}" \ 129 VXWORKS_ADDITIONAL_CPP_SPEC 130 131 /* FIXME: The only reason we allow no -mcpu switch at all is because 132 config-ml.in insists on a "." multilib. */ 133 134 #undef LIB_SPEC 135 #define LIB_SPEC VXWORKS_LIB_SPEC 136 137 #undef STARTFILE_SPEC 138 #define STARTFILE_SPEC VXWORKS_STARTFILE_SPEC 139 140 #undef ENDFILE_SPEC 141 #define ENDFILE_SPEC VXWORKS_ENDFILE_SPEC 142 143 /* There is no default multilib. */ 144 #undef MULTILIB_DEFAULTS 145 146 /* No _mcount profiling on VxWorks. */ 147 #undef FUNCTION_PROFILER 148 #define FUNCTION_PROFILER(FILE,LABELNO) VXWORKS_FUNCTION_PROFILER(FILE,LABELNO) 149 150 /* Nor sdata, for kernel mode. We use this in 151 SUBSUBTARGET_INITIALIZE_OPTIONS, after rs6000_rtp has been initialized. */ 152 #undef SDATA_DEFAULT_SIZE 153 #define SDATA_DEFAULT_SIZE (TARGET_VXWORKS_RTP ? 8 : 0) 154 155 #undef SUB3TARGET_OVERRIDE_OPTIONS 156 #define SUB3TARGET_OVERRIDE_OPTIONS \ 157 do { \ 158 if (!OPTION_SET_P (g_switch_value)) \ 159 g_switch_value = SDATA_DEFAULT_SIZE; \ 160 VXWORKS_OVERRIDE_OPTIONS; \ 161 } while (0) 162 163 /* The stack pointer need not be moved while checking the stack. */ 164 #undef STACK_CHECK_MOVING_SP 165 166 /* Define this to be nonzero if static stack checking is supported. */ 167 #define STACK_CHECK_STATIC_BUILTIN 1 168 169 /* Room needed to allow exception propagation, from what experiments 170 and low level observations taught us ... */ 171 #define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024) 172 173 /* Leverage linker relaxation for RTPs. This helps 32bit programs 174 referring to kernel services too far away for short calls, is more 175 precise than -mlongcall and can be overriden with -Wl,--no-relax. */ 176 #define VXWORKS_RELAX_LINK_SPEC "%{mrtp:--relax}" 177 178 /*-------------------------------------------------------------*/ 179 /* Pre-VxWorks7 configuration. */ 180 /*-------------------------------------------------------------*/ 181 182 #if !TARGET_VXWORKS7 183 184 #undef RS6000_STARTING_FRAME_OFFSET 185 #define RS6000_STARTING_FRAME_OFFSET \ 186 (cfun->calls_alloca \ 187 ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \ 188 : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA)) 189 190 #undef STACK_DYNAMIC_OFFSET 191 #define STACK_DYNAMIC_OFFSET(FUNDECL) \ 192 RS6000_ALIGN (crtl->outgoing_args_size.to_constant () \ 193 + STACK_POINTER_OFFSET, 16) 194 195 /* Enforce 16-byte alignment for the stack pointer, to permit general 196 compliance with e.g. Altivec instructions requirements. Make sure 197 this isn't overruled by the EABI constraints. */ 198 199 #undef STACK_BOUNDARY 200 #define STACK_BOUNDARY (16*BITS_PER_UNIT) 201 202 #undef PREFERRED_STACK_BOUNDARY 203 #define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY 204 205 #undef ABI_STACK_BOUNDARY 206 207 #undef STARTFILE_PREFIX_SPEC 208 #define STARTFILE_PREFIX_SPEC \ 209 "%{mrtp:%{!shared:/lib/usr/lib/ppc/PPC32/common}}" 210 211 /* For aggregates passing, use the same, consistent ABI as Linux. */ 212 #define AGGREGATE_PADDING_FIXED 0 213 #define AGGREGATES_PAD_UPWARD_ALWAYS 0 214 215 #undef ASM_SPEC 216 #define ASM_SPEC \ 217 "%(asm_cpu) \ 218 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \ 219 %{mrelocatable} %{mrelocatable-lib} %{" FPIC_SPEC ":-K PIC} -mbig" 220 221 #undef CC1_SPEC 222 #define CC1_SPEC VXWORKS_CC1_SPEC " \ 223 %{G*} %{mno-sdata:-msdata=none} %{msdata:-msdata=default} \ 224 %{mlittle|mlittle-endian:-mstrict-align}" 225 226 #undef LINK_SPEC 227 #define LINK_SPEC VXWORKS_LINK_SPEC " " VXWORKS_RELAX_LINK_SPEC 228 229 #undef TARGET_DEFAULT 230 #define TARGET_DEFAULT (MASK_EABI | MASK_STRICT_ALIGN) 231 232 #undef PROCESSOR_DEFAULT 233 #define PROCESSOR_DEFAULT PROCESSOR_PPC604 234 235 /* Only big endian PPC is supported by VxWorks. */ 236 #undef BYTES_BIG_ENDIAN 237 #define BYTES_BIG_ENDIAN 1 238 239 #undef WORDS_BIG_ENDIAN 240 #define WORDS_BIG_ENDIAN 1 241 242 #undef SUBTARGET_EXTRA_SPECS 243 #define SUBTARGET_EXTRA_SPECS /* none needed */ 244 245 #else /* TARGET_VXWORKS7 */ 246 247 /*-------------------------------------------------------------*/ 248 /* Post-VxWorks7 (SR600) configuration. */ 249 /*-------------------------------------------------------------*/ 250 251 /* VxWorks does not use local symbols for the function entry point. */ 252 #undef DOT_SYMBOLS 253 #define DOT_SYMBOLS 0 254 255 /* For link specs, we leverage the linux configuration bits through 256 LINK_OS_EXTRA_SPEC32/64 and need to cancel the default %(link_os) 257 expansion in VXWORKS_LINK_SPEC. */ 258 259 #undef VXWORKS_LINK_OS_SPEC 260 #define VXWORKS_LINK_OS_SPEC "" 261 262 #undef LINK_OS_EXTRA_SPEC32 263 #define LINK_OS_EXTRA_SPEC32 VXWORKS_LINK_SPEC " " VXWORKS_RELAX_LINK_SPEC 264 265 #undef LINK_OS_EXTRA_SPEC64 266 #define LINK_OS_EXTRA_SPEC64 VXWORKS_LINK_SPEC 267 268 /* linux64.h enables this, not supported in vxWorks. */ 269 #undef TARGET_FLOAT128_ENABLE_TYPE 270 #define TARGET_FLOAT128_ENABLE_TYPE 0 271 272 #endif /* TARGET_VXWORKS7 */ 273 274