efd90871451b4891e49df7913980c2e7f6e18308
[platform/upstream/gcc.git] / gcc / config / mcore / mcore-pe.h
1 /* Definitions of target machine for GNU compiler, for MCore using COFF/PE.
2    Copyright (C) 1994, 1999, 2000 Free Software Foundation, Inc.
3    Contributed by Michael Tiemann (tiemann@cygnus.com).
4
5 This file is part of GNU CC.
6
7 GNU CC 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 2, or (at your option)
10 any later version.
11
12 GNU CC 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 GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* Run-time Target Specification.  */
23 #define TARGET_VERSION fputs (" (MCORE/pe)", stderr)
24
25 #define SUBTARGET_CPP_PREDEFINES " -D__pe__"
26
27 /* The MCore ABI says that bitfields are unsigned by default.  */
28 /* The EPOC C++ environment does not support exceptions.  */
29 #define CC1_SPEC "-funsigned-bitfields %{!DIN_GCC:-fno-rtti} %{!DIN_GCC:-fno-exceptions}"
30
31 #include "svr3.h"
32 #include "mcore/mcore.h"
33 #include "dbxcoff.h"
34
35 #undef  SDB_DEBUGGING_INFO
36 #undef  DBX_DEBUGGING_INFO
37 #define DBX_DEBUGGING_INFO 1
38
39 /* Computed in toplev.c.  */
40 #undef  PREFERRED_DEBUGGING_TYPE
41
42 /* Lay out additional 'sections' where we place things like code
43    and readonly data. This gets them out of default places.  */
44
45 #define SUBTARGET_SWITCH_SECTIONS               \
46   case in_drectve: drectve_section (); break;   \
47   case in_rdata:   rdata_section (); break;
48
49 #define DRECTVE_SECTION_ASM_OP  "\t.section .drectve"
50 #define RDATA_SECTION_ASM_OP    "\t.section .rdata"
51
52 #define SUBTARGET_EXTRA_SECTIONS in_drectve, in_rdata
53
54 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS \
55   DRECTVE_SECTION_FUNCTION                \
56   RDATA_SECTION_FUNCTION
57
58 #define DRECTVE_SECTION_FUNCTION                                \
59 void                                                            \
60 drectve_section ()                                              \
61 {                                                               \
62   if (in_section != in_drectve)                                 \
63     {                                                           \
64       fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP);   \
65       in_section = in_drectve;                                  \
66     }                                                           \
67 }
68
69 #define RDATA_SECTION_FUNCTION                                  \
70 void                                                            \
71 rdata_section ()                                                \
72 {                                                               \
73   if (in_section != in_rdata)                                   \
74     {                                                           \
75       fprintf (asm_out_file, "%s\n", RDATA_SECTION_ASM_OP);     \
76       in_section = in_rdata;                                    \
77     }                                                           \
78 }
79
80 #undef  READONLY_DATA_SECTION
81 #define READONLY_DATA_SECTION() rdata_section ()
82
83 /* A C statement or statements to switch to the appropriate
84    section for output of DECL.  DECL is either a `VAR_DECL' node
85    or a constant of some sort.  RELOC indicates whether forming
86    the initial value of DECL requires link-time relocations.  */
87 #undef  SELECT_SECTION
88 #define SELECT_SECTION(DECL, RELOC, ALIGN)                              \
89 {                                                                       \
90   if (TREE_CODE (DECL) == STRING_CST)                                   \
91     {                                                                   \
92       if (! flag_writable_strings)                                      \
93         rdata_section ();                                               \
94       else                                                              \
95         data_section ();                                                \
96     }                                                                   \
97   else if (TREE_CODE (DECL) == VAR_DECL)                                \
98     {                                                                   \
99       if ((0 && RELOC)  /* should be (flag_pic && RELOC) */             \
100           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
101           || !DECL_INITIAL (DECL)                                       \
102           || (DECL_INITIAL (DECL) != error_mark_node                    \
103               && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
104         data_section ();                                                \
105       else                                                              \
106         rdata_section ();                                               \
107     }                                                                   \
108   else                                                                  \
109     rdata_section ();                                                   \
110 }
111
112 /* A C statement or statements to switch to the appropriate
113    section for output of RTX in mode MODE.  RTX is some kind
114    of constant in RTL.  The argument MODE is redundant except
115    in the case of a `const_int' rtx.  Currently, these always
116    go into the const section.  */
117 #undef  SELECT_RTX_SECTION
118 #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) rdata_section ()
119
120 #define MCORE_EXPORT_NAME(STREAM, NAME)                 \
121   do                                                    \
122     {                                                   \
123       drectve_section ();                               \
124       fprintf (STREAM, "\t.ascii \" -export:%s\"\n",    \
125                MCORE_STRIP_NAME_ENCODING (NAME));       \
126     }                                                   \
127   while (0);
128
129 /* Output the label for an initialized variable.  */
130 #undef  ASM_DECLARE_OBJECT_NAME
131 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)             \
132   do                                                            \
133     {                                                           \
134       if (mcore_dllexport_name_p (NAME))                        \
135         {                                                       \
136           enum in_section save_section = in_section;            \
137           MCORE_EXPORT_NAME (STREAM, NAME);                     \
138           switch_to_section (save_section, (DECL));             \
139         }                                                       \
140       ASM_OUTPUT_LABEL ((STREAM), (NAME));                      \
141     }                                                           \
142   while (0)
143
144 /* Output a function label definition.  */
145 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)           \
146   do                                                            \
147     {                                                           \
148       if (mcore_dllexport_name_p (NAME))                        \
149         {                                                       \
150           MCORE_EXPORT_NAME (STREAM, NAME);                     \
151           function_section (DECL);                              \
152         }                                                       \
153       ASM_OUTPUT_LABEL ((STREAM), (NAME));                      \
154     }                                                           \
155   while (0);
156
157 #undef  ASM_FILE_START
158 #define ASM_FILE_START(STREAM)                                  \
159   do                                                            \
160     {                                                           \
161       fprintf (STREAM, "%s Generated by gcc %s for MCore/pe\n", \
162            ASM_COMMENT_START, version_string);                  \
163       output_file_directive ((STREAM), main_input_filename);    \
164     }                                                           \
165   while (0)
166
167 #undef  ASM_OUTPUT_SOURCE_LINE
168 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE)                                \
169   {                                                                       \
170     if (write_symbols == DBX_DEBUG)                                       \
171       {                                                                   \
172         static int sym_lineno = 1;                                        \
173         char buffer[256];                                                 \
174                                                                           \
175         ASM_GENERATE_INTERNAL_LABEL (buffer, "LM", sym_lineno);           \
176         fprintf (FILE, ".stabn 68,0,%d,", LINE);                          \
177         assemble_name (FILE, buffer);                                     \
178         putc ('-', FILE);                                                 \
179         assemble_name (FILE,                                              \
180                    XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
181         putc ('\n', FILE);                                                \
182         ASM_OUTPUT_INTERNAL_LABEL (FILE, "LM", sym_lineno);               \
183         sym_lineno ++;                                                    \
184       }                                                                   \
185   }
186
187 #define STARTFILE_SPEC "crt0.o%s"
188 #define ENDFILE_SPEC  "%{!mno-lsim:-lsim}"
189
190 /* __CTOR_LIST__ and __DTOR_LIST__ must be defined by the linker script.  */
191 #define CTOR_LISTS_DEFINED_EXTERNALLY
192
193 #undef DO_GLOBAL_CTORS_BODY
194 #undef DO_GLOBAL_DTORS_BODY
195 #undef INIT_SECTION_ASM_OP
196 #undef DTORS_SECTION_ASM_OP
197
198 #define SUPPORTS_ONE_ONLY 1
199
200 /* Switch into a generic section.  */
201 #undef TARGET_ASM_NAMED_SECTION
202 #define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section