linux64.h revision 122180
1/* Definitions of target machine for GNU compiler, 2 for 64 bit PowerPC linux. 3 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. 4 5This file is part of GNU CC. 6 7GNU CC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GNU CC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GNU CC; see the file COPYING. If not, write to 19the Free Software Foundation, 59 Temple Place - Suite 330, 20Boston, MA 02111-1307, USA. */ 21 22/* Yes! We are AIX! Err. Wait. We're Linux!. No, wait, we're a 23 combo of both!*/ 24#undef DEFAULT_ABI 25#define DEFAULT_ABI ABI_AIX 26 27#undef TARGET_AIX 28#define TARGET_AIX 1 29 30#undef TARGET_DEFAULT 31#define TARGET_DEFAULT \ 32 (MASK_POWERPC | MASK_POWERPC64 | MASK_64BIT | MASK_NEW_MNEMONICS) 33 34#undef PROCESSOR_DEFAULT 35#define PROCESSOR_DEFAULT PROCESSOR_PPC630 36#undef PROCESSOR_DEFAULT64 37#define PROCESSOR_DEFAULT64 PROCESSOR_PPC630 38 39#undef ASM_DEFAULT_SPEC 40#define ASM_DEFAULT_SPEC "-mppc64" 41 42#undef ASM_SPEC 43#define ASM_SPEC "%{.s: %{mregnames} %{mno-regnames}} \ 44%{.S: %{mregnames} %{mno-regnames}} \ 45%{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian} \ 46%{v:-V} %{Qy:} %{!Qn:-Qy} -a64 %(asm_cpu) %{Wa,*:%*}" 47 48/* 64-bit PowerPC Linux always has a TOC. */ 49#undef TARGET_NO_TOC 50#define TARGET_NO_TOC 0 51#undef TARGET_TOC 52#define TARGET_TOC 1 53 54/* We use glibc _mcount for profiling. */ 55#define NO_PROFILE_COUNTERS 1 56#undef PROFILE_BEFORE_PROLOGUE 57 58/* Define this for kernel profiling, which just saves LR then calls 59 _mcount without worrying about arg saves. The idea is to change 60 the function prologue as little as possible as it isn't easy to 61 account for arg save/restore code added just for _mcount. */ 62/* #define PROFILE_KERNEL 1 */ 63#if PROFILE_KERNEL 64#define PROFILE_BEFORE_PROLOGUE 1 65#undef PROFILE_HOOK 66#else 67#define PROFILE_HOOK(LABEL) output_profile_hook (LABEL) 68#endif 69 70/* We don't need to generate entries in .fixup. */ 71#undef RELOCATABLE_NEEDS_FIXUP 72 73#define USER_LABEL_PREFIX "" 74 75/* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ 76#undef ADJUST_FIELD_ALIGN 77#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ 78 (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \ 79 ? get_inner_array_type (FIELD) \ 80 : TREE_TYPE (FIELD)) == DFmode \ 81 ? MIN ((COMPUTED), 32) : (COMPUTED)) 82 83/* AIX increases natural record alignment to doubleword if the first 84 field is an FP double while the FP fields remain word aligned. */ 85#undef ROUND_TYPE_ALIGN 86#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ 87 ((TREE_CODE (STRUCT) == RECORD_TYPE \ 88 || TREE_CODE (STRUCT) == UNION_TYPE \ 89 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ 90 && TYPE_FIELDS (STRUCT) != 0 \ 91 && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \ 92 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \ 93 : MAX ((COMPUTED), (SPECIFIED))) 94 95/* Indicate that jump tables go in the text section. */ 96#undef JUMP_TABLES_IN_TEXT_SECTION 97#define JUMP_TABLES_IN_TEXT_SECTION 1 98 99/* 64-bit PowerPC Linux always has GPR13 fixed. */ 100#define FIXED_R13 1 101 102/* __throw will restore its own return address to be the same as the 103 return address of the function that the throw is being made to. 104 This is unfortunate, because we want to check the original 105 return address to see if we need to restore the TOC. 106 So we have to squirrel it away with this. */ 107#define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init () 108 109/* Override svr4.h */ 110#undef MD_EXEC_PREFIX 111#undef MD_STARTFILE_PREFIX 112 113#undef TARGET_OS_CPP_BUILTINS 114#define TARGET_OS_CPP_BUILTINS() \ 115 do \ 116 { \ 117 builtin_define ("__PPC__"); \ 118 builtin_define ("__PPC64__"); \ 119 builtin_define ("__powerpc__"); \ 120 builtin_define ("__powerpc64__"); \ 121 builtin_define ("__PIC__"); \ 122 builtin_define ("__ELF__"); \ 123 builtin_assert ("cpu=powerpc64"); \ 124 builtin_assert ("machine=powerpc64"); \ 125 } \ 126 while (0) 127 128#undef CPP_OS_DEFAULT_SPEC 129#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)" 130 131/* The GNU C++ standard library currently requires _GNU_SOURCE being 132 defined on glibc-based systems. This temporary hack accomplishes this, 133 it should go away as soon as libstdc++-v3 has a real fix. */ 134#undef CPLUSPLUS_CPP_SPEC 135#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)" 136 137#undef LINK_SHLIB_SPEC 138#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}" 139 140#define LINK_GCC_C_SEQUENCE_SPEC \ 141 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" 142 143#undef LIB_DEFAULT_SPEC 144#define LIB_DEFAULT_SPEC "%(lib_linux)" 145 146#undef STARTFILE_DEFAULT_SPEC 147#define STARTFILE_DEFAULT_SPEC "%(startfile_linux)" 148 149#undef ENDFILE_DEFAULT_SPEC 150#define ENDFILE_DEFAULT_SPEC "%(endfile_linux)" 151 152#undef LINK_START_DEFAULT_SPEC 153#define LINK_START_DEFAULT_SPEC "%(link_start_linux)" 154 155#undef LINK_OS_DEFAULT_SPEC 156#define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" 157 158#undef LINK_OS_LINUX_SPEC 159#define LINK_OS_LINUX_SPEC "-m elf64ppc %{!shared: %{!static: \ 160 %{rdynamic:-export-dynamic} \ 161 %{!dynamic-linker:-dynamic-linker /lib64/ld64.so.1}}}" 162 163#ifdef NATIVE_CROSS 164#define STARTFILE_PREFIX_SPEC "/usr/local/lib64/ /lib64/ /usr/lib64/" 165#endif 166 167#undef STARTFILE_LINUX_SPEC 168#define STARTFILE_LINUX_SPEC "\ 169%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \ 170%{static:crtbeginT.o%s} \ 171%{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}" 172 173#undef ENDFILE_LINUX_SPEC 174#define ENDFILE_LINUX_SPEC "\ 175%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" 176 177#undef TOC_SECTION_ASM_OP 178#define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\"" 179 180#undef MINIMAL_TOC_SECTION_ASM_OP 181#define MINIMAL_TOC_SECTION_ASM_OP "\t.section\t\".toc1\",\"aw\"" 182 183#undef TARGET_VERSION 184#define TARGET_VERSION fprintf (stderr, " (PowerPC64 GNU/Linux)"); 185 186/* Must be at least as big as our pointer type. */ 187#undef SIZE_TYPE 188#define SIZE_TYPE "long unsigned int" 189 190#undef PTRDIFF_TYPE 191#define PTRDIFF_TYPE "long int" 192 193#undef WCHAR_TYPE 194#define WCHAR_TYPE "int" 195#undef WCHAR_TYPE_SIZE 196#define WCHAR_TYPE_SIZE 32 197 198/* Override rs6000.h definition. */ 199#undef ASM_APP_ON 200#define ASM_APP_ON "#APP\n" 201 202/* Override rs6000.h definition. */ 203#undef ASM_APP_OFF 204#define ASM_APP_OFF "#NO_APP\n" 205 206/* PowerPC no-op instruction. */ 207#undef RS6000_CALL_GLUE 208#define RS6000_CALL_GLUE "nop" 209 210#undef RS6000_MCOUNT 211#define RS6000_MCOUNT "_mcount" 212 213#ifdef __powerpc64__ 214/* _init and _fini functions are built from bits spread across many 215 object files, each potentially with a different TOC pointer. For 216 that reason, place a nop after the call so that the linker can 217 restore the TOC pointer if a TOC adjusting call stub is needed. */ 218#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ 219 asm (SECTION_OP "\n" \ 220" bl ." #FUNC "\n" \ 221" nop\n" \ 222" .previous"); 223#endif 224 225/* FP save and restore routines. */ 226#undef SAVE_FP_PREFIX 227#define SAVE_FP_PREFIX "._savef" 228#undef SAVE_FP_SUFFIX 229#define SAVE_FP_SUFFIX "" 230#undef RESTORE_FP_PREFIX 231#define RESTORE_FP_PREFIX "._restf" 232#undef RESTORE_FP_SUFFIX 233#define RESTORE_FP_SUFFIX "" 234 235/* Dwarf2 debugging. */ 236#undef PREFERRED_DEBUGGING_TYPE 237#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG 238 239#undef TARGET_ENCODE_SECTION_INFO 240#define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info 241 242/* This is how to output a reference to a user-level label named NAME. 243 `assemble_name' uses this. */ 244 245/* Override elfos.h definition. */ 246#undef ASM_OUTPUT_LABELREF 247#define ASM_OUTPUT_LABELREF(FILE,NAME) \ 248do { \ 249 const char *_name = NAME; \ 250 if (*_name == '@') \ 251 _name++; \ 252 \ 253 if (*_name == '*') \ 254 fprintf (FILE, "%s", _name + 1); \ 255 else \ 256 asm_fprintf (FILE, "%U%s", _name); \ 257} while (0) 258 259#undef ASM_DECLARE_FUNCTION_NAME 260#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 261 do \ 262 { \ 263 fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", (FILE)); \ 264 ASM_OUTPUT_LABEL ((FILE), (NAME)); \ 265 fputs (DOUBLE_INT_ASM_OP, (FILE)); \ 266 putc ('.', (FILE)); \ 267 assemble_name ((FILE), (NAME)); \ 268 fputs (",.TOC.@tocbase,0\n\t.previous\n\t.size\t", (FILE)); \ 269 assemble_name ((FILE), (NAME)); \ 270 fputs (",24\n\t.type\t.", (FILE)); \ 271 assemble_name ((FILE), (NAME)); \ 272 fputs (",@function\n", (FILE)); \ 273 if (TREE_PUBLIC (DECL) && ! DECL_WEAK (DECL)) \ 274 { \ 275 fputs ("\t.globl\t.", (FILE)); \ 276 assemble_name ((FILE), (NAME)); \ 277 putc ('\n', (FILE)); \ 278 } \ 279 ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL)); \ 280 putc ('.', (FILE)); \ 281 ASM_OUTPUT_LABEL ((FILE), (NAME)); \ 282 } \ 283 while (0) 284 285/* This is how to declare the size of a function. */ 286#undef ASM_DECLARE_FUNCTION_SIZE 287#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ 288 do \ 289 { \ 290 if (!flag_inhibit_size_directive) \ 291 { \ 292 fputs ("\t.size\t.", (FILE)); \ 293 assemble_name ((FILE), (FNAME)); \ 294 fputs (",.-.", (FILE)); \ 295 assemble_name ((FILE), (FNAME)); \ 296 putc ('\n', (FILE)); \ 297 } \ 298 } \ 299 while (0) 300 301/* Return nonzero if this entry is to be written into the constant 302 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF 303 or a CONST containing one of them. If -mfp-in-toc (the default), 304 we also do this for floating-point constants. We actually can only 305 do this if the FP formats of the target and host machines are the 306 same, but we can't check that since not every file that uses 307 GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when 308 we can write the entry into the TOC and the entry is not larger 309 than a TOC entry. */ 310 311#undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P 312#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ 313 (TARGET_TOC \ 314 && (GET_CODE (X) == SYMBOL_REF \ 315 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ 316 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ 317 || GET_CODE (X) == LABEL_REF \ 318 || (GET_CODE (X) == CONST_INT \ 319 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ 320 || (GET_CODE (X) == CONST_DOUBLE \ 321 && (TARGET_POWERPC64 \ 322 || TARGET_MINIMAL_TOC \ 323 || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ 324 && ! TARGET_NO_FP_IN_TOC))))) 325 326/* This is the same as the dbxelf.h version, except that we need to 327 use the function code label, not the function descriptor. */ 328#undef ASM_OUTPUT_SOURCE_LINE 329#define ASM_OUTPUT_SOURCE_LINE(FILE, LINE) \ 330do \ 331 { \ 332 static int sym_lineno = 1; \ 333 char temp[256]; \ 334 ASM_GENERATE_INTERNAL_LABEL (temp, "LM", sym_lineno); \ 335 fprintf (FILE, "\t.stabn 68,0,%d,", LINE); \ 336 assemble_name (FILE, temp); \ 337 fputs ("-.", FILE); \ 338 assemble_name (FILE, \ 339 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\ 340 putc ('\n', FILE); \ 341 ASM_OUTPUT_INTERNAL_LABEL (FILE, "LM", sym_lineno); \ 342 sym_lineno += 1; \ 343 } \ 344while (0) 345 346/* Similarly, we want the function code label here. */ 347#define DBX_OUTPUT_BRAC(FILE, NAME, BRAC) \ 348 do \ 349 { \ 350 const char *flab; \ 351 fprintf (FILE, "%s%d,0,0,", ASM_STABN_OP, BRAC); \ 352 assemble_name (FILE, NAME); \ 353 putc ('-', FILE); \ 354 if (current_function_func_begin_label != NULL_TREE) \ 355 flab = IDENTIFIER_POINTER (current_function_func_begin_label); \ 356 else \ 357 { \ 358 putc ('.', FILE); \ 359 flab = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); \ 360 } \ 361 assemble_name (FILE, flab); \ 362 putc ('\n', FILE); \ 363 } \ 364 while (0) 365 366#define DBX_OUTPUT_LBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_LBRAC) 367#define DBX_OUTPUT_RBRAC(FILE, NAME) DBX_OUTPUT_BRAC (FILE, NAME, N_RBRAC) 368 369/* Another case where we want the dot name. */ 370#define DBX_OUTPUT_NFUN(FILE, LSCOPE, DECL) \ 371 do \ 372 { \ 373 fprintf (FILE, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN); \ 374 assemble_name (FILE, LSCOPE); \ 375 fputs ("-.", FILE); \ 376 assemble_name (FILE, XSTR (XEXP (DECL_RTL (DECL), 0), 0)); \ 377 putc ('\n', FILE); \ 378 } \ 379 while (0) 380 381/* Override sysv4.h as these are ABI_V4 only. */ 382#undef ASM_OUTPUT_REG_PUSH 383#undef ASM_OUTPUT_REG_POP 384 385/* Select a format to encode pointers in exception handling data. CODE 386 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is 387 true if the symbol may be affected by dynamic relocations. */ 388#undef ASM_PREFERRED_EH_DATA_FORMAT 389#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ 390 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_udata8) 391