Backend for Motorola's MCore processors.
[official-gcc.git] / gcc / config / mcore / mcore-pe.h
blob89d4e6128b5ff04bed69d5db73d05e3286fe799e
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).
5 This file is part of GNU CC.
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.
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.
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. */
22 /* Run-time Target Specification. */
23 #define TARGET_VERSION fputs (" (MCORE/pe)", stderr)
25 #define SUBTARGET_CPP_PREDEFINES " -D__pe__"
27 #include "svr3.h"
28 #include "mcore/mcore.h"
29 #include "dbxcoff.h"
31 #undef SDB_DEBUGGING_INFO
32 #undef DBX_DEBUGGING_INFO
33 #define DBX_DEBUGGING_INFO 1
35 /* Computed in toplev.c. */
36 #undef PREFERRED_DEBUGGING_TYPE
38 /* Lay out additional 'sections' where we place things like code
39 and readonly data. This gets them out of default places. */
41 #define SUBTARGET_SWITCH_SECTIONS \
42 case in_drectve: drectve_section (); break; \
43 case in_rdata: rdata_section (); break;
45 #define DRECTVE_SECTION_ASM_OP "\t.section .drectve"
46 #define RDATA_SECTION_ASM_OP "\t.section .rdata"
48 #define SUBTARGET_EXTRA_SECTIONS in_drectve, in_rdata
50 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS \
51 DRECTVE_SECTION_FUNCTION \
52 RDATA_SECTION_FUNCTION
54 #define DRECTVE_SECTION_FUNCTION \
55 void \
56 drectve_section () \
57 { \
58 if (in_section != in_drectve) \
59 { \
60 fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP); \
61 in_section = in_drectve; \
62 } \
65 #define RDATA_SECTION_FUNCTION \
66 void \
67 rdata_section () \
68 { \
69 if (in_section != in_rdata) \
70 { \
71 fprintf (asm_out_file, "%s\n", RDATA_SECTION_ASM_OP); \
72 in_section = in_rdata; \
73 } \
76 #undef READONLY_DATA_SECTION
77 #define READONLY_DATA_SECTION() rdata_section ()
79 /* A C statement or statements to switch to the appropriate
80 section for output of DECL. DECL is either a `VAR_DECL' node
81 or a constant of some sort. RELOC indicates whether forming
82 the initial value of DECL requires link-time relocations. */
83 #undef SELECT_SECTION
84 #define SELECT_SECTION(DECL, RELOC) \
85 { \
86 if (TREE_CODE (DECL) == STRING_CST) \
87 { \
88 if (! flag_writable_strings) \
89 rdata_section (); \
90 else \
91 data_section (); \
92 } \
93 else if (TREE_CODE (DECL) == VAR_DECL) \
94 { \
95 if ((0 && RELOC) /* should be (flag_pic && RELOC) */ \
96 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
97 || !DECL_INITIAL (DECL) \
98 || (DECL_INITIAL (DECL) != error_mark_node \
99 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
100 data_section (); \
101 else \
102 rdata_section (); \
104 else \
105 rdata_section (); \
108 /* A C statement or statements to switch to the appropriate
109 section for output of RTX in mode MODE. RTX is some kind
110 of constant in RTL. The argument MODE is redundant except
111 in the case of a `const_int' rtx. Currently, these always
112 go into the const section. */
113 #undef SELECT_RTX_SECTION
114 #define SELECT_RTX_SECTION(MODE, RTX) rdata_section ()
116 #define MCORE_EXPORT_NAME(STREAM, NAME) \
117 do \
119 drectve_section (); \
120 fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \
121 MCORE_STRIP_NAME_ENCODING (NAME)); \
123 while (0);
125 /* Output the label for an initialized variable. */
126 #undef ASM_DECLARE_OBJECT_NAME
127 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
128 do \
130 if (mcore_dllexport_name_p (NAME)) \
132 enum in_section save_section = in_section; \
133 MCORE_EXPORT_NAME (STREAM, NAME); \
134 switch_to_section (save_section, (DECL)); \
136 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
138 while (0)
140 /* Output a function label definition. */
141 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
142 do \
144 if (mcore_dllexport_name_p (NAME)) \
146 MCORE_EXPORT_NAME (STREAM, NAME); \
147 function_section (DECL); \
149 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
151 while (0);
153 #undef ASM_FILE_START
154 #define ASM_FILE_START(STREAM) \
155 do \
157 extern char * version_string; \
158 fprintf (STREAM, "%s Generated by gcc %s for MCore/pe\n", \
159 ASM_COMMENT_START, version_string); \
160 output_file_directive ((STREAM), main_input_filename); \
162 while (0)
164 #undef ASM_OUTPUT_SOURCE_LINE
165 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE) \
167 if (write_symbols == DBX_DEBUG) \
169 static int sym_lineno = 1; \
170 char buffer[256]; \
172 ASM_GENERATE_INTERNAL_LABEL (buffer, "LM", sym_lineno); \
173 fprintf (FILE, ".stabn 68,0,%d,", LINE); \
174 assemble_name (FILE, buffer); \
175 putc ('-', FILE); \
176 assemble_name (FILE, \
177 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
178 putc ('\n', FILE); \
179 ASM_OUTPUT_INTERNAL_LABEL (FILE, "LM", sym_lineno); \
180 sym_lineno ++; \
184 #define STARTFILE_SPEC "crt0.o%s"
185 #define ENDFILE_SPEC "%{!mno-lsim:-lsim}"
187 #undef CTORS_SECTION_ASM_OP
188 #define CTORS_SECTION_ASM_OP ".section\t.ctors,\"x\""
189 #undef DTORS_SECTION_ASM_OP
190 #define DTORS_SECTION_ASM_OP ".section\t.dtors,\"x\""
192 #define INT_ASM_OP ".long"
194 #undef ASM_OUTPUT_CONSTRUCTOR
195 #define ASM_OUTPUT_CONSTRUCTOR(STREAM, NAME) \
196 do \
198 ctors_section (); \
199 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
200 assemble_name (STREAM, NAME); \
201 fprintf (STREAM, "\n"); \
203 while (0)
205 /* A C statement (sans semicolon) to output an element in the table of
206 global destructors. */
207 #undef ASM_OUTPUT_DESTRUCTOR
208 #define ASM_OUTPUT_DESTRUCTOR(STREAM, NAME) \
209 do \
211 dtors_section (); \
212 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
213 assemble_name (STREAM, NAME); \
214 fprintf (STREAM, "\n"); \
216 while (0)
218 /* __CTOR_LIST__ and __DTOR_LIST__ must be defined by the linker script. */
219 #define CTOR_LISTS_DEFINED_EXTERNALLY
221 #undef DO_GLOBAL_CTORS_BODY
222 #undef DO_GLOBAL_DTORS_BODY
223 #undef INIT_SECTION_ASM_OP
225 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
227 #define SUPPORTS_ONE_ONLY 1
229 /* A C statement to output something to the assembler file to switch to section
230 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
231 NULL_TREE. Some target formats do not support arbitrary sections. Do not
232 define this macro in such cases. */
233 #undef ASM_OUTPUT_SECTION_NAME
234 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
235 do \
237 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
238 fprintf (STREAM, "\t.section %s,\"x\"\n", NAME); \
239 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
240 fprintf (STREAM, "\t.section %s,\"\"\n", NAME); \
241 else \
242 fprintf (STREAM, "\t.section %s,\"w\"\n", NAME); \
243 /* Functions may have been compiled at various levels of \
244 optimization so we can't use `same_size' here. \
245 Instead, have the linker pick one. */ \
246 if ((DECL) && DECL_ONE_ONLY (DECL)) \
247 fprintf (STREAM, "\t.linkonce %s\n", \
248 TREE_CODE (DECL) == FUNCTION_DECL \
249 ? "discard" : "same_size"); \
251 while (0)