190075Sobrien/* Definitions of target machine for GNU compiler, 290075Sobrien for some generic XCOFF file format 3169689Skan Copyright (C) 2001, 2002, 2003, 2004, 2007 Free Software Foundation, Inc. 490075Sobrien 5132718Skan This file is part of GCC. 690075Sobrien 7132718Skan GCC is free software; you can redistribute it and/or modify it 8132718Skan under the terms of the GNU General Public License as published 9132718Skan by the Free Software Foundation; either version 2, or (at your 10132718Skan option) any later version. 1190075Sobrien 12132718Skan GCC is distributed in the hope that it will be useful, but WITHOUT 13132718Skan ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14132718Skan or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15132718Skan License for more details. 1690075Sobrien 17132718Skan You should have received a copy of the GNU General Public License 18132718Skan along with GCC; see the file COPYING. If not, write to the 19169689Skan Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 20169689Skan MA 02110-1301, USA. */ 2190075Sobrien 2290075Sobrien#define TARGET_OBJECT_FORMAT OBJECT_XCOFF 2390075Sobrien 2490075Sobrien/* The RS/6000 uses the XCOFF format. */ 25117395Skan#define XCOFF_DEBUGGING_INFO 1 2690075Sobrien 2790075Sobrien/* Define if the object format being used is COFF or a superset. */ 2890075Sobrien#define OBJECT_FORMAT_COFF 2990075Sobrien 3090075Sobrien/* Define the magic numbers that we recognize as COFF. 3190075Sobrien 3290075Sobrien AIX 4.3 adds U803XTOCMAGIC (0757) for 64-bit objects and AIX V5 adds 3390075Sobrien U64_TOCMAGIC (0767), but collect2.c does not include files in the 3490075Sobrien correct order to conditionally define the symbolic name in this macro. 3590075Sobrien 3690075Sobrien The AIX linker accepts import/export files as object files, 3790075Sobrien so accept "#!" (0x2321) magic number. */ 3890075Sobrien#define MY_ISCOFF(magic) \ 3990075Sobrien ((magic) == U802WRMAGIC || (magic) == U802ROMAGIC \ 4090075Sobrien || (magic) == U802TOCMAGIC || (magic) == 0757 || (magic) == 0767 \ 4190075Sobrien || (magic) == 0x2321) 4290075Sobrien 4390075Sobrien/* We don't have GAS for the RS/6000 yet, so don't write out special 4490075Sobrien .stabs in cc1plus. */ 4590075Sobrien 4690075Sobrien#define FASCIST_ASSEMBLER 4790075Sobrien 4890075Sobrien/* We define this to prevent the name mangler from putting dollar signs into 4990075Sobrien function names. */ 5090075Sobrien 5190075Sobrien#define NO_DOLLAR_IN_LABEL 5290075Sobrien 5390075Sobrien/* We define this to 0 so that gcc will never accept a dollar sign in a 5490075Sobrien variable name. This is needed because the AIX assembler will not accept 5590075Sobrien dollar signs. */ 5690075Sobrien 5790075Sobrien#define DOLLARS_IN_IDENTIFIERS 0 5890075Sobrien 59169689Skan/* AIX .align pseudo-op accept value from 0 to 12, corresponding to 60169689Skan log base 2 of the alignment in bytes; 12 = 4096 bytes = 32768 bits. */ 6190075Sobrien 62169689Skan#define MAX_OFILE_ALIGNMENT 32768 6390075Sobrien 64117395Skan/* Return nonzero if this entry is to be written into the constant 6590075Sobrien pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF 6690075Sobrien or a CONST containing one of them. If -mfp-in-toc (the default), 6790075Sobrien we also do this for floating-point constants. We actually can only 6890075Sobrien do this if the FP formats of the target and host machines are the 6990075Sobrien same, but we can't check that since not every file that uses 7090075Sobrien GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when 7190075Sobrien we can write the entry into the TOC and the entry is not larger 7290075Sobrien than a TOC entry. */ 7390075Sobrien 7490075Sobrien#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ 7590075Sobrien (TARGET_TOC \ 7690075Sobrien && (GET_CODE (X) == SYMBOL_REF \ 7790075Sobrien || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ 7890075Sobrien && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ 7990075Sobrien || GET_CODE (X) == LABEL_REF \ 8090075Sobrien || (GET_CODE (X) == CONST_INT \ 8190075Sobrien && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ 8290075Sobrien || (GET_CODE (X) == CONST_DOUBLE \ 8390075Sobrien && (TARGET_POWERPC64 \ 8490075Sobrien || TARGET_MINIMAL_TOC \ 85169689Skan || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ 8690075Sobrien && ! TARGET_NO_FP_IN_TOC))))) 8790075Sobrien 88169689Skan#define TARGET_ASM_OUTPUT_ANCHOR rs6000_xcoff_asm_output_anchor 89117395Skan#define TARGET_ASM_GLOBALIZE_LABEL rs6000_xcoff_asm_globalize_label 90169689Skan#define TARGET_ASM_INIT_SECTIONS rs6000_xcoff_asm_init_sections 91169689Skan#define TARGET_ASM_RELOC_RW_MASK rs6000_xcoff_reloc_rw_mask 92117395Skan#define TARGET_ASM_NAMED_SECTION rs6000_xcoff_asm_named_section 93117395Skan#define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section 94117395Skan#define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section 95117395Skan#define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section 96169689Skan#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section 97117395Skan#define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding 98117395Skan#define TARGET_SECTION_TYPE_FLAGS rs6000_xcoff_section_type_flags 9990075Sobrien 10090075Sobrien/* FP save and restore routines. */ 10190075Sobrien#define SAVE_FP_PREFIX "._savef" 10290075Sobrien#define SAVE_FP_SUFFIX "" 10390075Sobrien#define RESTORE_FP_PREFIX "._restf" 10490075Sobrien#define RESTORE_FP_SUFFIX "" 10590075Sobrien 10690075Sobrien/* Function name to call to do profiling. */ 107132718Skan#undef RS6000_MCOUNT 10890075Sobrien#define RS6000_MCOUNT ".__mcount" 10990075Sobrien 11090075Sobrien/* This outputs NAME to FILE up to the first null or '['. */ 11190075Sobrien 112117395Skan#define RS6000_OUTPUT_BASENAME(FILE, NAME) \ 113117395Skan assemble_name ((FILE), (*targetm.strip_name_encoding) (NAME)) 11490075Sobrien 11590075Sobrien/* This is how to output the definition of a user-level label named NAME, 11690075Sobrien such as the label on a static function or variable NAME. */ 11790075Sobrien 11890075Sobrien#define ASM_OUTPUT_LABEL(FILE,NAME) \ 11990075Sobrien do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0) 12090075Sobrien 12190075Sobrien/* This is how to output a command to make the user-level label named NAME 12290075Sobrien defined for reference from other files. */ 12390075Sobrien 124117395Skan/* Globalizing directive for a label. */ 125117395Skan#define GLOBAL_ASM_OP "\t.globl " 12690075Sobrien 127132718Skan#undef TARGET_ASM_FILE_START 128132718Skan#define TARGET_ASM_FILE_START rs6000_xcoff_file_start 129132718Skan#define TARGET_ASM_FILE_END rs6000_xcoff_file_end 130132718Skan#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE 131132718Skan#define TARGET_ASM_FILE_START_FILE_DIRECTIVE false 13290075Sobrien 13390075Sobrien/* This macro produces the initial definition of a function name. 13490075Sobrien On the RS/6000, we need to place an extra '.' in the function name and 13590075Sobrien output the function descriptor. 13690075Sobrien 137169689Skan The csect for the function will have already been created when 138169689Skan text_section was selected. We do have to go back to that csect, however. 13990075Sobrien 14090075Sobrien The third and fourth parameters to the .function pseudo-op (16 and 044) 14190075Sobrien are placeholders which no longer have any use. */ 14290075Sobrien 14390075Sobrien#define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \ 144132718Skan{ if (TREE_PUBLIC (DECL)) \ 14590075Sobrien { \ 14696263Sobrien if (!RS6000_WEAK || !DECL_WEAK (decl)) \ 14790075Sobrien { \ 14890075Sobrien fputs ("\t.globl .", FILE); \ 14990075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 15090075Sobrien putc ('\n', FILE); \ 15190075Sobrien } \ 15290075Sobrien } \ 15390075Sobrien else \ 15490075Sobrien { \ 15590075Sobrien fputs ("\t.lglobl .", FILE); \ 15690075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 15790075Sobrien putc ('\n', FILE); \ 15890075Sobrien } \ 15990075Sobrien fputs ("\t.csect ", FILE); \ 16090075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 16190075Sobrien fputs (TARGET_32BIT ? "[DS]\n" : "[DS],3\n", FILE); \ 16290075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 16390075Sobrien fputs (":\n", FILE); \ 16490075Sobrien fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", FILE); \ 16590075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 16690075Sobrien fputs (", TOC[tc0], 0\n", FILE); \ 167169689Skan in_section = NULL; \ 168169689Skan switch_to_section (function_section (DECL)); \ 16990075Sobrien putc ('.', FILE); \ 17090075Sobrien RS6000_OUTPUT_BASENAME (FILE, NAME); \ 17190075Sobrien fputs (":\n", FILE); \ 172132718Skan if (write_symbols != NO_DEBUG) \ 17390075Sobrien xcoffout_declare_function (FILE, DECL, NAME); \ 17490075Sobrien} 17590075Sobrien 17690075Sobrien/* Output a reference to SYM on FILE. */ 17790075Sobrien 17890075Sobrien#define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \ 17990075Sobrien rs6000_output_symbol_ref (FILE, SYM) 18090075Sobrien 18190075Sobrien/* This says how to output an external. */ 18290075Sobrien 183132718Skan#undef ASM_OUTPUT_EXTERNAL 184117395Skan#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ 185117395Skan{ rtx _symref = XEXP (DECL_RTL (DECL), 0); \ 186117395Skan if ((TREE_CODE (DECL) == VAR_DECL \ 187117395Skan || TREE_CODE (DECL) == FUNCTION_DECL) \ 188117395Skan && (NAME)[strlen (NAME) - 1] != ']') \ 189117395Skan { \ 190117395Skan XSTR (_symref, 0) = concat (XSTR (_symref, 0), \ 191117395Skan (TREE_CODE (DECL) == FUNCTION_DECL \ 192117395Skan ? "[DS]" : "[RW]"), \ 193117395Skan NULL); \ 194117395Skan } \ 19590075Sobrien} 19690075Sobrien 19790075Sobrien/* This is how to output an internal label prefix. rs6000.c uses this 19890075Sobrien when generating traceback tables. */ 19990075Sobrien 20090075Sobrien#define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \ 20190075Sobrien fprintf (FILE, "%s..", PREFIX) 20290075Sobrien 20390075Sobrien/* This is how to output a label for a jump table. Arguments are the same as 204132718Skan for (*targetm.asm_out.internal_label), except the insn for the jump table is 20590075Sobrien passed. */ 20690075Sobrien 20790075Sobrien#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \ 208132718Skan{ ASM_OUTPUT_ALIGN (FILE, 2); (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); } 20990075Sobrien 21090075Sobrien/* This is how to store into the string LABEL 21190075Sobrien the symbol_ref name of an internal numbered label where 21290075Sobrien PREFIX is the class of label and NUM is the number within the class. 21390075Sobrien This is suitable for output with `assemble_name'. */ 21490075Sobrien 21590075Sobrien#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ 21690075Sobrien sprintf (LABEL, "*%s..%u", (PREFIX), (unsigned) (NUM)) 21790075Sobrien 21890075Sobrien/* This is how to output an assembler line to define N characters starting 21990075Sobrien at P to FILE. */ 22090075Sobrien 22190075Sobrien#define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N)) 22290075Sobrien 22390075Sobrien/* This is how to advance the location counter by SIZE bytes. */ 22490075Sobrien 225117395Skan#define SKIP_ASM_OP "\t.space " 226117395Skan 22790075Sobrien#define ASM_OUTPUT_SKIP(FILE,SIZE) \ 228132718Skan fprintf (FILE, "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE)) 22990075Sobrien 23090075Sobrien/* This says how to output an assembler line 23190075Sobrien to define a global common symbol. */ 23290075Sobrien 233117395Skan#define COMMON_ASM_OP "\t.comm " 234117395Skan 235117395Skan#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ 236117395Skan do { fputs (COMMON_ASM_OP, (FILE)); \ 23790075Sobrien RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ 238117395Skan if ((ALIGN) > 32) \ 239132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \ 240117395Skan exact_log2 ((ALIGN) / BITS_PER_UNIT)); \ 241117395Skan else if ((SIZE) > 4) \ 242132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",3\n", (SIZE)); \ 24390075Sobrien else \ 244132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)); \ 24590075Sobrien } while (0) 24690075Sobrien 24790075Sobrien/* This says how to output an assembler line 24890075Sobrien to define a local common symbol. 24990075Sobrien Alignment cannot be specified, but we can try to maintain 25090075Sobrien alignment after preceding TOC section if it was aligned 25190075Sobrien for 64-bit mode. */ 25290075Sobrien 253117395Skan#define LOCAL_COMMON_ASM_OP "\t.lcomm " 254117395Skan 25590075Sobrien#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ 256117395Skan do { fputs (LOCAL_COMMON_ASM_OP, (FILE)); \ 25790075Sobrien RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ 258132718Skan fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%s\n", \ 259132718Skan (TARGET_32BIT ? (SIZE) : (ROUNDED)), \ 26090075Sobrien xcoff_bss_section_name); \ 26190075Sobrien } while (0) 26290075Sobrien 26390075Sobrien/* This is how we tell the assembler that two symbols have the same value. */ 26490075Sobrien#define SET_ASM_OP "\t.set " 26590075Sobrien 266102780Skan/* This is how we tell the assembler to equate two values. */ 267102780Skan#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 268102780Skan do { fprintf ((FILE), "%s", SET_ASM_OP); \ 269102780Skan RS6000_OUTPUT_BASENAME (FILE, LABEL1); \ 270102780Skan fprintf (FILE, ","); \ 271102780Skan RS6000_OUTPUT_BASENAME (FILE, LABEL2); \ 272102780Skan fprintf (FILE, "\n"); \ 273102780Skan } while (0) 274102780Skan 27590075Sobrien/* Used by rs6000_assemble_integer, among others. */ 27690075Sobrien#define DOUBLE_INT_ASM_OP "\t.llong\t" 27790075Sobrien 27890075Sobrien/* Output before instructions. */ 27990075Sobrien#define TEXT_SECTION_ASM_OP "\t.csect .text[PR]" 28090075Sobrien 28190075Sobrien/* Output before writable data. 28290075Sobrien Align entire section to BIGGEST_ALIGNMENT. */ 28390075Sobrien#define DATA_SECTION_ASM_OP "\t.csect .data[RW],3" 28490075Sobrien 28590075Sobrien/* Define to prevent DWARF2 unwind info in the data section rather 28690075Sobrien than in the .eh_frame section. We do this because the AIX linker 28790075Sobrien would otherwise garbage collect these sections. */ 28890075Sobrien#define EH_FRAME_IN_DATA_SECTION 1 289