i386: Fix some intrinsics without alignment requirements.
[official-gcc.git] / gcc / config / pa / som.h
blob1039a6a4af3f41fab8a469f67199712501633192
1 /* Definitions for SOM assembler support.
2 Copyright (C) 1999-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 /* So we can conditionalize small amounts of code in pa.cc or pa.md. */
21 #undef TARGET_SOM
22 #define TARGET_SOM 1
24 /* HPUX has a program 'chatr' to list the dependencies of dynamically
25 linked executables and shared libraries. */
26 #define LDD_SUFFIX "chatr"
27 /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl"
28 or "static /usr/lib/X11R5/libX11.sl".
30 HPUX 10.20 also has lines like "static branch prediction ..."
31 so we filter that out explicitly.
33 We also try to bound our search for libraries with marker
34 lines. What a pain. */
35 #define PARSE_LDD_OUTPUT(PTR) \
36 do { \
37 static int in_shlib_list = 0; \
38 while (*PTR == ' ') PTR++; \
39 if (startswith (PTR, "shared library list:")) \
40 { \
41 PTR = 0; \
42 in_shlib_list = 1; \
43 } \
44 else if (startswith (PTR, "shared library binding:")) \
45 { \
46 PTR = 0; \
47 in_shlib_list = 0; \
48 } \
49 else if (startswith (PTR, "static branch prediction disabled")) \
50 { \
51 PTR = 0; \
52 in_shlib_list = 0; \
53 } \
54 else if (in_shlib_list \
55 && startswith (PTR, "dynamic")) \
56 { \
57 PTR += sizeof ("dynamic") - 1; \
58 while (*p == ' ') PTR++; \
59 } \
60 else if (in_shlib_list \
61 && startswith (PTR, "static")) \
62 { \
63 PTR += sizeof ("static") - 1; \
64 while (*p == ' ') PTR++; \
65 } \
66 else \
67 PTR = 0; \
68 } while (0)
70 /* Output the label for a function definition. */
71 #ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
72 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
73 do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \
74 fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
75 #define DFMODE_RETURN_STRING ",RTNVAL=FU"
76 #define SFMODE_RETURN_STRING ",RTNVAL=FR"
77 #else
78 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
79 do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \
80 fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
81 #define DFMODE_RETURN_STRING ",RTNVAL=FR"
82 #define SFMODE_RETURN_STRING ",RTNVAL=FU"
83 #endif
86 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
87 do { tree tree_type = TREE_TYPE (DECL); \
88 tree fntype = TREE_TYPE (tree_type); \
89 tree parm; \
90 int i; \
91 if (TREE_PUBLIC (DECL) || TARGET_GAS) \
92 { \
93 if (TREE_PUBLIC (DECL)) \
94 { \
95 fputs ("\t.EXPORT ", FILE); \
96 assemble_name (FILE, NAME); \
97 fputs (",ENTRY,PRIV_LEV=3", FILE); \
98 } \
99 else \
101 fputs ("\t.PARAM ", FILE); \
102 assemble_name (FILE, NAME); \
103 fputs (",PRIV_LEV=3", FILE); \
105 for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \
106 parm = DECL_CHAIN (parm)) \
108 tree type = DECL_ARG_TYPE (parm); \
109 machine_mode mode = TYPE_MODE (type); \
110 if (!AGGREGATE_TYPE_P (type) \
111 && mode == SFmode && ! TARGET_SOFT_FLOAT) \
112 fprintf (FILE, ",ARGW%d=FR", i++); \
113 else if (!AGGREGATE_TYPE_P (type) \
114 && mode == DFmode && ! TARGET_SOFT_FLOAT) \
116 if (i <= 2) \
118 if (i == 1) i++; \
119 ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \
121 else \
122 break; \
124 else \
126 int arg_size = pa_function_arg_size (mode, type); \
127 /* Passing structs by invisible reference uses \
128 one general register. */ \
129 if (arg_size > 2 || TREE_ADDRESSABLE (type)) \
130 arg_size = 1; \
131 if (arg_size == 2 && i <= 2) \
133 if (i == 1) i++; \
134 fprintf (FILE, ",ARGW%d=GR", i++); \
135 fprintf (FILE, ",ARGW%d=GR", i++); \
137 else if (arg_size == 1) \
138 fprintf (FILE, ",ARGW%d=GR", i++); \
139 else \
140 i += arg_size; \
143 /* anonymous args */ \
144 if (stdarg_p (tree_type)) \
146 for (; i < 4; i++) \
147 fprintf (FILE, ",ARGW%d=GR", i); \
149 if (!AGGREGATE_TYPE_P (fntype) \
150 && TYPE_MODE (fntype) == DFmode \
151 && ! TARGET_SOFT_FLOAT) \
152 fputs (DFMODE_RETURN_STRING, FILE); \
153 else if (!AGGREGATE_TYPE_P (fntype) \
154 && TYPE_MODE (fntype) == SFmode \
155 && ! TARGET_SOFT_FLOAT) \
156 fputs (SFMODE_RETURN_STRING, FILE); \
157 else if (fntype != void_type_node) \
158 fputs (",RTNVAL=GR", FILE); \
159 fputs ("\n", FILE); \
160 }} while (0)
162 #define TARGET_ASM_FILE_START pa_som_file_start
163 #define TARGET_ASM_INIT_SECTIONS pa_som_asm_init_sections
165 /* String to output before writable data. */
166 #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
168 /* String to output before uninitialized data. */
169 #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
171 /* This is how to output a command to make the user-level label
172 named NAME defined for reference from other files. We use
173 assemble_name_raw instead of assemble_name since a symbol in
174 a .IMPORT directive that isn't otherwise referenced is not
175 placed in the symbol table of the assembled object.
177 Failure to import a function reference can cause the HP linker
178 to segmentation fault!
180 Note that the SOM based tools need the symbol imported as a
181 CODE symbol, while the ELF based tools require the symbol to
182 be imported as an ENTRY symbol. */
184 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
185 pa_hpux_asm_output_external ((FILE), (DECL), (NAME))
186 #define ASM_OUTPUT_EXTERNAL_REAL(FILE, DECL, NAME) \
187 do { fputs ("\t.IMPORT ", FILE); \
188 assemble_name_raw (FILE, NAME); \
189 if (FUNCTION_NAME_P (NAME)) \
190 fputs (",CODE\n", FILE); \
191 else \
192 fputs (",DATA\n", FILE); \
193 } while (0)
195 /* The bogus HP assembler requires ALL external references to be
196 "imported", even library calls. They look a bit different, so
197 here's this macro.
199 Also note not all libcall names are passed to pa_encode_section_info
200 (__main for example). To make sure all libcall names have section
201 info recorded in them, we do it here.
203 We must also ensure that a libcall that has been previously
204 exported is not subsequently imported since the HP assembler may
205 change the type from an ENTRY to a CODE symbol. This would make
206 the symbol local. We are forced to use the identifier node
207 associated with the real assembler name for this check as the
208 symbol_ref available in ASM_DECLARE_FUNCTION_NAME is not the
209 same as the one used here. As a result, we can't use flags
210 in the symbol_ref for this check. The identifier check assumes
211 assemble_external_libcall is called before the symbol is used. */
213 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
214 do { const char *name; \
215 tree id; \
217 if (!function_label_operand (RTL, VOIDmode)) \
218 pa_encode_label (RTL); \
220 name = targetm.strip_name_encoding (XSTR ((RTL), 0)); \
221 id = maybe_get_identifier (name); \
222 if (!id || !TREE_SYMBOL_REFERENCED (id)) \
224 fputs ("\t.IMPORT ", FILE); \
225 assemble_name_raw (FILE, XSTR ((RTL), 0)); \
226 fputs (",CODE\n", FILE); \
228 } while (0)
230 /* We want __gcc_plt_call to appear in every program built by
231 gcc, so we make a reference to it out of __main.
232 We use the asm statement to fool the optimizer into not
233 removing the dead (but important) initialization of
234 REFERENCE. */
236 #define DO_GLOBAL_DTORS_BODY \
237 do { \
238 extern void __gcc_plt_call (void); \
239 void (*reference)(void) = &__gcc_plt_call; \
240 func_ptr *p; \
241 __asm__ ("" : : "r" (reference)); \
242 for (p = __DTOR_LIST__ + 1; *p; ) \
243 (*p++) (); \
244 } while (0)
246 /* This macro specifies the biggest alignment supported by the object
247 file format of this machine.
249 The .align directive in the HP assembler allows alignments up to 4096
250 bytes. However, the maximum alignment of a global common symbol is 8
251 bytes for objects smaller than the page size (4096 bytes). For larger
252 objects, the linker provides an alignment of 32 bytes. Unfortunately,
253 this macro doesn't provide a mechanism to test for common symbols. */
254 #define MAX_OFILE_ALIGNMENT 32768
256 /* The SOM linker hardcodes paths into binaries. As a result, dotdots
257 must be removed from library prefixes to prevent binaries from depending
258 on the location of the GCC tool directory. The downside is GCC
259 cannot be moved after installation using a symlink. */
260 #undef TARGET_ALWAYS_STRIP_DOTDOT
261 #define TARGET_ALWAYS_STRIP_DOTDOT true
263 /* If GAS supports weak, we can support weak when we have working linker
264 support for secondary definitions and are generating code for GAS.
265 This is primarily for one-only support as SOM doesn't allow undefined
266 weak symbols or weak aliases. */
267 #ifdef HAVE_GAS_WEAK
268 #define TARGET_SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
269 #else
270 #define TARGET_SUPPORTS_WEAK 0
271 #endif
273 /* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
274 directive. This provides one-only linkage semantics even though we
275 don't have weak support. */
276 #ifdef HAVE_GAS_NSUBSPA_COMDAT
277 #define SUPPORTS_SOM_COMDAT (TARGET_GAS)
278 #else
279 #define SUPPORTS_SOM_COMDAT 0
280 #endif
282 /* We can support one only if we support weak or comdat. */
283 #define SUPPORTS_ONE_ONLY (TARGET_SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
285 /* We use DECL_COMMON for uninitialized one-only variables as we don't
286 have linkonce .bss. We use SOM secondary definitions or comdat for
287 initialized variables and functions. */
288 #define MAKE_DECL_ONE_ONLY(DECL) \
289 do { \
290 if (VAR_P (DECL) \
291 && (DECL_INITIAL (DECL) == 0 \
292 || DECL_INITIAL (DECL) == error_mark_node)) \
293 DECL_COMMON (DECL) = 1; \
294 else if (TARGET_SUPPORTS_WEAK) \
295 DECL_WEAK (DECL) = 1; \
296 } while (0)
298 /* This is how we tell the assembler that a symbol is weak. The SOM
299 weak implementation uses the secondary definition (sdef) flag.
301 The behavior of sdef symbols is similar to ELF weak symbols in that
302 multiple definitions can occur without incurring a link error.
303 However, they differ in the following ways:
304 1) Undefined sdef symbols are not allowed.
305 2) The linker searches for undefined sdef symbols and will load an
306 archive library member to resolve an undefined sdef symbol.
307 3) The exported symbol from a shared library is a primary symbol
308 rather than a sdef symbol. Thus, more care is needed in the
309 ordering of libraries.
311 It appears that the linker discards extra copies of "weak" functions
312 when linking shared libraries, independent of whether or not they
313 are in their own section. In linking final executables, -Wl,-O can
314 be used to remove dead procedures. Thus, support for named sections
315 is not needed and in previous testing caused problems with various
316 HP tools. */
317 #if defined HAVE_GAS_WEAK
318 #define ASM_WEAKEN_DECL(FILE,DECL,NAME,VALUE) \
319 do \
321 if ((VALUE) != NULL) \
322 error_at (DECL_SOURCE_LOCATION (DECL), \
323 "weak aliases are not supported"); \
324 fputs ("\t.weak\t", FILE); \
325 assemble_name (FILE, NAME); \
326 fputc ('\n', FILE); \
328 /* Import external objects. */ \
329 if (DECL_EXTERNAL (DECL)) \
331 fputs ("\t.IMPORT ", FILE); \
332 assemble_name (FILE, NAME); \
333 if (TREE_CODE (DECL) == FUNCTION_DECL) \
334 fputs (",CODE\n", FILE); \
335 else \
336 fputs (",DATA\n", FILE); \
338 /* Functions are globalized by ASM_DECLARE_FUNCTION_NAME. */ \
339 else if (TREE_CODE (DECL) != FUNCTION_DECL) \
341 fputs ("\t.EXPORT ", FILE); \
342 assemble_name (FILE, NAME); \
343 fputs (",DATA\n", FILE); \
346 while (0)
347 #endif
349 /* Although gas accepts .weakref, it doesn't provide the correct symbol
350 type for function references. For now, we use ASM_WEAKEN_DECL instead.
351 We have to undefine HAVE_GAS_WEAKREF to prevent default.h from defining
352 ASM_OUTPUT_WEAKREF. */
353 #undef HAVE_GAS_WEAKREF
355 /* We can't handle weak aliases, and therefore can't support pragma weak.
356 Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h. */
357 #define GTHREAD_USE_WEAK 0
359 /* Shared library suffix. Collect2 strips the version string after
360 this suffix when generating constructor/destructor names. */
361 #define SHLIB_SUFFIX ".sl"
363 /* We don't have named sections. */
364 #define TARGET_HAVE_NAMED_SECTIONS false
366 #define TARGET_ASM_TM_CLONE_TABLE_SECTION pa_som_tm_clone_table_section
368 /* Generate specially named labels to identify DWARF 2 frame unwind
369 information. */
370 #define EH_FRAME_THROUGH_COLLECT2