* alias.c, c-common.h, c-incpath.c, c-incpath.h, expr.c,
[official-gcc.git] / gcc / config / pa / som.h
blob985a253ab007e227b02d0fc5827c630b1afb70c9
1 /* Definitions for SOM assembler support.
2 Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
3 Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
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
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* So we can conditionalize small amounts of code in pa.c or pa.md. */
23 #undef TARGET_SOM
24 #define TARGET_SOM 1
26 /* We do not use BINCL stabs in SOM.
27 ??? If it does not hurt, we probably should to avoid useless divergence
28 from other embedded stabs implementations. */
29 #undef DBX_USE_BINCL
31 #define DBX_LINES_FUNCTION_RELATIVE 1
33 /* gdb needs a null N_SO at the end of each file for scattered loading. */
35 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
37 /* Select a format to encode pointers in exception handling data. CODE
38 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
39 true if the symbol may be affected by dynamic relocations. Because
40 the HP assembler does auto alignment, it is necessary to use
41 DW_EH_PE_aligned instead of the default DW_EH_PE_absptr. */
43 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
44 (TARGET_GAS ? DW_EH_PE_absptr : DW_EH_PE_aligned)
46 /* HPUX has a program 'chatr' to list the dependencies of dynamically
47 linked executables and shared libraries. */
48 #define LDD_SUFFIX "chatr"
49 /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl"
50 or "static /usr/lib/X11R5/libX11.sl".
52 HPUX 10.20 also has lines like "static branch prediction ..."
53 so we filter that out explicitly.
55 We also try to bound our search for libraries with marker
56 lines. What a pain. */
57 #define PARSE_LDD_OUTPUT(PTR) \
58 do { \
59 static int in_shlib_list = 0; \
60 while (*PTR == ' ') PTR++; \
61 if (strncmp (PTR, "shared library list:", \
62 sizeof ("shared library list:") - 1) == 0) \
63 { \
64 PTR = 0; \
65 in_shlib_list = 1; \
66 } \
67 else if (strncmp (PTR, "shared library binding:", \
68 sizeof ("shared library binding:") - 1) == 0)\
69 { \
70 PTR = 0; \
71 in_shlib_list = 0; \
72 } \
73 else if (strncmp (PTR, "static branch prediction disabled", \
74 sizeof ("static branch prediction disabled") - 1) == 0)\
75 { \
76 PTR = 0; \
77 in_shlib_list = 0; \
78 } \
79 else if (in_shlib_list \
80 && strncmp (PTR, "dynamic", sizeof ("dynamic") - 1) == 0) \
81 { \
82 PTR += sizeof ("dynamic") - 1; \
83 while (*p == ' ') PTR++; \
84 } \
85 else if (in_shlib_list \
86 && strncmp (PTR, "static", sizeof ("static") - 1) == 0) \
87 { \
88 PTR += sizeof ("static") - 1; \
89 while (*p == ' ') PTR++; \
90 } \
91 else \
92 PTR = 0; \
93 } while (0)
95 /* Output the label for a function definition. */
96 #ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
97 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
98 do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \
99 fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
100 #define DFMODE_RETURN_STRING ",RTNVAL=FU"
101 #define SFMODE_RETURN_STRING ",RTNVAL=FR"
102 #else
103 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
104 do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \
105 fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
106 #define DFMODE_RETURN_STRING ",RTNVAL=FR"
107 #define SFMODE_RETURN_STRING ",RTNVAL=FU"
108 #endif
111 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
112 do { tree fntype = TREE_TYPE (TREE_TYPE (DECL)); \
113 tree tree_type = TREE_TYPE (DECL); \
114 tree parm; \
115 int i; \
116 if (TREE_PUBLIC (DECL) || TARGET_GAS) \
118 if (TREE_PUBLIC (DECL)) \
120 fputs ("\t.EXPORT ", FILE); \
121 assemble_name (FILE, NAME); \
122 fputs (",ENTRY,PRIV_LEV=3", FILE); \
124 else \
126 fputs ("\t.PARAM ", FILE); \
127 assemble_name (FILE, NAME); \
128 fputs (",PRIV_LEV=3", FILE); \
130 for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \
131 parm = TREE_CHAIN (parm)) \
133 if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode \
134 && ! TARGET_SOFT_FLOAT) \
135 fprintf (FILE, ",ARGW%d=FR", i++); \
136 else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode \
137 && ! TARGET_SOFT_FLOAT) \
139 if (i <= 2) \
141 if (i == 1) i++; \
142 ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \
144 else \
145 break; \
147 else \
149 int arg_size = \
150 FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\
151 DECL_ARG_TYPE (parm)); \
152 /* Passing structs by invisible reference uses \
153 one general register. */ \
154 if (arg_size > 2 \
155 || TREE_ADDRESSABLE (DECL_ARG_TYPE (parm))) \
156 arg_size = 1; \
157 if (arg_size == 2 && i <= 2) \
159 if (i == 1) i++; \
160 fprintf (FILE, ",ARGW%d=GR", i++); \
161 fprintf (FILE, ",ARGW%d=GR", i++); \
163 else if (arg_size == 1) \
164 fprintf (FILE, ",ARGW%d=GR", i++); \
165 else \
166 i += arg_size; \
169 /* anonymous args */ \
170 if (TYPE_ARG_TYPES (tree_type) != 0 \
171 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
172 != void_type_node)) \
174 for (; i < 4; i++) \
175 fprintf (FILE, ",ARGW%d=GR", i); \
177 if (TYPE_MODE (fntype) == DFmode && ! TARGET_SOFT_FLOAT) \
178 fputs (DFMODE_RETURN_STRING, FILE); \
179 else if (TYPE_MODE (fntype) == SFmode && ! TARGET_SOFT_FLOAT) \
180 fputs (SFMODE_RETURN_STRING, FILE); \
181 else if (fntype != void_type_node) \
182 fputs (",RTNVAL=GR", FILE); \
183 fputs ("\n", FILE); \
184 }} while (0)
186 #define TARGET_ASM_FILE_START pa_som_file_start
188 /* String to output before text. */
189 #define TEXT_SECTION_ASM_OP som_text_section_asm_op ()
191 /* String to output before writable data. */
192 #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
194 /* String to output before uninitialized data. */
195 #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
197 /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups
198 which reference data within the $TEXT$ space (for example constant
199 strings in the $LIT$ subspace).
201 The assemblers (GAS and HP as) both have problems with handling
202 the difference of two symbols which is the other correct way to
203 reference constant data during PIC code generation.
205 So, there's no way to reference constant data which is in the
206 $TEXT$ space during PIC generation. Instead place all constant
207 data into the $PRIVATE$ subspace (this reduces sharing, but it
208 works correctly). */
209 #define READONLY_DATA_SECTION \
210 (flag_pic ? data_section : som_readonly_data_section)
212 /* We must not have a reference to an external symbol defined in a
213 shared library in a readonly section, else the SOM linker will
214 complain.
216 So, we force exception information into the data section. */
217 #define TARGET_ASM_EXCEPTION_SECTION data_section
219 /* This is how to output a command to make the user-level label named NAME
220 defined for reference from other files.
222 We call assemble_name, which in turn sets TREE_SYMBOL_REFERENCED. This
223 macro will restore the original value of TREE_SYMBOL_REFERENCED to avoid
224 placing useless function definitions in the output file.
226 Also note that the SOM based tools need the symbol imported as a CODE
227 symbol, while the ELF based tools require the symbol to be imported as
228 an ENTRY symbol. What a crock. */
230 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
231 do { int save_referenced; \
232 save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \
233 fputs ("\t.IMPORT ", FILE); \
234 assemble_name (FILE, NAME); \
235 if (FUNCTION_NAME_P (NAME)) \
236 fputs (",CODE\n", FILE); \
237 else \
238 fputs (",DATA\n", FILE); \
239 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced; \
240 } while (0)
242 /* The bogus HP assembler requires ALL external references to be
243 "imported", even library calls. They look a bit different, so
244 here's this macro.
246 Also note not all libcall names are passed to pa_encode_section_info
247 (__main for example). To make sure all libcall names have section
248 info recorded in them, we do it here. We must also ensure that
249 we don't import a libcall that has been previously exported since
250 the HP assembler may change an ENTRY symbol to a CODE symbol. */
252 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
253 do { const char *name; \
254 tree id; \
256 if (!function_label_operand (RTL, VOIDmode)) \
257 hppa_encode_label (RTL); \
259 name = (*targetm.strip_name_encoding) (XSTR ((RTL), 0)); \
260 id = maybe_get_identifier (name); \
261 if (! id || ! TREE_SYMBOL_REFERENCED (id)) \
263 fputs ("\t.IMPORT ", FILE); \
264 assemble_name (FILE, XSTR ((RTL), 0)); \
265 fputs (",CODE\n", FILE); \
267 } while (0)
269 /* We want __gcc_plt_call to appear in every program built by
270 gcc, so we make a reference to it out of __main.
271 We use the asm statement to fool the optimizer into not
272 removing the dead (but important) initialization of
273 REFERENCE. */
275 #define DO_GLOBAL_DTORS_BODY \
276 do { \
277 extern void __gcc_plt_call (void); \
278 void (*reference)(void) = &__gcc_plt_call; \
279 func_ptr *p; \
280 __asm__ ("" : : "r" (reference)); \
281 for (p = __DTOR_LIST__ + 1; *p; ) \
282 (*p++) (); \
283 } while (0)
285 /* This macro specifies the biggest alignment supported by the object
286 file format of this machine.
288 The .align directive in the HP assembler allows alignments up to 4096
289 bytes. However, the maximum alignment of a global common symbol is 8
290 bytes for objects smaller than the page size (4096 bytes). For larger
291 objects, the linker provides an alignment of 32 bytes. Unfortunately,
292 this macro doesn't provide a mechanism to test for common symbols. */
293 #define MAX_OFILE_ALIGNMENT 32768
295 /* The SOM linker hardcodes paths into binaries. As a result, dotdots
296 must be removed from library prefixes to prevent binaries from depending
297 on the location of the GCC tool directory. The downside is GCC
298 cannot be moved after installation using a symlink. */
299 #define ALWAYS_STRIP_DOTDOT 1
301 /* Aggregates with a single float or double field should be passed and
302 returned in the general registers. */
303 #define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) (MODE==SFmode || MODE==DFmode)
305 /* If GAS supports weak, we can support weak when we have working linker
306 support for secondary definitions and are generating code for GAS. */
307 #ifdef HAVE_GAS_WEAK
308 #define SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
309 #else
310 #define SUPPORTS_WEAK 0
311 #endif
313 /* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
314 directive. This provides one-only linkage semantics even though we
315 don't have weak support. */
316 #ifdef HAVE_GAS_NSUBSPA_COMDAT
317 #define SUPPORTS_SOM_COMDAT (TARGET_GAS)
318 #else
319 #define SUPPORTS_SOM_COMDAT 0
320 #endif
322 /* We can support one only if we support weak or comdat. */
323 #define SUPPORTS_ONE_ONLY (SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
325 /* We use DECL_COMMON for uninitialized one-only variables as we don't
326 have linkonce .bss. We use SOM secondary definitions or comdat for
327 initialized variables and functions. */
328 #define MAKE_DECL_ONE_ONLY(DECL) \
329 do { \
330 if (TREE_CODE (DECL) == VAR_DECL \
331 && (DECL_INITIAL (DECL) == 0 \
332 || DECL_INITIAL (DECL) == error_mark_node)) \
333 DECL_COMMON (DECL) = 1; \
334 else if (SUPPORTS_WEAK) \
335 DECL_WEAK (DECL) = 1; \
336 } while (0)
338 /* This is how we tell the assembler that a symbol is weak. The SOM
339 weak implementation uses the secondary definition (sdef) flag.
341 The behavior of sdef symbols is similar to ELF weak symbols in that
342 multiple definitions can occur without incurring a link error.
343 However, they differ in the following ways:
344 1) Undefined sdef symbols are not allowed.
345 2) The linker searches for undefined sdef symbols and will load an
346 archive library member to resolve an undefined sdef symbol.
347 3) The exported symbol from a shared library is a primary symbol
348 rather than a sdef symbol. Thus, more care is needed in the
349 ordering of libraries.
351 It appears that the linker discards extra copies of "weak" functions
352 when linking shared libraries, independent of whether or not they
353 are in their own section. In linking final executables, -Wl,-O can
354 be used to remove dead procedures. Thus, support for named sections
355 is not needed and in previous testing caused problems with various
356 HP tools. */
357 #define ASM_WEAKEN_LABEL(FILE,NAME) \
358 do { fputs ("\t.weak\t", FILE); \
359 assemble_name (FILE, NAME); \
360 fputc ('\n', FILE); \
361 if (! FUNCTION_NAME_P (NAME)) \
363 fputs ("\t.EXPORT ", FILE); \
364 assemble_name (FILE, NAME); \
365 fputs (",DATA\n", FILE); \
367 } while (0)
369 /* We can't handle weak aliases, and therefore can't support pragma weak.
370 Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h. */
371 #define GTHREAD_USE_WEAK 0