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