OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [vms/] [vms.c] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 709 jeremybenn
/* 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).
4
 
5
This file is part of GCC.
6
 
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)
10
any later version.
11
 
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.
16
 
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/>.  */
20
 
21
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "tree.h"
25
#include "vms-protos.h"
26
#include "tm.h"
27
#include "ggc.h"
28
 
29
/* Correlation of standard CRTL names with DECCRTL function names.  */
30
 
31
/* Name is for a function that allocate memory.  Use the 64bit version
32
   if -mmalloc64.  */
33
#define VMS_CRTL_MALLOC (1 << 0)
34
 
35
/* If long pointer are enabled, use _NAME64 instead.  */
36
#define VMS_CRTL_64     (1 << 1)
37
 
38
/* Use tNAME instead.  To be applied after the previous rule.  */
39
#define VMS_CRTL_FLOAT  (1 << 2)
40
 
41
/* Prepend __bsd44__ before the name.  To be applied after the P64
42
   rule.  */
43
#define VMS_CRTL_BSD44  (1 << 3)
44
 
45
/* Prepend x before the name for printf like functions.  */
46
#define VMS_CRTL_PRNTF  (1 << 4)
47
 
48
/* Prepend ga_ for global data.  */
49
#define VMS_CRTL_GLOBAL (1 << 5)
50
 
51
struct vms_crtl_name
52
{
53
  /* The standard C name.  */
54
  const char *const name;
55
 
56
  /* Flags to drive the translation.  */
57
  unsigned int flags;
58
};
59
 
60
/* Map for the translation.  */
61
 
62
static const struct vms_crtl_name vms_crtl_names[] =
63
  {
64
#include "vms-crtlmap.h"
65
  };
66
 
67
/* Number of entires in the above array.  */
68
 
69
#define NBR_CRTL_NAMES (sizeof (vms_crtl_names) / sizeof (*vms_crtl_names))
70
 
71
/* List of aliased identifiers.  They must be persistant accross gc.  */
72
 
73
static GTY(()) VEC(tree,gc) *aliases_id;
74
 
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).  */
78
 
79
static void
80
vms_add_crtl_xlat (const char *name, size_t nlen,
81
                   const char *id_str, size_t id_len)
82
{
83
  tree targ;
84
 
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);
89
 
90
  VEC_safe_push (tree, gc, aliases_id, targ);
91
 
92
  /* printf ("vms: %s (%p) -> %.*s\n", name, targ, id_len, id_str); */
93
}
94
 
95
/* Do VMS specific stuff on builtins: disable the ones that are not
96
   standard, mangle names.  */
97
 
98
void
99
vms_patch_builtins (void)
100
{
101
  /* enum built_in_function bi; */
102
  unsigned int i;
103
 
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);
107
 
108
  if (builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED))
109
    set_builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED, false);
110
 
111
  /* Define aliases for names.  */
112
  for (i = 0; i < NBR_CRTL_NAMES; i++)
113
    {
114
      const struct vms_crtl_name *n = &vms_crtl_names[i];
115
      char res[VMS_CRTL_MAXLEN + 3 + 9 + 1 + 1];
116
      int rlen;
117
      int nlen;
118
 
119
      /* Add the dec-c prefix.  */
120
      memcpy (res, "decc$", 5);
121
      rlen = 5;
122
 
123
      if (n->flags & VMS_CRTL_BSD44)
124
        {
125
          memcpy (res + rlen, "__bsd44__", 9);
126
          rlen += 9;
127
        }
128
 
129
      if (n->flags & VMS_CRTL_GLOBAL)
130
        {
131
          memcpy (res + rlen, "ga_", 3);
132
          rlen += 3;
133
        }
134
 
135
      if (n->flags & VMS_CRTL_FLOAT)
136
        res[rlen++] = 't';
137
 
138
      if (n->flags & VMS_CRTL_PRNTF)
139
        res[rlen++] = 'x';
140
 
141
      nlen = strlen (n->name);
142
      memcpy (res + rlen, n->name, nlen);
143
 
144
      if ((n->flags & VMS_CRTL_64) == 0)
145
        vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen);
146
      else
147
        {
148
          char alt[VMS_CRTL_MAXLEN + 3];
149
          bool use_64;
150
 
151
          /* Add three translations:
152
             _X32 -> X
153
             _X64 -> _X64
154
             X -> X if short, _X64 if long.  */
155
          alt[0] = '_';
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);
161
 
162
          use_64 = (((n->flags & VMS_CRTL_64) && POINTER_SIZE == 64)
163
                    || ((n->flags & VMS_CRTL_MALLOC)
164
                        && TARGET_MALLOC64));
165
          if (!use_64)
166
            vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen);
167
 
168
          res[rlen++] = '_';
169
          memcpy (res + rlen, n->name, nlen);
170
          res[rlen + nlen + 0] = '6';
171
          res[rlen + nlen + 1] = '4';
172
 
173
          if (use_64)
174
            vms_add_crtl_xlat (n->name, nlen, res, rlen + nlen + 2);
175
 
176
          alt[1 + nlen + 0] = '6';
177
          alt[1 + nlen + 1] = '4';
178
          vms_add_crtl_xlat (alt, nlen + 3, res, rlen + nlen + 2);
179
        }
180
    }
181
}
182
 
183
/* Always default to .text section.  */
184
 
185
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)
190
{
191
  return NULL;
192
}
193
 
194
#include "gt-vms.h"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.