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