1 /* Definitions for rtems targeting a PowerPC using elf. 2 Copyright (C) 1996-2019 Free Software Foundation, Inc. 3 Contributed by Joel Sherrill (joel@OARcorp.com). 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published 9 by the Free Software Foundation; either version 3, or (at your 10 option) any later version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 License for more details. 16 17 Under Section 7 of GPL version 3, you are granted additional 18 permissions described in the GCC Runtime Library Exception, version 19 3.1, as published by the Free Software Foundation. 20 21 You should have received a copy of the GNU General Public License and 22 a copy of the GCC Runtime Library Exception along with this program; 23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 <http://www.gnu.org/licenses/>. */ 25 26 /* Copy and paste from linux64.h and freebsd64.h */ 27 #ifdef IN_LIBGCC2 28 #undef TARGET_64BIT 29 #ifdef __powerpc64__ 30 #define TARGET_64BIT 1 31 #else 32 #define TARGET_64BIT 0 33 #endif 34 #endif 35 36 /* Copy and paste from linux64.h and freebsd64.h */ 37 #undef TARGET_AIX 38 #define TARGET_AIX TARGET_64BIT 39 40 /* Simplified copy and paste from linux64.h and freebsd64.h */ 41 #undef DOT_SYMBOLS 42 #define DOT_SYMBOLS 0 43 44 /* Copy and paste from linux64.h and freebsd64.h */ 45 #undef TARGET_CMODEL 46 #define TARGET_CMODEL rs6000_current_cmodel 47 #define SET_CMODEL(opt) rs6000_current_cmodel = opt 48 49 #undef TARGET_OS_CPP_BUILTINS 50 #define TARGET_OS_CPP_BUILTINS() \ 51 do \ 52 { \ 53 builtin_define ("__rtems__"); \ 54 builtin_define ("__USE_INIT_FINI__"); \ 55 builtin_assert ("system=rtems"); \ 56 if (TARGET_64BIT) \ 57 { \ 58 builtin_define ("__PPC__"); \ 59 builtin_define ("__PPC64__"); \ 60 builtin_define ("__powerpc64__"); \ 61 builtin_assert ("cpu=powerpc64"); \ 62 builtin_assert ("machine=powerpc64"); \ 63 } \ 64 else \ 65 { \ 66 builtin_define_std ("PPC"); \ 67 builtin_define_std ("powerpc"); \ 68 builtin_assert ("cpu=powerpc"); \ 69 builtin_assert ("machine=powerpc"); \ 70 TARGET_OS_SYSV_CPP_BUILTINS (); \ 71 } \ 72 } \ 73 while (0) 74 75 /* Copy and paste from linux64.h and freebsd64.h */ 76 #undef RELOCATABLE_NEEDS_FIXUP 77 #define RELOCATABLE_NEEDS_FIXUP \ 78 (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE) 79 80 /* Copy and paste from linux64.h */ 81 #undef RS6000_ABI_NAME 82 #define RS6000_ABI_NAME "linux" 83 84 /* Copy and paste from linux64.h and freebsd64.h */ 85 #define INVALID_64BIT "-m%s not supported in this configuration" 86 87 /* A lot of copy and paste from linux64.h and freebsd64.h */ 88 #undef SUBSUBTARGET_OVERRIDE_OPTIONS 89 #define SUBSUBTARGET_OVERRIDE_OPTIONS \ 90 do \ 91 { \ 92 if (rs6000_isa_flags & OPTION_MASK_64BIT) \ 93 { \ 94 rs6000_elf_abi = 2; \ 95 rs6000_current_abi = ABI_ELFv2; \ 96 if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \ 97 { \ 98 rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \ 99 error (INVALID_64BIT, "relocatable"); \ 100 } \ 101 if (rs6000_isa_flags & OPTION_MASK_EABI) \ 102 { \ 103 rs6000_isa_flags &= ~OPTION_MASK_EABI; \ 104 error (INVALID_64BIT, "eabi"); \ 105 } \ 106 if (TARGET_PROTOTYPE) \ 107 { \ 108 target_prototype = 0; \ 109 error (INVALID_64BIT, "prototype"); \ 110 } \ 111 if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \ 112 { \ 113 rs6000_isa_flags |= OPTION_MASK_POWERPC64; \ 114 error ("%<-m64%> requires a PowerPC64 cpu"); \ 115 } \ 116 if ((rs6000_isa_flags_explicit \ 117 & OPTION_MASK_MINIMAL_TOC) != 0) \ 118 { \ 119 if (global_options_set.x_rs6000_current_cmodel \ 120 && rs6000_current_cmodel != CMODEL_SMALL) \ 121 error ("%<-mcmodel%> incompatible with other toc options"); \ 122 SET_CMODEL (CMODEL_SMALL); \ 123 } \ 124 else \ 125 { \ 126 if (!global_options_set.x_rs6000_current_cmodel) \ 127 SET_CMODEL (CMODEL_MEDIUM); \ 128 if (rs6000_current_cmodel != CMODEL_SMALL) \ 129 { \ 130 TARGET_NO_FP_IN_TOC = 0; \ 131 TARGET_NO_SUM_IN_TOC = 0; \ 132 } \ 133 } \ 134 } \ 135 } \ 136 while (0) 137 138 #undef TARGET_LIBGCC_SDATA_SECTION 139 #define TARGET_LIBGCC_SDATA_SECTION ".sdata" 140 141 /* Copy and paste from linux64.h and freebsd64.h */ 142 #undef SIZE_TYPE 143 #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") 144 145 /* Copy and paste from linux64.h and freebsd64.h */ 146 #undef PTRDIFF_TYPE 147 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") 148 149 /* Copy and paste from freebsd64.h */ 150 #undef WCHAR_TYPE 151 152 /* Copy and paste from freebsd64.h */ 153 #undef WCHAR_TYPE_SIZE 154 #define WCHAR_TYPE_SIZE 32 155 156 /* Copy and paste from linux64.h and freebsd64.h */ 157 #ifdef __powerpc64__ 158 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ 159 asm (SECTION_OP "\n" \ 160 " bl " #FUNC "\n" \ 161 " nop\n" \ 162 " .previous"); 163 #endif 164 165 /* This could be also POWERPC_FREEBSD. It is related to the save/restore 166 defines below. */ 167 #define POWERPC_LINUX 168 169 /* Copy and paste from linux64.h and freebsd64.h */ 170 #undef SAVE_FP_PREFIX 171 #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_") 172 #undef SAVE_FP_SUFFIX 173 #define SAVE_FP_SUFFIX "" 174 #undef RESTORE_FP_PREFIX 175 #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_") 176 #undef RESTORE_FP_SUFFIX 177 #define RESTORE_FP_SUFFIX "" 178 179 /* Copy and paste from linux64.h and freebsd64.h */ 180 #undef ASM_PREFERRED_EH_DATA_FORMAT 181 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ 182 (TARGET_64BIT || flag_pic \ 183 ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \ 184 | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \ 185 : DW_EH_PE_absptr) 186 187 /* Copy and paste from linux64.h and freebsd64.h */ 188 #undef TOC_SECTION_ASM_OP 189 #define TOC_SECTION_ASM_OP \ 190 (TARGET_64BIT \ 191 ? "\t.section\t\".toc\",\"aw\"" \ 192 : "\t.section\t\".got\",\"aw\"") 193 194 /* Copy and paste from linux64.h and freebsd64.h */ 195 #undef MINIMAL_TOC_SECTION_ASM_OP 196 #define MINIMAL_TOC_SECTION_ASM_OP \ 197 (TARGET_64BIT \ 198 ? "\t.section\t\".toc1\",\"aw\"" \ 199 : (flag_pic \ 200 ? "\t.section\t\".got2\",\"aw\"" \ 201 : "\t.section\t\".got1\",\"aw\"")) 202 203 /* Copy and paste from linux64.h and freebsd64.h */ 204 #undef ASM_DECLARE_FUNCTION_SIZE 205 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ 206 do \ 207 { \ 208 if (!flag_inhibit_size_directive) \ 209 { \ 210 fputs ("\t.size\t", (FILE)); \ 211 if (TARGET_64BIT && DOT_SYMBOLS) \ 212 putc ('.', (FILE)); \ 213 assemble_name ((FILE), (FNAME)); \ 214 fputs (",.-", (FILE)); \ 215 rs6000_output_function_entry (FILE, FNAME); \ 216 putc ('\n', (FILE)); \ 217 } \ 218 } \ 219 while (0) 220 221 /* Copy and paste from linux64.h and freebsd64.h */ 222 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P 223 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ 224 (TARGET_TOC \ 225 && (SYMBOL_REF_P (X) \ 226 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ 227 && SYMBOL_REF_P (XEXP (XEXP (X, 0), 0))) \ 228 || GET_CODE (X) == LABEL_REF \ 229 || (CONST_INT_P (X) \ 230 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ 231 || (CONST_DOUBLE_P (X) \ 232 && ((TARGET_64BIT \ 233 && (TARGET_MINIMAL_TOC \ 234 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ 235 && ! TARGET_NO_FP_IN_TOC))) \ 236 || (!TARGET_64BIT \ 237 && !TARGET_NO_FP_IN_TOC \ 238 && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ 239 && BITS_PER_WORD == HOST_BITS_PER_INT))))) 240 241 #undef CPP_OS_DEFAULT_SPEC 242 #define CPP_OS_DEFAULT_SPEC "\ 243 %{!mcpu*: %{!Dppc*: %{!Dmpc*: -Dmpc750} } }\ 244 %{mcpu=403: %{!Dppc*: %{!Dmpc*: -Dppc403} } } \ 245 %{mcpu=505: %{!Dppc*: %{!Dmpc*: -Dmpc505} } } \ 246 %{mcpu=601: %{!Dppc*: %{!Dmpc*: -Dppc601} } } \ 247 %{mcpu=602: %{!Dppc*: %{!Dmpc*: -Dppc602} } } \ 248 %{mcpu=603: %{!Dppc*: %{!Dmpc*: -Dppc603} } } \ 249 %{mcpu=603e: %{!Dppc*: %{!Dmpc*: -Dppc603e} } } \ 250 %{mcpu=604: %{!Dppc*: %{!Dmpc*: -Dmpc604} } } \ 251 %{mcpu=750: %{!Dppc*: %{!Dmpc*: -Dmpc750} } } \ 252 %{mcpu=821: %{!Dppc*: %{!Dmpc*: -Dmpc821} } } \ 253 %{mcpu=860: %{!Dppc*: %{!Dmpc*: -Dmpc860} } } \ 254 %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540} } } \ 255 %{mcpu=e6500: -D__PPC_CPU_E6500__}" 256 257 #undef ASM_DEFAULT_SPEC 258 #define ASM_DEFAULT_SPEC "-mppc%{m64:64}" 259 260 #undef ASM_SPEC 261 #define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)" 262 263 #define ASM_SPEC32 "-a32 \ 264 %{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \ 265 %{memb|msdata=eabi: -memb}" 266 267 #define ASM_SPEC64 "-a64" 268 269 #define ASM_SPEC_COMMON "%(asm_cpu) \ 270 %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \ 271 ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) 272 273 #undef LINK_OS_DEFAULT_SPEC 274 #define LINK_OS_DEFAULT_SPEC \ 275 "%{!m64:%(link_os_spec32)}%{m64:%(link_os_spec64)}" 276 277 #define LINK_OS_SPEC32 ENDIAN_SELECT(" -m elf32ppc", \ 278 " -m elf32lppc", \ 279 " -m elf32ppc") 280 #define LINK_OS_SPEC64 ENDIAN_SELECT(" -m elf64ppc", \ 281 " -m elf64lppc", \ 282 " -m elf64ppc") 283 284 #undef SUBSUBTARGET_EXTRA_SPECS 285 #define SUBSUBTARGET_EXTRA_SPECS \ 286 { "asm_spec_common", ASM_SPEC_COMMON }, \ 287 { "asm_spec32", ASM_SPEC32 }, \ 288 { "asm_spec64", ASM_SPEC64 }, \ 289 { "link_os_spec32", LINK_OS_SPEC32 }, \ 290 { "link_os_spec64", LINK_OS_SPEC64 }, 291 292 /* Use gnu-user.h LINK_GCC_SEQUENCE_SPEC for rtems. */ 293 #undef LINK_GCC_C_SEQUENCE_SPEC 294 #define LINK_GCC_C_SEQUENCE_SPEC \ 295 "%{mads|myellowknife|mmvme|msim:%G %L %G;" \ 296 "!mcall-*|mcall-linux:" GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC ";" \ 297 ":%G %L %G}" 298