]>
gcc.gnu.org Git - gcc.git/blob - gcc/config/vax/vms.h
1 /* Output variables, constants and external declarations, for GNU compiler.
2 Copyright (C) 1988 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* This enables certain macros in vax.h, which will make an indirect
21 reference to an external symbol an invalid address. This needs to be
22 defined before we include vax.h, since it determines which macros
23 are used for GO_IF_*. */
25 #define NO_EXTERNAL_INDIRECT_ADDRESS
33 #undef CALL_USED_REGISTERS
34 #undef MAYBE_VMS_FUNCTION_PROLOGUE
36 /* Predefine this in CPP because VMS limits the size of command options
37 and GNU CPP is not used on VMS except with GNU C. */
38 /* ??? __GNU__ is probably obsolete; delete it for 2.1. */
39 #define CPP_PREDEFINES "-Dvax -Dvms -DVMS -D__GNU__ -D__GNUC__=2"
41 /* These match the definitions used in VAXCRTL, the VMS C run-time library */
43 #define SIZE_TYPE "unsigned int"
44 #define PTRDIFF_TYPE "int"
45 #define WCHAR_TYPE "unsigned int"
47 /* Use memcpy for structure copying, and so forth. */
48 #define TARGET_MEM_FUNCTIONS
50 /* Strictly speaking, VMS does not use DBX at all, but the interpreter built
51 into gas only speaks straight DBX. */
53 #define DEFAULT_GDB_EXTENSIONS 0
55 /* By default, allow $ to be part of an identifier. */
56 #define DOLLARS_IN_IDENTIFIERS 2
58 #define TARGET_DEFAULT 1
59 #define TARGET_VERSION fprintf (stderr, " (vax vms)");
61 #define CALL_USED_REGISTERS {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
63 #define __MAIN_NAME " main ("
65 * The MAYBE_VMS_FUNCTION_PROLOGUE macro works for both gcc and g++. It
66 * first checks to see if the current routine is "main", which will only
67 * happen for GCC, and add the jsb if it is. If is not the case then try and
68 * see if __MAIN_NAME is part of current_function_name, which will only happen
69 * if we are running g++, and add the jsb if it is. In gcc there should never
70 * be a space in the function name, and in g++ there is always a "(" in the
71 * function name, thus there should never be any confusion.
73 #define MAYBE_VMS_FUNCTION_PROLOGUE(FILE) \
74 { extern char *current_function_name; \
75 if (!strcmp ("main", current_function_name)) \
76 fprintf(FILE, "\tjsb _c$main_args\n"); \
78 char *p = current_function_name; \
80 if (*p == *__MAIN_NAME) \
81 if (strncmp(p, __MAIN_NAME, (sizeof __MAIN_NAME)-1) == 0) {\
82 fprintf(FILE, "\tjsb _c$main_args\n");\
91 /* This macro definition sets up a default value for `main' to return. */
92 #define DEFAULT_MAIN_RETURN c_expand_return (integer_one_node)
94 /* This makes use of a hook in varasm.c to mark all external variables
95 for us. We use this to make sure that external variables are correctly
96 addressed. Under VMS there is some brain damage in the linker that requires
99 #define ENCODE_SECTION_INFO(decl) \
100 if (TREE_EXTERNAL (decl) && TREE_PUBLIC (decl)) \
101 SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0)) = 1;
103 /* Under VMS we write the actual size of the storage to be allocated even
104 though the symbol is external. Although it is possible to give external
105 symbols a size of 0 (as unix does), the VMS linker does not make the
106 distinction between a variable definition and an external reference of a
107 variable, and thus the linker will not complain about a missing definition.
108 If we followed the unix example of giving external symbols a size of
109 zero, you tried to link a program where a given variable was externally
110 defined but none of the object modules contained a non-extern definition,
111 the linker would allocate 0 bytes for the variable, and any attempt to
112 use that variable would use the storage allocated to some other variable.
114 We must also select either const_section or data_section: this will indicate
115 whether or not the variable will get the readonly bit set. Since the
116 VMS linker does not distinguish between a variable's definition and an
117 external reference, all usages of a given variable must have the readonly
118 bit set the same way, or the linker will get confused and give warning
121 /* We used to round the size up to a multiple of 4,
122 but that causes linker errors sometimes when the variable was initialized
123 since the size of its definition was not likewise rounded up. */
125 #define ASM_OUTPUT_EXTERNAL(FILE,DECL,NAME) \
126 { if (DECL_INITIAL (DECL) == 0 && TREE_CODE (DECL) != FUNCTION_DECL) \
128 if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl)) \
132 fputs (".comm ", (FILE)); \
133 assemble_name ((FILE), (NAME)); \
134 if (DECL_SIZE (DECL) == 0) \
135 fprintf ((FILE), ",0\n"); \
139 size_tree = size_binop (CEIL_DIV_EXPR, \
140 DECL_SIZE (DECL), size_int (BITS_PER_UNIT)); \
141 fprintf ((FILE), ",%d\n", TREE_INT_CST_LOW (size_tree)); \
146 /* Here we redefine ASM_OUTPUT_COMMON to select the data_section or the
147 const_section before writing the ".const" assembler directive.
148 If we were specifying a size of zero for external variables, we would
149 not have to select a section, since the assembler can assume that
150 when the size > 0, the storage is for a non-external, uninitialized
151 variable (for which a "const" declaration would be senseless),
152 and the assembler can make the storage read/write.
154 Since the ".const" directive specifies the actual size of the storage used
155 for both external and non-external variables, the assembler cannot
156 make this assumption, and thus it has no way of deciding if storage should
157 be read/write or read-only. To resolve this, we give the assembler some
158 assistance, in the form of a ".const" or a ".data" directive.
160 Under GCC 1.40, external variables were declared with a size of zero.
161 The GNU assembler, GAS, will recognize the "-2" switch when built for VMS;
162 when compiling programs with GCC 2.n this switch should be used or the
163 assembler will not give the read-only attribute to external constants.
164 Failure to use this switch will result in linker warning messages about
165 mismatched psect attributes. */
167 #undef ASM_OUTPUT_COMMON
169 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
170 ( ((TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl)) \
171 ? (const_section (), 0) : (data_section (), 0)), \
172 fputs (".comm ", (FILE)), \
173 assemble_name ((FILE), (NAME)), \
174 fprintf ((FILE), ",%u\n", (SIZE)))
176 /* We define this to prevent the name mangler from putting dollar signs into
177 function names. This isn't really needed, but it has been here for
178 some time and removing it would cause the object files generated by the
179 compiler to be incompatible with the object files from a compiler that
180 had this defined. Since it does no harm, we leave it in. */
182 #define NO_DOLLAR_IN_LABEL
184 /* Add a "const" section. This is viewed by the assembler as being nearly
185 the same as the "data" section, with the only difference being that a
186 flag is set for variables declared while in the const section. This
187 flag is used to determine whether or not the read/write bit should be
188 set in the Psect definition. */
190 #define EXTRA_SECTIONS in_const
192 #define EXTRA_SECTION_FUNCTIONS \
196 if (in_section != in_const) { \
197 fprintf(asm_out_file,".const\n"); \
198 in_section = in_const; \
202 /* This macro contains the logic to decide which section a variable
203 should be stored in. Static constant variables go in the text_section,
204 non-const variables go in the data_section, and non-static const
205 variables go in the const_section.
207 Since this macro is used in a number of places, we must also be able
208 to decide where to place string constants. */
210 #define SELECT_SECTION(T,RELOC) \
212 if (TREE_CODE (T) == VAR_DECL) \
214 if (TREE_READONLY (T) && ! TREE_THIS_VOLATILE (T)) \
216 if (TREE_PUBLIC (T)) \
224 if (*tree_code_type[(int) TREE_CODE (T)] == 'c') \
226 if ((TREE_CODE (T) == STRING_CST && flag_writable_strings)) \
233 /* This is used by a hook in varasm.c to write the assembler directives
234 that are needed to tell the startup code which constructors need to
237 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
239 fprintf ((FILE),".globl $$PsectAttributes_NOOVR$$__gxx_init_1\n"); \
241 fprintf ((FILE),"$$PsectAttributes_NOOVR$$__gxx_init_1:\n\t.long\t"); \
242 assemble_name ((FILE), (NAME)); \
243 fputc ('\n', (FILE)); \
246 /* This is used by a hook in varasm.c to write the assembler directives
247 that are needed to tell the startup code which destructors need to
250 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
252 fprintf ((FILE),".globl $$PsectAttributes_NOOVR$$__gxx_clean_1\n"); \
254 fprintf ((FILE),"$$PsectAttributes_NOOVR$$__gxx_clean_1:\n\t.long\t");\
255 assemble_name ((FILE), (NAME)); \
256 fputc ('\n', (FILE)); \
259 /* The following definitions are used in libgcc2.c with the __main
260 function. The _SHR symbol is used when the sharable image library
261 for libg++ is used - this is picked up automatically by the linker
262 and this symbol points to the start of the __CTOR_LIST__ from libg++.
263 If libg++ is not being used, then __CTOR_LIST_SHR__ occurs just after
264 __CTOR_LIST__, and essentially points to the same list as __CTOR_LIST. */
268 #define __CTOR_LIST__ __gxx_init_0
269 #define __CTOR_LIST_END__ __gxx_init_2
271 #define __CTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_init_0_shr
272 #define __CTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_init_2_shr
274 #define DO_GLOBAL_CTORS_BODY \
277 extern func_ptr __CTOR_LIST__[1]; \
278 extern func_ptr __CTOR_LIST_END__[1]; \
279 extern func_ptr __CTOR_LIST_SHR__[1]; \
280 extern func_ptr __CTOR_LIST_SHR_END__[1]; \
281 if( &__CTOR_LIST_SHR__[0] != &__CTOR_LIST__[1]) \
282 for (p = __CTOR_LIST_SHR__ + 1; p < __CTOR_LIST_SHR_END__ ; p++ ) \
284 for (p = __CTOR_LIST__ + 1; p < __CTOR_LIST_END__ ; p++ ) \
286 atexit (__do_global_dtors); \
289 int *callers_caller_fp = (int *) __builtin_frame_address (3); \
290 register int retval asm ("r0"); \
291 callers_caller_fp[4] = (int) && foo; \
298 #define __DTOR_LIST__ __gxx_clean_0
299 #define __DTOR_LIST_END__ __gxx_clean_2
301 #define __DTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_clean_0_shr
302 #define __DTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_clean_2_shr
304 #define DO_GLOBAL_DTORS_BODY \
307 extern func_ptr __DTOR_LIST__[1]; \
308 extern func_ptr __DTOR_LIST_END__[1]; \
309 extern func_ptr __DTOR_LIST_SHR__[1]; \
310 extern func_ptr __DTOR_LIST_SHR_END__[1]; \
311 for (p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__ ; p++ ) \
313 if( &__DTOR_LIST_SHR__[0] != &__DTOR_LIST__[1]) \
314 for (p = __DTOR_LIST_SHR__ + 1; p < __DTOR_LIST_SHR_END__ ; p++ ) \
This page took 0.048675 seconds and 5 git commands to generate.