OSDN Git Service

* target.h (asm_out.file_start, file_start_app_off,
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / vms.h
1 /* Output variables, constants and external declarations, for GNU compiler.
2    Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002
3    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 #define TARGET_OBJECT_SUFFIX ".obj"
23 #define TARGET_EXECUTABLE_SUFFIX ".exe"
24
25 /* This enables certain macros in alpha.h, which will make an indirect
26    reference to an external symbol an invalid address.  This needs to be
27    defined before we include alpha.h, since it determines which macros
28    are used for GO_IF_*.  */
29
30 #define NO_EXTERNAL_INDIRECT_ADDRESS
31
32 #define TARGET_OS_CPP_BUILTINS()                \
33     do {                                        \
34         builtin_define_std ("vms");             \
35         builtin_define_std ("VMS");             \
36         builtin_define ("__ALPHA");             \
37         builtin_assert ("system=vms");          \
38         if (TARGET_FLOAT_VAX)                   \
39           builtin_define ("__G_FLOAT");         \
40         else                                    \
41           builtin_define ("__IEEE_FLOAT");      \
42     } while (0)
43
44 #undef TARGET_DEFAULT
45 #define TARGET_DEFAULT (MASK_FP|MASK_FPREGS|MASK_GAS)
46 #undef TARGET_ABI_OPEN_VMS
47 #define TARGET_ABI_OPEN_VMS 1
48
49 #undef TARGET_NAME   
50 #define TARGET_NAME "OpenVMS/Alpha"
51 #undef TARGET_VERSION
52 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);           
53
54 /* The structure return address arrives as an "argument" on VMS.  */
55 #undef STRUCT_VALUE_REGNUM
56 #define STRUCT_VALUE 0
57 #undef PCC_STATIC_STRUCT_RETURN
58
59 /* "long" is 32 bits, but 64 bits for Ada.  */
60 #undef LONG_TYPE_SIZE
61 #define LONG_TYPE_SIZE 32
62 #define ADA_LONG_TYPE_SIZE 64
63
64 /* Pointer is 32 bits but the hardware has 64-bit addresses, sign extended.  */
65 #undef POINTER_SIZE
66 #define POINTER_SIZE 32
67 #define POINTERS_EXTEND_UNSIGNED 0
68
69 #define MAX_OFILE_ALIGNMENT 524288  /* 8 x 2^16 by DEC Ada Test CD40VRA */
70
71 #undef FIXED_REGISTERS
72 #define FIXED_REGISTERS  \
73  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
74   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, \
75   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
76   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
77
78 #undef CALL_USED_REGISTERS
79 #define CALL_USED_REGISTERS  \
80  {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
81   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
82   1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, \
83   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
84
85 /* List the order in which to allocate registers.  Each register must be
86    listed once, even those in FIXED_REGISTERS.
87
88    We allocate in the following order:
89    $f1                  (nonsaved floating-point register)
90    $f10-$f15            (likewise)
91    $f22-$f30            (likewise)
92    $f21-$f16            (likewise, but input args)
93    $f0                  (nonsaved, but return value)
94    $f2-$f9              (saved floating-point registers)
95    $1                   (nonsaved integer registers)
96    $22-$25              (likewise)
97    $28                  (likewise)
98    $0                   (likewise, but return value)
99    $21-$16              (likewise, but input args)
100    $27                  (procedure value in OSF, nonsaved in NT)
101    $2-$8                (saved integer registers)
102    $9-$14               (saved integer registers)
103    $26                  (return PC)
104    $15                  (frame pointer)
105    $29                  (global pointer)
106    $30, $31, $f31       (stack pointer and always zero/ap & fp)  */
107
108 #undef REG_ALLOC_ORDER
109 #define REG_ALLOC_ORDER         \
110   {33,                                  \
111    42, 43, 44, 45, 46, 47,              \
112    54, 55, 56, 57, 58, 59, 60, 61, 62,  \
113    53, 52, 51, 50, 49, 48,              \
114    32,                                  \
115    34, 35, 36, 37, 38, 39, 40, 41,      \
116    1,                                   \
117    22, 23, 24, 25,                      \
118    28,                                  \
119    0,                                   \
120    21, 20, 19, 18, 17, 16,              \
121    27,                                  \
122    2, 3, 4, 5, 6, 7, 8,                 \
123    9, 10, 11, 12, 13, 14,               \
124    26,                                  \
125    15,                                  \
126    29,                                  \
127    30, 31, 63 }
128
129 #undef HARD_FRAME_POINTER_REGNUM
130 #define HARD_FRAME_POINTER_REGNUM 29
131
132 /* Define registers used by the epilogue and return instruction.  */
133 #undef EPILOGUE_USES
134 #define EPILOGUE_USES(REGNO)    ((REGNO) == 26 || (REGNO) == 29)
135
136 #undef CAN_ELIMINATE
137 #define CAN_ELIMINATE(FROM, TO)  \
138 ((TO) != STACK_POINTER_REGNUM || ! alpha_using_fp ())
139
140 #undef INITIAL_ELIMINATION_OFFSET
141 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
142 { if ((FROM) == FRAME_POINTER_REGNUM)                                   \
143     (OFFSET) = alpha_sa_size () + alpha_pv_save_size ();                \
144   else if ((FROM) == ARG_POINTER_REGNUM)                                \
145     (OFFSET) = (ALPHA_ROUND (alpha_sa_size () + alpha_pv_save_size ()   \
146                              + get_frame_size ()                        \
147                              + current_function_pretend_args_size)      \
148                 - current_function_pretend_args_size);                  \
149   else                                                                  \
150     abort();                                                            \
151   if ((TO) == STACK_POINTER_REGNUM)                                     \
152     (OFFSET) += ALPHA_ROUND (current_function_outgoing_args_size);      \
153 }
154 \f
155 /* Define a data type for recording info about an argument list
156    during the scan of that argument list.  This data type should
157    hold all necessary information about the function itself
158    and about the args processed so far, enough to enable macros
159    such as FUNCTION_ARG to determine where the next arg should go.
160
161    On Alpha/VMS, this is a structure that contains the number of
162    arguments and, for each argument, the datatype of that argument.
163
164    The number of arguments is a number of words of arguments scanned so far.
165    Thus 6 or more means all following args should go on the stack.  */
166
167 enum avms_arg_type {I64, FF, FD, FG, FS, FT};
168 typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info;
169
170 #undef CUMULATIVE_ARGS
171 #define CUMULATIVE_ARGS avms_arg_info
172
173 /* Initialize a variable CUM of type CUMULATIVE_ARGS
174    for a call to a function whose data type is FNTYPE.
175    For a library call, FNTYPE is 0.  */
176
177 #undef INIT_CUMULATIVE_ARGS
178 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
179   (CUM).num_args = 0;                                           \
180   (CUM).atypes[0] = (CUM).atypes[1] = (CUM).atypes[2] = I64;    \
181   (CUM).atypes[3] = (CUM).atypes[4] = (CUM).atypes[5] = I64;
182
183 #undef FUNCTION_ARG_ADVANCE
184 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)                    \
185   if (MUST_PASS_IN_STACK (MODE, TYPE))                                  \
186     (CUM).num_args += 6;                                                \
187   else                                                                  \
188     {                                                                   \
189       if ((CUM).num_args < 6)                                           \
190         (CUM).atypes[(CUM).num_args] = alpha_arg_type (MODE);           \
191                                                                         \
192      (CUM).num_args += ALPHA_ARG_SIZE (MODE, TYPE, NAMED);              \
193     }
194
195 /* For an arg passed partly in registers and partly in memory,
196    this is the number of registers used.
197    For args passed entirely in registers or entirely in memory, zero.  */
198
199 #undef FUNCTION_ARG_PARTIAL_NREGS
200 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED)              \
201 ((CUM).num_args < 6 && 6 < (CUM).num_args                               \
202    + ALPHA_ARG_SIZE (MODE, TYPE, NAMED)                                 \
203  ? 6 - (CUM).num_args : 0)
204
205 /* Perform any needed actions needed for a function that is receiving a
206    variable number of arguments. 
207
208    CUM is as for INIT_CUMULATIVE_ARGS.
209
210    MODE and TYPE are the mode and type of the current parameter.
211
212    PRETEND_SIZE is a variable that should be set to the amount of stack
213    that must be pushed by the prolog to pretend that our caller pushed
214    it.
215
216    Normally, this macro will push all remaining incoming registers on the
217    stack and set PRETEND_SIZE to the length of the registers pushed. 
218
219    For VMS, we allocate space for all 6 arg registers plus a count.
220
221    However, if NO registers need to be saved, don't allocate any space.
222    This is not only because we won't need the space, but because AP includes
223    the current_pretend_args_size and we don't want to mess up any
224    ap-relative addresses already made.  */
225
226 #undef SETUP_INCOMING_VARARGS
227 #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL)       \
228 { if ((CUM).num_args < 6)                               \
229     {                                                   \
230       if (! (NO_RTL))                                   \
231         {                                               \
232           emit_move_insn (gen_rtx_REG (DImode, 1),      \
233                           virtual_incoming_args_rtx);   \
234           emit_insn (gen_arg_home ());                  \
235         }                                               \
236                                                         \
237       PRETEND_SIZE = 7 * UNITS_PER_WORD;                \
238     }                                                   \
239 }
240
241 /* ABI has stack checking, but it's broken.  */
242 #undef STACK_CHECK_BUILTIN
243 #define STACK_CHECK_BUILTIN 0
244
245 #define LINK_SECTION_ASM_OP "\t.link"
246 #define READONLY_DATA_SECTION_ASM_OP "\t.rdata"
247 #define LITERALS_SECTION_ASM_OP "\t.literals"
248 #define CTORS_SECTION_ASM_OP "\t.ctors"
249 #define DTORS_SECTION_ASM_OP "\t.dtors"
250
251 #undef EXTRA_SECTIONS
252 #define EXTRA_SECTIONS  in_link, in_literals
253
254 #undef EXTRA_SECTION_FUNCTIONS
255 #define EXTRA_SECTION_FUNCTIONS                                 \
256 void                                                            \
257 link_section ()                                                 \
258 {                                                               \
259   if (in_section != in_link)                                    \
260     {                                                           \
261       fprintf (asm_out_file, "%s\n", LINK_SECTION_ASM_OP);      \
262       in_section = in_link;                                     \
263     }                                                           \
264 }                                                               \
265 void                                                            \
266 literals_section ()                                             \
267 {                                                               \
268   if (in_section != in_literals)                                \
269     {                                                           \
270       fprintf (asm_out_file, "%s\n", LITERALS_SECTION_ASM_OP);  \
271       in_section = in_literals;                                 \
272     }                                                           \
273 }
274
275 extern void link_section (void);
276 extern void literals_section (void);
277
278 #undef ASM_OUTPUT_ADDR_DIFF_ELT
279 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) abort ()
280
281 #undef ASM_OUTPUT_ADDR_VEC_ELT
282 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
283   fprintf (FILE, "\t.quad $L%d\n", (VALUE))
284
285 #undef CASE_VECTOR_MODE
286 #define CASE_VECTOR_MODE DImode
287 #undef CASE_VECTOR_PC_RELATIVE
288
289 #undef ASM_OUTPUT_CASE_LABEL
290 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN)        \
291 { ASM_OUTPUT_ALIGN (FILE, 3); (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM); }
292
293 /* This says how to output assembler code to declare an                
294    uninitialized external linkage data object.  */ 
295
296 #define COMMON_ASM_OP "\t.comm\t"
297
298 #undef ASM_OUTPUT_ALIGNED_COMMON
299 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)              \
300 do {                                                                    \
301   fprintf ((FILE), "%s", COMMON_ASM_OP);                                \
302   assemble_name ((FILE), (NAME));                                       \
303   fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED ",%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);  \
304 } while (0)
305
306 \f
307 /* Output assembler code for a block containing the constant parts
308    of a trampoline, leaving space for the variable parts.
309
310    The trampoline should set the static chain pointer to value placed
311    into the trampoline and should branch to the specified routine.  
312    Note that $27 has been set to the address of the trampoline, so we can
313    use it for addressability of the two data items.  */
314
315 #undef TRAMPOLINE_TEMPLATE
316 #define TRAMPOLINE_TEMPLATE(FILE)               \
317 {                                               \
318   fprintf (FILE, "\t.quad 0\n");                \
319   fprintf (FILE, "\t.linkage __tramp\n");       \
320   fprintf (FILE, "\t.quad 0\n");                \
321 }
322
323 /* Length in units of the trampoline for entering a nested function.  */
324
325 #undef TRAMPOLINE_SIZE
326 #define TRAMPOLINE_SIZE    32
327
328 /* The alignment of a trampoline, in bits.  */
329
330 #undef TRAMPOLINE_ALIGNMENT
331 #define TRAMPOLINE_ALIGNMENT  64
332
333 /* Emit RTL insns to initialize the variable parts of a trampoline.
334    FNADDR is an RTX for the address of the function's pure code.
335    CXT is an RTX for the static chain value for the function.  */
336
337 #undef INITIALIZE_TRAMPOLINE
338 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
339   alpha_initialize_trampoline (TRAMP, FNADDR, CXT, 16, 24, -1)
340
341 /* Control how constructors and destructors are emitted.  */
342 #define TARGET_ASM_CONSTRUCTOR  vms_asm_out_constructor
343 #define TARGET_ASM_DESTRUCTOR   vms_asm_out_destructor
344
345 #undef SDB_DEBUGGING_INFO
346 #undef MIPS_DEBUGGING_INFO
347 #undef DBX_DEBUGGING_INFO
348
349 #define DWARF2_DEBUGGING_INFO 1
350 #define VMS_DEBUGGING_INFO 1
351
352 #define DWARF2_UNWIND_INFO 1
353
354 #undef EH_RETURN_HANDLER_RTX
355 #define EH_RETURN_HANDLER_RTX \
356   gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx, 8))
357
358 #define LINK_EH_SPEC "vms-dwarf2eh.o%s "
359
360 #ifdef IN_LIBGCC2
361 #include <pdscdef.h>
362
363 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
364  do {                                                                   \
365   PDSCDEF *pv = *((PDSCDEF **) (CONTEXT)->reg [29]);                    \
366                                                                         \
367   if (pv && ((long) pv & 0x7) == 0) /* low bits 0 means address */      \
368     pv = *(PDSCDEF **) pv;                                              \
369                                                                         \
370   if (pv && ((pv->pdsc$w_flags & 0xf) == PDSC$K_KIND_FP_STACK))         \
371     {                                                                   \
372       int i, j;                                                         \
373                                                                         \
374       (FS)->cfa_offset = pv->pdsc$l_size;                               \
375       (FS)->cfa_reg = pv->pdsc$w_flags & PDSC$M_BASE_REG_IS_FP ? 29 : 30; \
376       (FS)->retaddr_column = 26;                                        \
377       (FS)->cfa_how = CFA_REG_OFFSET;                                   \
378       (FS)->regs.reg[27].loc.offset = -pv->pdsc$l_size;                 \
379       (FS)->regs.reg[27].how = REG_SAVED_OFFSET;                        \
380       (FS)->regs.reg[26].loc.offset                                     \
381          = -(pv->pdsc$l_size - pv->pdsc$w_rsa_offset);                  \
382       (FS)->regs.reg[26].how = REG_SAVED_OFFSET;                        \
383                                                                         \
384       for (i = 0, j = 0; i < 32; i++)                                   \
385         if (1<<i & pv->pdsc$l_ireg_mask)                                \
386           {                                                             \
387             (FS)->regs.reg[i].loc.offset                                \
388               = -(pv->pdsc$l_size - pv->pdsc$w_rsa_offset - 8 * ++j);   \
389             (FS)->regs.reg[i].how = REG_SAVED_OFFSET;                   \
390           }                                                             \
391                                                                         \
392       goto SUCCESS;                                                     \
393     }                                                                   \
394   else if (pv && ((pv->pdsc$w_flags & 0xf) == PDSC$K_KIND_FP_REGISTER)) \
395     {                                                                   \
396       (FS)->cfa_offset = pv->pdsc$l_size;                               \
397       (FS)->cfa_reg = pv->pdsc$w_flags & PDSC$M_BASE_REG_IS_FP ? 29 : 30; \
398       (FS)->retaddr_column = 26;                                        \
399       (FS)->cfa_how = CFA_REG_OFFSET;                                   \
400       (FS)->regs.reg[26].loc.reg = pv->pdsc$b_save_ra;                  \
401       (FS)->regs.reg[26].how = REG_SAVED_REG;                           \
402       (FS)->regs.reg[29].loc.reg = pv->pdsc$b_save_fp;                  \
403       (FS)->regs.reg[29].how = REG_SAVED_REG;                           \
404                                                                         \
405       goto SUCCESS;                                                     \
406     }                                                                   \
407 } while (0)
408 #endif
409
410 /* This is how to output an assembler line
411    that says to advance the location counter
412    to a multiple of 2**LOG bytes.  */
413
414 #undef ASM_OUTPUT_ALIGN
415 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
416     fprintf (FILE, "\t.align %d\n", LOG);
417
418 /* Switch into a generic section.  */
419 #define TARGET_ASM_NAMED_SECTION vms_asm_named_section
420
421 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
422   do {  literals_section();                                             \
423         fprintf ((FILE), "\t");                                         \
424         assemble_name (FILE, LABEL1);                                   \
425         fprintf (FILE, " = ");                                          \
426         assemble_name (FILE, LABEL2);                                   \
427         fprintf (FILE, "\n");                                           \
428   } while (0)
429
430 #undef PREFERRED_DEBUGGING_TYPE
431 #define PREFERRED_DEBUGGING_TYPE VMS_AND_DWARF2_DEBUG
432
433 #define ASM_PN_FORMAT "%s___%lu"
434
435 /* ??? VMS uses different linkage.  */
436 #undef TARGET_ASM_OUTPUT_MI_THUNK
437
438 #undef ASM_SPEC
439 #undef ASM_FINAL_SPEC
440
441 /* The VMS convention is to always provide minimal debug info
442    for a traceback unless specifically overridden.  Defaulting this here
443    is a kludge.  */
444
445 #define OPTIMIZATION_OPTIONS(OPTIMIZE, OPTIMIZE_SIZE) \
446 {                                                  \
447    write_symbols = VMS_DEBUG;                      \
448    debug_info_level = (enum debug_info_level) 1;   \
449 }
450
451 /* Override traceback debug info on -g0.  */
452 #undef OVERRIDE_OPTIONS
453 #define OVERRIDE_OPTIONS                           \
454 {                                                  \
455    if (write_symbols == NO_DEBUG)                  \
456      debug_info_level = (enum debug_info_level) 0; \
457    override_options ();                            \
458 }
459
460 /* Link with vms-dwarf2.o if -g (except -g0). This causes the
461    VMS link to pull all the dwarf2 debug sections together. */
462 #undef LINK_SPEC
463 #define LINK_SPEC "%{g:-g vms-dwarf2.o%s} %{g0} %{g1:-g1 vms-dwarf2.o%s} \
464 %{g2:-g2 vms-dwarf2.o%s} %{g3:-g3 vms-dwarf2.o%s} %{shared} %{v} %{map}"
465
466 #undef STARTFILE_SPEC
467 #define STARTFILE_SPEC "%{!shared:%{mvms-return-codes:vcrt0.o%s} \
468 %{!mvms-return-codes:pcrt0.o%s}}"
469
470 #undef LIB_SPEC
471 #define LIB_SPEC "-lc"
472
473 /* Define the names of the division and modulus functions.  */
474 #define DIVSI3_LIBCALL "OTS$DIV_I"
475 #define DIVDI3_LIBCALL "OTS$DIV_L"
476 #define UDIVSI3_LIBCALL "OTS$DIV_UI"
477 #define UDIVDI3_LIBCALL "OTS$DIV_UL"
478 #define MODSI3_LIBCALL "OTS$REM_I"
479 #define MODDI3_LIBCALL "OTS$REM_L"
480 #define UMODSI3_LIBCALL "OTS$REM_UI"
481 #define UMODDI3_LIBCALL "OTS$REM_UL"
482
483 #define NAME__MAIN "__gccmain"
484 #define SYMBOL__MAIN __gccmain
485
486 #define MD_EXEC_PREFIX "/gnu/lib/gcc-lib/"
487 #define MD_STARTFILE_PREFIX "/gnu/lib/gcc-lib/"
488
489 /* Specify the list of include file directories.  */
490 #define INCLUDE_DEFAULTS                   \
491 {                                          \
492   { "/gnu/lib/gcc-lib/include", 0, 0, 0 }, \
493   { "/gnu_gxx_include", 0, 1, 1 },         \
494   { "/gnu_cc_include", 0, 0, 0 },          \
495   { "/gnu/include", 0, 0, 0 },             \
496   { 0, 0, 0, 0 }                           \
497 }
498
499 #define LONGLONG_STANDALONE 1