OSDN Git Service

4272116f5a9c206d76c9eac00e883e3ecc5836b5
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / pa-64.h
1 /* Definitions of target machine for GNU compiler, for HPs using the
2    64bit runtime model.
3    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC 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.
11
12 GNU CC 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.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* We can debug dynamically linked executables on hpux11; we also
23    want dereferencing of a NULL pointer to cause a SEGV.  */
24 #undef LINK_SPEC
25 #define LINK_SPEC \
26   "-E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:-shared}"
27
28 /* Like the default, except no -lg.  */
29 #undef LIB_SPEC
30 #define LIB_SPEC \
31   "%{!shared:\
32      %{!p:\
33        %{!pg:\
34          %{!threads:-lc}\
35          %{threads:-lcma -lc_r}}\
36        %{p: -L/lib/libp/ -lc}\
37        %{pg: -L/lib/libp/ -lc}}} /usr/lib/pa20_64/milli.a"
38
39 /* Under hpux11, the normal location of the `ld' and `as' programs is the
40    /usr/ccs/bin directory.  */
41
42 #ifndef CROSS_COMPILE
43 #undef MD_EXEC_PREFIX
44 #define MD_EXEC_PREFIX "/opt/langtools/bin"
45 #endif
46
47 /* Under hpux11 the normal location of the various *crt*.o files is the
48    /usr/ccs/lib directory.  */
49
50 #ifndef CROSS_COMPILE
51 #undef MD_STARTFILE_PREFIX
52 #define MD_STARTFILE_PREFIX "/opt/langtools/lib/pa20_64/"
53 #endif
54
55 /* hpux11 has the new HP assembler.  It's still lousy, but it's a whole lot
56    better than the assembler shipped with older versions of hpux.  */
57 #define NEW_HP_ASSEMBLER
58
59 /* The default sizes for basic datatypes provided by GCC are not
60    correct for the PA64 runtime architecture.
61
62    In PA64, basic types have the following sizes
63
64      char       1 byte
65      short      2 bytes
66      int        4 bytes
67      long       8 bytes
68      long long  8 bytes
69      pointer    8 bytes
70      float      4 bytes
71      double     8 bytes
72      long double 16 bytes
73      size_t     8 bytes
74      ptrdiff_t  8 bytes
75      wchar      4 bytes
76      
77   Make GCC agree with types.h.  */
78 #undef SIZE_TYPE
79 #undef PTRDIFF_TYPE
80
81 #define SIZE_TYPE "long unsigned int"
82 #define PTRDIFF_TYPE "long int"
83
84 /* If it is not listed here, then the default selected by GCC is OK.  */
85 #define SHORT_TYPE_SIZE 16
86 #define INT_TYPE_SIZE 32
87 #define MAX_LONG_TYPE_SIZE 64
88 #define LONG_TYPE_SIZE 64
89 #define LONG_LONG_TYPE_SIZE 64
90 #define FLOAT_TYPE_SIZE 32
91 #define DOUBLE_TYPE_SIZE 64
92 /* This should be 128, but until we work out the ABI for the 128bit
93    FP codes supplied by HP we'll keep it at 64 bits.  */
94 #undef LONG_DOUBLE_TYPE_SIZE
95 #define LONG_DOUBLE_TYPE_SIZE 64
96 #define MAX_WCHAR_TYPE_SIZE 32
97
98 #undef ASM_FILE_START
99 #define ASM_FILE_START(FILE) \
100 do {  \
101      if (TARGET_64BIT) \
102        fputs("\t.LEVEL 2.0w\n", FILE); \
103      else if (TARGET_PA_11) \
104        fputs("\t.LEVEL 2.0\n", FILE); \
105      else if (TARGET_PA_11) \
106        fputs("\t.LEVEL 1.1\n", FILE); \
107      else \
108        fputs("\t.LEVEL 1.0\n", FILE); \
109      if (profile_flag)\
110        fprintf (FILE, "\t.IMPORT _mcount, CODE\n");\
111      if (write_symbols != NO_DEBUG) \
112        output_file_directive ((FILE), main_input_filename); \
113    } while (0)
114
115 /* Temporary until we figure out what to do with those *(&@$ 32bit
116    relocs which appear in stabs.  */
117 #undef DBX_DEBUGGING_INFO
118
119 /* We want the compiler to select a suitable secondary memory location.
120    ?!? This may not work reliably.  Keep an eye out for problems.  */
121 #undef SECONDARY_MEMORY_NEEDED_RTX
122
123
124 /* ?!? This needs to be made compile-time selectable.
125
126    The PA64 runtime model has arguments that grow to higher addresses
127    (like most other targets).  The older runtime model has arguments
128    that grow to lower addresses.  What fun.  */
129 #undef ARGS_GROW_DOWNWARD
130 #undef ARG_POINTER_REGNUM
131 #define ARG_POINTER_REGNUM 29
132 #undef STATIC_CHAIN_REGNUM
133 #define STATIC_CHAIN_REGNUM 31
134
135 /* This is not needed for correct operation in 32bit mode, and since
136    older versions of gas and the hpux assembler do not accept .dword
137    we put this here instead of the more logical location, pa.h.  */
138 #define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE)  \
139 { fputs ("\t.dword ", FILE);                    \
140   if (function_label_operand (VALUE, VOIDmode)) \
141     fputs ("P%", FILE);                         \
142   output_addr_const (FILE, (VALUE));            \
143   fputs ("\n", FILE);}
144
145 /* It looks like DWARF2 will be the easiest debug format to handle on this
146    platform.  */
147 #define OBJECT_FORMAT_ELF
148 #define DWARF2_DEBUGGING_INFO
149 #define PREFERRED_DEBUGGING_FORMAT DWARF2_DEBUG
150 /* This isn't quite ready yet.  I'm seeing it mess up some line
151    tables.  For example, we're getting lines starting/ending at
152    impossible addresses.  */
153 #define DWARF2_ASM_LINE_DEBUG_INFO 1
154
155
156 /* Nonzero if we do not know how to pass TYPE solely in registers. */
157 #define MUST_PASS_IN_STACK(MODE,TYPE)                   \
158   ((TYPE) != 0                                          \
159    && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST      \
160        || TREE_ADDRESSABLE (TYPE)))
161
162 /* The rest of this file is copied from the generic svr4.h.  One day we
163    would like to simply include svr4.h instead of copying all these
164    definitions.  */
165
166 /* Support const sections and the ctors and dtors sections for g++.
167    Note that there appears to be two different ways to support const
168    sections at the moment.  You can either #define the symbol
169    READONLY_DATA_SECTION (giving it some code which switches to the
170    readonly data section) or else you can #define the symbols
171    EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
172    SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
173
174 #define USE_CONST_SECTION       1
175
176 #define CONST_SECTION_ASM_OP    "\t.section\t.rodata"
177
178 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
179
180    Note that we want to give these sections the SHF_WRITE attribute
181    because these sections will actually contain data (i.e. tables of
182    addresses of functions in the current root executable or shared library
183    file) and, in the case of a shared library, the relocatable addresses
184    will have to be properly resolved/relocated (and then written into) by
185    the dynamic linker when it actually attaches the given shared library
186    to the executing process.  (Note that on SVR4, you may wish to use the
187    `-z text' option to the ELF linker, when building a shared library, as
188    an additional check that you are doing everything right.  But if you do
189    use the `-z text' option when building a shared library, you will get
190    errors unless the .ctors and .dtors sections are marked as writable
191    via the SHF_WRITE attribute.)  */
192
193 #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"aw\""
194 #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"aw\""
195
196 /* On svr4, we *do* have support for the .init and .fini sections, and we
197    can put stuff in there to be executed before and after `main'.  We let
198    crtstuff.c and other files know this by defining the following symbols.
199    The definitions say how to change sections to the .init and .fini
200    sections.  This is the same for all known svr4 assemblers.  */
201
202 /* ??? For the time being, we aren't using init sections. */
203 #if 0
204 #define INIT_SECTION_ASM_OP     "\t.section\t.init"
205 #define FINI_SECTION_ASM_OP     "\t.section\t.fini"
206 #endif
207
208 /* A default list of other sections which we might be "in" at any given
209    time.  For targets that use additional sections (e.g. .tdesc) you
210    should override this definition in the target-specific file which
211    includes this file.  */
212
213 #undef EXTRA_SECTIONS
214 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
215
216 /* A default list of extra section function definitions.  For targets
217    that use additional sections (e.g. .tdesc) you should override this
218    definition in the target-specific file which includes this file.  */
219
220 #undef EXTRA_SECTION_FUNCTIONS
221 #define EXTRA_SECTION_FUNCTIONS                                         \
222   CONST_SECTION_FUNCTION                                                \
223   CTORS_SECTION_FUNCTION                                                \
224   DTORS_SECTION_FUNCTION
225
226 #define READONLY_DATA_SECTION() const_section ()
227
228 extern void text_section ();
229
230 #define CONST_SECTION_FUNCTION                                          \
231 void                                                                    \
232 const_section ()                                                        \
233 {                                                                       \
234   if (!USE_CONST_SECTION)                                               \
235     text_section();                                                     \
236   else if (in_section != in_const)                                      \
237     {                                                                   \
238       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
239       in_section = in_const;                                            \
240     }                                                                   \
241 }
242
243 #define CTORS_SECTION_FUNCTION                                          \
244 void                                                                    \
245 ctors_section ()                                                        \
246 {                                                                       \
247   if (in_section != in_ctors)                                           \
248     {                                                                   \
249       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);             \
250       in_section = in_ctors;                                            \
251     }                                                                   \
252 }
253
254 #define DTORS_SECTION_FUNCTION                                          \
255 void                                                                    \
256 dtors_section ()                                                        \
257 {                                                                       \
258   if (in_section != in_dtors)                                           \
259     {                                                                   \
260       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);             \
261       in_section = in_dtors;                                            \
262     }                                                                   \
263 }
264
265 /* Switch into a generic section.
266  
267    We make the section read-only and executable for a function decl,
268    read-only for a const data decl, and writable for a non-const data decl.
269  
270    If the section has already been defined, we must not
271    emit the attributes here. The SVR4 assembler does not
272    recognize section redefinitions.
273    If DECL is NULL, no attributes are emitted.  */
274
275 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)                \
276 do {                                                                    \
277   static struct section_info                                            \
278     {                                                                   \
279       struct section_info *next;                                        \
280       char *name;                                                       \
281       enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type;                \
282     } *sections;                                                        \
283   struct section_info *s;                                               \
284   char *mode;                                                           \
285   enum sect_enum type;                                                  \
286                                                                         \
287   for (s = sections; s; s = s->next)                                    \
288     if (!strcmp (NAME, s->name))                                        \
289       break;                                                            \
290                                                                         \
291   if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)                        \
292     type = SECT_EXEC, mode = "ax";                                      \
293   else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))                 \
294     type = SECT_RO, mode = "a";                                         \
295   else                                                                  \
296     type = SECT_RW, mode = "aw";                                        \
297                                                                         \
298   if (s == 0)                                                           \
299     {                                                                   \
300       s = (struct section_info *) xmalloc (sizeof (struct section_info));  \
301       s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME));         \
302       strcpy (s->name, NAME);                                           \
303       s->type = type;                                                   \
304       s->next = sections;                                               \
305       sections = s;                                                     \
306       fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", NAME, mode);  \
307     }                                                                   \
308   else                                                                  \
309     {                                                                   \
310       if (DECL && s->type != type)                                      \
311         error_with_decl (DECL, "%s causes a section type conflict");    \
312                                                                         \
313       fprintf (FILE, "\t.section\t%s\n", NAME);                         \
314     }                                                                   \
315 } while (0)
316
317 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
318 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
319 #define UNIQUE_SECTION(DECL,RELOC)                              \
320 do {                                                            \
321   int len;                                                      \
322   char *name, *string, *prefix;                                 \
323                                                                 \
324   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));       \
325                                                                 \
326   if (! DECL_ONE_ONLY (DECL))                                   \
327     {                                                           \
328       prefix = ".";                                             \
329       if (TREE_CODE (DECL) == FUNCTION_DECL)                    \
330         prefix = ".text.";                                      \
331       else if (DECL_READONLY_SECTION (DECL, RELOC))             \
332         prefix = ".rodata.";                                    \
333       else                                                      \
334         prefix = ".data.";                                      \
335     }                                                           \
336   else if (TREE_CODE (DECL) == FUNCTION_DECL)                   \
337     prefix = ".gnu.linkonce.t.";                                \
338   else if (DECL_READONLY_SECTION (DECL, RELOC))                 \
339     prefix = ".gnu.linkonce.r.";                                \
340   else                                                          \
341     prefix = ".gnu.linkonce.d.";                                \
342                                                                 \
343   len = strlen (name) + strlen (prefix);                        \
344   string = alloca (len + 1);                                    \
345   sprintf (string, "%s%s", prefix, name);                       \
346                                                                 \
347   DECL_SECTION_NAME (DECL) = build_string (len, string);        \
348 } while (0)
349
350 #define INT_ASM_OP "\t.dword\t"
351 /* A C statement (sans semicolon) to output an element in the table of
352    global constructors.  */
353 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                               \
354   do {                                                                  \
355     ctors_section ();                                                   \
356     fprintf (FILE, "%sP%%", INT_ASM_OP);                                \
357     assemble_name (FILE, NAME);                                         \
358     fprintf (FILE, "\n");                                               \
359   } while (0)
360
361 /* A C statement (sans semicolon) to output an element in the table of
362    global destructors.  */
363 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                                \
364   do {                                                                  \
365     dtors_section ();                                                   \
366     fprintf (FILE, "%sP%%", INT_ASM_OP);                                \
367     assemble_name (FILE, NAME);                                         \
368     fprintf (FILE, "\n");                                               \
369   } while (0)
370
371 /* ??? For the time being, we aren't using .ctors/.dtors sections. */
372 #undef ASM_OUTPUT_DESTRUCTOR
373 #undef ASM_OUTPUT_CONSTRUCTOR
374
375 /* Define the strings used for the special svr4 .type and .size directives.
376    These strings generally do not vary from one system running svr4 to
377    another, but if a given system (e.g. m88k running svr) needs to use
378    different pseudo-op names for these, they may be overridden in the
379    file which includes this one.  */
380
381 #define TYPE_ASM_OP     "\t.type\t"
382 #define SIZE_ASM_OP     "\t.size\t"
383
384 /* This is how we tell the assembler that a symbol is weak.  */
385
386 #define ASM_WEAKEN_LABEL(FILE,NAME) \
387   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
388        fputc ('\n', FILE); } while (0)
389
390 /* The following macro defines the format used to output the second
391    operand of the .type assembler directive.  Different svr4 assemblers
392    expect various different forms for this operand.  The one given here
393    is just a default.  You may need to override it in your machine-
394    specific tm.h file (depending upon the particulars of your assembler).  */
395
396 #define TYPE_OPERAND_FMT        "@%s"
397
398 /* Write the extra assembler code needed to declare a function's result.
399    Most svr4 assemblers don't require any special declaration of the
400    result value, but there are exceptions.  */
401
402 #ifndef ASM_DECLARE_RESULT
403 #define ASM_DECLARE_RESULT(FILE, RESULT)
404 #endif