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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [pa/] [som.h] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Definitions for SOM assembler support.
2
   Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation,
3
   Inc.
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
/* So we can conditionalize small amounts of code in pa.c or pa.md.  */
22
#undef TARGET_SOM
23
#define TARGET_SOM 1
24
 
25
/* We do not use BINCL stabs in SOM.
26
   ??? If it does not hurt, we probably should to avoid useless divergence
27
   from other embedded stabs implementations.  */
28
#undef DBX_USE_BINCL
29
 
30
#define DBX_LINES_FUNCTION_RELATIVE 1
31
 
32
/* gdb needs a null N_SO at the end of each file for scattered loading.  */
33
 
34
#define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
35
 
36
/* HPUX has a program 'chatr' to list the dependencies of dynamically
37
   linked executables and shared libraries.  */
38
#define LDD_SUFFIX "chatr"
39
/* Look for lines like "dynamic   /usr/lib/X11R5/libX11.sl"
40
   or "static    /usr/lib/X11R5/libX11.sl".
41
 
42
   HPUX 10.20 also has lines like "static branch prediction ..."
43
   so we filter that out explicitly.
44
 
45
   We also try to bound our search for libraries with marker
46
   lines.  What a pain.  */
47
#define PARSE_LDD_OUTPUT(PTR)                                   \
48
do {                                                            \
49
  static int in_shlib_list = 0;                                  \
50
  while (*PTR == ' ') PTR++;                                    \
51
  if (strncmp (PTR, "shared library list:",                     \
52
               sizeof ("shared library list:") - 1) == 0)        \
53
    {                                                           \
54
      PTR = 0;                                                   \
55
      in_shlib_list = 1;                                        \
56
    }                                                           \
57
  else if (strncmp (PTR, "shared library binding:",             \
58
                    sizeof ("shared library binding:") - 1) == 0)\
59
    {                                                           \
60
      PTR = 0;                                                   \
61
      in_shlib_list = 0;                                 \
62
    }                                                           \
63
  else if (strncmp (PTR, "static branch prediction disabled",   \
64
                    sizeof ("static branch prediction disabled") - 1) == 0)\
65
    {                                                           \
66
      PTR = 0;                                                   \
67
      in_shlib_list = 0;                                 \
68
    }                                                           \
69
  else if (in_shlib_list                                        \
70
           &&  strncmp (PTR, "dynamic", sizeof ("dynamic") - 1) == 0) \
71
    {                                                           \
72
      PTR += sizeof ("dynamic") - 1;                            \
73
      while (*p == ' ') PTR++;                                  \
74
    }                                                           \
75
  else if (in_shlib_list                                        \
76
           && strncmp (PTR, "static", sizeof ("static") - 1) == 0) \
77
    {                                                           \
78
      PTR += sizeof ("static") - 1;                             \
79
      while (*p == ' ') PTR++;                                  \
80
    }                                                           \
81
  else                                                          \
82
    PTR = 0;                                                     \
83
} while (0)
84
 
85
/* Output the label for a function definition.  */
86
#ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
87
#define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1)    \
88
  do { fprintf (FILE, ",ARGW%d=FR", (ARG0));            \
89
       fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
90
#define DFMODE_RETURN_STRING ",RTNVAL=FU"
91
#define SFMODE_RETURN_STRING ",RTNVAL=FR"
92
#else
93
#define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1)    \
94
  do { fprintf (FILE, ",ARGW%d=FU", (ARG0));            \
95
       fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
96
#define DFMODE_RETURN_STRING ",RTNVAL=FR"
97
#define SFMODE_RETURN_STRING ",RTNVAL=FU"
98
#endif
99
 
100
 
101
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
102
    do { tree fntype = TREE_TYPE (TREE_TYPE (DECL));                    \
103
         tree tree_type = TREE_TYPE (DECL);                             \
104
         tree parm;                                                     \
105
         int i;                                                         \
106
         if (TREE_PUBLIC (DECL) || TARGET_GAS)                          \
107
           {                                                            \
108
             if (TREE_PUBLIC (DECL))                                    \
109
               {                                                        \
110
                 fputs ("\t.EXPORT ", FILE);                            \
111
                 assemble_name (FILE, NAME);                            \
112
                 fputs (",ENTRY,PRIV_LEV=3", FILE);                     \
113
               }                                                        \
114
             else                                                       \
115
               {                                                        \
116
                 fputs ("\t.PARAM ", FILE);                             \
117
                 assemble_name (FILE, NAME);                            \
118
                 fputs (",PRIV_LEV=3", FILE);                           \
119
               }                                                        \
120
             for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4;    \
121
                  parm = TREE_CHAIN (parm))                             \
122
               {                                                        \
123
                 if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode         \
124
                     && ! TARGET_SOFT_FLOAT)                            \
125
                   fprintf (FILE, ",ARGW%d=FR", i++);                   \
126
                 else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode    \
127
                          && ! TARGET_SOFT_FLOAT)                       \
128
                   {                                                    \
129
                     if (i <= 2)                                        \
130
                       {                                                \
131
                         if (i == 1) i++;                               \
132
                         ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++);   \
133
                       }                                                \
134
                     else                                               \
135
                       break;                                           \
136
                   }                                                    \
137
                 else                                                   \
138
                   {                                                    \
139
                     int arg_size =                                     \
140
                       FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\
141
                                          DECL_ARG_TYPE (parm));        \
142
                     /* Passing structs by invisible reference uses     \
143
                        one general register.  */                       \
144
                     if (arg_size > 2                                   \
145
                         || TREE_ADDRESSABLE (DECL_ARG_TYPE (parm)))    \
146
                       arg_size = 1;                                    \
147
                     if (arg_size == 2 && i <= 2)                       \
148
                       {                                                \
149
                         if (i == 1) i++;                               \
150
                         fprintf (FILE, ",ARGW%d=GR", i++);             \
151
                         fprintf (FILE, ",ARGW%d=GR", i++);             \
152
                       }                                                \
153
                     else if (arg_size == 1)                            \
154
                       fprintf (FILE, ",ARGW%d=GR", i++);               \
155
                     else                                               \
156
                       i += arg_size;                                   \
157
                   }                                                    \
158
               }                                                        \
159
             /* anonymous args */                                       \
160
             if (TYPE_ARG_TYPES (tree_type) != 0                 \
161
                 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
162
                     != void_type_node))                                \
163
               {                                                        \
164
                 for (; i < 4; i++)                                     \
165
                   fprintf (FILE, ",ARGW%d=GR", i);                     \
166
               }                                                        \
167
             if (TYPE_MODE (fntype) == DFmode && ! TARGET_SOFT_FLOAT)   \
168
               fputs (DFMODE_RETURN_STRING, FILE);                      \
169
             else if (TYPE_MODE (fntype) == SFmode && ! TARGET_SOFT_FLOAT) \
170
               fputs (SFMODE_RETURN_STRING, FILE);                      \
171
             else if (fntype != void_type_node)                         \
172
               fputs (",RTNVAL=GR", FILE);                              \
173
             fputs ("\n", FILE);                                        \
174
           }} while (0)
175
 
176
#define TARGET_ASM_FILE_START pa_som_file_start
177
#define TARGET_ASM_INIT_SECTIONS pa_som_asm_init_sections
178
 
179
/* String to output before writable data.  */
180
#define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
181
 
182
/* String to output before uninitialized data.  */
183
#define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
184
 
185
/* This is how to output a command to make the user-level label
186
   named NAME defined for reference from other files.  We use
187
   assemble_name_raw instead of assemble_name since a symbol in
188
   a .IMPORT directive that isn't otherwise referenced is not
189
   placed in the symbol table of the assembled object.
190
 
191
   Failure to import a function reference can cause the HP linker
192
   to segmentation fault!
193
 
194
   Note that the SOM based tools need the symbol imported as a
195
   CODE symbol, while the ELF based tools require the symbol to
196
   be imported as an ENTRY symbol.  */
197
 
198
#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
199
  pa_hpux_asm_output_external ((FILE), (DECL), (NAME))
200
#define ASM_OUTPUT_EXTERNAL_REAL(FILE, DECL, NAME) \
201
  do { fputs ("\t.IMPORT ", FILE);                                      \
202
       assemble_name_raw (FILE, NAME);                                  \
203
       if (FUNCTION_NAME_P (NAME))                                      \
204
         fputs (",CODE\n", FILE);                                       \
205
       else                                                             \
206
         fputs (",DATA\n", FILE);                                       \
207
     } while (0)
208
 
209
/* The bogus HP assembler requires ALL external references to be
210
   "imported", even library calls.  They look a bit different, so
211
   here's this macro.
212
 
213
   Also note not all libcall names are passed to pa_encode_section_info
214
   (__main for example).  To make sure all libcall names have section
215
   info recorded in them, we do it here.
216
 
217
   We must also ensure that a libcall that has been previously
218
   exported is not subsequently imported since the HP assembler may
219
   change the type from an ENTRY to a CODE symbol.  This would make
220
   the symbol local.  We are forced to use the identifier node
221
   associated with the real assembler name for this check as the
222
   symbol_ref available in ASM_DECLARE_FUNCTION_NAME is not the
223
   same as the one used here.  As a result, we can't use flags
224
   in the symbol_ref for this check.  The identifier check assumes
225
   assemble_external_libcall is called before the symbol is used.  */
226
 
227
#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
228
  do { const char *name;                                                \
229
       tree id;                                                         \
230
                                                                        \
231
       if (!function_label_operand (RTL, VOIDmode))                     \
232
         hppa_encode_label (RTL);                                       \
233
                                                                        \
234
       name = targetm.strip_name_encoding (XSTR ((RTL), 0));             \
235
       id = maybe_get_identifier (name);                                \
236
       if (!id || !TREE_SYMBOL_REFERENCED (id))                         \
237
         {                                                              \
238
           fputs ("\t.IMPORT ", FILE);                                  \
239
           assemble_name_raw (FILE, XSTR ((RTL), 0));                    \
240
           fputs (",CODE\n", FILE);                                     \
241
         }                                                              \
242
     } while (0)
243
 
244
/* We want __gcc_plt_call to appear in every program built by
245
   gcc, so we make a reference to it out of __main.
246
   We use the asm statement to fool the optimizer into not
247
   removing the dead (but important) initialization of
248
   REFERENCE.  */
249
 
250
#define DO_GLOBAL_DTORS_BODY                    \
251
do {                                            \
252
  extern void __gcc_plt_call (void);            \
253
  void (*reference)(void) = &__gcc_plt_call;    \
254
  func_ptr *p;                                  \
255
  __asm__ ("" : : "r" (reference));             \
256
  for (p = __DTOR_LIST__ + 1; *p; )             \
257
    (*p++) ();                                  \
258
} while (0)
259
 
260
/* This macro specifies the biggest alignment supported by the object
261
   file format of this machine.
262
 
263
   The .align directive in the HP assembler allows alignments up to 4096
264
   bytes.  However, the maximum alignment of a global common symbol is 8
265
   bytes for objects smaller than the page size (4096 bytes).  For larger
266
   objects, the linker provides an alignment of 32 bytes.  Unfortunately,
267
   this macro doesn't provide a mechanism to test for common symbols.  */
268
#define MAX_OFILE_ALIGNMENT 32768
269
 
270
/* The SOM linker hardcodes paths into binaries.  As a result, dotdots
271
   must be removed from library prefixes to prevent binaries from depending
272
   on the location of the GCC tool directory.  The downside is GCC
273
   cannot be moved after installation using a symlink.  */
274
#define ALWAYS_STRIP_DOTDOT 1
275
 
276
/* If GAS supports weak, we can support weak when we have working linker
277
   support for secondary definitions and are generating code for GAS.  */
278
#ifdef HAVE_GAS_WEAK
279
#define SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
280
#else
281
#define SUPPORTS_WEAK 0
282
#endif
283
 
284
/* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
285
   directive.  This provides one-only linkage semantics even though we
286
   don't have weak support.  */
287
#ifdef HAVE_GAS_NSUBSPA_COMDAT
288
#define SUPPORTS_SOM_COMDAT (TARGET_GAS)
289
#else
290
#define SUPPORTS_SOM_COMDAT 0
291
#endif
292
 
293
/* We can support one only if we support weak or comdat.  */
294
#define SUPPORTS_ONE_ONLY (SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
295
 
296
/* We use DECL_COMMON for uninitialized one-only variables as we don't
297
   have linkonce .bss.  We use SOM secondary definitions or comdat for
298
   initialized variables and functions.  */
299
#define MAKE_DECL_ONE_ONLY(DECL) \
300
  do {                                                                  \
301
    if (TREE_CODE (DECL) == VAR_DECL                                    \
302
        && (DECL_INITIAL (DECL) == 0                                     \
303
            || DECL_INITIAL (DECL) == error_mark_node))                 \
304
      DECL_COMMON (DECL) = 1;                                           \
305
    else if (SUPPORTS_WEAK)                                             \
306
      DECL_WEAK (DECL) = 1;                                             \
307
  } while (0)
308
 
309
/* This is how we tell the assembler that a symbol is weak.  The SOM
310
   weak implementation uses the secondary definition (sdef) flag.
311
 
312
   The behavior of sdef symbols is similar to ELF weak symbols in that
313
   multiple definitions can occur without incurring a link error.
314
   However, they differ in the following ways:
315
     1) Undefined sdef symbols are not allowed.
316
     2) The linker searches for undefined sdef symbols and will load an
317
        archive library member to resolve an undefined sdef symbol.
318
     3) The exported symbol from a shared library is a primary symbol
319
        rather than a sdef symbol.  Thus, more care is needed in the
320
        ordering of libraries.
321
 
322
   It appears that the linker discards extra copies of "weak" functions
323
   when linking shared libraries, independent of whether or not they
324
   are in their own section.  In linking final executables, -Wl,-O can
325
   be used to remove dead procedures.  Thus, support for named sections
326
   is not needed and in previous testing caused problems with various
327
   HP tools.  */
328
#define ASM_WEAKEN_LABEL(FILE,NAME) \
329
  do { fputs ("\t.weak\t", FILE);                               \
330
       assemble_name (FILE, NAME);                              \
331
       fputc ('\n', FILE);                                      \
332
       targetm.asm_out.globalize_label (FILE, NAME);            \
333
  } while (0)
334
 
335
/* We can't handle weak aliases, and therefore can't support pragma weak.
336
   Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h.  */
337
#define GTHREAD_USE_WEAK 0

powered by: WebSVN 2.1.0

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