annotate gcc/config/vms/vms.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Definitions of target machine GNU compiler. 32bit VMS version.
kono
parents:
diff changeset
2 Copyright (C) 2009-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3 Contributed by Douglas B Rupp (rupp@gnat.com).
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
10 any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 GNU General Public License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 #include "config.h"
kono
parents:
diff changeset
22 #include "system.h"
kono
parents:
diff changeset
23 #include "coretypes.h"
kono
parents:
diff changeset
24 #include "target.h"
kono
parents:
diff changeset
25 #include "tree.h"
kono
parents:
diff changeset
26 #include "stringpool.h"
kono
parents:
diff changeset
27 #include "alias.h"
kono
parents:
diff changeset
28 #include "vms-protos.h"
kono
parents:
diff changeset
29 #include "output.h"
kono
parents:
diff changeset
30 #include "dwarf2out.h"
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Correlation of standard CRTL names with DECCRTL function names. */
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 /* Name is for a function that allocate memory. Use the 64bit version
kono
parents:
diff changeset
35 if -mmalloc64. */
kono
parents:
diff changeset
36 #define VMS_CRTL_MALLOC (1 << 0)
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 /* If long pointer are enabled, use _NAME64 instead. */
kono
parents:
diff changeset
39 #define VMS_CRTL_64 (1 << 1)
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 /* Prepend s/f before the name. To be applied after the previous rule.
kono
parents:
diff changeset
42 use 's' for S float, 'f' for IEEE 32. */
kono
parents:
diff changeset
43 #define VMS_CRTL_FLOAT32 (1 << 2)
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 /* Prepend t/g/d before the name. To be applied after the previous rule.
kono
parents:
diff changeset
46 use 'g' for VAX G float, 'd' for VAX D float, 't' for IEEE 64. */
kono
parents:
diff changeset
47 #define VMS_CRTL_FLOAT64 (1 << 3)
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 /* Prepend d before the name, only if using VAX fp. */
kono
parents:
diff changeset
50 #define VMS_CRTL_FLOAT64_VAXD (1 << 4)
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* Prepend x before the name for if 128 bit long doubles are enabled. This
kono
parents:
diff changeset
53 concern mostly 'printf'-like functions. */
kono
parents:
diff changeset
54 #define VMS_CRTL_FLOAT128 (1 << 5)
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 /* From xxx, create xxx, xxxf, xxxl using MATH$XXX_T, MATH$XXX_S
kono
parents:
diff changeset
57 and MATH$XXX{_X} if DPML is used. */
kono
parents:
diff changeset
58 #define VMS_CRTL_DPML (1 << 6)
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* Together with DPML, it means that all variant (ie xxx, xxxf and xxxl) are
kono
parents:
diff changeset
61 overridden by decc. Without DPML, it means this is a variant (ie xxxf
kono
parents:
diff changeset
62 or xxxl) of a function. */
kono
parents:
diff changeset
63 #define VMS_CRTL_NODPML (1 << 7)
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 /* Prepend __bsd44_ before the name. To be applied after the P64
kono
parents:
diff changeset
66 rule. */
kono
parents:
diff changeset
67 #define VMS_CRTL_BSD44 (1 << 8)
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /* Define only in 32 bits mode, as this has no 64 bit variants.
kono
parents:
diff changeset
70 Concerns getopt/getarg. */
kono
parents:
diff changeset
71 #define VMS_CRTL_32ONLY (1 << 9)
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 /* GLobal data prefix (ga_, gl_...) */
kono
parents:
diff changeset
74 #define VMS_CRTL_G_MASK (7 << 10)
kono
parents:
diff changeset
75 #define VMS_CRTL_G_NONE (0 << 10)
kono
parents:
diff changeset
76 #define VMS_CRTL_GA (1 << 10)
kono
parents:
diff changeset
77 #define VMS_CRTL_GL (2 << 10)
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* Append '_2'. Not compatible with 64. */
kono
parents:
diff changeset
80 #define VMS_CRTL_FLOATV2 (1 << 13)
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 struct vms_crtl_name
kono
parents:
diff changeset
83 {
kono
parents:
diff changeset
84 /* The standard C name. */
kono
parents:
diff changeset
85 const char *const name;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 /* Flags to drive the translation. */
kono
parents:
diff changeset
88 unsigned int flags;
kono
parents:
diff changeset
89 };
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 /* Map for the translation. */
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 static const struct vms_crtl_name vms_crtl_names[] =
kono
parents:
diff changeset
94 {
kono
parents:
diff changeset
95 #include "vms-crtlmap.h"
kono
parents:
diff changeset
96 };
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 /* Number of entires in the above array. */
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 #define NBR_CRTL_NAMES (sizeof (vms_crtl_names) / sizeof (*vms_crtl_names))
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* List of aliased identifiers. They must be persistent across gc. */
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 static GTY(()) vec<tree, va_gc> *aliases_id;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 /* Add a CRTL translation. This simply use the transparent alias
kono
parents:
diff changeset
107 mechanism, which is platform independent and works with the
kono
parents:
diff changeset
108 #pragma extern_prefix (which set the assembler name). */
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 static void
kono
parents:
diff changeset
111 vms_add_crtl_xlat (const char *name, size_t nlen,
kono
parents:
diff changeset
112 const char *id_str, size_t id_len)
kono
parents:
diff changeset
113 {
kono
parents:
diff changeset
114 tree targ;
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 /* printf ("vms crtl: %.*s -> %.*s\n", nlen, name, id_len, id_str); */
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 targ = get_identifier_with_length (name, nlen);
kono
parents:
diff changeset
119 gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (targ));
kono
parents:
diff changeset
120 IDENTIFIER_TRANSPARENT_ALIAS (targ) = 1;
kono
parents:
diff changeset
121 TREE_CHAIN (targ) = get_identifier_with_length (id_str, id_len);
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 vec_safe_push (aliases_id, targ);
kono
parents:
diff changeset
124 }
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 /* Do VMS specific stuff on builtins: disable the ones that are not
kono
parents:
diff changeset
127 standard, mangle names. */
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 void
kono
parents:
diff changeset
130 vms_patch_builtins (void)
kono
parents:
diff changeset
131 {
kono
parents:
diff changeset
132 /* enum built_in_function bi; */
kono
parents:
diff changeset
133 unsigned int i;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 /* Fwrite on VMS is non-standard. */
kono
parents:
diff changeset
136 if (builtin_decl_implicit_p (BUILT_IN_FWRITE))
kono
parents:
diff changeset
137 set_builtin_decl_implicit_p (BUILT_IN_FWRITE, false);
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 if (builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED))
kono
parents:
diff changeset
140 set_builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED, false);
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 /* Define aliases for names. */
kono
parents:
diff changeset
143 for (i = 0; i < NBR_CRTL_NAMES; i++)
kono
parents:
diff changeset
144 {
kono
parents:
diff changeset
145 const struct vms_crtl_name *n = &vms_crtl_names[i];
kono
parents:
diff changeset
146 char res[VMS_CRTL_MAXLEN + 3 + 9 + 1 + 1];
kono
parents:
diff changeset
147 int rlen;
kono
parents:
diff changeset
148 int nlen = strlen (n->name);
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 /* Discard 32ONLY if using 64 bit pointers. */
kono
parents:
diff changeset
151 if ((n->flags & VMS_CRTL_32ONLY)
kono
parents:
diff changeset
152 && flag_vms_pointer_size == VMS_POINTER_SIZE_64)
kono
parents:
diff changeset
153 continue;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 /* Handle DPML unless overridden by decc. */
kono
parents:
diff changeset
156 if ((n->flags & VMS_CRTL_DPML)
kono
parents:
diff changeset
157 && !(n->flags & VMS_CRTL_NODPML))
kono
parents:
diff changeset
158 {
kono
parents:
diff changeset
159 const char *p;
kono
parents:
diff changeset
160 char alt[VMS_CRTL_MAXLEN + 3];
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 memcpy (res, "MATH$", 5);
kono
parents:
diff changeset
163 rlen = 5;
kono
parents:
diff changeset
164 for (p = n->name; *p; p++)
kono
parents:
diff changeset
165 res[rlen++] = TOUPPER (*p);
kono
parents:
diff changeset
166 res[rlen++] = '_';
kono
parents:
diff changeset
167 res[rlen++] = 'T';
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 /* Double version. */
kono
parents:
diff changeset
170 if (!(n->flags & VMS_CRTL_FLOAT64))
kono
parents:
diff changeset
171 vms_add_crtl_xlat (n->name, nlen, res, rlen);
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 /* Float version. */
kono
parents:
diff changeset
174 res[rlen - 1] = 'S';
kono
parents:
diff changeset
175 memcpy (alt, n->name, nlen);
kono
parents:
diff changeset
176 alt[nlen] = 'f';
kono
parents:
diff changeset
177 vms_add_crtl_xlat (alt, nlen + 1, res, rlen);
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 /* Long double version. */
kono
parents:
diff changeset
180 res[rlen - 1] = (LONG_DOUBLE_TYPE_SIZE == 128 ? 'X' : 'T');
kono
parents:
diff changeset
181 alt[nlen] = 'l';
kono
parents:
diff changeset
182 vms_add_crtl_xlat (alt, nlen + 1, res, rlen);
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 if (!(n->flags & (VMS_CRTL_FLOAT32 | VMS_CRTL_FLOAT64)))
kono
parents:
diff changeset
185 continue;
kono
parents:
diff changeset
186 }
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 if (n->flags & VMS_CRTL_FLOAT64_VAXD)
kono
parents:
diff changeset
189 continue;
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 /* Add the dec-c prefix. */
kono
parents:
diff changeset
192 memcpy (res, "decc$", 5);
kono
parents:
diff changeset
193 rlen = 5;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 if (n->flags & VMS_CRTL_BSD44)
kono
parents:
diff changeset
196 {
kono
parents:
diff changeset
197 memcpy (res + rlen, "__bsd44_", 8);
kono
parents:
diff changeset
198 rlen += 8;
kono
parents:
diff changeset
199 }
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 if ((n->flags & VMS_CRTL_G_MASK) != VMS_CRTL_G_NONE)
kono
parents:
diff changeset
202 {
kono
parents:
diff changeset
203 res[rlen++] = 'g';
kono
parents:
diff changeset
204 switch (n->flags & VMS_CRTL_G_MASK)
kono
parents:
diff changeset
205 {
kono
parents:
diff changeset
206 case VMS_CRTL_GA:
kono
parents:
diff changeset
207 res[rlen++] = 'a';
kono
parents:
diff changeset
208 break;
kono
parents:
diff changeset
209 case VMS_CRTL_GL:
kono
parents:
diff changeset
210 res[rlen++] = 'l';
kono
parents:
diff changeset
211 break;
kono
parents:
diff changeset
212 default:
kono
parents:
diff changeset
213 gcc_unreachable ();
kono
parents:
diff changeset
214 }
kono
parents:
diff changeset
215 res[rlen++] = '_';
kono
parents:
diff changeset
216 }
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 if (n->flags & VMS_CRTL_FLOAT32)
kono
parents:
diff changeset
219 res[rlen++] = 'f';
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 if (n->flags & VMS_CRTL_FLOAT64)
kono
parents:
diff changeset
222 res[rlen++] = 't';
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 if ((n->flags & VMS_CRTL_FLOAT128) && LONG_DOUBLE_TYPE_SIZE == 128)
kono
parents:
diff changeset
225 res[rlen++] = 'x';
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 memcpy (res + rlen, n->name, nlen);
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 if ((n->flags & VMS_CRTL_64) == 0)
kono
parents:
diff changeset
230 {
kono
parents:
diff changeset
231 rlen += nlen;
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 if (n->flags & VMS_CRTL_FLOATV2)
kono
parents:
diff changeset
234 {
kono
parents:
diff changeset
235 res[rlen++] = '_';
kono
parents:
diff changeset
236 res[rlen++] = '2';
kono
parents:
diff changeset
237 }
kono
parents:
diff changeset
238 vms_add_crtl_xlat (n->name, nlen, res, rlen);
kono
parents:
diff changeset
239 }
kono
parents:
diff changeset
240 else
kono
parents:
diff changeset
241 {
kono
parents:
diff changeset
242 char alt[VMS_CRTL_MAXLEN + 3];
kono
parents:
diff changeset
243 bool use_64;
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 /* Add three translations:
kono
parents:
diff changeset
246 _X32 -> X
kono
parents:
diff changeset
247 _X64 -> _X64
kono
parents:
diff changeset
248 X -> X if short, _X64 if long. */
kono
parents:
diff changeset
249 alt[0] = '_';
kono
parents:
diff changeset
250 memcpy (alt + 1, n->name, nlen);
kono
parents:
diff changeset
251 alt[1 + nlen + 0] = '3';
kono
parents:
diff changeset
252 alt[1 + nlen + 1] = '2';
kono
parents:
diff changeset
253 alt[1 + nlen + 2] = 0;
kono
parents:
diff changeset
254 vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen);
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 use_64 = (((n->flags & VMS_CRTL_64)
kono
parents:
diff changeset
257 && flag_vms_pointer_size == VMS_POINTER_SIZE_64)
kono
parents:
diff changeset
258 || ((n->flags & VMS_CRTL_MALLOC)
kono
parents:
diff changeset
259 && flag_vms_malloc64
kono
parents:
diff changeset
260 && flag_vms_pointer_size != VMS_POINTER_SIZE_NONE));
kono
parents:
diff changeset
261 if (!use_64)
kono
parents:
diff changeset
262 vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen);
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 res[rlen++] = '_';
kono
parents:
diff changeset
265 memcpy (res + rlen, n->name, nlen);
kono
parents:
diff changeset
266 res[rlen + nlen + 0] = '6';
kono
parents:
diff changeset
267 res[rlen + nlen + 1] = '4';
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 if (use_64)
kono
parents:
diff changeset
270 vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen + 2);
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 alt[1 + nlen + 0] = '6';
kono
parents:
diff changeset
273 alt[1 + nlen + 1] = '4';
kono
parents:
diff changeset
274 vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen + 2);
kono
parents:
diff changeset
275 }
kono
parents:
diff changeset
276 }
kono
parents:
diff changeset
277 }
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 /* Always default to .text section. */
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 section *
kono
parents:
diff changeset
282 vms_function_section (tree decl ATTRIBUTE_UNUSED,
kono
parents:
diff changeset
283 enum node_frequency freq ATTRIBUTE_UNUSED,
kono
parents:
diff changeset
284 bool startup ATTRIBUTE_UNUSED,
kono
parents:
diff changeset
285 bool exit ATTRIBUTE_UNUSED)
kono
parents:
diff changeset
286 {
kono
parents:
diff changeset
287 return NULL;
kono
parents:
diff changeset
288 }
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 /* Additionnal VMS specific code for start_function. */
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 /* Must be kept in sync with libgcc/config/vms/vms-ucrt0.c */
kono
parents:
diff changeset
293 #define VMS_MAIN_FLAGS_SYMBOL "__gcc_main_flags"
kono
parents:
diff changeset
294 #define MAIN_FLAG_64BIT (1 << 0)
kono
parents:
diff changeset
295 #define MAIN_FLAG_POSIX (1 << 1)
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 void
kono
parents:
diff changeset
298 vms_start_function (const char *fnname)
kono
parents:
diff changeset
299 {
kono
parents:
diff changeset
300 #if VMS_DEBUGGING_INFO
kono
parents:
diff changeset
301 if (vms_debug_main
kono
parents:
diff changeset
302 && debug_info_level > DINFO_LEVEL_NONE
kono
parents:
diff changeset
303 && strncmp (vms_debug_main, fnname, strlen (vms_debug_main)) == 0)
kono
parents:
diff changeset
304 {
kono
parents:
diff changeset
305 targetm.asm_out.globalize_label (asm_out_file, VMS_DEBUG_MAIN_POINTER);
kono
parents:
diff changeset
306 ASM_OUTPUT_DEF (asm_out_file, VMS_DEBUG_MAIN_POINTER, fnname);
kono
parents:
diff changeset
307 dwarf2out_vms_debug_main_pointer ();
kono
parents:
diff changeset
308 vms_debug_main = 0;
kono
parents:
diff changeset
309 }
kono
parents:
diff changeset
310 #endif
kono
parents:
diff changeset
311
kono
parents:
diff changeset
312 /* Registers flags used for function main. This is necessary for
kono
parents:
diff changeset
313 crt0 code. */
kono
parents:
diff changeset
314 if (strcmp (fnname, "main") == 0)
kono
parents:
diff changeset
315 {
kono
parents:
diff changeset
316 unsigned int flags = 0;
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 if (flag_vms_pointer_size == VMS_POINTER_SIZE_64)
kono
parents:
diff changeset
319 flags |= MAIN_FLAG_64BIT;
kono
parents:
diff changeset
320 if (!flag_vms_return_codes)
kono
parents:
diff changeset
321 flags |= MAIN_FLAG_POSIX;
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 targetm.asm_out.globalize_label (asm_out_file, VMS_MAIN_FLAGS_SYMBOL);
kono
parents:
diff changeset
324 assemble_name (asm_out_file, VMS_MAIN_FLAGS_SYMBOL);
kono
parents:
diff changeset
325 fprintf (asm_out_file, " = %u\n", flags);
kono
parents:
diff changeset
326 }
kono
parents:
diff changeset
327 }
kono
parents:
diff changeset
328
kono
parents:
diff changeset
329 #include "gt-vms.h"