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