]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/rs6000/xcoff.h
alpha.c (alpha_start_function): Use switch_to_section.
[thirdparty/gcc.git] / gcc / config / rs6000 / xcoff.h
CommitLineData
2bfcf297
DB
1/* Definitions of target machine for GNU compiler,
2 for some generic XCOFF file format
283334f0 3 Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2bfcf297 4
5de601cf 5 This file is part of GCC.
2bfcf297 6
5de601cf
NC
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 2, or (at your
10 option) any later version.
2bfcf297 11
5de601cf
NC
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.
2bfcf297 16
5de601cf
NC
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the
39d14dda
KC
19 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
20 MA 02110-1301, USA. */
2bfcf297
DB
21
22#define TARGET_OBJECT_FORMAT OBJECT_XCOFF
23
2bfcf297 24/* The RS/6000 uses the XCOFF format. */
23532de9 25#define XCOFF_DEBUGGING_INFO 1
2bfcf297
DB
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.c 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
a0ab749a 59/* Return nonzero if this entry is to be written into the constant
2bfcf297
DB
60 pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF
61 or a CONST containing one of them. If -mfp-in-toc (the default),
62 we also do this for floating-point constants. We actually can only
63 do this if the FP formats of the target and host machines are the
64 same, but we can't check that since not every file that uses
65 GO_IF_LEGITIMATE_ADDRESS_P includes real.h. We also do this when
66 we can write the entry into the TOC and the entry is not larger
67 than a TOC entry. */
68
69#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
70 (TARGET_TOC \
71 && (GET_CODE (X) == SYMBOL_REF \
72 || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
73 && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
74 || GET_CODE (X) == LABEL_REF \
75 || (GET_CODE (X) == CONST_INT \
76 && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
77 || (GET_CODE (X) == CONST_DOUBLE \
78 && (TARGET_POWERPC64 \
79 || TARGET_MINIMAL_TOC \
ebb109ad 80 || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
2bfcf297
DB
81 && ! TARGET_NO_FP_IN_TOC)))))
82
5add3202 83#define TARGET_ASM_GLOBALIZE_LABEL rs6000_xcoff_asm_globalize_label
d6b5193b 84#define TARGET_ASM_INIT_SECTIONS rs6000_xcoff_asm_init_sections
5add3202
DE
85#define TARGET_ASM_NAMED_SECTION rs6000_xcoff_asm_named_section
86#define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section
b64a1b53 87#define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section
5add3202 88#define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section
ab5c8549 89#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
5b5198f7 90#define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding
5add3202 91#define TARGET_SECTION_TYPE_FLAGS rs6000_xcoff_section_type_flags
2bfcf297
DB
92
93/* FP save and restore routines. */
94#define SAVE_FP_PREFIX "._savef"
95#define SAVE_FP_SUFFIX ""
96#define RESTORE_FP_PREFIX "._restf"
97#define RESTORE_FP_SUFFIX ""
98
99/* Function name to call to do profiling. */
5de601cf 100#undef RS6000_MCOUNT
2bfcf297
DB
101#define RS6000_MCOUNT ".__mcount"
102
54ee9799
DE
103/* This outputs NAME to FILE up to the first null or '['. */
104
772c5265
RH
105#define RS6000_OUTPUT_BASENAME(FILE, NAME) \
106 assemble_name ((FILE), (*targetm.strip_name_encoding) (NAME))
54ee9799 107
2bfcf297
DB
108/* This is how to output the definition of a user-level label named NAME,
109 such as the label on a static function or variable NAME. */
110
111#define ASM_OUTPUT_LABEL(FILE,NAME) \
54ee9799 112 do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
2bfcf297
DB
113
114/* This is how to output a command to make the user-level label named NAME
115 defined for reference from other files. */
116
5eb99654
KG
117/* Globalizing directive for a label. */
118#define GLOBAL_ASM_OP "\t.globl "
2bfcf297 119
1bc7c5b6
ZW
120#undef TARGET_ASM_FILE_START
121#define TARGET_ASM_FILE_START rs6000_xcoff_file_start
a5fe455b 122#define TARGET_ASM_FILE_END rs6000_xcoff_file_end
1bc7c5b6
ZW
123#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
124#define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
2bfcf297
DB
125
126/* This macro produces the initial definition of a function name.
127 On the RS/6000, we need to place an extra '.' in the function name and
128 output the function descriptor.
129
d6b5193b
RS
130 The csect for the function will have already been created when
131 text_section was selected. We do have to go back to that csect, however.
2bfcf297 132
2bfcf297
DB
133 The third and fourth parameters to the .function pseudo-op (16 and 044)
134 are placeholders which no longer have any use. */
135
136#define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \
ad929cd5 137{ if (TREE_PUBLIC (DECL)) \
2bfcf297 138 { \
79c4e63f 139 if (!RS6000_WEAK || !DECL_WEAK (decl)) \
b92b324d
DE
140 { \
141 fputs ("\t.globl .", FILE); \
142 RS6000_OUTPUT_BASENAME (FILE, NAME); \
143 putc ('\n', FILE); \
144 } \
2bfcf297
DB
145 } \
146 else \
147 { \
148 fputs ("\t.lglobl .", FILE); \
54ee9799 149 RS6000_OUTPUT_BASENAME (FILE, NAME); \
2bfcf297
DB
150 putc ('\n', FILE); \
151 } \
152 fputs ("\t.csect ", FILE); \
54ee9799 153 RS6000_OUTPUT_BASENAME (FILE, NAME); \
2bfcf297 154 fputs (TARGET_32BIT ? "[DS]\n" : "[DS],3\n", FILE); \
54ee9799 155 RS6000_OUTPUT_BASENAME (FILE, NAME); \
2bfcf297
DB
156 fputs (":\n", FILE); \
157 fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", FILE); \
54ee9799 158 RS6000_OUTPUT_BASENAME (FILE, NAME); \
2bfcf297 159 fputs (", TOC[tc0], 0\n", FILE); \
d6b5193b
RS
160 in_section = NULL; \
161 switch_to_section (function_section (DECL)); \
2bfcf297 162 putc ('.', FILE); \
54ee9799 163 RS6000_OUTPUT_BASENAME (FILE, NAME); \
2bfcf297 164 fputs (":\n", FILE); \
5b71a4e7 165 if (write_symbols != NO_DEBUG) \
2bfcf297
DB
166 xcoffout_declare_function (FILE, DECL, NAME); \
167}
168
169/* Output a reference to SYM on FILE. */
170
171#define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \
172 rs6000_output_symbol_ref (FILE, SYM)
173
174/* This says how to output an external. */
175
5de601cf 176#undef ASM_OUTPUT_EXTERNAL
6d9f628e
GK
177#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
178{ rtx _symref = XEXP (DECL_RTL (DECL), 0); \
179 if ((TREE_CODE (DECL) == VAR_DECL \
180 || TREE_CODE (DECL) == FUNCTION_DECL) \
181 && (NAME)[strlen (NAME) - 1] != ']') \
182 { \
183 XSTR (_symref, 0) = concat (XSTR (_symref, 0), \
184 (TREE_CODE (DECL) == FUNCTION_DECL \
185 ? "[DS]" : "[RW]"), \
186 NULL); \
187 } \
2bfcf297
DB
188}
189
2bfcf297
DB
190/* This is how to output an internal label prefix. rs6000.c uses this
191 when generating traceback tables. */
192
193#define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \
194 fprintf (FILE, "%s..", PREFIX)
195
196/* This is how to output a label for a jump table. Arguments are the same as
4977bab6 197 for (*targetm.asm_out.internal_label), except the insn for the jump table is
82e41834 198 passed. */
2bfcf297
DB
199
200#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \
4977bab6 201{ ASM_OUTPUT_ALIGN (FILE, 2); (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); }
2bfcf297
DB
202
203/* This is how to store into the string LABEL
204 the symbol_ref name of an internal numbered label where
205 PREFIX is the class of label and NUM is the number within the class.
206 This is suitable for output with `assemble_name'. */
207
208#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
671f5733 209 sprintf (LABEL, "*%s..%u", (PREFIX), (unsigned) (NUM))
2bfcf297
DB
210
211/* This is how to output an assembler line to define N characters starting
212 at P to FILE. */
213
214#define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N))
215
216/* This is how to advance the location counter by SIZE bytes. */
217
e34eaae5
DE
218#define SKIP_ASM_OP "\t.space "
219
2bfcf297 220#define ASM_OUTPUT_SKIP(FILE,SIZE) \
f08b4d88 221 fprintf (FILE, "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n", SKIP_ASM_OP, (SIZE))
2bfcf297
DB
222
223/* This says how to output an assembler line
224 to define a global common symbol. */
225
e34eaae5
DE
226#define COMMON_ASM_OP "\t.comm "
227
228#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
229 do { fputs (COMMON_ASM_OP, (FILE)); \
54ee9799 230 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
e34eaae5 231 if ((ALIGN) > 32) \
f08b4d88 232 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \
e34eaae5
DE
233 exact_log2 ((ALIGN) / BITS_PER_UNIT)); \
234 else if ((SIZE) > 4) \
f08b4d88 235 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",3\n", (SIZE)); \
2bfcf297 236 else \
f08b4d88 237 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)); \
2bfcf297
DB
238 } while (0)
239
2bfcf297
DB
240/* This says how to output an assembler line
241 to define a local common symbol.
242 Alignment cannot be specified, but we can try to maintain
243 alignment after preceding TOC section if it was aligned
244 for 64-bit mode. */
245
e34eaae5
DE
246#define LOCAL_COMMON_ASM_OP "\t.lcomm "
247
2bfcf297 248#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
e34eaae5 249 do { fputs (LOCAL_COMMON_ASM_OP, (FILE)); \
54ee9799 250 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
f08b4d88
DE
251 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%s\n", \
252 (TARGET_32BIT ? (SIZE) : (ROUNDED)), \
2bfcf297
DB
253 xcoff_bss_section_name); \
254 } while (0)
255
256/* This is how we tell the assembler that two symbols have the same value. */
ebd97b96 257#define SET_ASM_OP "\t.set "
2bfcf297 258
cbaaba19
DE
259/* This is how we tell the assembler to equate two values. */
260#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
261 do { fprintf ((FILE), "%s", SET_ASM_OP); \
262 RS6000_OUTPUT_BASENAME (FILE, LABEL1); \
263 fprintf (FILE, ","); \
264 RS6000_OUTPUT_BASENAME (FILE, LABEL2); \
265 fprintf (FILE, "\n"); \
266 } while (0)
267
301d03af
RS
268/* Used by rs6000_assemble_integer, among others. */
269#define DOUBLE_INT_ASM_OP "\t.llong\t"
2bfcf297
DB
270
271/* Output before instructions. */
272#define TEXT_SECTION_ASM_OP "\t.csect .text[PR]"
273
274/* Output before writable data.
275 Align entire section to BIGGEST_ALIGNMENT. */
276#define DATA_SECTION_ASM_OP "\t.csect .data[RW],3"
277
02c9b1ca
RH
278/* Define to prevent DWARF2 unwind info in the data section rather
279 than in the .eh_frame section. We do this because the AIX linker
280 would otherwise garbage collect these sections. */
281#define EH_FRAME_IN_DATA_SECTION 1