1 /* Definitions of target machine GNU compiler. 32bit VMS version.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3 Contributed by Douglas B Rupp (rupp@gnat.com).
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
25 #include "vms-protos.h"
29 /* Correlation of standard CRTL names with DECCRTL function names. */
31 /* Name is for a function that allocate memory. Use the 64bit version
33 #define VMS_CRTL_MALLOC (1 << 0)
35 /* If long pointer are enabled, use _NAME64 instead. */
36 #define VMS_CRTL_64 (1 << 1)
38 /* Use tNAME instead. To be applied after the previous rule. */
39 #define VMS_CRTL_FLOAT (1 << 2)
41 /* Prepend __bsd44__ before the name. To be applied after the P64
43 #define VMS_CRTL_BSD44 (1 << 3)
45 /* Prepend x before the name for printf like functions. */
46 #define VMS_CRTL_PRNTF (1 << 4)
48 /* Prepend ga_ for global data. */
49 #define VMS_CRTL_GLOBAL (1 << 5)
53 /* The standard C name. */
54 const char *const name;
56 /* Flags to drive the translation. */
60 /* Map for the translation. */
62 static const struct vms_crtl_name vms_crtl_names[] =
64 #include "vms-crtlmap.h"
67 /* Number of entires in the above array. */
69 #define NBR_CRTL_NAMES (sizeof (vms_crtl_names) / sizeof (*vms_crtl_names))
71 /* List of aliased identifiers. They must be persistant accross gc. */
73 static GTY(()) VEC(tree,gc) *aliases_id;
75 /* Add a CRTL translation. This simply use the transparent alias
76 mechanism, which is platform independant and works with the
77 #pragma extern_prefix (which set the assembler name). */
80 vms_add_crtl_xlat (const char *name, size_t nlen,
81 const char *id_str, size_t id_len)
85 targ = get_identifier_with_length (name, nlen);
86 gcc_assert (!IDENTIFIER_TRANSPARENT_ALIAS (targ));
87 IDENTIFIER_TRANSPARENT_ALIAS (targ) = 1;
88 TREE_CHAIN (targ) = get_identifier_with_length (id_str, id_len);
90 VEC_safe_push (tree, gc, aliases_id, targ);
92 /* printf ("vms: %s (%p) -> %.*s\n", name, targ, id_len, id_str); */
95 /* Do VMS specific stuff on builtins: disable the ones that are not
96 standard, mangle names. */
99 vms_patch_builtins (void)
101 /* enum built_in_function bi; */
104 /* Fwrite on VMS is non-standard. */
105 if (builtin_decl_implicit_p (BUILT_IN_FWRITE))
106 set_builtin_decl_implicit_p (BUILT_IN_FWRITE, false);
108 if (builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED))
109 set_builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED, false);
111 /* Define aliases for names. */
112 for (i = 0; i < NBR_CRTL_NAMES; i++)
114 const struct vms_crtl_name *n = &vms_crtl_names[i];
115 char res[VMS_CRTL_MAXLEN + 3 + 9 + 1 + 1];
119 /* Add the dec-c prefix. */
120 memcpy (res, "decc$", 5);
123 if (n->flags & VMS_CRTL_BSD44)
125 memcpy (res + rlen, "__bsd44__", 9);
129 if (n->flags & VMS_CRTL_GLOBAL)
131 memcpy (res + rlen, "ga_", 3);
135 if (n->flags & VMS_CRTL_FLOAT)
138 if (n->flags & VMS_CRTL_PRNTF)
141 nlen = strlen (n->name);
142 memcpy (res + rlen, n->name, nlen);
144 if ((n->flags & VMS_CRTL_64) == 0)
145 vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen);
148 char alt[VMS_CRTL_MAXLEN + 3];
151 /* Add three translations:
154 X -> X if short, _X64 if long. */
156 memcpy (alt + 1, n->name, nlen);
157 alt[1 + nlen + 0] = '3';
158 alt[1 + nlen + 1] = '2';
159 alt[1 + nlen + 2] = 0;
160 vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen);
162 use_64 = (((n->flags & VMS_CRTL_64) && POINTER_SIZE == 64)
163 || ((n->flags & VMS_CRTL_MALLOC)
164 && TARGET_MALLOC64));
166 vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen);
169 memcpy (res + rlen, n->name, nlen);
170 res[rlen + nlen + 0] = '6';
171 res[rlen + nlen + 1] = '4';
174 vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen + 2);
176 alt[1 + nlen + 0] = '6';
177 alt[1 + nlen + 1] = '4';
178 vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen + 2);
183 /* Always default to .text section. */
186 vms_function_section (tree decl ATTRIBUTE_UNUSED,
187 enum node_frequency freq ATTRIBUTE_UNUSED,
188 bool startup ATTRIBUTE_UNUSED,
189 bool exit ATTRIBUTE_UNUSED)