summaryrefslogtreecommitdiff
path: root/gcc/config/i386/midipix.h
blob: 3502ba618b32fa350eeefe288693812a59495f70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
/*****************************************************************************/
/*                                                                           */
/*  midipix target definitions                                               */
/*                                                                           */
/*  Copyright (C)  2014,2015  Z. Gilboa                                      */
/*                                                                           */
/*  This program is free software: you can redistribute it and/or modify     */
/*  it under the terms of the GNU General Public License as published by     */
/*  the Free Software Foundation, either version 3 of the License, or        */
/*  (at your option) any later version.                                      */
/*                                                                           */
/*  This program is distributed in the hope that it will be useful,          */
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of           */
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             */
/*  GNU General Public License for more details.                             */
/*                                                                           */
/*  You should have received a copy of the GNU General Public License        */
/*  along with this program. If not, see <http://www.gnu.org/licenses/>.     */
/*                                                                           */
/*****************************************************************************/

#include <stdio.h>
#include "coretypes.h"

#if TARGET_64BIT_DEFAULT
#define MULTILIB_DEFAULTS			{ "m64" }
#else
#define MULTILIB_DEFAULTS			{ "m32" }
#endif


/* identify targets */
#define TARGET_NT64				(TARGET_64BIT)
#define TARGET_NT32				(!TARGET_64BIT)


/* target constraints */
#undef  TARGET_SEH
#define TARGET_SEH				(TARGET_NT64 && flag_unwind_tables)

#undef  MAX_OFILE_ALIGNMENT
#define MAX_OFILE_ALIGNMENT			(8 * (2 * 4096))

#define NT64_MAX_STACK_ALIGNMENT		(8 * 16)
#define NT32_MAX_STACK_ALIGNMENT		MAX_OFILE_ALIGNMENT

#define NT64_STACK_BOUNDARY			(8 * 16)
#define NT32_STACK_BOUNDARY			BITS_PER_WORD

#undef  MAX_STACK_ALIGNMENT
#define MAX_STACK_ALIGNMENT			(TARGET_NT64                \
						? NT64_MAX_STACK_ALIGNMENT  \
						: NT32_MAX_STACK_ALIGNMENT)

#undef  STACK_BOUNDARY
#define STACK_BOUNDARY				(TARGET_NT64)            \
						? (NT64_STACK_BOUNDARY)  \
						: (NT32_STACK_BOUNDARY)

#undef  STACK_CHECK_BUILTIN
#define STACK_CHECK_BUILTIN			(1)

#undef  STACK_CHECK_STATIC_BUILTIN
#define STACK_CHECK_STATIC_BUILTIN		(1)

#undef  DEFAULT_ABI
#define DEFAULT_ABI				(TARGET_NT64)  \
						? MS_ABI       \
						: SYSV_ABI


#undef  MULTIPLE_SYMBOL_SPACES
#define MULTIPLE_SYMBOL_SPACES			(1)

#undef  MS_AGGREGATE_RETURN
#define MS_AGGREGATE_RETURN			(0)

#undef  DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN		(0)

#undef  NO_PROFILE_COUNTERS
#define NO_PROFILE_COUNTERS			(1)

#undef  NT_MANDATED_FLAG_PIC
#define NT_MANDATED_FLAG_PIC			(TARGET_NT64)          \
						? (flag_pic ? 1 : 0 )  \
						: 0

#undef  SUBTARGET_OVERRIDE_OPTIONS
#define SUBTARGET_OVERRIDE_OPTIONS		do {					  \
							flag_pic = NT_MANDATED_FLAG_PIC;  \
						} while (0)

#undef  PCC_BITFIELD_TYPE_MATTERS
#define PCC_BITFIELD_TYPE_MATTERS		(1)


#define TARGET_OS_CPP_BUILTINS			midipix_target_os_cpp_builtins
#define EXTRA_OS_CPP_BUILTINS			midipix_extra_os_cpp_builtins


/* general target options */
#undef  TARGET_PECOFF
#define TARGET_PECOFF				(1)

#undef  HAS_INIT_SECTION
#define HAS_INIT_SECTION			(1)


#undef  HOST_EXECUTABLE_SUFFIX
#define HOST_EXECUTABLE_SUFFIX			""

#undef  TARGET_EXECUTABLE_SUFFIX
#define TARGET_EXECUTABLE_SUFFIX		""

#undef  MATH_LIBRARY
#define MATH_LIBRARY				""

#undef  CHECK_STACK_LIMIT
#define CHECK_STACK_LIMIT			(4096 - (8*32))

#undef  TARGET_DLLIMPORT_DECL_ATTRIBUTES
#define TARGET_DLLIMPORT_DECL_ATTRIBUTES	(1)

#undef  TARGET_POSIX_IO
#define TARGET_POSIX_IO				(1)

#undef  TARGET_SUBTARGET_DEFAULT
#define TARGET_SUBTARGET_DEFAULT		(MASK_ALIGN_DOUBLE    \
						| MASK_STACK_PROBE    \
						| MASK_80387          \
						| MASK_IEEE_FP        \
						| MASK_FLOAT_RETURNS)


/* assembler options */
#undef  HAVE_GAS_PE_SECREL32_RELOC
#define HAVE_GAS_PE_SECREL32_RELOC		(1)

#undef  HAVE_GAS_BALIGN_AND_P2ALIGN
#define HAVE_GAS_BALIGN_AND_P2ALIGN		(1)

#undef  SUPPORTS_ONE_ONLY
#define SUPPORTS_ONE_ONLY			(1)

#undef  GAS_SPACE
#define GAS_SPACE				" "

#undef  GAS_TAB
#define GAS_TAB					"\t"

#undef  GAS_SECTION
#define GAS_SECTION				GAS_TAB ".section" GAS_SPACE

#undef  INIT_SECTION_ASM_OP
#define INIT_SECTION_ASM_OP			GAS_SECTION ".init"

#undef  DRECTVE_SECTION_NAME
#define DRECTVE_SECTION_NAME			".drectve"

#undef  RODATA_SECTION_NAME
#define RODATA_SECTION_NAME			".rdata,\"r\""

#undef  GAS_PE_ASM_SET_OP
#define GAS_PE_ASM_SET_OP			"\t.set\t"

#undef  SET_ASM_OP
#define SET_ASM_OP				GAS_PE_ASM_SET_OP

#undef  READONLY_DATA_SECTION_ASM_OP
#define READONLY_DATA_SECTION_ASM_OP		GAS_SECTION RODATA_SECTION_NAME

#undef  TARGET_EMUTLS_VAR_SECTION_EMUTLS
#define TARGET_EMUTLS_VAR_SECTION_EMUTLS


/* debugging options */
#undef  PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE		DWARF2_DEBUG

#undef  DWARF_FRAME_REGISTERS
#define DWARF_FRAME_REGISTERS			(TARGET_NT64 ? 33 : 17)

#undef  DBX_DEBUGGING_INFO
#define DBX_DEBUGGING_INFO			(1)

#undef  SDB_DEBUGGING_INFO
#define SDB_DEBUGGING_INFO			(1)

#undef  DWARF2_DEBUGGING_INFO
#define DWARF2_DEBUGGING_INFO			(1)

#undef  HAVE_ENABLE_EXECUTE_STACK
#define HAVE_ENABLE_EXECUTE_STACK		(1)

#undef  CHECK_EXECUTE_STACK_ENABLED
#define CHECK_EXECUTE_STACK_ENABLED		(1)

#undef  DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(n)			midipix_dbx_get_register_number(n)

#undef  DWARF_FRAME_REGNUM
#define DWARF_FRAME_REGNUM(n)			midipix_dbx_get_dwarf_frame_register_number(n)

#undef  ASM_OUTPUT_DWARF_OFFSET
#define ASM_OUTPUT_DWARF_OFFSET			midipix_asm_output_dwarf_offset

/* assembler labels */
#undef  USER_LABEL_PREFIX
#define USER_LABEL_PREFIX			(TARGET_NT64 ? ""   : "_")

#undef  LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX			(TARGET_NT64 ? "."  : "")

#undef  LPREFIX
#define LPREFIX					(TARGET_NT64 ? ".L" : "L")

#undef	ASM_COMMENT_START
#define ASM_COMMENT_START			"\t#"

#undef  ASM_OUTPUT_LABELREF
#define ASM_OUTPUT_LABELREF			midipix_asm_output_label_ref

#undef  ASM_GENERATE_INTERNAL_LABEL
#define ASM_GENERATE_INTERNAL_LABEL		midipix_asm_generate_internal_label

#undef  ASM_DECLARE_OBJECT_NAME
#define ASM_DECLARE_OBJECT_NAME			midipix_asm_declare_object_name

#undef  ASM_OUTPUT_DEF_FROM_DECLS
#define ASM_OUTPUT_DEF_FROM_DECLS		midipix_asm_output_def_from_decls

#undef  ASM_OUTPUT_EXTERNAL
#define ASM_OUTPUT_EXTERNAL			midipix_asm_output_external

#undef  ASM_OUTPUT_EXTERNAL_LIBCALL
#define ASM_OUTPUT_EXTERNAL_LIBCALL		midipix_asm_output_external_libcall

#undef  TARGET_USE_LOCAL_THUNK_ALIAS_P
#define TARGET_USE_LOCAL_THUNK_ALIAS_P		midipix_target_use_local_thunk_alias

#undef  drectve_section
#define drectve_section				midipix_asm_drectve_section


/* common target hooks */
#undef  ASM_DECLARE_FUNCTION_NAME
#define ASM_DECLARE_FUNCTION_NAME		midipix_i386_pe_start_function

#undef  ASM_DECLARE_FUNCTION_SIZE
#define ASM_DECLARE_FUNCTION_SIZE		midipix_i386_pe_end_function

#undef  TARGET_ASM_ASSEMBLE_VISIBILITY
#define TARGET_ASM_ASSEMBLE_VISIBILITY		midipix_i386_pe_assemble_visibility

#undef  TARGET_ASM_FILE_END
#define TARGET_ASM_FILE_END			i386_pe_file_end

#undef  ASM_OUTPUT_ALIGNED_BSS
#define ASM_OUTPUT_ALIGNED_BSS			asm_output_aligned_bss

#undef  ASM_OUTPUT_ALIGNED_DECL_COMMON
#define ASM_OUTPUT_ALIGNED_DECL_COMMON		i386_pe_asm_output_aligned_decl_common

#undef  TARGET_ASM_UNIQUE_SECTION
#define TARGET_ASM_UNIQUE_SECTION		i386_pe_unique_section

#undef  TARGET_ASM_NAMED_SECTION
#define TARGET_ASM_NAMED_SECTION		i386_pe_asm_named_section

#undef  TARGET_SECTION_TYPE_FLAGS
#define TARGET_SECTION_TYPE_FLAGS		i386_pe_section_type_flags

#undef  TARGET_MANGLE_ASSEMBLER_NAME
#define TARGET_MANGLE_ASSEMBLER_NAME		i386_pe_mangle_assembler_name

#undef  SUBTARGET_ENCODE_SECTION_INFO
#define SUBTARGET_ENCODE_SECTION_INFO		i386_pe_encode_section_info

#undef  TARGET_VALID_DLLIMPORT_ATTRIBUTE_P
#define TARGET_VALID_DLLIMPORT_ATTRIBUTE_P	i386_pe_valid_dllimport_attribute_p

#undef  TARGET_CXX_ADJUST_CLASS_AT_DEFINITION
#define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION	i386_pe_adjust_class_at_definition

#undef  SUBTARGET_MANGLE_DECL_ASSEMBLER_NAME
#define SUBTARGET_MANGLE_DECL_ASSEMBLER_NAME	i386_pe_mangle_decl_assembler_name

#undef  TARGET_ASM_RELOC_RW_MASK
#define TARGET_ASM_RELOC_RW_MASK		midipix_i386_pe_reloc_rw_mask


/* libgcc */
#define __CXX_SEH__				(1)

#define LIBGCC2_TF_CEXT				q
#define LIBGCC2_TF_SIZE				113

#undef  TF_SIZE
#define TF_SIZE					LIBGCC2_TF_SIZE

#undef  LIBGCC2_HAS_TF_MODE
#define LIBGCC2_HAS_TF_MODE			(1)


/* source compatibility: seh prototypes */
extern void midipix_seh_hook__pe_seh_init(FILE *);
extern void midipix_seh_hook__pe_seh_end_prologue(FILE *);
extern void midipix_seh_hook__pe_seh_unwind_emit(FILE *, rtx);
extern void midipix_seh_hook__pe_seh_emit_except_personality(rtx);
extern void midipix_seh_hook__pe_seh_init_sections(void);


/* SEH hooks: 64-bit provided by winnt.c, 32-bit (to be) provided by midipix.c */
#define TARGET_ASM_UNWIND_EMIT			midipix_seh_hook__pe_seh_unwind_emit
#define TARGET_ASM_FUNCTION_END_PROLOGUE	midipix_seh_hook__pe_seh_end_prologue
#define TARGET_ASM_EMIT_EXCEPT_PERSONALITY	midipix_seh_hook__pe_seh_emit_except_personality
#define TARGET_ASM_INIT_SECTIONS		midipix_seh_hook__pe_seh_init_sections
#define SUBTARGET_ASM_UNWIND_INIT		midipix_seh_hook__pe_seh_init


/* target-specific definitions */
#ifndef IN_TARGET_LIBRARY_BUILD

#undef  BIGGEST_FIELD_ALIGNMENT
#define BIGGEST_FIELD_ALIGNMENT			(8 * __CHAR_BIT__)

#undef  ASM_WEAKEN_DECL
#define ASM_WEAKEN_DECL				midipix_i386_pe_asm_weaken_decl

#undef  ASM_WEAKEN_LABEL
#define ASM_WEAKEN_LABEL			midipix_i386_pe_asm_weaken_label

#undef  TARGET_ASM_FUNCTION_SECTION
#define TARGET_ASM_FUNCTION_SECTION		midipix_i386_pe_function_section


/* forward declarations */
extern void builtin_define_std			(const char *);

extern void midipix_asm_drectve_section		(void);
extern void midipix_asm_generate_internal_label	(char * strbuf, const char * prefix, unsigned long number);

extern int  midipix_target_use_local_thunk_alias(tree decl);
extern void midipix_i386_pe_assemble_visibility (tree decl, int visible);

extern void midipix_asm_output_external		(FILE * asmout, tree decl, const char * name);
extern void midipix_asm_output_def_from_decls	(FILE * asmout, tree decl, tree target);
extern void midipix_asm_output_external_libcall (FILE * asmout, rtx fn);

extern void midipix_asm_declare_object_name	(FILE * asmout, const char * name, tree decl);
extern void midipix_i386_pe_start_function	(FILE * asmout, const char * name, tree decl);
extern void midipix_i386_pe_end_function	(FILE * asmout, const char * name, tree decl);
extern void midipix_asm_output_label_ref	(FILE * asmout, const char * name);
extern void midipix_i386_pe_asm_weaken_label	(FILE * asmout, const char * name);

extern void midipix_i386_pe_asm_weaken_decl	(FILE * asmout,  tree decl, const char * name, const char * alias);
extern void midipix_asm_output_dwarf_offset	(FILE * asmout,  unsigned size, const char * label, section * section);

extern unsigned int midipix_dbx_get_register_number		(unsigned int n);
extern unsigned int midipix_dbx_get_dwarf_frame_register_number	(unsigned int n);

extern section * midipix_i386_pe_function_section(
	tree			decl,
	enum node_frequency	freq,
	bool			startup,
	bool			exit);


/* inlined functions */
static inline void midipix_extra_os_cpp_builtins(void)
{
	if (TARGET_NT64)
		builtin_define_std("__NT64");
	else
		builtin_define_std("__NT32");
}

static inline void midipix_target_os_cpp_builtins(void)
{
	builtin_define_std("__PE__");
	builtin_define_std("__midipix__");
	midipix_extra_os_cpp_builtins();
}

static inline int midipix_i386_pe_reloc_rw_mask	(void)
{
	return 0;
}

#endif