]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/pa/som.h
1 /* Definitions for SOM assembler support.
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC 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 2, or (at your option)
11 GNU CC 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 GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* So we can conditionalize small amounts of code in pa.c or pa.md. */
24 /* We do not use BINCL stabs in SOM.
25 ??? If it does not hurt, we probably should to avoid useless divergence
26 from other embedded stabs implementations. */
29 #undef ASM_IDENTIFY_GCC
30 #define ASM_IDENTIFY_GCC(FILE)
32 #undef ASM_IDENTIFY_GCC_AFTER_SOURCE
33 #define ASM_IDENTIFY_GCC_AFTER_SOURCE(FILE)
35 /* We make the first line stab special to avoid adding several
36 gross hacks to GAS. */
37 #undef ASM_OUTPUT_SOURCE_LINE
38 #define ASM_OUTPUT_SOURCE_LINE(file, line) \
39 { static int sym_lineno = 1; \
40 static tree last_function_decl = NULL; \
41 if (current_function_decl == last_function_decl) \
42 fprintf (file, "\t.stabn 68,0,%d,L$M%d-%s\nL$M%d:\n", \
44 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0) + 1, \
47 fprintf (file, "\t.stabn 68,0,%d,0\n", line); \
48 last_function_decl = current_function_decl; \
51 /* gdb needs a null N_SO at the end of each file for scattered loading. */
53 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
54 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
56 fputs ("\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
58 "\t.stabs \"\",%d,0,0,L$text_end0000\nL$text_end0000:\n", N_SO)
60 /* HPUX has a program 'chatr' to list the dependencies of dynamically
61 linked executables and shared libraries. */
62 #define LDD_SUFFIX "chatr"
63 /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl"
64 or "static /usr/lib/X11R5/libX11.sl".
66 HPUX 10.20 also has lines like "static branch prediction ..."
67 so we filter that out explicitly.
69 We also try to bound our search for libraries with marker
70 lines. What a pain. */
71 #define PARSE_LDD_OUTPUT(PTR) \
73 static int in_shlib_list = 0; \
74 while (*PTR == ' ') PTR++; \
75 if (strncmp (PTR, "shared library list:", \
76 sizeof ("shared library list:") - 1) == 0) \
81 else if (strncmp (PTR, "shared library binding:", \
82 sizeof ("shared library binding:") - 1) == 0)\
87 else if (strncmp (PTR, "static branch prediction disabled", \
88 sizeof ("static branch prediction disabled") - 1) == 0)\
93 else if (in_shlib_list \
94 && strncmp (PTR, "dynamic", sizeof ("dynamic") - 1) == 0) \
96 PTR += sizeof ("dynamic") - 1; \
97 while (*p == ' ') PTR++; \
99 else if (in_shlib_list \
100 && strncmp (PTR, "static", sizeof ("static") - 1) == 0) \
102 PTR += sizeof ("static") - 1; \
103 while (*p == ' ') PTR++; \
109 /* Output the label for a function definition. */
110 #ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
111 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
112 do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \
113 fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
114 #define DFMODE_RETURN_STRING ",RTNVAL=FU"
115 #define SFMODE_RETURN_STRING ",RTNVAL=FR"
117 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
118 do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \
119 fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
120 #define DFMODE_RETURN_STRING ",RTNVAL=FR"
121 #define SFMODE_RETURN_STRING ",RTNVAL=FU"
125 /* NAME refers to the function's name. If we are placing each function into
126 its own section, we need to switch to the section for this function. Note
127 that the section name will have a "." prefix. */
128 #define ASM_OUTPUT_FUNCTION_PREFIX(FILE, NAME) \
131 STRIP_NAME_ENCODING (name, NAME); \
132 if (TARGET_GAS && in_section == in_text) \
133 fputs ("\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
134 else if (TARGET_GAS) \
136 "\t.SUBSPA .%s\n", name); \
139 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
140 do { tree fntype = TREE_TYPE (TREE_TYPE (DECL)); \
141 tree tree_type = TREE_TYPE (DECL); \
144 if (TREE_PUBLIC (DECL) || TARGET_GAS) \
146 if (TREE_PUBLIC (DECL)) \
148 fputs ("\t.EXPORT ", FILE); \
149 assemble_name (FILE, NAME); \
150 fputs (",ENTRY,PRIV_LEV=3", FILE); \
154 fputs ("\t.PARAM ", FILE); \
155 assemble_name (FILE, NAME); \
156 fputs (",PRIV_LEV=3", FILE); \
158 for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \
159 parm = TREE_CHAIN (parm)) \
161 if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode \
162 && ! TARGET_SOFT_FLOAT) \
163 fprintf (FILE, ",ARGW%d=FR", i++); \
164 else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode \
165 && ! TARGET_SOFT_FLOAT) \
170 ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \
178 FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\
179 DECL_ARG_TYPE (parm)); \
180 /* Passing structs by invisible reference uses \
181 one general register. */ \
183 || TREE_ADDRESSABLE (DECL_ARG_TYPE (parm))) \
185 if (arg_size == 2 && i <= 2) \
188 fprintf (FILE, ",ARGW%d=GR", i++); \
189 fprintf (FILE, ",ARGW%d=GR", i++); \
191 else if (arg_size == 1) \
192 fprintf (FILE, ",ARGW%d=GR", i++); \
197 /* anonymous args */ \
198 if ((TYPE_ARG_TYPES (tree_type) != 0 \
199 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
200 != void_type_node)) \
201 || current_function_varargs) \
204 fprintf (FILE, ",ARGW%d=GR", i); \
206 if (TYPE_MODE (fntype) == DFmode && ! TARGET_SOFT_FLOAT) \
207 fputs (DFMODE_RETURN_STRING, FILE); \
208 else if (TYPE_MODE (fntype) == SFmode && ! TARGET_SOFT_FLOAT) \
209 fputs (SFMODE_RETURN_STRING, FILE); \
210 else if (fntype != void_type_node) \
211 fputs (",RTNVAL=GR", FILE); \
212 fputs ("\n", FILE); \
215 /* Output at beginning of assembler file. */
217 #define ASM_FILE_START(FILE) \
220 fputs("\t.LEVEL 2.0\n", FILE); \
221 else if (TARGET_PA_11) \
222 fputs("\t.LEVEL 1.1\n", FILE); \
224 fputs("\t.LEVEL 1.0\n", FILE); \
225 fputs ("\t.SPACE $PRIVATE$\n\
226 \t.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31\n\
227 \t.SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82\n\
229 \t.SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44\n\
230 \t.SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n\
231 \t.IMPORT $global$,DATA\n\
232 \t.IMPORT $$dyncall,MILLICODE\n", FILE);\
234 fprintf (FILE, "\t.IMPORT _mcount, CODE\n");\
235 if (write_symbols != NO_DEBUG) \
236 output_file_directive ((FILE), main_input_filename); \
239 /* Output before code. */
241 /* Supposedly the assembler rejects the command if there is no tab! */
242 #define TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$\n"
244 /* Output before read-only data. */
246 /* Supposedly the assembler rejects the command if there is no tab! */
247 #define READONLY_DATA_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $LIT$\n"
249 #define READONLY_DATA_SECTION readonly_data
251 /* Output before writable data. */
253 /* Supposedly the assembler rejects the command if there is no tab! */
254 #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
256 /* Output before uninitialized data. */
258 #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
260 /* Define the .bss section for ASM_OUTPUT_LOCAL to use. */
262 #ifndef CTORS_SECTION_FUNCTION
263 #define EXTRA_SECTIONS in_readonly_data
264 #define CTORS_SECTION_FUNCTION
265 #define DTORS_SECTION_FUNCTION
267 #define EXTRA_SECTIONS in_readonly_data, in_ctors, in_dtors
270 /* Switch into a generic section.
271 This is currently only used to support section attributes.
273 We make the section read-only and executable for a function decl,
274 read-only for a const data decl, and writable for a non-const data decl. */
275 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
276 if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
278 fputs ("\t.SPACE $TEXT$\n", FILE); \
280 "\t.SUBSPA %s%s%s,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY,SORT=24\n",\
281 TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \
283 else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
285 fputs ("\t.SPACE $TEXT$\n", FILE); \
287 "\t.SUBSPA %s%s%s,QUAD=0,ALIGN=8,ACCESS=44,SORT=16\n", \
288 TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \
292 fputs ("\t.SPACE $PRIVATE$\n", FILE); \
294 "\t.SUBSPA %s%s%s,QUAD=1,ALIGN=8,ACCESS=31,SORT=16\n", \
295 TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \
298 /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups
299 which reference data within the $TEXT$ space (for example constant
300 strings in the $LIT$ subspace).
302 The assemblers (GAS and HP as) both have problems with handling
303 the difference of two symbols which is the other correct way to
304 reference constant data during PIC code generation.
306 So, there's no way to reference constant data which is in the
307 $TEXT$ space during PIC generation. Instead place all constant
308 data into the $PRIVATE$ subspace (this reduces sharing, but it
311 #define EXTRA_SECTION_FUNCTIONS \
315 if (in_section != in_readonly_data) \
318 fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); \
320 fprintf (asm_out_file, "%s\n", READONLY_DATA_ASM_OP); \
321 in_section = in_readonly_data; \
324 CTORS_SECTION_FUNCTION \
325 DTORS_SECTION_FUNCTION
327 /* This is how to output a command to make the user-level label named NAME
328 defined for reference from other files.
330 We call assemble_name, which in turn sets TREE_SYMBOL_REFERENCED. This
331 macro will restore the original value of TREE_SYMBOL_REFERENCED to avoid
332 placing useless function definitions in the output file.
334 Also note that the SOM based tools need the symbol imported as a CODE
335 symbol, while the ELF based tools require the symbol to be imported as
336 an ENTRY symbol. What a crock. */
338 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
339 do { int save_referenced; \
340 save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \
341 fputs ("\t.IMPORT ", FILE); \
342 assemble_name (FILE, NAME); \
343 if (FUNCTION_NAME_P (NAME)) \
344 fputs (",CODE\n", FILE); \
346 fputs (",DATA\n", FILE); \
347 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced; \
350 /* The bogus HP assembler requires ALL external references to be
351 "imported", even library calls. They look a bit different, so
354 Also note not all libcall names are passed to ENCODE_SECTION_INFO
355 (__main for example). To make sure all libcall names have section
356 info recorded in them, we do it here. */
358 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
359 do { fputs ("\t.IMPORT ", FILE); \
360 if (!function_label_operand (RTL, VOIDmode)) \
361 hppa_encode_label (RTL); \
362 assemble_name (FILE, XSTR ((RTL), 0)); \
363 fputs (",CODE\n", FILE); \
366 #define ASM_FILE_END(FILE) output_deferred_plabels (FILE)
368 /* We want __gcc_plt_call to appear in every program built by
369 gcc, so we make a reference to it out of __main.
370 We use the asm statement to fool the optimizer into not
371 removing the dead (but important) initialization of
374 #define DO_GLOBAL_DTORS_BODY \
376 extern void __gcc_plt_call (); \
377 void (*reference)() = &__gcc_plt_call; \
379 __asm__ ("" : : "r" (reference)); \
380 for (p = __DTOR_LIST__ + 1; *p; ) \
384 /* The .align directive in the HP assembler allows up to a 32 alignment. */
385 #define MAX_OFILE_ALIGNMENT 32768
388 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
390 /* This is how we tell the assembler that a symbol is weak. */
392 #define ASM_WEAKEN_LABEL(FILE,NAME) \
393 do { fputs ("\t.weak\t", FILE); \
394 assemble_name (FILE, NAME); \
395 fputc ('\n', FILE); \
396 if (! FUNCTION_NAME_P (NAME)) \
398 fputs ("\t.EXPORT ", FILE); \
399 assemble_name (FILE, NAME); \
400 fputs (",DATA\n", FILE); \