* config/arm/arm.c (arm_legitimize_address): Limit the value passed
[official-gcc.git] / gcc / config / pa / som.h
blob109e2a1647645b55ebd0a6b1895e5230ceb8a7cd
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, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, 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
220 named NAME defined for reference from other files. We use
221 assemble_name_raw instead of assemble_name since a symbol in
222 a .IMPORT directive that isn't otherwise referenced is not
223 placed in the symbol table of the assembled object.
225 Failure to import a function reference can cause the HP linker
226 to segmentation fault!
228 Note that the SOM based tools need the symbol imported as a
229 CODE symbol, while the ELF based tools require the symbol to
230 be imported as an ENTRY symbol. */
232 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
233 pa_hpux_asm_output_external ((FILE), (DECL), (NAME))
234 #define ASM_OUTPUT_EXTERNAL_REAL(FILE, DECL, NAME) \
235 do { fputs ("\t.IMPORT ", FILE); \
236 assemble_name_raw (FILE, NAME); \
237 if (FUNCTION_NAME_P (NAME)) \
238 fputs (",CODE\n", FILE); \
239 else \
240 fputs (",DATA\n", FILE); \
241 } while (0)
243 /* The bogus HP assembler requires ALL external references to be
244 "imported", even library calls. They look a bit different, so
245 here's this macro.
247 Also note not all libcall names are passed to pa_encode_section_info
248 (__main for example). To make sure all libcall names have section
249 info recorded in them, we do it here.
251 We must also ensure that a libcall that has been previously
252 exported is not subsequently imported since the HP assembler may
253 change the type from an ENTRY to a CODE symbol. This would make
254 the symbol local. We are forced to use the identifier node
255 associated with the real assembler name for this check as the
256 symbol_ref available in ASM_DECLARE_FUNCTION_NAME is not the
257 same as the one used here. As a result, we can't use flags
258 in the symbol_ref for this check. The identifier check assumes
259 assemble_external_libcall is called before the symbol is used. */
261 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
262 do { const char *name; \
263 tree id; \
265 if (!function_label_operand (RTL, VOIDmode)) \
266 hppa_encode_label (RTL); \
268 name = targetm.strip_name_encoding (XSTR ((RTL), 0)); \
269 id = maybe_get_identifier (name); \
270 if (!id || !TREE_SYMBOL_REFERENCED (id)) \
272 fputs ("\t.IMPORT ", FILE); \
273 assemble_name_raw (FILE, XSTR ((RTL), 0)); \
274 fputs (",CODE\n", FILE); \
276 } while (0)
278 /* We want __gcc_plt_call to appear in every program built by
279 gcc, so we make a reference to it out of __main.
280 We use the asm statement to fool the optimizer into not
281 removing the dead (but important) initialization of
282 REFERENCE. */
284 #define DO_GLOBAL_DTORS_BODY \
285 do { \
286 extern void __gcc_plt_call (void); \
287 void (*reference)(void) = &__gcc_plt_call; \
288 func_ptr *p; \
289 __asm__ ("" : : "r" (reference)); \
290 for (p = __DTOR_LIST__ + 1; *p; ) \
291 (*p++) (); \
292 } while (0)
294 /* This macro specifies the biggest alignment supported by the object
295 file format of this machine.
297 The .align directive in the HP assembler allows alignments up to 4096
298 bytes. However, the maximum alignment of a global common symbol is 8
299 bytes for objects smaller than the page size (4096 bytes). For larger
300 objects, the linker provides an alignment of 32 bytes. Unfortunately,
301 this macro doesn't provide a mechanism to test for common symbols. */
302 #define MAX_OFILE_ALIGNMENT 32768
304 /* The SOM linker hardcodes paths into binaries. As a result, dotdots
305 must be removed from library prefixes to prevent binaries from depending
306 on the location of the GCC tool directory. The downside is GCC
307 cannot be moved after installation using a symlink. */
308 #define ALWAYS_STRIP_DOTDOT 1
310 /* If GAS supports weak, we can support weak when we have working linker
311 support for secondary definitions and are generating code for GAS. */
312 #ifdef HAVE_GAS_WEAK
313 #define SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
314 #else
315 #define SUPPORTS_WEAK 0
316 #endif
318 /* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
319 directive. This provides one-only linkage semantics even though we
320 don't have weak support. */
321 #ifdef HAVE_GAS_NSUBSPA_COMDAT
322 #define SUPPORTS_SOM_COMDAT (TARGET_GAS)
323 #else
324 #define SUPPORTS_SOM_COMDAT 0
325 #endif
327 /* We can support one only if we support weak or comdat. */
328 #define SUPPORTS_ONE_ONLY (SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
330 /* We use DECL_COMMON for uninitialized one-only variables as we don't
331 have linkonce .bss. We use SOM secondary definitions or comdat for
332 initialized variables and functions. */
333 #define MAKE_DECL_ONE_ONLY(DECL) \
334 do { \
335 if (TREE_CODE (DECL) == VAR_DECL \
336 && (DECL_INITIAL (DECL) == 0 \
337 || DECL_INITIAL (DECL) == error_mark_node)) \
338 DECL_COMMON (DECL) = 1; \
339 else if (SUPPORTS_WEAK) \
340 DECL_WEAK (DECL) = 1; \
341 } while (0)
343 /* This is how we tell the assembler that a symbol is weak. The SOM
344 weak implementation uses the secondary definition (sdef) flag.
346 The behavior of sdef symbols is similar to ELF weak symbols in that
347 multiple definitions can occur without incurring a link error.
348 However, they differ in the following ways:
349 1) Undefined sdef symbols are not allowed.
350 2) The linker searches for undefined sdef symbols and will load an
351 archive library member to resolve an undefined sdef symbol.
352 3) The exported symbol from a shared library is a primary symbol
353 rather than a sdef symbol. Thus, more care is needed in the
354 ordering of libraries.
356 It appears that the linker discards extra copies of "weak" functions
357 when linking shared libraries, independent of whether or not they
358 are in their own section. In linking final executables, -Wl,-O can
359 be used to remove dead procedures. Thus, support for named sections
360 is not needed and in previous testing caused problems with various
361 HP tools. */
362 #define ASM_WEAKEN_LABEL(FILE,NAME) \
363 do { fputs ("\t.weak\t", FILE); \
364 assemble_name (FILE, NAME); \
365 fputc ('\n', FILE); \
366 targetm.asm_out.globalize_label (FILE, NAME); \
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