]> gcc.gnu.org Git - gcc.git/blob - gcc/config/rs6000/win-nt.h
varasm.c (asm_output_bss): New argument DECL.
[gcc.git] / gcc / config / rs6000 / win-nt.h
1 /* Definitions of target machine for GNU compiler, for PowerPC
2 running Windows/NT.
3 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4 Contributed by Cygnus Support.
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
22
23 /* Say this is Windows/NT for the other config files. */
24 #define WINDOWS_NT 1
25 #define COFF_WITH_PE 1
26
27 /* Default ABI to compile code for */
28 #define DEFAULT_ABI ABI_NT
29
30 #include "rs6000/powerpc.h"
31
32 /* Pseudo target that we can test in the md file. */
33 #undef TARGET_WINDOWS_NT
34 #define TARGET_WINDOWS_NT 1
35
36 #undef CPP_PREDEFINES
37 #define CPP_PREDEFINES "-DWIN32 -D_WIN32 \
38 -DWINNT -D__STDC__=0 -DALMOST_STDC \
39 -D_POWER -D_ARCH_PPC -D__PPC__ -Asystem(winnt) -Acpu(powerpc) -Amachine(powerpc)"
40
41 #if 0
42 #include "winnt/win-nt.h"
43 #endif
44
45 #undef LIB_SPEC
46 #define LIB_SPEC "%{mwindows:-subsystem:windows -entry:WinMainCRTStartup \
47 USER32.LIB GDI32.LIB COMDLG32.LIB WINSPOOL.LIB} \
48 %{!mwindows:-subsystem console -e mainCRTStartup} \
49 %{mcrtmt:LIBCMT.LIB KERNEL32.LIB} %{!mcrtmt:-lkernel32 -lcygwin} \
50 %{v}"
51
52 #undef LINK_SPEC
53 #define LINK_SPEC "%{v:-V}"
54
55 /* Allow switches specified in LIB_SPEC, but don't do anything with them
56 in the compiler. */
57 #undef SUBTARGET_SWITCHES
58 #define SUBTARGET_SWITCHES \
59 { "windows", 0 }, \
60 { "crtmt", 0 },
61
62 #undef XCOFF_DEBUGGING_INFO
63
64 /* this is pure coff, not xcoff */
65 #define SDB_DEBUGGING_INFO
66 #define DBX_DEBUGGING_INFO
67
68 #undef SDB_DELIM
69 #define SDB_DELIM ";"
70
71 #undef PREFERRED_DEBUGGING_TYPE
72 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
73
74 #undef PROCESSOR_DEFAULT
75 #define PROCESSOR_DEFAULT PROCESSOR_POWERPC
76
77 /* NT always runs little endian */
78 #undef BYTES_BIG_ENDIAN
79 #define BYTES_BIG_ENDIAN 0
80
81 #undef WORDS_BIG_ENDIAN
82 #define WORDS_BIG_ENDIAN 0
83
84 /* Define cutoff for using external functions to save floating point.
85 Currently on NT, always use inline stores */
86 #undef FP_SAVE_INLINE
87 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
88
89 /* Note, little endian systems trap on unaligned addresses, so never
90 turn off strict alignment in that case. */
91
92 #undef STRICT_ALIGNMENT
93 #define STRICT_ALIGNMENT 1
94
95 /* Align stack to 16 byte boundaries */
96 #undef STACK_BOUNDARY
97 #define STACK_BOUNDARY 128
98
99 /* No data type wants to be aligned rounder than this. */
100 #undef BIGGEST_ALIGNMENT
101 #define BIGGEST_ALIGNMENT 128
102
103 /* NT aligns internal doubles in structures on dword boundaries. */
104 #undef BIGGEST_FIELD_ALIGNMENT
105 #define BIGGEST_FIELD_ALIGNMENT 64
106
107 #undef ADJUST_FIELD_ALIGN
108 #undef ROUND_TYPE_ALIGN
109
110 #undef TARGET_VERSION
111 #define TARGET_VERSION fprintf (stderr, " (PowerPC PE)");
112
113 #undef TARGET_DEFAULT
114 #define TARGET_DEFAULT (MASK_POWERPC | MASK_NEW_MNEMONICS | MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC)
115
116 #undef PROCESSOR_DEFAULT
117 #define PROCESSOR_DEFAULT PROCESSOR_PPC601
118
119 /* Address to save the TOC register */
120 #undef RS6000_SAVE_TOC
121 #define RS6000_SAVE_TOC plus_constant (virtual_incoming_args_rtx, -RS6000_SAVE_AREA - 8)
122
123 /* Windows NT specifies that r13 is reserved to the OS, so it is not available
124 to the normal user. */
125
126 #undef FIXED_R13
127 #define FIXED_R13 1
128 \f
129 /* This says how to output an assembler line
130 to define a global common symbol. */
131
132 #undef ASM_OUTPUT_ALIGNED_COMMON
133 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGNMENT) \
134 do { fputs ("\t.comm \t", (FILE)); \
135 assemble_name ((FILE), (NAME)); \
136 if ( (SIZE) > 4) \
137 fprintf ((FILE), ",%d,%d\n", (SIZE), 3); \
138 else \
139 fprintf( (FILE), ",%d\n", (SIZE)); \
140 } while (0)
141
142 #undef ASM_OUTPUT_ALIGNED_LOCAL
143
144 /* This says how to output an assembler line
145 to define a global common symbol. */
146
147 #undef ASM_OUTPUT_COMMON
148 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
149 do { fputs ("\t.comm \t", (FILE)); \
150 assemble_name ((FILE), (NAME)); \
151 fprintf ((FILE), ",%d\n", (SIZE)); } while (0)
152
153 /* This says how to output an assembler line
154 to define an aligned local common symbol. */
155
156 #undef ASM_OUTPUT_ALIGNED_LOCAL
157 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
158 do { \
159 bss_section (); \
160 ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT)); \
161 ASM_OUTPUT_LABEL (FILE, NAME); \
162 ASM_OUTPUT_SKIP (FILE, SIZE); \
163 } while (0)
164
165 /* Describe how to emit unitialized external linkage items */
166 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
167 do { \
168 ASM_GLOBALIZE_LABEL (FILE, NAME); \
169 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
170 } while (0)
171
172 /* This says out to put a global symbol in the BSS section */
173 #undef ASM_OUTPUT_ALIGNED_BSS
174 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
175 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
176
177
178 /* Stuff to force fit us into the Motorola PPC assembler */
179
180 #if 0
181 #undef ASM_FILE_START
182 #define ASM_FILE_START(FILE) \
183 { \
184 output_file_directive (FILE, main_input_filename); \
185 fprintf (FILE, "\n#\tDirective section\n"); \
186 fprintf (FILE, "\t.section\t.drectve,\"iR\"\n"); \
187 fprintf (FILE, "\t.byte\t\"-defaultlib:LIBC\" \n"); \
188 fprintf (FILE, "\t.previous\n\n"); \
189 }
190 #endif
191
192 #undef ASM_FILE_START
193 #define ASM_FILE_START(FILE) \
194 do { \
195 output_file_directive ((FILE), main_input_filename); \
196 data_section (); \
197 } while (0)
198
199 #undef ASM_FILE_END
200
201 #undef ASM_DECLARE_FUNCTION_NAME
202 #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \
203 { \
204 tree exception_args; \
205 int i; \
206 \
207 if (TREE_PUBLIC (DECL)) \
208 { \
209 fprintf (FILE, "\t.globl .."); \
210 assemble_name (FILE, NAME); \
211 fprintf (FILE, "\n"); \
212 } \
213 assemble_name (FILE, NAME); \
214 fprintf (FILE, ":\n"); \
215 fprintf (FILE, "\t.ualong .."); \
216 assemble_name (FILE, NAME); \
217 fprintf (FILE, ",.toc\n"); \
218 \
219 fprintf (FILE, "\n#\tFunction: '.."); \
220 assemble_name (FILE, NAME); \
221 fputs ("'\n", FILE); \
222 fputs ("#\tText in section: <default>\n\n", FILE); \
223 fputs ("#\tSetup MS Structured-Exception-Handling\n", FILE); \
224 fputs ("\t.pdata\n", FILE); \
225 fputs ("\t.align 2\n", FILE); \
226 fputs ("\t.ualong ..", FILE); \
227 assemble_name (FILE, NAME); \
228 fputs (",", FILE); \
229 assemble_name (FILE, NAME); \
230 fputs (".e,", FILE); \
231 exception_args = lookup_attribute ("exception", \
232 TYPE_ATTRIBUTES (TREE_TYPE (DECL))); \
233 \
234 if (exception_args) \
235 exception_args = TREE_VALUE (exception_args); \
236 \
237 for (i = 0; i < 2; i++) \
238 { \
239 if (!exception_args) \
240 fputs ("0,", FILE); \
241 else \
242 { \
243 tree field = TREE_VALUE (exception_args); \
244 exception_args = TREE_PURPOSE (exception_args); \
245 if (TREE_CODE (field) == STRING_CST) \
246 fprintf (FILE, "%.*s,", TREE_STRING_LENGTH (field), \
247 TREE_STRING_POINTER (field)); \
248 else if (TREE_CODE (field) == IDENTIFIER_NODE) \
249 fprintf (FILE, "%.*s,", IDENTIFIER_LENGTH (field), \
250 IDENTIFIER_POINTER (field)); \
251 else \
252 abort (); \
253 } \
254 } \
255 \
256 assemble_name (FILE, NAME); \
257 fprintf (FILE, ".b\n\n"); \
258 fprintf (FILE, "#\tSwitch to the relocation section\n"); \
259 fprintf (FILE, "\t.reldata\n"); \
260 \
261 if (lookup_attribute ("dllexport", \
262 TYPE_ATTRIBUTES (TREE_TYPE (DECL)))) \
263 { \
264 fprintf (FILE, "\t.globl __imp_"); \
265 assemble_name (FILE, NAME); \
266 fprintf (FILE, "\n__imp_"); \
267 assemble_name (FILE, NAME); \
268 fprintf (FILE, ":\n\t.ulong "); \
269 assemble_name (FILE, NAME); \
270 fprintf (FILE, "\n"); \
271 } \
272 \
273 fprintf (FILE, "\t.section .text\n\t.align 2\n.."); \
274 assemble_name (FILE, NAME); \
275 fprintf (FILE, ":\n"); \
276 fprintf (FILE, "\t.function\t.."); \
277 assemble_name (FILE, NAME); \
278 fprintf (FILE, "\n"); \
279 }
280
281 /* This is how to output an assembler line defining a `double' constant. */
282
283 #undef ASM_OUTPUT_DOUBLE
284 #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
285 { \
286 if (REAL_VALUE_ISINF (VALUE) \
287 || REAL_VALUE_ISNAN (VALUE) \
288 || REAL_VALUE_MINUS_ZERO (VALUE)) \
289 { \
290 long t[2]; \
291 REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \
292 fprintf (FILE, "\t.ualong 0x%lx\n\t.long 0x%lx\n", \
293 t[0] & 0xffffffff, t[1] & 0xffffffff); \
294 } \
295 else \
296 { \
297 char str[30]; \
298 REAL_VALUE_TO_DECIMAL (VALUE, "%.20e", str); \
299 fprintf (FILE, "\t.double %s\n", str); \
300 } \
301 }
302
303 /* This is how to output an assembler line defining a `float' constant. */
304
305 #undef ASM_OUTPUT_FLOAT
306 #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
307 { \
308 if (REAL_VALUE_ISINF (VALUE) \
309 || REAL_VALUE_ISNAN (VALUE) \
310 || REAL_VALUE_MINUS_ZERO (VALUE)) \
311 { \
312 long t; \
313 REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \
314 fprintf (FILE, "\t.ualong 0x%lx\n", t & 0xffffffff); \
315 } \
316 else \
317 { \
318 char str[30]; \
319 REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \
320 fprintf (FILE, "\t.float %s\n", str); \
321 } \
322 }
323
324 /* Output before instructions. */
325 #undef TEXT_SECTION_ASM_OP
326 #define TEXT_SECTION_ASM_OP "\t.text"
327
328 /* Output before writable data. */
329 #undef DATA_SECTION_ASM_OP
330 #define DATA_SECTION_ASM_OP "\t.data"
331
332 /* Output to the bss section. */
333 #undef BSS_SECTION_ASM_OP
334 #define BSS_SECTION_ASM_OP "\t.section .bss"
335
336 /* Define the extra sections we need. We define a dummy TOC section,
337 plus sections to hold the list of static constructors (.ctors) and
338 destructors (.dtors). */
339
340 #undef READONLY_DATA_SECTION
341 #undef EXTRA_SECTIONS
342 #define EXTRA_SECTIONS in_toc, in_ctors, in_dtors
343
344 /* Define the routines to implement these extra sections. */
345
346 #undef EXTRA_SECTION_FUNCTIONS
347 #define EXTRA_SECTION_FUNCTIONS \
348 CTORS_SECTION_FUNCTION \
349 DTORS_SECTION_FUNCTION \
350 TOC_SECTION_FUNCTION \
351
352 #define TOC_SECTION_FUNCTION \
353 void \
354 toc_section () \
355 { \
356 }
357
358 #define CTORS_SECTION_ASM_OP ".section\t.ctors"
359 #define CTORS_SECTION_FUNCTION \
360 void \
361 ctors_section () \
362 { \
363 if (in_section != in_ctors) \
364 { \
365 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
366 in_section = in_ctors; \
367 } \
368 }
369
370 #define DTORS_SECTION_ASM_OP ".section\t.dtors"
371 #define DTORS_SECTION_FUNCTION \
372 void \
373 dtors_section () \
374 { \
375 if (in_section != in_dtors) \
376 { \
377 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
378 in_section = in_dtors; \
379 } \
380 }
381
382 #undef SELECT_SECTION
383 #undef SELECT_RTX_SECTION
384
385 /* Make sure __main gets called */
386 #define INVOKE__main 1
387
388 /* A C statement (sans semicolon) to output an element in the table of
389 global constructors. */
390 #undef ASM_OUTPUT_CONSTRUCTOR
391 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
392 do { \
393 ctors_section (); \
394 fprintf (FILE, "\t.ualong "); \
395 assemble_name (FILE, NAME); \
396 fprintf (FILE, "\n"); \
397 } while (0)
398
399 /* A C statement (sans semicolon) to output an element in the table of
400 global destructors. */
401 #undef ASM_OUTPUT_DESTRUCTOR
402 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
403 do { \
404 dtors_section (); \
405 fprintf (FILE, "\t.ualong "); \
406 assemble_name (FILE, NAME); \
407 fprintf (FILE, "\n"); \
408 } while (0)
409
410
411 /* Text to write out after a CALL that may be replaced by glue code by
412 the loader. The motorola asm demands that, for dll support, a .znop
413 be issued after a bl instruction, and the symbol on the .znop is the
414 symbol on the bl instruction */
415
416 #undef RS6000_CALL_GLUE
417 #define RS6000_CALL_GLUE "nop #\tFIXME: only works for non-dll calls."
418
419 #define RS6000_CALL_GLUE2 ".znop "
420
421 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY
422
423 /* Output something to declare an external symbol to the assembler. Most
424 assemblers don't need this. */
425
426 #undef ASM_OUTPUT_EXTERNAL
427
428 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
429 { \
430 char *_name; \
431 rtx _symref = XEXP (DECL_RTL (DECL), 0); \
432 if ((TREE_CODE (DECL) == VAR_DECL \
433 || TREE_CODE (DECL) == FUNCTION_DECL) \
434 && (NAME)[strlen (NAME) - 1] != ']') \
435 { \
436 _name = (char *) permalloc (strlen (XSTR (_symref, 0)) + 5); \
437 strcpy (_name, XSTR (_symref, 0)); \
438 XSTR (_symref, 0) = _name; \
439 } \
440 else \
441 _name = XSTR (_symref, 0); \
442 \
443 if (DECL_FUNCTION_CODE (DECL) == 0) \
444 { \
445 fputs ("\t.extern ", FILE); \
446 assemble_name (FILE, _name); \
447 putc ('\n', FILE); \
448 if (TREE_CODE (DECL) == FUNCTION_DECL) \
449 { \
450 fputs ("\t.extern ..", FILE); \
451 assemble_name (FILE, _name); \
452 putc ('\n', FILE); \
453 } \
454 } \
455 }
456
457 /* Similar, but for libcall. We only have to worry about the function name,
458 not that of the descriptor. */
459
460 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
461
462 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
463 { fprintf (FILE, "\t.extern .."); \
464 assemble_name (FILE, XSTR (FUN, 0)); \
465 fprintf (FILE, "\n"); \
466 }
467
468
469 /* Eliminate AIX style constant pool processing */
470 #undef LEGITIMATE_CONSTANT_POOL_BASE_P
471 #define LEGITIMATE_CONSTANT_POOL_BASE_P(X) 0
472
473 #undef LEGITIMATE_CONSTANT_POOL_ADDRESS_P
474 #define LEGITIMATE_CONSTANT_POOL_ADDRESS_P(X) 0
475
476 #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY
477
478 #undef ASM_IDENTIFY_GCC
479 #define ASM_IDENTIFY_GCC(x)
480
481 #undef HAS_INIT_SECTION
482 #define HAS_INIT_SECTION
This page took 0.061884 seconds and 6 git commands to generate.