OSDN Git Service

8b33a8d224ded2884ca5d165ea28ad5f5656c66a
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / vms.h
1 /* Output variables, constants and external declarations, for GNU compiler.
2    Copyright (C) 1996, 1997 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 OPEN_VMS 1
22
23 /* This enables certain macros in alpha.h, which will make an indirect
24    reference to an external symbol an invalid address.  This needs to be
25    defined before we include alpha.h, since it determines which macros
26    are used for GO_IF_*.  */
27
28 #define NO_EXTERNAL_INDIRECT_ADDRESS
29
30 #include "alpha/alpha.h"
31
32 /* Predefine this in CPP because VMS limits the size of command options
33    and GNU CPP is not used on VMS except with GNU C.  */
34 #undef CPP_PREDEFINES
35 #define CPP_PREDEFINES \
36 "-Dalpha -D__ALPHA -Dvms -DVMS -D__alpha__ -D__alpha -D__vms__ -D__VMS__\
37  -D__VMS_VER=70000022 \
38  -D__GNUC__=2 -D__GNUC_MINOR__=7 -Asystem(vms) -Acpu(alpha) -Amachine(alpha)"
39
40 #undef CPP_SPEC
41 #define CPP_SPEC "\
42 %{mfloat-ieee:-D__IEEE_FLOAT} \
43 %{mfloat-vax:-D__G_FLOAT} \
44 %{!mfloat-vax:-D__IEEE_FLOAT} \
45 %{!.S:  -D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}  \
46 %{.S:   -D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
47 %{.cc:  -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
48 %{.cxx: -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
49 %{.C:   -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
50 %{.m:   -D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C}"
51
52 /* We allow $'s in identifiers unless -ansi is used .. */
53
54 #define DOLLARS_IN_IDENTIFIERS 2
55
56 /* These match the definitions used in DECCRTL, the VMS C run-time library
57
58 #define SIZE_TYPE       "unsigned int"
59 #define PTRDIFF_TYPE    "int"
60 */
61
62 /* Use memcpy for structure copying, and so forth.  */
63 #define TARGET_MEM_FUNCTIONS
64
65 /* By default, allow $ to be part of an identifier.  */
66 #define DOLLARS_IN_IDENTIFIERS 2
67
68 #undef TARGET_DEFAULT
69 #define TARGET_DEFAULT (MASK_FP|MASK_FPREGS|MASK_GAS|MASK_OPEN_VMS)
70 #undef TARGET_NAME   
71 #define TARGET_NAME "OpenVMS/Alpha"
72 #undef TARGET_VERSION
73 #define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);           
74
75 /* The structure return address arrives as an "argument" on VMS.  */
76 #undef STRUCT_VALUE_REGNUM
77 #define STRUCT_VALUE 0
78 #undef PCC_STATIC_STRUCT_RETURN
79
80 /* no floating emulation.  */
81 #undef REAL_ARITHMETIC
82
83 /* "long" is 32 bits.  */
84 #undef LONG_TYPE_SIZE
85 #define LONG_TYPE_SIZE 32
86
87 /* Pointer is 32 bits but the hardware has 64-bit addresses, sign extended. */
88 #undef POINTER_SIZE
89 #define POINTER_SIZE 32
90 #define POINTERS_EXTEND_UNSIGNED 0
91
92 #define MAX_OFILE_ALIGNMENT 524288  /* 8 x 2^16 by DEC Ada Test CD40VRA */
93
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 }
100
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 }
107
108 #undef HARD_FRAME_POINTER_REGNUM
109 #define HARD_FRAME_POINTER_REGNUM 29
110
111 #undef CAN_ELIMINATE
112 #define CAN_ELIMINATE(FROM, TO)  \
113 ((TO) != STACK_POINTER_REGNUM || ! alpha_using_fp ())
114
115 #undef INITIAL_ELIMINATION_OFFSET
116 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
117 { if ((FROM) == FRAME_POINTER_REGNUM)                                   \
118     (OFFSET) = alpha_sa_size () + alpha_pv_save_size ();                \
119   else if ((FROM) == ARG_POINTER_REGNUM)                                \
120     (OFFSET) = (ALPHA_ROUND (alpha_sa_size () + alpha_pv_save_size ()   \
121                              + get_frame_size ()                        \
122                              + current_function_pretend_args_size)      \
123                 - current_function_pretend_args_size);                  \
124   if ((TO) == STACK_POINTER_REGNUM)                                     \
125     (OFFSET) += ALPHA_ROUND (current_function_outgoing_args_size);      \
126 }
127 \f
128 /* Define a data type for recording info about an argument list
129    during the scan of that argument list.  This data type should
130    hold all necessary information about the function itself
131    and about the args processed so far, enough to enable macros
132    such as FUNCTION_ARG to determine where the next arg should go.
133
134    On Alpha/VMS, this is a structure that contains the number of
135    arguments and, for each argument, the datatype of that argument.
136
137    The number of arguments is a number of words of arguments scanned so far.
138    Thus 6 or more means all following args should go on the stack.  */
139
140 enum avms_arg_type {I64, FF, FD, FG, FS, FT};
141 typedef struct {char num_args; enum avms_arg_type atypes[6];} avms_arg_info;
142
143 #undef CUMULATIVE_ARGS
144 #define CUMULATIVE_ARGS avms_arg_info
145
146 /* Initialize a variable CUM of type CUMULATIVE_ARGS
147    for a call to a function whose data type is FNTYPE.
148    For a library call, FNTYPE is 0.  */
149
150 #undef INIT_CUMULATIVE_ARGS
151 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
152   (CUM).num_args = 0;                                           \
153   (CUM).atypes[0] = (CUM).atypes[1] = (CUM).atypes[2] = I64;    \
154   (CUM).atypes[3] = (CUM).atypes[4] = (CUM).atypes[5] = I64;
155
156 /* Update the data in CUM to advance over an argument
157    of mode MODE and data type TYPE.
158    (TYPE is null for libcalls where that information may not be available.)  */
159
160 extern enum avms_arg_type alpha_arg_type ();
161
162 /* Determine where to put an argument to a function.
163    Value is zero to push the argument on the stack,
164    or a hard register in which to store the argument.
165
166    MODE is the argument's machine mode (or VOIDmode for no more args).
167    TYPE is the data type of the argument (as a tree).
168     This is null for libcalls where that information may
169     not be available.
170    CUM is a variable of type CUMULATIVE_ARGS which gives info about
171     the preceding args and about the function being called.
172    NAMED is nonzero if this argument is a named parameter
173     (otherwise it is an extra parameter matching an ellipsis).
174
175    On Alpha the first 6 words of args are normally in registers
176    and the rest are pushed.  */
177
178 extern struct rtx_def *alpha_arg_info_reg_val ();
179 #undef FUNCTION_ARG
180 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)    \
181 ((MODE) == VOIDmode ? alpha_arg_info_reg_val (CUM)              \
182  : ((CUM.num_args) < 6 && ! MUST_PASS_IN_STACK (MODE, TYPE)     \
183     ? gen_rtx(REG, (MODE),                                      \
184               ((CUM).num_args + 16                              \
185                + ((TARGET_FPREGS                                \
186                    && (GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
187                        || GET_MODE_CLASS (MODE) == MODE_FLOAT)) \
188                   * 32)))                       \
189     : 0))
190
191 #undef FUNCTION_ARG_ADVANCE
192 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)                    \
193   if (MUST_PASS_IN_STACK (MODE, TYPE))                                  \
194     (CUM).num_args += 6;                                                \
195   else                                                                  \
196     {                                                                   \
197       if ((CUM).num_args < 6)                                           \
198         (CUM).atypes[(CUM).num_args] = alpha_arg_type (MODE);           \
199                                                                         \
200      (CUM).num_args += ALPHA_ARG_SIZE (MODE, TYPE, NAMED);              \
201     }
202
203 /* For an arg passed partly in registers and partly in memory,
204    this is the number of registers used.
205    For args passed entirely in registers or entirely in memory, zero.  */
206
207 #undef FUNCTION_ARG_PARTIAL_NREGS
208 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED)              \
209 ((CUM).num_args < 6 && 6 < (CUM).num_args                               \
210    + ALPHA_ARG_SIZE (MODE, TYPE, NAMED)                                 \
211  ? 6 - (CUM).num_args : 0)
212
213 /* Perform any needed actions needed for a function that is receiving a
214    variable number of arguments. 
215
216    CUM is as for INIT_CUMULATIVE_ARGS.
217
218    MODE and TYPE are the mode and type of the current parameter.
219
220    PRETEND_SIZE is a variable that should be set to the amount of stack
221    that must be pushed by the prolog to pretend that our caller pushed
222    it.
223
224    Normally, this macro will push all remaining incoming registers on the
225    stack and set PRETEND_SIZE to the length of the registers pushed. 
226
227    For VMS, we allocate space for all 6 arg registers plus a count.
228
229    However, if NO registers need to be saved, don't allocate any space.
230    This is not only because we won't need the space, but because AP includes
231    the current_pretend_args_size and we don't want to mess up any
232    ap-relative addresses already made.   */
233
234 #undef SETUP_INCOMING_VARARGS
235 #define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL)       \
236 { if ((CUM).num_args < 6)                               \
237     {                                                   \
238       if (! (NO_RTL))                                   \
239         {                                               \
240           emit_move_insn (gen_rtx (REG, DImode, 1),     \
241                           virtual_incoming_args_rtx);   \
242           emit_insn (gen_arg_home ());                  \
243         }                                               \
244                                                         \
245       PRETEND_SIZE = 7 * UNITS_PER_WORD;                \
246     }                                                   \
247 }
248
249 #undef ASM_FILE_START
250 #define ASM_FILE_START(FILE)                                    \
251 {                                                               \
252   alpha_write_verstamp (FILE);                                  \
253   fprintf (FILE, "\t.set noreorder\n");                         \
254   fprintf (FILE, "\t.set volatile\n");                          \
255   ASM_OUTPUT_SOURCE_FILENAME (FILE, main_input_filename);       \
256 }
257
258 #undef ASM_OUTPUT_FLOAT
259 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                                    \
260   {                                                                     \
261     if (REAL_VALUE_ISINF (VALUE)                                        \
262         || REAL_VALUE_ISNAN (VALUE)                                     \
263         || REAL_VALUE_MINUS_ZERO (VALUE))                               \
264       {                                                                 \
265         long t;                                                         \
266         REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t);                       \
267         fprintf (FILE, "\t.long 0x%lx\n", t & 0xffffffff);              \
268       }                                                                 \
269     else                                                                \
270       {                                                                 \
271         char str[30];                                                   \
272         REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str);                  \
273         fprintf (FILE, "\t.%c_floating %s\n", (TARGET_FLOAT_VAX)?'f':'s', str); \
274       }                                                                 \
275   }
276
277 #define LINK_SECTION_ASM_OP ".link"
278 #define READONLY_SECTION_ASM_OP ".rdata"
279 #define LITERALS_SECTION_ASM_OP ".literals"
280
281 #undef EXTRA_SECTIONS
282 #define EXTRA_SECTIONS  in_link, in_rdata, in_literals
283
284 #undef EXTRA_SECTION_FUNCTIONS
285 #define EXTRA_SECTION_FUNCTIONS                                 \
286 void                                                            \
287 readonly_section ()                                             \
288 {                                                               \
289   if (in_section != in_rdata)                           \
290     {                                                           \
291       fprintf (asm_out_file, "%s\n", READONLY_SECTION_ASM_OP);  \
292       in_section = in_rdata;                            \
293     }                                                           \
294 }                                                               \
295 void                                                            \
296 link_section ()                                                 \
297 {                                                               \
298   if (in_section != in_link)                                    \
299     {                                                           \
300       fprintf (asm_out_file, "%s\n", LINK_SECTION_ASM_OP);      \
301       in_section = in_link;                                     \
302     }                                                           \
303 }                                                               \
304 void                                                            \
305 literals_section ()                                             \
306 {                                                               \
307   if (in_section != in_literals)                                \
308     {                                                           \
309       fprintf (asm_out_file, "%s\n", LITERALS_SECTION_ASM_OP);  \
310       in_section = in_literals;                                 \
311     }                                                           \
312 }
313
314 #undef ASM_OUTPUT_ADDR_DIFF_ELT
315 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, 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 #define NO_MD_PROTOTYPES
335 \f
336 /* Output assembler code for a block containing the constant parts
337    of a trampoline, leaving space for the variable parts.
338
339    The trampoline should set the static chain pointer to value placed
340    into the trampoline and should branch to the specified routine.  
341    Note that $27 has been set to the address of the trampoline, so we can
342    use it for addressability of the two data items.  Trampolines are always
343    aligned to FUNCTION_BOUNDARY, which is 64 bits.  */
344
345 #undef TRAMPOLINE_TEMPLATE
346 #define TRAMPOLINE_TEMPLATE(FILE)               \
347 {                                               \
348   fprintf (FILE, "\t.quad 0\n");                \
349   fprintf (FILE, "\t.linkage __tramp\n");       \
350   fprintf (FILE, "\t.quad 0\n");                \
351 }
352
353 /* Length in units of the trampoline for entering a nested function.  */
354
355 #undef TRAMPOLINE_SIZE
356 #define TRAMPOLINE_SIZE    32
357
358 /* Emit RTL insns to initialize the variable parts of a trampoline.
359    FNADDR is an RTX for the address of the function's pure code.
360    CXT is an RTX for the static chain value for the function.  */
361
362 #undef INITIALIZE_TRAMPOLINE
363 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                         \
364 {                                                                         \
365   emit_move_insn (gen_rtx (MEM, Pmode,                                    \
366                            memory_address (Pmode,                         \
367                                            plus_constant ((TRAMP), 16))), \
368                   (FNADDR));                                              \
369   emit_move_insn (gen_rtx (MEM, Pmode,                                    \
370                            memory_address (Pmode,                         \
371                                            plus_constant ((TRAMP), 24))), \
372                   (CXT));                                                 \
373 }
374
375 #undef TRANSFER_FROM_TRAMPOLINE
376
377 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, NAME, ARGS) \
378   (vms_valid_decl_attribute_p (DECL, ATTRIBUTES, NAME, ARGS))
379 extern int vms_valid_decl_attribute_p ();
380
381 #undef SDB_DEBUGGING_INFO
382 #undef MIPS_DEBUGGING_INFO
383 #undef DBX_DEBUGGING_INFO
384
385 #define DWARF2_DEBUGGING_INFO
386
387 /* This is how to output an assembler line
388    that says to advance the location counter
389    to a multiple of 2**LOG bytes.  */
390
391 #undef ASM_OUTPUT_ALIGN
392 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
393     fprintf (FILE, "\t.align %d\n", LOG);
394
395 #define UNALIGNED_SHORT_ASM_OP  ".word"
396 #define UNALIGNED_INT_ASM_OP    ".long"
397 #define UNALIGNED_DOUBLE_INT_ASM_OP     ".quad"
398
399 #undef ASM_OUTPUT_ALIGNED_COMMON
400 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)              \
401 do {                                                                    \
402   fprintf ((FILE), "\t.comm\t");                                        \
403   assemble_name ((FILE), (NAME));                                       \
404   fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);        \
405 } while (0)
406
407 #define ASM_OUTPUT_SECTION(FILE,SECTION)                        \
408    (strcmp (SECTION, ".text") == 0)                             \
409      ? text_section ()                                          \
410      : named_section (NULL_TREE, SECTION, 0),                   \
411        ASM_OUTPUT_ALIGN (FILE, 0)                               \
412
413 #define ASM_OUTPUT_SECTION_NAME(FILE,DECL,NAME,RELOC)           \
414   do                                                            \
415     {                                                           \
416       char *flags;                                              \
417       int ovr = 0;                                              \
418       if (DECL && DECL_MACHINE_ATTRIBUTES (DECL)                \
419           && lookup_attribute                                   \
420               ("overlaid", DECL_MACHINE_ATTRIBUTES (DECL)))     \
421         flags = ",OVR", ovr = 1;                                \
422       else if (strncmp (NAME,".debug", 6) == 0)                 \
423         flags = ",NOWRT";                                       \
424       else                                                      \
425         flags = "";                                             \
426       fputc ('\n', (FILE));                                     \
427       fprintf (FILE, ".section\t%s%s\n", NAME, flags);          \
428       if (ovr)                                                  \
429         (NAME) = "";                                            \
430     } while (0)
431
432 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                              \
433   do {  literals_section();                                             \
434         fprintf ((FILE), "\t");                                         \
435         assemble_name (FILE, LABEL1);                                   \
436         fprintf (FILE, " = ");                                          \
437         assemble_name (FILE, LABEL2);                                   \
438         fprintf (FILE, "\n");                                           \
439   } while (0)
440
441 #undef PREFERRED_DEBUGGING_TYPE
442 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
443
444 #undef ASM_FORMAT_PRIVATE_NAME
445 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO)  \
446 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 12),    \
447   sprintf ((OUTPUT), "%s___%d", (NAME), (LABELNO)))
448
449 #undef ASM_SPEC
450 #undef ASM_FINAL_SPEC
451 #undef LINK_SPEC
452 #undef STARTFILE_SPEC
453 #define ASM_SPEC "-nocpp %{pg}"
454 #define LINK_SPEC "%{g3:-g3} %{g0:-g0} %{shared:-shared} %{v:-v}"
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"