1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1996, 1997, 1998, 2000, 2001 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 #define TARGET_OBJECT_SUFFIX ".obj"
22 #define TARGET_EXECUTABLE_SUFFIX ".exe"
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_*. */
29 #define NO_EXTERNAL_INDIRECT_ADDRESS
31 #include "alpha/alpha.h"
34 #define CPP_PREDEFINES \
35 "-D__ALPHA -Dvms -DVMS -D__vms__ -D__VMS__ -Asystem=vms"
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}"
43 /* Under OSF4, -p and -pg require -lprof1, and -lprof1 requires -lpdf. */
45 #define LIB_SPEC "%{p:-lprof1 -lpdf} %{pg:-lprof1 -lpdf} %{a:-lprof2} -lc"
47 /* Pass "-G 8" to ld because Alpha's CC does. Pass -O3 if we are
48 optimizing, -O1 if we are not. Pass -shared, -non_shared or
49 -call_shared as appropriate. Also pass -pg. */
51 "-G 8 %{O*:-O3} %{!O*:-O1} %{static:-non_shared} \
52 %{!static:%{shared:-shared} %{!shared:-call_shared}} %{pg} %{taso} \
55 /* We allow $'s in identifiers unless -ansi is used .. */
57 #define DOLLARS_IN_IDENTIFIERS 2
59 /* These match the definitions used in DECCRTL, the VMS C run-time library
61 #define SIZE_TYPE "unsigned int"
62 #define PTRDIFF_TYPE "int"
65 /* By default, allow $ to be part of an identifier. */
66 #define DOLLARS_IN_IDENTIFIERS 2
69 #define TARGET_DEFAULT (MASK_FP|MASK_FPREGS|MASK_GAS)
70 #undef TARGET_ABI_OPEN_VMS
71 #define TARGET_ABI_OPEN_VMS 1
74 #define TARGET_NAME "OpenVMS/Alpha"
76 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
78 /* The structure return address arrives as an "argument" on VMS. */
79 #undef STRUCT_VALUE_REGNUM
80 #define STRUCT_VALUE 0
81 #undef PCC_STATIC_STRUCT_RETURN
83 /* "long" is 32 bits. */
85 #define LONG_TYPE_SIZE 32
87 /* Pointer is 32 bits but the hardware has 64-bit addresses, sign extended. */
89 #define POINTER_SIZE 32
90 #define POINTERS_EXTEND_UNSIGNED 0
92 #define MAX_OFILE_ALIGNMENT 524288 /* 8 x 2^16 by DEC Ada Test CD40VRA */
94 #undef FIXED_REGISTERS
95 #define FIXED_REGISTERS \
96 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
97 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, \
98 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
99 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
101 #undef CALL_USED_REGISTERS
102 #define CALL_USED_REGISTERS \
103 {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
104 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
105 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, \
106 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
108 /* List the order in which to allocate registers. Each register must be
109 listed once, even those in FIXED_REGISTERS.
111 We allocate in the following order:
112 $f1 (nonsaved floating-point register)
115 $f21-$f16 (likewise, but input args)
116 $f0 (nonsaved, but return value)
117 $f2-$f9 (saved floating-point registers)
118 $1 (nonsaved integer registers)
121 $0 (likewise, but return value)
122 $21-$16 (likewise, but input args)
123 $27 (procedure value in OSF, nonsaved in NT)
124 $2-$8 (saved integer registers)
125 $9-$14 (saved integer registers)
129 $30, $31, $f31 (stack pointer and always zero/ap & fp) */
131 #undef REG_ALLOC_ORDER
132 #define REG_ALLOC_ORDER \
134 42, 43, 44, 45, 46, 47, \
135 54, 55, 56, 57, 58, 59, 60, 61, 62, \
136 53, 52, 51, 50, 49, 48, \
138 34, 35, 36, 37, 38, 39, 40, 41, \
143 21, 20, 19, 18, 17, 16, \
145 2, 3, 4, 5, 6, 7, 8, \
146 9, 10, 11, 12, 13, 14, \
152 #undef HARD_FRAME_POINTER_REGNUM
153 #define HARD_FRAME_POINTER_REGNUM 29
155 /* Define registers used by the epilogue and return instruction. */
157 #define EPILOGUE_USES(REGNO) ((REGNO) == 26 || (REGNO) == 29)
160 #define CAN_ELIMINATE(FROM, TO) \
161 ((TO) != STACK_POINTER_REGNUM || ! alpha_using_fp ())
163 #undef INITIAL_ELIMINATION_OFFSET
164 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
165 { if ((FROM) == FRAME_POINTER_REGNUM) \
166 (OFFSET) = alpha_sa_size () + alpha_pv_save_size (); \
167 else if ((FROM) == ARG_POINTER_REGNUM) \
168 (OFFSET) = (ALPHA_ROUND (alpha_sa_size () + alpha_pv_save_size () \
169 + get_frame_size () \
170 + current_function_pretend_args_size) \
171 - current_function_pretend_args_size); \
172 if ((TO) == STACK_POINTER_REGNUM) \
173 (OFFSET) += ALPHA_ROUND (current_function_outgoing_args_size); \
176 /* Define a data type for recording info about an argument list
177 during the scan of that argument list. This data type should
178 hold all necessary information about the function itself
179 and about the args processed so far, enough to enable macros
180 such as FUNCTION_ARG to determine where the next arg should go.
182 On Alpha/VMS, this is a structure that contains the number of
183 arguments and, for each argument, the datatype of that argument.
185 The number of arguments is a number of words of arguments scanned so far.
186 Thus 6 or more means all following args should go on the stack. */
188 enum avms_arg_type {I64, FF, FD, FG, FS, FT};
189 typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info;
191 #undef CUMULATIVE_ARGS
192 #define CUMULATIVE_ARGS avms_arg_info
194 /* Initialize a variable CUM of type CUMULATIVE_ARGS
195 for a call to a function whose data type is FNTYPE.
196 For a library call, FNTYPE is 0. */
198 #undef INIT_CUMULATIVE_ARGS
199 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
200 (CUM).num_args = 0; \
201 (CUM).atypes[0] = (CUM).atypes[1] = (CUM).atypes[2] = I64; \
202 (CUM).atypes[3] = (CUM).atypes[4] = (CUM).atypes[5] = I64;
204 #undef FUNCTION_ARG_ADVANCE
205 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
206 if (MUST_PASS_IN_STACK (MODE, TYPE)) \
207 (CUM).num_args += 6; \
210 if ((CUM).num_args < 6) \
211 (CUM).atypes[(CUM).num_args] = alpha_arg_type (MODE); \
213 (CUM).num_args += ALPHA_ARG_SIZE (MODE, TYPE, NAMED); \
216 /* For an arg passed partly in registers and partly in memory,
217 this is the number of registers used.
218 For args passed entirely in registers or entirely in memory, zero. */
220 #undef FUNCTION_ARG_PARTIAL_NREGS
221 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
222 ((CUM).num_args < 6 && 6 < (CUM).num_args \
223 + ALPHA_ARG_SIZE (MODE, TYPE, NAMED) \
224 ? 6 - (CUM).num_args : 0)
226 /* Perform any needed actions needed for a function that is receiving a
227 variable number of arguments.
229 CUM is as for INIT_CUMULATIVE_ARGS.
231 MODE and TYPE are the mode and type of the current parameter.
233 PRETEND_SIZE is a variable that should be set to the amount of stack
234 that must be pushed by the prolog to pretend that our caller pushed
237 Normally, this macro will push all remaining incoming registers on the
238 stack and set PRETEND_SIZE to the length of the registers pushed.
240 For VMS, we allocate space for all 6 arg registers plus a count.
242 However, if NO registers need to be saved, don't allocate any space.
243 This is not only because we won't need the space, but because AP includes
244 the current_pretend_args_size and we don't want to mess up any
245 ap-relative addresses already made. */
247 #undef SETUP_INCOMING_VARARGS
248 #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \
249 { if ((CUM).num_args < 6) \
253 emit_move_insn (gen_rtx_REG (DImode, 1), \
254 virtual_incoming_args_rtx); \
255 emit_insn (gen_arg_home ()); \
258 PRETEND_SIZE = 7 * UNITS_PER_WORD; \
262 #undef ASM_FILE_START
263 #define ASM_FILE_START(FILE) \
265 alpha_write_verstamp (FILE); \
266 fprintf (FILE, "\t.set noreorder\n"); \
267 fprintf (FILE, "\t.set volatile\n"); \
268 ASM_OUTPUT_SOURCE_FILENAME (FILE, main_input_filename); \
271 #undef ASM_OUTPUT_FLOAT
272 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
274 if (REAL_VALUE_ISINF (VALUE) \
275 || REAL_VALUE_ISNAN (VALUE) \
276 || REAL_VALUE_MINUS_ZERO (VALUE)) \
279 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \
280 fprintf (FILE, "\t.long 0x%lx\n", t & 0xffffffff); \
285 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \
286 fprintf (FILE, "\t.%c_floating %s\n", (TARGET_FLOAT_VAX)?'f':'s', str); \
290 #define LINK_SECTION_ASM_OP "\t.link"
291 #define READONLY_SECTION_ASM_OP "\t.rdata"
292 #define LITERALS_SECTION_ASM_OP "\t.literals"
293 #define CTORS_SECTION_ASM_OP "\t.ctors"
294 #define DTORS_SECTION_ASM_OP "\t.dtors"
296 #undef EXTRA_SECTIONS
297 #define EXTRA_SECTIONS in_link, in_rdata, in_literals
299 #undef EXTRA_SECTION_FUNCTIONS
300 #define EXTRA_SECTION_FUNCTIONS \
302 readonly_section () \
304 if (in_section != in_rdata) \
306 fprintf (asm_out_file, "%s\n", READONLY_SECTION_ASM_OP); \
307 in_section = in_rdata; \
313 if (in_section != in_link) \
315 fprintf (asm_out_file, "%s\n", LINK_SECTION_ASM_OP); \
316 in_section = in_link; \
320 literals_section () \
322 if (in_section != in_literals) \
324 fprintf (asm_out_file, "%s\n", LITERALS_SECTION_ASM_OP); \
325 in_section = in_literals; \
329 extern void readonly_section PARAMS ((void));
330 extern void link_section PARAMS ((void));
331 extern void literals_section PARAMS ((void));
333 #undef ASM_OUTPUT_ADDR_DIFF_ELT
334 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) abort ()
336 #undef ASM_OUTPUT_ADDR_VEC_ELT
337 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
338 fprintf (FILE, "\t.quad $L%d\n", (VALUE))
340 #undef READONLY_DATA_SECTION
341 #define READONLY_DATA_SECTION readonly_section
343 #define ASM_FILE_END(FILE) alpha_write_linkage (FILE);
345 #undef CASE_VECTOR_MODE
346 #define CASE_VECTOR_MODE DImode
347 #undef CASE_VECTOR_PC_RELATIVE
349 #undef ASM_OUTPUT_CASE_LABEL
350 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,TABLEINSN) \
351 { ASM_OUTPUT_ALIGN (FILE, 3); ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); }
353 /* This says how to output assembler code to declare an
354 uninitialized external linkage data object. */
356 #define COMMON_ASM_OP "\t.comm\t"
358 #undef ASM_OUTPUT_ALIGNED_COMMON
359 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
361 fprintf ((FILE), "%s", COMMON_ASM_OP); \
362 assemble_name ((FILE), (NAME)); \
363 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
367 /* Output assembler code for a block containing the constant parts
368 of a trampoline, leaving space for the variable parts.
370 The trampoline should set the static chain pointer to value placed
371 into the trampoline and should branch to the specified routine.
372 Note that $27 has been set to the address of the trampoline, so we can
373 use it for addressability of the two data items. Trampolines are always
374 aligned to FUNCTION_BOUNDARY, which is 64 bits. */
376 #undef TRAMPOLINE_TEMPLATE
377 #define TRAMPOLINE_TEMPLATE(FILE) \
379 fprintf (FILE, "\t.quad 0\n"); \
380 fprintf (FILE, "\t.linkage __tramp\n"); \
381 fprintf (FILE, "\t.quad 0\n"); \
384 /* Length in units of the trampoline for entering a nested function. */
386 #undef TRAMPOLINE_SIZE
387 #define TRAMPOLINE_SIZE 32
389 /* Emit RTL insns to initialize the variable parts of a trampoline.
390 FNADDR is an RTX for the address of the function's pure code.
391 CXT is an RTX for the static chain value for the function. */
393 #undef INITIALIZE_TRAMPOLINE
394 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
395 alpha_initialize_trampoline (TRAMP, FNADDR, CXT, 16, 24, -1)
397 /* Control how constructors and destructors are emitted. */
398 #define TARGET_ASM_CONSTRUCTOR vms_asm_out_constructor
399 #define TARGET_ASM_DESTRUCTOR vms_asm_out_destructor
401 #undef SDB_DEBUGGING_INFO
402 #undef MIPS_DEBUGGING_INFO
403 #undef DBX_DEBUGGING_INFO
405 #define DWARF2_DEBUGGING_INFO
407 /* This is how to output an assembler line
408 that says to advance the location counter
409 to a multiple of 2**LOG bytes. */
411 #undef ASM_OUTPUT_ALIGN
412 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
413 fprintf (FILE, "\t.align %d\n", LOG);
415 /* Switch into a generic section. */
416 #define TARGET_ASM_NAMED_SECTION vms_asm_named_section
418 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
419 do { literals_section(); \
420 fprintf ((FILE), "\t"); \
421 assemble_name (FILE, LABEL1); \
422 fprintf (FILE, " = "); \
423 assemble_name (FILE, LABEL2); \
424 fprintf (FILE, "\n"); \
427 #undef PREFERRED_DEBUGGING_TYPE
428 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
430 #undef ASM_FORMAT_PRIVATE_NAME
431 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
432 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 12), \
433 sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
435 /* ??? VMS uses different linkage. */
436 #undef ASM_OUTPUT_MI_THUNK
439 #undef ASM_FINAL_SPEC
441 #undef STARTFILE_SPEC
442 #define ASM_SPEC "-nocpp %{pg}"
443 #define LINK_SPEC "%{g3:-g3} %{g0:-g0} %{shared:-shared} %{v:-v}"
445 /* Define the names of the division and modulus functions. */
446 #define DIVSI3_LIBCALL "OTS$DIV_I"
447 #define DIVDI3_LIBCALL "OTS$DIV_L"
448 #define UDIVSI3_LIBCALL "OTS$DIV_UI"
449 #define UDIVDI3_LIBCALL "OTS$DIV_UL"
450 #define MODSI3_LIBCALL "OTS$REM_I"
451 #define MODDI3_LIBCALL "OTS$REM_L"
452 #define UMODSI3_LIBCALL "OTS$REM_UI"
453 #define UMODDI3_LIBCALL "OTS$REM_UL"
455 /* crt0 calls __main */
456 #define HAS_INIT_SECTION
458 /* XXX Really? Even with modern CRTL? */