OSDN Git Service

* config/i386/i386.h (SHIFT_COUNT_TRUNCATED): Expand comment.
[pf3gnuchains/gcc-fork.git] / gcc / config / darwin.c
1 /* Functions for generic Darwin as target machine for GNU C compiler.
2    Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002, 2003, 2004,
3    2005, 2006, 2007, 2008, 2009, 2010
4    Free Software Foundation, Inc.
5    Contributed by Apple Computer Inc.
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3.  If not see
21 <http://www.gnu.org/licenses/>.  */
22
23 #include "config.h"
24 #include "system.h"
25 #include "coretypes.h"
26 #include "tm.h"
27 #include "rtl.h"
28 #include "regs.h"
29 #include "hard-reg-set.h"
30 #include "insn-config.h"
31 #include "conditions.h"
32 #include "insn-flags.h"
33 #include "output.h"
34 #include "insn-attr.h"
35 #include "flags.h"
36 #include "tree.h"
37 #include "expr.h"
38 #include "reload.h"
39 #include "function.h"
40 #include "ggc.h"
41 #include "langhooks.h"
42 #include "target.h"
43 #include "tm_p.h"
44 #include "diagnostic-core.h"
45 #include "toplev.h"
46 #include "hashtab.h"
47 #include "df.h"
48 #include "debug.h"
49 #include "obstack.h"
50 #include "lto-streamer.h"
51
52 /* Darwin supports a feature called fix-and-continue, which is used
53    for rapid turn around debugging.  When code is compiled with the
54    -mfix-and-continue flag, two changes are made to the generated code
55    that allow the system to do things that it would normally not be
56    able to do easily.  These changes allow gdb to load in
57    recompilation of a translation unit that has been changed into a
58    running program and replace existing functions and methods of that
59    translation unit with versions of those functions and methods
60    from the newly compiled translation unit.  The new functions access
61    the existing static symbols from the old translation unit, if the
62    symbol existed in the unit to be replaced, and from the new
63    translation unit, otherwise.
64
65    The changes are to insert 5 nops at the beginning of all functions
66    and to use indirection to get at static symbols.  The 5 nops
67    are required by consumers of the generated code.  Currently, gdb
68    uses this to patch in a jump to the overriding function, this
69    allows all uses of the old name to forward to the replacement,
70    including existing function pointers and virtual methods.  See
71    rs6000_emit_prologue for the code that handles the nop insertions.
72
73    The added indirection allows gdb to redirect accesses to static
74    symbols from the newly loaded translation unit to the existing
75    symbol, if any.  @code{static} symbols are special and are handled by
76    setting the second word in the .non_lazy_symbol_pointer data
77    structure to symbol.  See indirect_data for the code that handles
78    the extra indirection, and machopic_output_indirection and its use
79    of MACHO_SYMBOL_STATIC for the code that handles @code{static}
80    symbol indirection.  */
81
82 /* Section names.  */
83 section * darwin_sections[NUM_DARWIN_SECTIONS];
84
85 /* True if we're setting __attribute__ ((ms_struct)).  */
86 int darwin_ms_struct = false;
87
88 /* A get_unnamed_section callback used to switch to an ObjC section.
89    DIRECTIVE is as for output_section_asm_op.  */
90
91 static void
92 output_objc_section_asm_op (const void *directive)
93 {
94   static bool been_here = false;
95
96   /* The NeXT ObjC Runtime requires these sections to be present and in 
97      order in the object.  The code below implements this by emitting 
98      a section header for each ObjC section the first time that an ObjC
99      section is requested.  */
100   if (! been_here)
101     {
102       section *saved_in_section = in_section;
103       static const enum darwin_section_enum tomark[] =
104         {
105           /* written, cold -> hot */
106           objc_cat_cls_meth_section,
107           objc_cat_inst_meth_section,
108           objc_string_object_section,
109           objc_constant_string_object_section,
110           objc_selector_refs_section,
111           objc_selector_fixup_section,
112           objc_cls_refs_section,
113           objc_class_section,
114           objc_meta_class_section,
115           /* shared, hot -> cold */
116           objc_cls_meth_section,
117           objc_inst_meth_section,
118           objc_protocol_section,
119           objc_class_names_section,
120           objc_meth_var_types_section,
121           objc_meth_var_names_section,
122           objc_category_section,
123           objc_class_vars_section,
124           objc_instance_vars_section,
125           objc_module_info_section,
126           objc_symbols_section
127         };
128       size_t i;
129
130       been_here = true;
131       for (i = 0; i < ARRAY_SIZE (tomark); i++)
132         switch_to_section (darwin_sections[tomark[i]]);
133       switch_to_section (saved_in_section);
134     }
135   output_section_asm_op (directive);
136 }
137
138 /* Implement TARGET_ASM_INIT_SECTIONS.  */
139
140 void
141 darwin_init_sections (void)
142 {
143 #define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC)               \
144   darwin_sections[NAME] =                                       \
145     get_unnamed_section (FLAGS, (OBJC                           \
146                                  ? output_objc_section_asm_op   \
147                                  : output_section_asm_op),      \
148                          "\t" DIRECTIVE);
149 #include "config/darwin-sections.def"
150 #undef DEF_SECTION
151
152   readonly_data_section = darwin_sections[const_section];
153   exception_section = darwin_sections[darwin_exception_section];
154   eh_frame_section = darwin_sections[darwin_eh_frame_section];
155 }
156
157 int
158 name_needs_quotes (const char *name)
159 {
160   int c;
161   while ((c = *name++) != '\0')
162     if (! ISIDNUM (c) 
163           && c != '.' && c != '$' && c != '_' )
164       return 1;
165   return 0;
166 }
167
168 /* Return true if SYM_REF can be used without an indirection.  */
169 static int
170 machopic_symbol_defined_p (rtx sym_ref)
171 {
172   if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
173     return true;
174
175   /* If a symbol references local and is not an extern to this
176      file, then the symbol might be able to declared as defined.  */
177   if (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref))
178     {
179       /* If the symbol references a variable and the variable is a
180          common symbol, then this symbol is not defined.  */
181       if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_VARIABLE)
182         {
183           tree decl = SYMBOL_REF_DECL (sym_ref);
184           if (!decl)
185             return true;
186           if (DECL_COMMON (decl))
187             return false;
188         }
189       return true;
190     }
191   return false;
192 }
193
194 /* This module assumes that (const (symbol_ref "foo")) is a legal pic
195    reference, which will not be changed.  */
196
197 enum machopic_addr_class
198 machopic_classify_symbol (rtx sym_ref)
199 {
200   bool function_p;
201
202   function_p = SYMBOL_REF_FUNCTION_P (sym_ref);
203   if (machopic_symbol_defined_p (sym_ref))
204     return (function_p
205             ? MACHOPIC_DEFINED_FUNCTION : MACHOPIC_DEFINED_DATA);
206   else
207     return (function_p
208             ? MACHOPIC_UNDEFINED_FUNCTION : MACHOPIC_UNDEFINED_DATA);
209 }
210
211 #ifndef TARGET_FIX_AND_CONTINUE
212 #define TARGET_FIX_AND_CONTINUE 0
213 #endif
214
215 /* Indicate when fix-and-continue style code generation is being used
216    and when a reference to data should be indirected so that it can be
217    rebound in a new translation unit to reference the original instance
218    of that data.  Symbol names that are for code generation local to
219    the translation unit are bound to the new translation unit;
220    currently this means symbols that begin with L or _OBJC_;
221    otherwise, we indicate that an indirect reference should be made to
222    permit the runtime to rebind new instances of the translation unit
223    to the original instance of the data.  */
224
225 static int
226 indirect_data (rtx sym_ref)
227 {
228   int lprefix;
229   const char *name;
230
231   /* If we aren't generating fix-and-continue code, don't do anything
232      special.  */
233   if (TARGET_FIX_AND_CONTINUE == 0)
234     return 0;
235
236   /* Otherwise, all symbol except symbols that begin with L or _OBJC_
237      are indirected.  Symbols that begin with L and _OBJC_ are always
238      bound to the current translation unit as they are used for
239      generated local data of the translation unit.  */
240
241   name = XSTR (sym_ref, 0);
242
243   lprefix = (((name[0] == '*' || name[0] == '&')
244               && (name[1] == 'L' || (name[1] == '"' && name[2] == 'L')))
245              || (strncmp (name, "_OBJC_", 6) == 0));
246
247   return ! lprefix;
248 }
249
250
251 static int
252 machopic_data_defined_p (rtx sym_ref)
253 {
254   if (indirect_data (sym_ref))
255     return 0;
256
257   switch (machopic_classify_symbol (sym_ref))
258     {
259     case MACHOPIC_DEFINED_DATA:
260     case MACHOPIC_DEFINED_FUNCTION:
261       return 1;
262     default:
263       return 0;
264     }
265 }
266
267 void
268 machopic_define_symbol (rtx mem)
269 {
270   rtx sym_ref;
271
272   gcc_assert (GET_CODE (mem) == MEM);
273   sym_ref = XEXP (mem, 0);
274   SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_DEFINED;
275 }
276
277 /* Return either ORIG or:
278
279      (const:P (unspec:P [ORIG] UNSPEC_MACHOPIC_OFFSET))
280
281    depending on MACHO_DYNAMIC_NO_PIC_P.  */
282 rtx
283 machopic_gen_offset (rtx orig)
284 {
285   if (MACHO_DYNAMIC_NO_PIC_P)
286     return orig;
287   else
288     {
289       /* Play games to avoid marking the function as needing pic if we
290          are being called as part of the cost-estimation process.  */
291       if (current_ir_type () != IR_GIMPLE || currently_expanding_to_rtl)
292         crtl->uses_pic_offset_table = 1;
293       orig = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, orig),
294                              UNSPEC_MACHOPIC_OFFSET);
295       return gen_rtx_CONST (Pmode, orig);
296     }
297 }
298
299 static GTY(()) const char * function_base_func_name;
300 static GTY(()) int current_pic_label_num;
301
302 void
303 machopic_output_function_base_name (FILE *file)
304 {
305   const char *current_name;
306
307   /* If dynamic-no-pic is on, we should not get here.  */
308   gcc_assert (!MACHO_DYNAMIC_NO_PIC_P);
309   current_name =
310     IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
311   if (function_base_func_name != current_name)
312     {
313       ++current_pic_label_num;
314       function_base_func_name = current_name;
315     }
316   fprintf (file, "L%011d$pb", current_pic_label_num);
317 }
318
319 /* The suffix attached to non-lazy pointer symbols.  */
320 #define NON_LAZY_POINTER_SUFFIX "$non_lazy_ptr"
321 /* The suffix attached to stub symbols.  */
322 #define STUB_SUFFIX "$stub"
323
324 typedef struct GTY (()) machopic_indirection
325 {
326   /* The SYMBOL_REF for the entity referenced.  */
327   rtx symbol;
328   /* The name of the stub or non-lazy pointer.  */
329   const char * ptr_name;
330   /* True iff this entry is for a stub (as opposed to a non-lazy
331      pointer).  */
332   bool stub_p;
333   /* True iff this stub or pointer pointer has been referenced.  */
334   bool used;
335 } machopic_indirection;
336
337 /* A table mapping stub names and non-lazy pointer names to
338    SYMBOL_REFs for the stubbed-to and pointed-to entities.  */
339
340 static GTY ((param_is (struct machopic_indirection))) htab_t
341   machopic_indirections;
342
343 /* Return a hash value for a SLOT in the indirections hash table.  */
344
345 static hashval_t
346 machopic_indirection_hash (const void *slot)
347 {
348   const machopic_indirection *p = (const machopic_indirection *) slot;
349   return htab_hash_string (p->ptr_name);
350 }
351
352 /* Returns true if the KEY is the same as that associated with
353    SLOT.  */
354
355 static int
356 machopic_indirection_eq (const void *slot, const void *key)
357 {
358   return strcmp (((const machopic_indirection *) slot)->ptr_name,
359                  (const char *) key) == 0;
360 }
361
362 /* Return the name of the non-lazy pointer (if STUB_P is false) or
363    stub (if STUB_B is true) corresponding to the given name.  */
364
365 const char *
366 machopic_indirection_name (rtx sym_ref, bool stub_p)
367 {
368   char *buffer;
369   const char *name = XSTR (sym_ref, 0);
370   size_t namelen = strlen (name);
371   machopic_indirection *p;
372   void ** slot;
373   bool needs_quotes;
374   const char *suffix;
375   const char *prefix = user_label_prefix;
376   const char *quote = "";
377   tree id;
378
379   id = maybe_get_identifier (name);
380   if (id)
381     {
382       tree id_orig = id;
383
384       while (IDENTIFIER_TRANSPARENT_ALIAS (id))
385         id = TREE_CHAIN (id);
386       if (id != id_orig)
387         {
388           name = IDENTIFIER_POINTER (id);
389           namelen = strlen (name);
390         }
391     }
392
393   if (name[0] == '*')
394     {
395       prefix = "";
396       ++name;
397       --namelen;
398     }
399
400   needs_quotes = name_needs_quotes (name);
401   if (needs_quotes)
402     {
403       quote = "\"";
404     }
405
406   if (stub_p)
407     suffix = STUB_SUFFIX;
408   else
409     suffix = NON_LAZY_POINTER_SUFFIX;
410
411   buffer = XALLOCAVEC (char, strlen ("&L")
412                    + strlen (prefix)
413                    + namelen
414                    + strlen (suffix)
415                    + 2 * strlen (quote)
416                    + 1 /* '\0' */);
417
418   /* Construct the name of the non-lazy pointer or stub.  */
419   sprintf (buffer, "&%sL%s%s%s%s", quote, prefix, name, suffix, quote);
420
421   if (!machopic_indirections)
422     machopic_indirections = htab_create_ggc (37,
423                                              machopic_indirection_hash,
424                                              machopic_indirection_eq,
425                                              /*htab_del=*/NULL);
426
427   slot = htab_find_slot_with_hash (machopic_indirections, buffer,
428                                    htab_hash_string (buffer), INSERT);
429   if (*slot)
430     {
431       p = (machopic_indirection *) *slot;
432     }
433   else
434     {
435       p = ggc_alloc_machopic_indirection ();
436       p->symbol = sym_ref;
437       p->ptr_name = xstrdup (buffer);
438       p->stub_p = stub_p;
439       p->used = false;
440       *slot = p;
441     }
442
443   return p->ptr_name;
444 }
445
446 /* Return the name of the stub for the mcount function.  */
447
448 const char*
449 machopic_mcount_stub_name (void)
450 {
451   rtx symbol = gen_rtx_SYMBOL_REF (Pmode, "*mcount");
452   return machopic_indirection_name (symbol, /*stub_p=*/true);
453 }
454
455 /* If NAME is the name of a stub or a non-lazy pointer , mark the stub
456    or non-lazy pointer as used -- and mark the object to which the
457    pointer/stub refers as used as well, since the pointer/stub will
458    emit a reference to it.  */
459
460 void
461 machopic_validate_stub_or_non_lazy_ptr (const char *name)
462 {
463   machopic_indirection *p;
464
465   p = ((machopic_indirection *)
466        (htab_find_with_hash (machopic_indirections, name,
467                              htab_hash_string (name))));
468   if (p && ! p->used)
469     {
470       const char *real_name;
471       tree id;
472
473       p->used = true;
474
475       /* Do what output_addr_const will do when we actually call it.  */
476       if (SYMBOL_REF_DECL (p->symbol))
477         mark_decl_referenced (SYMBOL_REF_DECL (p->symbol));
478
479       real_name = targetm.strip_name_encoding (XSTR (p->symbol, 0));
480
481       id = maybe_get_identifier (real_name);
482       if (id)
483         mark_referenced (id);
484     }
485 }
486
487 /* Transform ORIG, which may be any data source, to the corresponding
488    source using indirections.  */
489
490 rtx
491 machopic_indirect_data_reference (rtx orig, rtx reg)
492 {
493   rtx ptr_ref = orig;
494
495   if (! MACHOPIC_INDIRECT)
496     return orig;
497
498   if (GET_CODE (orig) == SYMBOL_REF)
499     {
500       int defined = machopic_data_defined_p (orig);
501
502       if (defined && MACHO_DYNAMIC_NO_PIC_P)
503         {
504 #if defined (TARGET_TOC)
505           /* Create a new register for CSE opportunities.  */
506           rtx hi_reg = (!can_create_pseudo_p () ? reg : gen_reg_rtx (Pmode));
507           emit_insn (gen_macho_high (hi_reg, orig));
508           emit_insn (gen_macho_low (reg, hi_reg, orig));
509 #else
510            /* some other cpu -- writeme!  */
511            gcc_unreachable ();
512 #endif
513            return reg;
514         }
515       else if (defined)
516         {
517 #if defined (TARGET_TOC) || defined (HAVE_lo_sum)
518           rtx offset = machopic_gen_offset (orig);
519 #endif
520
521 #if defined (TARGET_TOC) /* i.e., PowerPC */
522           rtx hi_sum_reg = (!can_create_pseudo_p ()
523                             ? reg
524                             : gen_reg_rtx (Pmode));
525
526           gcc_assert (reg);
527
528           emit_insn (gen_rtx_SET (Pmode, hi_sum_reg,
529                               gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
530                                        gen_rtx_HIGH (Pmode, offset))));
531           emit_insn (gen_rtx_SET (Pmode, reg,
532                                   gen_rtx_LO_SUM (Pmode, hi_sum_reg,
533                                                   copy_rtx (offset))));
534
535           orig = reg;
536 #else
537 #if defined (HAVE_lo_sum)
538           gcc_assert (reg);
539
540           emit_insn (gen_rtx_SET (VOIDmode, reg,
541                                   gen_rtx_HIGH (Pmode, offset)));
542           emit_insn (gen_rtx_SET (VOIDmode, reg,
543                                   gen_rtx_LO_SUM (Pmode, reg,
544                                                   copy_rtx (offset))));
545           emit_use (pic_offset_table_rtx);
546
547           orig = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, reg);
548 #endif
549 #endif
550           return orig;
551         }
552
553       ptr_ref = (gen_rtx_SYMBOL_REF
554                  (Pmode,
555                   machopic_indirection_name (orig, /*stub_p=*/false)));
556
557       SYMBOL_REF_DATA (ptr_ref) = SYMBOL_REF_DATA (orig);
558
559       ptr_ref = gen_const_mem (Pmode, ptr_ref);
560       machopic_define_symbol (ptr_ref);
561
562       return ptr_ref;
563     }
564   else if (GET_CODE (orig) == CONST)
565     {
566       rtx base, result;
567
568       /* legitimize both operands of the PLUS */
569       if (GET_CODE (XEXP (orig, 0)) == PLUS)
570         {
571           base = machopic_indirect_data_reference (XEXP (XEXP (orig, 0), 0),
572                                                    reg);
573           orig = machopic_indirect_data_reference (XEXP (XEXP (orig, 0), 1),
574                                                    (base == reg ? 0 : reg));
575         }
576       else
577         return orig;
578
579       if (MACHOPIC_PURE && GET_CODE (orig) == CONST_INT)
580         result = plus_constant (base, INTVAL (orig));
581       else
582         result = gen_rtx_PLUS (Pmode, base, orig);
583
584       if (MACHOPIC_JUST_INDIRECT && GET_CODE (base) == MEM)
585         {
586           if (reg)
587             {
588               emit_move_insn (reg, result);
589               result = reg;
590             }
591           else
592             {
593               result = force_reg (GET_MODE (result), result);
594             }
595         }
596
597       return result;
598
599     }
600   else if (GET_CODE (orig) == MEM)
601     XEXP (ptr_ref, 0) = machopic_indirect_data_reference (XEXP (orig, 0), reg);
602   /* When the target is i386, this code prevents crashes due to the
603      compiler's ignorance on how to move the PIC base register to
604      other registers.  (The reload phase sometimes introduces such
605      insns.)  */
606   else if (GET_CODE (orig) == PLUS
607            && GET_CODE (XEXP (orig, 0)) == REG
608            && REGNO (XEXP (orig, 0)) == PIC_OFFSET_TABLE_REGNUM
609 #ifdef I386
610            /* Prevent the same register from being erroneously used
611               as both the base and index registers.  */
612            && GET_CODE (XEXP (orig, 1)) == CONST
613 #endif
614            && reg)
615     {
616       emit_move_insn (reg, XEXP (orig, 0));
617       XEXP (ptr_ref, 0) = reg;
618     }
619   return ptr_ref;
620 }
621
622 /* Transform TARGET (a MEM), which is a function call target, to the
623    corresponding symbol_stub if necessary.  Return a new MEM.  */
624
625 rtx
626 machopic_indirect_call_target (rtx target)
627 {
628   if (GET_CODE (target) != MEM)
629     return target;
630
631   if (MACHOPIC_INDIRECT
632       && GET_CODE (XEXP (target, 0)) == SYMBOL_REF
633       && !(SYMBOL_REF_FLAGS (XEXP (target, 0))
634            & MACHO_SYMBOL_FLAG_DEFINED))
635     {
636       rtx sym_ref = XEXP (target, 0);
637       const char *stub_name = machopic_indirection_name (sym_ref,
638                                                          /*stub_p=*/true);
639       enum machine_mode mode = GET_MODE (sym_ref);
640
641       XEXP (target, 0) = gen_rtx_SYMBOL_REF (mode, stub_name);
642       SYMBOL_REF_DATA (XEXP (target, 0)) = SYMBOL_REF_DATA (sym_ref);
643       MEM_READONLY_P (target) = 1;
644       MEM_NOTRAP_P (target) = 1;
645     }
646
647   return target;
648 }
649
650 rtx
651 machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg)
652 {
653   rtx pic_ref = orig;
654
655   if (! MACHOPIC_INDIRECT)
656     return orig;
657
658   /* First handle a simple SYMBOL_REF or LABEL_REF */
659   if (GET_CODE (orig) == LABEL_REF
660       || (GET_CODE (orig) == SYMBOL_REF
661           ))
662     {
663       /* addr(foo) = &func+(foo-func) */
664       orig = machopic_indirect_data_reference (orig, reg);
665
666       if (GET_CODE (orig) == PLUS
667           && GET_CODE (XEXP (orig, 0)) == REG)
668         {
669           if (reg == 0)
670             return force_reg (mode, orig);
671
672           emit_move_insn (reg, orig);
673           return reg;
674         }
675
676       if (GET_CODE (orig) == MEM)
677         {
678           if (reg == 0)
679             {
680               gcc_assert (!reload_in_progress);
681               reg = gen_reg_rtx (Pmode);
682             }
683
684 #ifdef HAVE_lo_sum
685           if (MACHO_DYNAMIC_NO_PIC_P
686               && (GET_CODE (XEXP (orig, 0)) == SYMBOL_REF
687                   || GET_CODE (XEXP (orig, 0)) == LABEL_REF))
688             {
689 #if defined (TARGET_TOC)        /* ppc  */
690               rtx temp_reg = (!can_create_pseudo_p ()
691                               ? reg :
692                               gen_reg_rtx (Pmode));
693               rtx asym = XEXP (orig, 0);
694               rtx mem;
695
696               emit_insn (gen_macho_high (temp_reg, asym));
697               mem = gen_const_mem (GET_MODE (orig),
698                                    gen_rtx_LO_SUM (Pmode, temp_reg,
699                                                    copy_rtx (asym)));
700               emit_insn (gen_rtx_SET (VOIDmode, reg, mem));
701 #else
702               /* Some other CPU -- WriteMe! but right now there are no other
703                  platforms that can use dynamic-no-pic  */
704               gcc_unreachable ();
705 #endif
706               pic_ref = reg;
707             }
708           else
709           if (GET_CODE (XEXP (orig, 0)) == SYMBOL_REF
710               || GET_CODE (XEXP (orig, 0)) == LABEL_REF)
711             {
712               rtx offset = machopic_gen_offset (XEXP (orig, 0));
713 #if defined (TARGET_TOC) /* i.e., PowerPC */
714               /* Generating a new reg may expose opportunities for
715                  common subexpression elimination.  */
716               rtx hi_sum_reg = (!can_create_pseudo_p ()
717                                 ? reg
718                                 : gen_reg_rtx (Pmode));
719               rtx mem;
720               rtx insn;
721               rtx sum;
722
723               sum = gen_rtx_HIGH (Pmode, offset);
724               if (! MACHO_DYNAMIC_NO_PIC_P)
725                 sum = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, sum);
726
727               emit_insn (gen_rtx_SET (Pmode, hi_sum_reg, sum));
728
729               mem = gen_const_mem (GET_MODE (orig),
730                                   gen_rtx_LO_SUM (Pmode,
731                                                   hi_sum_reg,
732                                                   copy_rtx (offset)));
733               insn = emit_insn (gen_rtx_SET (VOIDmode, reg, mem));
734               set_unique_reg_note (insn, REG_EQUAL, pic_ref);
735
736               pic_ref = reg;
737 #else
738               emit_use (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
739
740               emit_insn (gen_rtx_SET (VOIDmode, reg,
741                                       gen_rtx_HIGH (Pmode,
742                                                     gen_rtx_CONST (Pmode,
743                                                                    offset))));
744               emit_insn (gen_rtx_SET (VOIDmode, reg,
745                                   gen_rtx_LO_SUM (Pmode, reg,
746                                            gen_rtx_CONST (Pmode,
747                                                           copy_rtx (offset)))));
748               pic_ref = gen_rtx_PLUS (Pmode,
749                                       pic_offset_table_rtx, reg);
750 #endif
751             }
752           else
753 #endif  /* HAVE_lo_sum */
754             {
755               rtx pic = pic_offset_table_rtx;
756               if (GET_CODE (pic) != REG)
757                 {
758                   emit_move_insn (reg, pic);
759                   pic = reg;
760                 }
761 #if 0
762               emit_use (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
763 #endif
764
765               if (reload_in_progress)
766                 df_set_regs_ever_live (REGNO (pic), true);
767               pic_ref = gen_rtx_PLUS (Pmode, pic,
768                                       machopic_gen_offset (XEXP (orig, 0)));
769             }
770
771 #if !defined (TARGET_TOC)
772           emit_move_insn (reg, pic_ref);
773           pic_ref = gen_const_mem (GET_MODE (orig), reg);
774 #endif
775         }
776       else
777         {
778
779 #ifdef HAVE_lo_sum
780           if (GET_CODE (orig) == SYMBOL_REF
781               || GET_CODE (orig) == LABEL_REF)
782             {
783               rtx offset = machopic_gen_offset (orig);
784 #if defined (TARGET_TOC) /* i.e., PowerPC */
785               rtx hi_sum_reg;
786
787               if (reg == 0)
788                 {
789                   gcc_assert (!reload_in_progress);
790                   reg = gen_reg_rtx (Pmode);
791                 }
792
793               hi_sum_reg = reg;
794
795               emit_insn (gen_rtx_SET (Pmode, hi_sum_reg,
796                                       (MACHO_DYNAMIC_NO_PIC_P)
797                                       ? gen_rtx_HIGH (Pmode, offset)
798                                       : gen_rtx_PLUS (Pmode,
799                                                       pic_offset_table_rtx,
800                                                       gen_rtx_HIGH (Pmode,
801                                                                     offset))));
802               emit_insn (gen_rtx_SET (VOIDmode, reg,
803                                       gen_rtx_LO_SUM (Pmode,
804                                                       hi_sum_reg,
805                                                       copy_rtx (offset))));
806               pic_ref = reg;
807 #else
808               emit_insn (gen_rtx_SET (VOIDmode, reg,
809                                       gen_rtx_HIGH (Pmode, offset)));
810               emit_insn (gen_rtx_SET (VOIDmode, reg,
811                                       gen_rtx_LO_SUM (Pmode, reg,
812                                                       copy_rtx (offset))));
813               pic_ref = gen_rtx_PLUS (Pmode,
814                                       pic_offset_table_rtx, reg);
815 #endif
816             }
817           else
818 #endif  /*  HAVE_lo_sum  */
819             {
820               if (REG_P (orig)
821                   || GET_CODE (orig) == SUBREG)
822                 {
823                   return orig;
824                 }
825               else
826                 {
827                   rtx pic = pic_offset_table_rtx;
828                   if (GET_CODE (pic) != REG)
829                     {
830                       emit_move_insn (reg, pic);
831                       pic = reg;
832                     }
833 #if 0
834                   emit_use (pic_offset_table_rtx);
835 #endif
836                   if (reload_in_progress)
837                     df_set_regs_ever_live (REGNO (pic), true);
838                   pic_ref = gen_rtx_PLUS (Pmode,
839                                           pic,
840                                           machopic_gen_offset (orig));
841                 }
842             }
843         }
844
845       if (GET_CODE (pic_ref) != REG)
846         {
847           if (reg != 0)
848             {
849               emit_move_insn (reg, pic_ref);
850               return reg;
851             }
852           else
853             {
854               return force_reg (mode, pic_ref);
855             }
856         }
857       else
858         {
859           return pic_ref;
860         }
861     }
862
863   else if (GET_CODE (orig) == SYMBOL_REF)
864     return orig;
865
866   else if (GET_CODE (orig) == PLUS
867            && (GET_CODE (XEXP (orig, 0)) == MEM
868                || GET_CODE (XEXP (orig, 0)) == SYMBOL_REF
869                || GET_CODE (XEXP (orig, 0)) == LABEL_REF)
870            && XEXP (orig, 0) != pic_offset_table_rtx
871            && GET_CODE (XEXP (orig, 1)) != REG)
872
873     {
874       rtx base;
875       int is_complex = (GET_CODE (XEXP (orig, 0)) == MEM);
876
877       base = machopic_legitimize_pic_address (XEXP (orig, 0), Pmode, reg);
878       orig = machopic_legitimize_pic_address (XEXP (orig, 1),
879                                               Pmode, (base == reg ? 0 : reg));
880       if (GET_CODE (orig) == CONST_INT)
881         {
882           pic_ref = plus_constant (base, INTVAL (orig));
883           is_complex = 1;
884         }
885       else
886         pic_ref = gen_rtx_PLUS (Pmode, base, orig);
887
888       if (reg && is_complex)
889         {
890           emit_move_insn (reg, pic_ref);
891           pic_ref = reg;
892         }
893       /* Likewise, should we set special REG_NOTEs here?  */
894     }
895
896   else if (GET_CODE (orig) == CONST)
897     {
898       return machopic_legitimize_pic_address (XEXP (orig, 0), Pmode, reg);
899     }
900
901   else if (GET_CODE (orig) == MEM
902            && GET_CODE (XEXP (orig, 0)) == SYMBOL_REF)
903     {
904       rtx addr = machopic_legitimize_pic_address (XEXP (orig, 0), Pmode, reg);
905       addr = replace_equiv_address (orig, addr);
906       emit_move_insn (reg, addr);
907       pic_ref = reg;
908     }
909
910   return pic_ref;
911 }
912
913 /* Output the stub or non-lazy pointer in *SLOT, if it has been used.
914    DATA is the FILE* for assembly output.  Called from
915    htab_traverse.  */
916
917 static int
918 machopic_output_indirection (void **slot, void *data)
919 {
920   machopic_indirection *p = *((machopic_indirection **) slot);
921   FILE *asm_out_file = (FILE *) data;
922   rtx symbol;
923   const char *sym_name;
924   const char *ptr_name;
925
926   if (!p->used)
927     return 1;
928
929   symbol = p->symbol;
930   sym_name = XSTR (symbol, 0);
931   ptr_name = p->ptr_name;
932
933   if (p->stub_p)
934     {
935       char *sym;
936       char *stub;
937       tree id;
938
939       id = maybe_get_identifier (sym_name);
940       if (id)
941         {
942           tree id_orig = id;
943
944           while (IDENTIFIER_TRANSPARENT_ALIAS (id))
945             id = TREE_CHAIN (id);
946           if (id != id_orig)
947             sym_name = IDENTIFIER_POINTER (id);
948         }
949
950       sym = XALLOCAVEC (char, strlen (sym_name) + 2);
951       if (sym_name[0] == '*' || sym_name[0] == '&')
952         strcpy (sym, sym_name + 1);
953       else if (sym_name[0] == '-' || sym_name[0] == '+')
954         strcpy (sym, sym_name);
955       else
956         sprintf (sym, "%s%s", user_label_prefix, sym_name);
957
958       stub = XALLOCAVEC (char, strlen (ptr_name) + 2);
959       if (ptr_name[0] == '*' || ptr_name[0] == '&')
960         strcpy (stub, ptr_name + 1);
961       else
962         sprintf (stub, "%s%s", user_label_prefix, ptr_name);
963
964       machopic_output_stub (asm_out_file, sym, stub);
965     }
966   else if (! indirect_data (symbol)
967            && (machopic_symbol_defined_p (symbol)
968                || SYMBOL_REF_LOCAL_P (symbol)))
969     {
970       switch_to_section (data_section);
971       assemble_align (GET_MODE_ALIGNMENT (Pmode));
972       assemble_label (asm_out_file, ptr_name);
973       assemble_integer (gen_rtx_SYMBOL_REF (Pmode, sym_name),
974                         GET_MODE_SIZE (Pmode),
975                         GET_MODE_ALIGNMENT (Pmode), 1);
976     }
977   else
978     {
979       rtx init = const0_rtx;
980
981       switch_to_section (darwin_sections[machopic_nl_symbol_ptr_section]);
982
983       /* Mach-O symbols are passed around in code through indirect
984          references and the original symbol_ref hasn't passed through
985          the generic handling and reference-catching in
986          output_operand, so we need to manually mark weak references
987          as such.  */
988       if (SYMBOL_REF_WEAK (symbol))
989         {
990           tree decl = SYMBOL_REF_DECL (symbol);
991           gcc_assert (DECL_P (decl));
992
993           if (decl != NULL_TREE
994               && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)
995               /* Handle only actual external-only definitions, not
996                  e.g. extern inline code or variables for which
997                  storage has been allocated.  */
998               && !TREE_STATIC (decl))
999             {
1000               fputs ("\t.weak_reference ", asm_out_file);
1001               assemble_name (asm_out_file, sym_name);
1002               fputc ('\n', asm_out_file);
1003             }
1004         }
1005
1006       assemble_name (asm_out_file, ptr_name);
1007       fprintf (asm_out_file, ":\n");
1008
1009       fprintf (asm_out_file, "\t.indirect_symbol ");
1010       assemble_name (asm_out_file, sym_name);
1011       fprintf (asm_out_file, "\n");
1012
1013       /* Variables that are marked with MACHO_SYMBOL_STATIC need to
1014          have their symbol name instead of 0 in the second entry of
1015          the non-lazy symbol pointer data structure when they are
1016          defined.  This allows the runtime to rebind newer instances
1017          of the translation unit with the original instance of the
1018          symbol.  */
1019
1020       if ((SYMBOL_REF_FLAGS (symbol) & MACHO_SYMBOL_STATIC)
1021           && machopic_symbol_defined_p (symbol))
1022         init = gen_rtx_SYMBOL_REF (Pmode, sym_name);
1023
1024       assemble_integer (init, GET_MODE_SIZE (Pmode),
1025                         GET_MODE_ALIGNMENT (Pmode), 1);
1026     }
1027
1028   return 1;
1029 }
1030
1031 void
1032 machopic_finish (FILE *asm_out_file)
1033 {
1034   if (machopic_indirections)
1035     htab_traverse_noresize (machopic_indirections,
1036                             machopic_output_indirection,
1037                             asm_out_file);
1038 }
1039
1040 int
1041 machopic_operand_p (rtx op)
1042 {
1043   if (MACHOPIC_JUST_INDIRECT)
1044     return (GET_CODE (op) == SYMBOL_REF
1045             && machopic_symbol_defined_p (op));
1046   else
1047     return (GET_CODE (op) == CONST
1048             && GET_CODE (XEXP (op, 0)) == UNSPEC
1049             && XINT (XEXP (op, 0), 1) == UNSPEC_MACHOPIC_OFFSET);
1050 }
1051
1052 /* This function records whether a given name corresponds to a defined
1053    or undefined function or variable, for machopic_classify_ident to
1054    use later.  */
1055
1056 void
1057 darwin_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED)
1058 {
1059   rtx sym_ref;
1060
1061   /* Do the standard encoding things first.  */
1062   default_encode_section_info (decl, rtl, first);
1063
1064   if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL)
1065     return;
1066
1067   sym_ref = XEXP (rtl, 0);
1068   if (TREE_CODE (decl) == VAR_DECL)
1069     SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_VARIABLE;
1070
1071   if (!DECL_EXTERNAL (decl)
1072       && (!TREE_PUBLIC (decl) || !DECL_WEAK (decl))
1073       && ! lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
1074       && ((TREE_STATIC (decl)
1075            && (!DECL_COMMON (decl) || !TREE_PUBLIC (decl)))
1076           || (!DECL_COMMON (decl) && DECL_INITIAL (decl)
1077               && DECL_INITIAL (decl) != error_mark_node)))
1078     SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_DEFINED;
1079
1080   if (! TREE_PUBLIC (decl))
1081     SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_STATIC;
1082 }
1083
1084 void
1085 darwin_mark_decl_preserved (const char *name)
1086 {
1087   fprintf (asm_out_file, "\t.no_dead_strip ");
1088   assemble_name (asm_out_file, name);
1089   fputc ('\n', asm_out_file);
1090 }
1091
1092 static section *
1093 darwin_text_section (int reloc, int weak)
1094 {
1095   if (reloc)
1096     return (weak
1097             ? darwin_sections[text_unlikely_coal_section]
1098             : unlikely_text_section ());
1099   else
1100     return (weak
1101             ? darwin_sections[text_coal_section]
1102             : text_section);
1103 }
1104
1105 static section *
1106 darwin_rodata_section (int weak)
1107 {
1108   return (weak
1109           ? darwin_sections[const_coal_section]
1110           : darwin_sections[const_section]);
1111 }
1112
1113 static section *
1114 darwin_mergeable_string_section (tree exp,
1115                                  unsigned HOST_WIDE_INT align)
1116 {
1117   if (flag_merge_constants
1118       && TREE_CODE (exp) == STRING_CST
1119       && TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
1120       && align <= 256
1121       && (int_size_in_bytes (TREE_TYPE (exp))
1122           == TREE_STRING_LENGTH (exp))
1123       && ((size_t) TREE_STRING_LENGTH (exp)
1124           == strlen (TREE_STRING_POINTER (exp)) + 1))
1125     return darwin_sections[cstring_section];
1126
1127   return readonly_data_section;
1128 }
1129
1130 #ifndef HAVE_GAS_LITERAL16
1131 #define HAVE_GAS_LITERAL16 0
1132 #endif
1133
1134 static section *
1135 darwin_mergeable_constant_section (tree exp,
1136                                    unsigned HOST_WIDE_INT align)
1137 {
1138   enum machine_mode mode = DECL_MODE (exp);
1139   unsigned int modesize = GET_MODE_BITSIZE (mode);
1140
1141   if (flag_merge_constants
1142       && mode != VOIDmode
1143       && mode != BLKmode
1144       && modesize <= align
1145       && align >= 8
1146       && align <= 256
1147       && (align & (align -1)) == 0)
1148     {
1149       tree size = TYPE_SIZE_UNIT (TREE_TYPE (exp));
1150
1151       if (TREE_CODE (size) == INTEGER_CST
1152           && TREE_INT_CST_LOW (size) == 4
1153           && TREE_INT_CST_HIGH (size) == 0)
1154         return darwin_sections[literal4_section];
1155       else if (TREE_CODE (size) == INTEGER_CST
1156                && TREE_INT_CST_LOW (size) == 8
1157                && TREE_INT_CST_HIGH (size) == 0)
1158         return darwin_sections[literal8_section];
1159       else if (HAVE_GAS_LITERAL16
1160                && TARGET_64BIT
1161                && TREE_CODE (size) == INTEGER_CST
1162                && TREE_INT_CST_LOW (size) == 16
1163                && TREE_INT_CST_HIGH (size) == 0)
1164         return darwin_sections[literal16_section];
1165       else
1166         return readonly_data_section;
1167     }
1168
1169   return readonly_data_section;
1170 }
1171
1172 int
1173 machopic_reloc_rw_mask (void)
1174 {
1175   return MACHOPIC_INDIRECT ? 3 : 0;
1176 }
1177
1178 section *
1179 machopic_select_section (tree decl,
1180                          int reloc,
1181                          unsigned HOST_WIDE_INT align)
1182 {
1183   bool weak = (DECL_P (decl)
1184                && DECL_WEAK (decl)
1185                && !lookup_attribute ("weak_import",
1186                                      DECL_ATTRIBUTES (decl)));
1187   section *base_section;
1188
1189   switch (categorize_decl_for_section (decl, reloc))
1190     {
1191     case SECCAT_TEXT:
1192       base_section = darwin_text_section (reloc, weak);
1193       break;
1194
1195     case SECCAT_RODATA:
1196     case SECCAT_SRODATA:
1197       base_section = darwin_rodata_section (weak);
1198       break;
1199
1200     case SECCAT_RODATA_MERGE_STR:
1201       base_section = darwin_mergeable_string_section (decl, align);
1202       break;
1203
1204     case SECCAT_RODATA_MERGE_STR_INIT:
1205       base_section = darwin_mergeable_string_section (DECL_INITIAL (decl), align);
1206       break;
1207
1208     case SECCAT_RODATA_MERGE_CONST:
1209       base_section =  darwin_mergeable_constant_section (decl, align);
1210       break;
1211
1212     case SECCAT_DATA:
1213     case SECCAT_DATA_REL:
1214     case SECCAT_DATA_REL_LOCAL:
1215     case SECCAT_DATA_REL_RO:
1216     case SECCAT_DATA_REL_RO_LOCAL:
1217     case SECCAT_SDATA:
1218     case SECCAT_TDATA:
1219     case SECCAT_BSS:
1220     case SECCAT_SBSS:
1221     case SECCAT_TBSS:
1222       if (TREE_READONLY (decl) || TREE_CONSTANT (decl))
1223         base_section = weak ? darwin_sections[const_data_coal_section]
1224                             : darwin_sections[const_data_section];
1225       else
1226         base_section = weak ? darwin_sections[data_coal_section] : data_section;
1227       break;
1228
1229     default:
1230       gcc_unreachable ();
1231     }
1232
1233   /* Darwin weird special cases.  */
1234   if (TREE_CODE (decl) == CONSTRUCTOR
1235       && TREE_TYPE (decl)
1236       && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
1237       && TYPE_NAME (TREE_TYPE (decl)))
1238     {
1239       tree name = TYPE_NAME (TREE_TYPE (decl));
1240       if (TREE_CODE (name) == TYPE_DECL)
1241         name = DECL_NAME (name);
1242
1243       if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_ObjCString"))
1244         {
1245           if (flag_next_runtime)
1246             return darwin_sections[objc_constant_string_object_section];
1247           else
1248             return darwin_sections[objc_string_object_section];
1249         }
1250       else
1251         return base_section;
1252     }
1253   else if (TREE_CODE (decl) == VAR_DECL
1254            && DECL_NAME (decl)
1255            && TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE
1256            && IDENTIFIER_POINTER (DECL_NAME (decl))
1257            && !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "_OBJC_", 6))
1258     {
1259       const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1260
1261       if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))
1262         return darwin_sections[objc_cls_meth_section];
1263       else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))
1264         return darwin_sections[objc_inst_meth_section];
1265       else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20))
1266         return darwin_sections[objc_cat_cls_meth_section];
1267       else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23))
1268         return darwin_sections[objc_cat_inst_meth_section];
1269       else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))
1270         return darwin_sections[objc_class_vars_section];
1271       else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))
1272         return darwin_sections[objc_instance_vars_section];
1273       else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))
1274         return darwin_sections[objc_cat_cls_meth_section];
1275       else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))
1276         return darwin_sections[objc_class_names_section];
1277       else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))
1278         return darwin_sections[objc_meth_var_names_section];
1279       else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))
1280         return darwin_sections[objc_meth_var_types_section];
1281       else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))
1282         return darwin_sections[objc_cls_refs_section];
1283       else if (!strncmp (name, "_OBJC_CLASS_", 12))
1284         return darwin_sections[objc_class_section];
1285       else if (!strncmp (name, "_OBJC_METACLASS_", 16))
1286         return darwin_sections[objc_meta_class_section];
1287       else if (!strncmp (name, "_OBJC_CATEGORY_", 15))
1288         return darwin_sections[objc_category_section];
1289       else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))
1290         return darwin_sections[objc_selector_refs_section];
1291       else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20))
1292         return darwin_sections[objc_selector_fixup_section];
1293       else if (!strncmp (name, "_OBJC_SYMBOLS", 13))
1294         return darwin_sections[objc_symbols_section];
1295       else if (!strncmp (name, "_OBJC_MODULES", 13))
1296         return darwin_sections[objc_module_info_section];
1297       else if (!strncmp (name, "_OBJC_IMAGE_INFO", 16))
1298         return darwin_sections[objc_image_info_section];
1299       else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32))
1300         return darwin_sections[objc_cat_inst_meth_section];
1301       else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29))
1302         return darwin_sections[objc_cat_cls_meth_section];
1303       else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))
1304         return darwin_sections[objc_cat_cls_meth_section];
1305       else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))
1306         return darwin_sections[objc_protocol_section];
1307       else
1308         return base_section;
1309     }
1310
1311   return base_section;
1312 }
1313
1314 /* This can be called with address expressions as "rtx".
1315    They must go in "const".  */
1316
1317 section *
1318 machopic_select_rtx_section (enum machine_mode mode, rtx x,
1319                              unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
1320 {
1321   if (GET_MODE_SIZE (mode) == 8
1322       && (GET_CODE (x) == CONST_INT
1323           || GET_CODE (x) == CONST_DOUBLE))
1324     return darwin_sections[literal8_section];
1325   else if (GET_MODE_SIZE (mode) == 4
1326            && (GET_CODE (x) == CONST_INT
1327                || GET_CODE (x) == CONST_DOUBLE))
1328     return darwin_sections[literal4_section];
1329   else if (HAVE_GAS_LITERAL16
1330            && TARGET_64BIT
1331            && GET_MODE_SIZE (mode) == 16
1332            && (GET_CODE (x) == CONST_INT
1333                || GET_CODE (x) == CONST_DOUBLE
1334                || GET_CODE (x) == CONST_VECTOR))
1335     return darwin_sections[literal16_section];
1336   else if (MACHOPIC_INDIRECT
1337            && (GET_CODE (x) == SYMBOL_REF
1338                || GET_CODE (x) == CONST
1339                || GET_CODE (x) == LABEL_REF))
1340     return darwin_sections[const_data_section];
1341   else
1342     return darwin_sections[const_section];
1343 }
1344
1345 void
1346 machopic_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
1347 {
1348   if (MACHOPIC_INDIRECT)
1349     switch_to_section (darwin_sections[mod_init_section]);
1350   else
1351     switch_to_section (darwin_sections[constructor_section]);
1352   assemble_align (POINTER_SIZE);
1353   assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
1354
1355   if (! MACHOPIC_INDIRECT)
1356     fprintf (asm_out_file, ".reference .constructors_used\n");
1357 }
1358
1359 void
1360 machopic_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
1361 {
1362   if (MACHOPIC_INDIRECT)
1363     switch_to_section (darwin_sections[mod_term_section]);
1364   else
1365     switch_to_section (darwin_sections[destructor_section]);
1366   assemble_align (POINTER_SIZE);
1367   assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
1368
1369   if (! MACHOPIC_INDIRECT)
1370     fprintf (asm_out_file, ".reference .destructors_used\n");
1371 }
1372
1373 void
1374 darwin_globalize_label (FILE *stream, const char *name)
1375 {
1376   if (!!strncmp (name, "_OBJC_", 6))
1377     default_globalize_label (stream, name);
1378 }
1379
1380 /* This routine returns non-zero if 'name' starts with the special objective-c 
1381    anonymous file-scope static name.  It accommodates c++'s mangling of such 
1382    symbols (in this case the symbols will have form _ZL{d}*_OBJC_* d=digit).  */
1383    
1384 int 
1385 darwin_label_is_anonymous_local_objc_name (const char *name)
1386 {
1387   const unsigned char *p = (const unsigned char *) name;
1388   if (*p != '_')
1389     return 0;
1390   if (p[1] == 'Z' && p[2] == 'L')
1391   {
1392     p += 3;
1393     while (*p >= '0' && *p <= '9')
1394       p++;
1395   }
1396   return (!strncmp ((const char *)p, "_OBJC_", 6));
1397 }
1398
1399 /* LTO support for Mach-O.  */
1400
1401 /* Section names for LTO sections.  */
1402 static unsigned int lto_section_names_offset = 0;
1403
1404 /* This is the obstack which we use to allocate the many strings.  */
1405 static struct obstack lto_section_names_obstack;
1406
1407 /* Segment name for LTO sections.  */
1408 #define LTO_SEGMENT_NAME "__GNU_LTO"
1409
1410 /* Section name for LTO section names section.  */
1411 #define LTO_NAMES_SECTION "__section_names"
1412
1413 /* File to temporarily store LTO data.  This is appended to asm_out_file
1414    in darwin_end_file.  */
1415 static FILE *lto_asm_out_file, *saved_asm_out_file;
1416 static char *lto_asm_out_name;
1417
1418 /* Prepare asm_out_file for LTO output.  For darwin, this means hiding
1419    asm_out_file and switching to an alternative output file.  */
1420 void
1421 darwin_asm_lto_start (void)
1422 {
1423   gcc_assert (! saved_asm_out_file);
1424   saved_asm_out_file = asm_out_file;
1425   if (! lto_asm_out_name)
1426     lto_asm_out_name = make_temp_file (".lto.s");
1427   lto_asm_out_file = fopen (lto_asm_out_name, "a");
1428   if (lto_asm_out_file == NULL)
1429     fatal_error ("failed to open temporary file %s for LTO output",
1430                  lto_asm_out_name);
1431   asm_out_file = lto_asm_out_file;
1432 }
1433
1434 /* Restore asm_out_file.  */
1435 void
1436 darwin_asm_lto_end (void)
1437 {
1438   gcc_assert (saved_asm_out_file);
1439   fclose (lto_asm_out_file);
1440   asm_out_file = saved_asm_out_file;
1441   saved_asm_out_file = NULL;
1442 }
1443
1444 void
1445 darwin_asm_named_section (const char *name,
1446                           unsigned int flags,
1447                           tree decl ATTRIBUTE_UNUSED)
1448 {
1449   /* LTO sections go in a special segment __GNU_LTO.  We want to replace the
1450      section name with something we can use to represent arbitrary-length
1451      names (section names in Mach-O are at most 16 characters long).  */
1452   if (strncmp (name, LTO_SECTION_NAME_PREFIX,
1453                strlen (LTO_SECTION_NAME_PREFIX)) == 0)
1454     {
1455       /* We expect certain flags to be set...  */
1456       gcc_assert ((flags & (SECTION_DEBUG | SECTION_NAMED))
1457                   == (SECTION_DEBUG | SECTION_NAMED));
1458
1459       /* Add the section name to the things to output when we end the
1460          current assembler output file.
1461          This is all not very efficient, but that doesn't matter -- this
1462          shouldn't be a hot path in the compiler...  */
1463       obstack_1grow (&lto_section_names_obstack, '\t');
1464       obstack_grow (&lto_section_names_obstack, ".ascii ", 7);
1465       obstack_1grow (&lto_section_names_obstack, '"');
1466       obstack_grow (&lto_section_names_obstack, name, strlen (name));
1467       obstack_grow (&lto_section_names_obstack, "\\0\"\n", 4);
1468
1469       /* Output the dummy section name.  */
1470       fprintf (asm_out_file, "\t# %s\n", name);
1471       fprintf (asm_out_file, "\t.section %s,__%08X,regular,debug\n",
1472                LTO_SEGMENT_NAME, lto_section_names_offset);
1473
1474       /* Update the offset for the next section name.  Make sure we stay
1475          within reasonable length.  */  
1476       lto_section_names_offset += strlen (name) + 1;
1477       gcc_assert (lto_section_names_offset > 0
1478                   && lto_section_names_offset < ((unsigned) 1 << 31));
1479     }
1480   else
1481     fprintf (asm_out_file, "\t.section %s\n", name);
1482 }
1483
1484 void
1485 darwin_unique_section (tree decl ATTRIBUTE_UNUSED, int reloc ATTRIBUTE_UNUSED)
1486 {
1487   /* Darwin does not use unique sections.  */
1488 }
1489
1490 /* Handle __attribute__ ((apple_kext_compatibility)).
1491    This only applies to darwin kexts for 2.95 compatibility -- it shrinks the
1492    vtable for classes with this attribute (and their descendants) by not
1493    outputting the new 3.0 nondeleting destructor.  This means that such
1494    objects CANNOT be allocated on the stack or as globals UNLESS they have
1495    a completely empty `operator delete'.
1496    Luckily, this fits in with the Darwin kext model.
1497
1498    This attribute also disables gcc3's potential overlaying of derived
1499    class data members on the padding at the end of the base class.  */
1500
1501 tree
1502 darwin_handle_kext_attribute (tree *node, tree name,
1503                               tree args ATTRIBUTE_UNUSED,
1504                               int flags ATTRIBUTE_UNUSED,
1505                               bool *no_add_attrs)
1506 {
1507   /* APPLE KEXT stuff -- only applies with pure static C++ code.  */
1508   if (! TARGET_KEXTABI)
1509     {
1510       warning (0, "%qE 2.95 vtable-compatibility attribute applies "
1511                "only when compiling a kext", name);
1512
1513       *no_add_attrs = true;
1514     }
1515   else if (TREE_CODE (*node) != RECORD_TYPE)
1516     {
1517       warning (0, "%qE 2.95 vtable-compatibility attribute applies "
1518                "only to C++ classes", name);
1519
1520       *no_add_attrs = true;
1521     }
1522
1523   return NULL_TREE;
1524 }
1525
1526 /* Handle a "weak_import" attribute; arguments as in
1527    struct attribute_spec.handler.  */
1528
1529 tree
1530 darwin_handle_weak_import_attribute (tree *node, tree name,
1531                                      tree ARG_UNUSED (args),
1532                                      int ARG_UNUSED (flags),
1533                                      bool * no_add_attrs)
1534 {
1535   if (TREE_CODE (*node) != FUNCTION_DECL && TREE_CODE (*node) != VAR_DECL)
1536     {
1537       warning (OPT_Wattributes, "%qE attribute ignored",
1538                name);
1539       *no_add_attrs = true;
1540     }
1541   else
1542     declare_weak (*node);
1543
1544   return NULL_TREE;
1545 }
1546
1547 /* Emit a label for an FDE, making it global and/or weak if appropriate.
1548    The third parameter is nonzero if this is for exception handling.
1549    The fourth parameter is nonzero if this is just a placeholder for an
1550    FDE that we are omitting. */
1551
1552 void
1553 darwin_emit_unwind_label (FILE *file, tree decl, int for_eh, int empty)
1554 {
1555   char *lab;
1556
1557   if (! for_eh)
1558     return;
1559
1560   lab = concat (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), ".eh", NULL);
1561
1562   if (TREE_PUBLIC (decl))
1563     {
1564       targetm.asm_out.globalize_label (file, lab);
1565       if (DECL_VISIBILITY (decl) == VISIBILITY_HIDDEN)
1566         {
1567           fputs ("\t.private_extern ", file);
1568           assemble_name (file, lab);
1569           fputc ('\n', file);
1570         }
1571     }
1572
1573   if (DECL_WEAK (decl))
1574     {
1575       fputs ("\t.weak_definition ", file);
1576       assemble_name (file, lab);
1577       fputc ('\n', file);
1578     }
1579
1580   assemble_name (file, lab);
1581   if (empty)
1582     {
1583       fputs (" = 0\n", file);
1584
1585       /* Mark the absolute .eh and .eh1 style labels as needed to
1586          ensure that we don't dead code strip them and keep such
1587          labels from another instantiation point until we can fix this
1588          properly with group comdat support.  */
1589       darwin_mark_decl_preserved (lab);
1590     }
1591   else
1592     fputs (":\n", file);
1593
1594   free (lab);
1595 }
1596
1597 static GTY(()) unsigned long except_table_label_num;
1598
1599 void
1600 darwin_emit_except_table_label (FILE *file)
1601 {
1602   char section_start_label[30];
1603
1604   ASM_GENERATE_INTERNAL_LABEL (section_start_label, "GCC_except_table",
1605                                except_table_label_num++);
1606   ASM_OUTPUT_LABEL (file, section_start_label);
1607 }
1608 /* Generate a PC-relative reference to a Mach-O non-lazy-symbol.  */
1609
1610 void
1611 darwin_non_lazy_pcrel (FILE *file, rtx addr)
1612 {
1613   const char *nlp_name;
1614
1615   gcc_assert (GET_CODE (addr) == SYMBOL_REF);
1616
1617   nlp_name = machopic_indirection_name (addr, /*stub_p=*/false);
1618   fputs ("\t.long\t", file);
1619   ASM_OUTPUT_LABELREF (file, nlp_name);
1620   fputs ("-.", file);
1621 }
1622
1623 /* The implementation of ASM_DECLARE_CONSTANT_NAME.  */
1624
1625 void
1626 darwin_asm_declare_constant_name (FILE *file, const char *name,
1627                                   const_tree exp ATTRIBUTE_UNUSED,
1628                                   HOST_WIDE_INT size)
1629 {
1630   assemble_label (file, name);
1631
1632   /* Darwin doesn't support zero-size objects, so give them a byte.  */
1633   if ((size) == 0)
1634     assemble_zeros (1);
1635 }
1636
1637 /* Emit an assembler directive to set visibility for a symbol.  The
1638    only supported visibilities are VISIBILITY_DEFAULT and
1639    VISIBILITY_HIDDEN; the latter corresponds to Darwin's "private
1640    extern".  There is no MACH-O equivalent of ELF's
1641    VISIBILITY_INTERNAL or VISIBILITY_PROTECTED. */
1642
1643 void
1644 darwin_assemble_visibility (tree decl, int vis)
1645 {
1646   if (vis == VISIBILITY_DEFAULT)
1647     ;
1648   else if (vis == VISIBILITY_HIDDEN)
1649     {
1650       fputs ("\t.private_extern ", asm_out_file);
1651       assemble_name (asm_out_file,
1652                      (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
1653       fputs ("\n", asm_out_file);
1654     }
1655   else
1656     warning (OPT_Wattributes, "internal and protected visibility attributes "
1657              "not supported in this configuration; ignored");
1658 }
1659
1660 /* Output a difference of two labels that will be an assembly time
1661    constant if the two labels are local.  (.long lab1-lab2 will be
1662    very different if lab1 is at the boundary between two sections; it
1663    will be relocated according to the second section, not the first,
1664    so one ends up with a difference between labels in different
1665    sections, which is bad in the dwarf2 eh context for instance.)  */
1666
1667 static int darwin_dwarf_label_counter;
1668
1669 void
1670 darwin_asm_output_dwarf_delta (FILE *file, int size,
1671                                const char *lab1, const char *lab2)
1672 {
1673   int islocaldiff = (lab1[0] == '*' && lab1[1] == 'L'
1674                      && lab2[0] == '*' && lab2[1] == 'L');
1675   const char *directive = (size == 8 ? ".quad" : ".long");
1676
1677   if (islocaldiff)
1678     fprintf (file, "\t.set L$set$%d,", darwin_dwarf_label_counter);
1679   else
1680     fprintf (file, "\t%s\t", directive);
1681   assemble_name_raw (file, lab1);
1682   fprintf (file, "-");
1683   assemble_name_raw (file, lab2);
1684   if (islocaldiff)
1685     fprintf (file, "\n\t%s L$set$%d", directive, darwin_dwarf_label_counter++);
1686 }
1687
1688 /* Output labels for the start of the DWARF sections if necessary.
1689    Initialize the stuff we need for LTO long section names support.  */
1690 void
1691 darwin_file_start (void)
1692 {
1693   if (write_symbols == DWARF2_DEBUG)
1694     {
1695       static const char * const debugnames[] =
1696         {
1697           DEBUG_FRAME_SECTION,
1698           DEBUG_INFO_SECTION,
1699           DEBUG_ABBREV_SECTION,
1700           DEBUG_ARANGES_SECTION,
1701           DEBUG_MACINFO_SECTION,
1702           DEBUG_LINE_SECTION,
1703           DEBUG_LOC_SECTION,
1704           DEBUG_PUBNAMES_SECTION,
1705           DEBUG_PUBTYPES_SECTION,
1706           DEBUG_STR_SECTION,
1707           DEBUG_RANGES_SECTION
1708         };
1709       size_t i;
1710
1711       for (i = 0; i < ARRAY_SIZE (debugnames); i++)
1712         {
1713           int namelen;
1714
1715           switch_to_section (get_section (debugnames[i], SECTION_DEBUG, NULL));
1716
1717           gcc_assert (strncmp (debugnames[i], "__DWARF,", 8) == 0);
1718           gcc_assert (strchr (debugnames[i] + 8, ','));
1719
1720           namelen = strchr (debugnames[i] + 8, ',') - (debugnames[i] + 8);
1721           fprintf (asm_out_file, "Lsection%.*s:\n", namelen, debugnames[i] + 8);
1722         }
1723     }
1724
1725   /* We fill this obstack with the complete section text for the lto section
1726      names to write in darwin_file_end.  */
1727   obstack_init (&lto_section_names_obstack);
1728   lto_section_names_offset = 0;
1729 }
1730
1731 /* Output an offset in a DWARF section on Darwin.  On Darwin, DWARF section
1732    offsets are not represented using relocs in .o files; either the
1733    section never leaves the .o file, or the linker or other tool is
1734    responsible for parsing the DWARF and updating the offsets.  */
1735
1736 void
1737 darwin_asm_output_dwarf_offset (FILE *file, int size, const char * lab,
1738                                 section *base)
1739 {
1740   char sname[64];
1741   int namelen;
1742
1743   gcc_assert (base->common.flags & SECTION_NAMED);
1744   gcc_assert (strncmp (base->named.name, "__DWARF,", 8) == 0);
1745   gcc_assert (strchr (base->named.name + 8, ','));
1746
1747   namelen = strchr (base->named.name + 8, ',') - (base->named.name + 8);
1748   sprintf (sname, "*Lsection%.*s", namelen, base->named.name + 8);
1749   darwin_asm_output_dwarf_delta (file, size, lab, sname);
1750 }
1751
1752 void
1753 darwin_file_end (void)
1754 {
1755   const char *lto_section_names;
1756
1757   machopic_finish (asm_out_file);
1758   if (strcmp (lang_hooks.name, "GNU C++") == 0)
1759     {
1760       switch_to_section (darwin_sections[constructor_section]);
1761       switch_to_section (darwin_sections[destructor_section]);
1762       ASM_OUTPUT_ALIGN (asm_out_file, 1);
1763     }
1764
1765   /* If there was LTO assembler output, append it to asm_out_file.  */
1766   if (lto_asm_out_name)
1767     {
1768       int n;
1769       char *buf, *lto_asm_txt;
1770
1771       /* Shouldn't be here if we failed to switch back.  */
1772       gcc_assert (! saved_asm_out_file);
1773
1774       lto_asm_out_file = fopen (lto_asm_out_name, "r");
1775       if (lto_asm_out_file == NULL)
1776         fatal_error ("failed to open temporary file %s with LTO output",
1777                      lto_asm_out_name);
1778       fseek (lto_asm_out_file, 0, SEEK_END);
1779       n = ftell (lto_asm_out_file);
1780       if (n > 0)
1781         {
1782           fseek (lto_asm_out_file, 0, SEEK_SET);
1783           lto_asm_txt = buf = (char *) xmalloc (n + 1);
1784           while (fgets (lto_asm_txt, n, lto_asm_out_file))
1785             fputs (lto_asm_txt, asm_out_file);
1786         }
1787
1788       /* Remove the temporary file.  */
1789       fclose (lto_asm_out_file);
1790       unlink_if_ordinary (lto_asm_out_name);
1791       free (lto_asm_out_name);
1792     }
1793
1794   /* Finish the LTO section names obstack.  Don't output anything if
1795      there are no recorded section names.  */
1796   obstack_1grow (&lto_section_names_obstack, '\0');
1797   lto_section_names = XOBFINISH (&lto_section_names_obstack, const char *);
1798   if (strlen (lto_section_names) > 0)
1799     {
1800       fprintf (asm_out_file,
1801                "\t.section %s,%s,regular,debug\n",
1802                LTO_SEGMENT_NAME, LTO_NAMES_SECTION);
1803       fprintf (asm_out_file,
1804                "\t# Section names in %s are offsets into this table\n",
1805                LTO_SEGMENT_NAME);
1806       fprintf (asm_out_file, "%s\n", lto_section_names);
1807     }
1808   obstack_free (&lto_section_names_obstack, NULL);
1809
1810   fprintf (asm_out_file, "\t.subsections_via_symbols\n");
1811 }
1812
1813 /* TODO: Add a language hook for identifying if a decl is a vtable.  */
1814 #define DARWIN_VTABLE_P(DECL) 0
1815
1816 /* Cross-module name binding.  Darwin does not support overriding
1817    functions at dynamic-link time, except for vtables in kexts.  */
1818
1819 bool
1820 darwin_binds_local_p (const_tree decl)
1821 {
1822   return default_binds_local_p_1 (decl,
1823                                   TARGET_KEXTABI && DARWIN_VTABLE_P (decl));
1824 }
1825
1826 #if 0
1827 /* See TARGET_ASM_OUTPUT_ANCHOR for why we can't do this yet.  */
1828 /* The Darwin's implementation of TARGET_ASM_OUTPUT_ANCHOR.  Define the
1829    anchor relative to ".", the current section position.  We cannot use
1830    the default one because ASM_OUTPUT_DEF is wrong for Darwin.  */
1831
1832 void
1833 darwin_asm_output_anchor (rtx symbol)
1834 {
1835   fprintf (asm_out_file, "\t.set\t");
1836   assemble_name (asm_out_file, XSTR (symbol, 0));
1837   fprintf (asm_out_file, ", . + " HOST_WIDE_INT_PRINT_DEC "\n",
1838            SYMBOL_REF_BLOCK_OFFSET (symbol));
1839 }
1840 #endif
1841
1842 /* Set the darwin specific attributes on TYPE.  */
1843 void
1844 darwin_set_default_type_attributes (tree type)
1845 {
1846   if (darwin_ms_struct
1847       && TREE_CODE (type) == RECORD_TYPE)
1848     TYPE_ATTRIBUTES (type) = tree_cons (get_identifier ("ms_struct"),
1849                                         NULL_TREE,
1850                                         TYPE_ATTRIBUTES (type));
1851 }
1852
1853 /* True, iff we're generating code for loadable kernel extensions.  */
1854
1855 bool
1856 darwin_kextabi_p (void) {
1857   return flag_apple_kext;
1858 }
1859
1860 void
1861 darwin_override_options (void)
1862 {
1863   /* Don't emit DWARF3/4 unless specifically selected.  This is a 
1864      workaround for tool bugs.  */
1865   if (dwarf_strict < 0) 
1866     dwarf_strict = 1;
1867
1868   /* Disable -freorder-blocks-and-partition for darwin_emit_unwind_label.  */
1869   if (flag_reorder_blocks_and_partition 
1870       && (targetm.asm_out.emit_unwind_label == darwin_emit_unwind_label))
1871     {
1872       inform (input_location,
1873               "-freorder-blocks-and-partition does not work with exceptions "
1874               "on this architecture");
1875       flag_reorder_blocks_and_partition = 0;
1876       flag_reorder_blocks = 1;
1877     }
1878
1879   if (flag_mkernel || flag_apple_kext)
1880     {
1881       /* -mkernel implies -fapple-kext for C++ */
1882       if (strcmp (lang_hooks.name, "GNU C++") == 0)
1883         flag_apple_kext = 1;
1884
1885       flag_no_common = 1;
1886
1887       /* No EH in kexts.  */
1888       flag_exceptions = 0;
1889       /* No -fnon-call-exceptions data in kexts.  */
1890       flag_non_call_exceptions = 0;
1891     }
1892   if (flag_var_tracking
1893       && strverscmp (darwin_macosx_version_min, "10.5") >= 0
1894       && debug_info_level >= DINFO_LEVEL_NORMAL
1895       && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
1896     flag_var_tracking_uninit = 1;
1897 }
1898
1899 /* Add $LDBL128 suffix to long double builtins.  */
1900
1901 static void
1902 darwin_patch_builtin (int fncode)
1903 {
1904   tree fn = built_in_decls[fncode];
1905   tree sym;
1906   char *newname;
1907
1908   if (!fn)
1909     return;
1910
1911   sym = DECL_ASSEMBLER_NAME (fn);
1912   newname = ACONCAT (("_", IDENTIFIER_POINTER (sym), "$LDBL128", NULL));
1913
1914   set_user_assembler_name (fn, newname);
1915
1916   fn = implicit_built_in_decls[fncode];
1917   if (fn)
1918     set_user_assembler_name (fn, newname);
1919 }
1920
1921 void
1922 darwin_patch_builtins (void)
1923 {
1924   if (LONG_DOUBLE_TYPE_SIZE != 128)
1925     return;
1926
1927 #define PATCH_BUILTIN(fncode) darwin_patch_builtin (fncode);
1928 #define PATCH_BUILTIN_NO64(fncode)              \
1929   if (!TARGET_64BIT)                            \
1930     darwin_patch_builtin (fncode);
1931 #define PATCH_BUILTIN_VARIADIC(fncode)                            \
1932   if (!TARGET_64BIT                                               \
1933       && (strverscmp (darwin_macosx_version_min, "10.3.9") >= 0)) \
1934     darwin_patch_builtin (fncode);
1935 #include "darwin-ppc-ldouble-patch.def"
1936 #undef PATCH_BUILTIN
1937 #undef PATCH_BUILTIN_NO64
1938 #undef PATCH_BUILTIN_VARIADIC
1939 }
1940
1941
1942 #include "gt-darwin.h"