]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/xcoff.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / rs6000 / xcoff.h
1 /* Definitions of target machine for GNU compiler,
2 for some generic XCOFF file format
3 Copyright (C) 2001-2016 Free Software Foundation, Inc.
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 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 #define TARGET_OBJECT_FORMAT OBJECT_XCOFF
22
23 /* The RS/6000 uses the XCOFF format. */
24 #define XCOFF_DEBUGGING_INFO 1
25
26 /* Define if the object format being used is COFF or a superset. */
27 #define OBJECT_FORMAT_COFF
28
29 /* Define the magic numbers that we recognize as COFF.
30
31 AIX 4.3 adds U803XTOCMAGIC (0757) for 64-bit objects and AIX V5 adds
32 U64_TOCMAGIC (0767), but collect2.c does not include files in the
33 correct order to conditionally define the symbolic name in this macro.
34
35 The AIX linker accepts import/export files as object files,
36 so accept "#!" (0x2321) magic number. */
37 #define MY_ISCOFF(magic) \
38 ((magic) == U802WRMAGIC || (magic) == U802ROMAGIC \
39 || (magic) == U802TOCMAGIC || (magic) == 0757 || (magic) == 0767 \
40 || (magic) == 0x2321)
41
42 /* We don't have GAS for the RS/6000 yet, so don't write out special
43 .stabs in cc1plus. */
44
45 #define FASCIST_ASSEMBLER
46
47 /* We define this to prevent the name mangler from putting dollar signs into
48 function names. */
49
50 #define NO_DOLLAR_IN_LABEL
51
52 /* We define this to 0 so that gcc will never accept a dollar sign in a
53 variable name. This is needed because the AIX assembler will not accept
54 dollar signs. */
55
56 #define DOLLARS_IN_IDENTIFIERS 0
57
58 /* AIX .align pseudo-op accept value from 0 to 12, corresponding to
59 log base 2 of the alignment in bytes; 12 = 4096 bytes = 32768 bits. */
60
61 #define MAX_OFILE_ALIGNMENT 32768
62
63 /* Default alignment factor for csect directives, chosen to honor
64 BIGGEST_ALIGNMENT. */
65 #define XCOFF_CSECT_DEFAULT_ALIGNMENT_STR "4"
66
67 /* Return nonzero if this entry is to be written into the constant
68 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
69 or a CONST containing one of them. If -mfp-in-toc (the default),
70 we also do this for floating-point constants. We actually can only
71 do this if the FP formats of the target and host machines are the
72 same, but we can't check that since not every file that uses these
73 target macros includes real.h. We also do this when we can write the
74 entry into the TOC and the entry is not larger than a TOC entry. */
75
76 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
77 (TARGET_TOC \
78 && (GET_CODE (X) == SYMBOL_REF \
79 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
80 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
81 || GET_CODE (X) == LABEL_REF \
82 || (GET_CODE (X) == CONST_INT \
83 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
84 || (GET_CODE (X) == CONST_DOUBLE \
85 && (TARGET_MINIMAL_TOC \
86 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
87 && ! TARGET_NO_FP_IN_TOC)))))
88
89 #undef TARGET_DEBUG_UNWIND_INFO
90 #define TARGET_DEBUG_UNWIND_INFO rs6000_xcoff_debug_unwind_info
91 #define TARGET_ASM_OUTPUT_ANCHOR rs6000_xcoff_asm_output_anchor
92 #define TARGET_ASM_GLOBALIZE_LABEL rs6000_xcoff_asm_globalize_label
93 #define TARGET_ASM_INIT_SECTIONS rs6000_xcoff_asm_init_sections
94 #define TARGET_ASM_RELOC_RW_MASK rs6000_xcoff_reloc_rw_mask
95 #define TARGET_ASM_NAMED_SECTION rs6000_xcoff_asm_named_section
96 #define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section
97 #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section
98 #define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section
99 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
100 #define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding
101 #define TARGET_SECTION_TYPE_FLAGS rs6000_xcoff_section_type_flags
102 #ifdef HAVE_AS_TLS
103 #define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info
104 #endif
105
106 /* FP save and restore routines. */
107 #define SAVE_FP_PREFIX "._savef"
108 #define SAVE_FP_SUFFIX ""
109 #define RESTORE_FP_PREFIX "._restf"
110 #define RESTORE_FP_SUFFIX ""
111
112 /* Function name to call to do profiling. */
113 #undef RS6000_MCOUNT
114 #define RS6000_MCOUNT ".__mcount"
115
116 /* This outputs NAME to FILE up to the first null or '['. */
117
118 #define RS6000_OUTPUT_BASENAME(FILE, NAME) \
119 assemble_name ((FILE), (*targetm.strip_name_encoding) (NAME))
120
121 /* This is how to output the definition of a user-level label named NAME,
122 such as the label on a static function or variable NAME. */
123
124 #define ASM_OUTPUT_LABEL(FILE,NAME) \
125 do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
126
127 /* This is how to output a command to make the user-level label named NAME
128 defined for reference from other files. */
129
130 /* Globalizing directive for a label. */
131 #define GLOBAL_ASM_OP "\t.globl "
132
133 #undef TARGET_ASM_FILE_START
134 #define TARGET_ASM_FILE_START rs6000_xcoff_file_start
135 #define TARGET_ASM_FILE_END rs6000_xcoff_file_end
136 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
137 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
138
139 /* This macro produces the initial definition of a function name. */
140
141 #undef ASM_DECLARE_FUNCTION_NAME
142 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
143 rs6000_xcoff_declare_function_name ((FILE), (NAME), (DECL))
144 #undef ASM_DECLARE_OBJECT_NAME
145 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
146 rs6000_xcoff_declare_object_name ((FILE), (NAME), (DECL))
147
148 /* Output a reference to SYM on FILE. */
149
150 #define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \
151 rs6000_output_symbol_ref (FILE, SYM)
152
153 /* This says how to output an external.
154 Dollar signs are converted to underscores. */
155
156 #undef ASM_OUTPUT_EXTERNAL
157 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
158 { char *buffer = (char *) alloca (strlen (NAME) + 1); \
159 char *p; \
160 int dollar_inside = 0; \
161 strcpy (buffer, NAME); \
162 p = strchr (buffer, '$'); \
163 while (p) { \
164 *p = '_'; \
165 dollar_inside++; \
166 p = strchr (p + 1, '$'); \
167 } \
168 if (dollar_inside) { \
169 fputs ("\t.extern .", FILE); \
170 RS6000_OUTPUT_BASENAME (FILE, buffer); \
171 putc ('\n', FILE); \
172 fprintf(FILE, "\t.rename .%s,\".%s\"\n", buffer, NAME); \
173 } \
174 }
175
176 /* This is how to output a reference to a user-level label named NAME.
177 `assemble_name' uses this. */
178
179 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
180 asm_fprintf ((FILE), "%U%s", rs6000_xcoff_strip_dollar (NAME));
181
182 /* This is how to output an internal label prefix. rs6000.c uses this
183 when generating traceback tables. */
184
185 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \
186 fprintf (FILE, "%s..", PREFIX)
187
188 /* This is how to output a label for a jump table. Arguments are the same as
189 for (*targetm.asm_out.internal_label), except the insn for the jump table is
190 passed. */
191
192 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \
193 { ASM_OUTPUT_ALIGN (FILE, 2); (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); }
194
195 /* This is how to store into the string LABEL
196 the symbol_ref name of an internal numbered label where
197 PREFIX is the class of label and NUM is the number within the class.
198 This is suitable for output with `assemble_name'. */
199
200 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
201 sprintf (LABEL, "*%s..%u", rs6000_xcoff_strip_dollar (PREFIX), (unsigned) (NUM))
202
203 /* This is how to output an assembler line to define N characters starting
204 at P to FILE. */
205
206 #define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N))
207
208 /* This is how to advance the location counter by SIZE bytes. */
209
210 #define SKIP_ASM_OP "\t.space "
211
212 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
213 fprintf (FILE, "%s" HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE))
214
215 /* This says how to output an assembler line
216 to define a global common symbol. */
217
218 #define COMMON_ASM_OP "\t.comm "
219
220 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
221 do { fputs (COMMON_ASM_OP, (FILE)); \
222 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
223 if ((ALIGN) > 32) \
224 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \
225 floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
226 else if ((SIZE) > 4) \
227 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",3\n", (SIZE)); \
228 else \
229 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)); \
230 } while (0)
231
232 /* This says how to output an assembler line
233 to define a local common symbol.
234 The assembler in AIX 6.1 and later supports an alignment argument.
235 For earlier releases of AIX, we try to maintain
236 alignment after preceding TOC section if it was aligned
237 for 64-bit mode. */
238
239 #define LOCAL_COMMON_ASM_OP "\t.lcomm "
240
241 #if TARGET_AIX_VERSION >= 61
242 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
243 do { fputs (LOCAL_COMMON_ASM_OP, (FILE)); \
244 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
245 if ((ALIGN) > 32) \
246 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s%u_,%u\n", \
247 (SIZE), xcoff_bss_section_name, \
248 floor_log2 ((ALIGN) / BITS_PER_UNIT), \
249 floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
250 else if ((SIZE) > 4) \
251 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s3_,3\n", \
252 (SIZE), xcoff_bss_section_name); \
253 else \
254 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s,2\n", \
255 (SIZE), xcoff_bss_section_name); \
256 } while (0)
257 #endif
258
259 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
260 do { fputs (LOCAL_COMMON_ASM_OP, (FILE)); \
261 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
262 fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%s\n", \
263 (TARGET_32BIT ? (SIZE) : (ROUNDED)), \
264 xcoff_bss_section_name); \
265 } while (0)
266
267 #ifdef HAVE_AS_TLS
268 #define ASM_OUTPUT_TLS_COMMON(FILE, DECL, NAME, SIZE) \
269 do { fputs (COMMON_ASM_OP, (FILE)); \
270 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
271 fprintf ((FILE), "[UL]," HOST_WIDE_INT_PRINT_UNSIGNED"\n", \
272 (SIZE)); \
273 } while (0)
274 #endif
275
276 /* This is how we tell the assembler that two symbols have the same value. */
277 #define SET_ASM_OP "\t.set "
278
279 /* This is how we tell the assembler to equate two values.
280 The semantic of AIX assembler's .set do not correspond to middle-end expectations.
281 We output aliases as alternative symbols in the front of the definition
282 via DECLARE_FUNCTION_NAME and DECLARE_OBJECT_NAME.
283 We still need to define this macro to let middle-end know that aliases are
284 supported.
285 */
286 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) do { } while (0)
287
288 /* Used by rs6000_assemble_integer, among others. */
289
290 /* Used by rs6000_assemble_integer, among others. */
291 #define DOUBLE_INT_ASM_OP "\t.llong\t"
292
293 /* Output before instructions. */
294 #define TEXT_SECTION_ASM_OP "\t.csect .text[PR]"
295
296 /* Output before writable data. */
297 #define DATA_SECTION_ASM_OP \
298 "\t.csect .data[RW]," XCOFF_CSECT_DEFAULT_ALIGNMENT_STR
299
300
301 /* The eh_frames are put in the read-only text segment.
302 Local code labels/function will also be in the local text segment so use
303 PC relative addressing.
304 Global symbols must be in the data segment to allow loader relocations.
305 So use DW_EH_PE_indirect to allocate a slot in the local data segment.
306 There is no constant offset to this data segment from the text segment,
307 so use addressing relative to the data segment.
308 */
309 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
310 (((GLOBAL) ? DW_EH_PE_indirect | DW_EH_PE_datarel : DW_EH_PE_pcrel) \
311 | (TARGET_64BIT ? DW_EH_PE_sdata8 : DW_EH_PE_sdata4))
312
313 #define EH_FRAME_THROUGH_COLLECT2 1
314 #define EH_TABLES_CAN_BE_READ_ONLY 1
315
316 #define ASM_OUTPUT_DWARF_PCREL(FILE,SIZE,LABEL) \
317 rs6000_asm_output_dwarf_pcrel ((FILE), (SIZE), (LABEL));
318
319 #define ASM_OUTPUT_DWARF_DATAREL(FILE,SIZE,LABEL) \
320 rs6000_asm_output_dwarf_datarel ((FILE), (SIZE), (LABEL));
321
322 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
323