Mercurial > hg > CbC > CbC_gcc
comparison gcc/langhooks.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
35 #include "langhooks.h" | 35 #include "langhooks.h" |
36 #include "target.h" | 36 #include "target.h" |
37 #include "langhooks-def.h" | 37 #include "langhooks-def.h" |
38 #include "ggc.h" | 38 #include "ggc.h" |
39 #include "diagnostic.h" | 39 #include "diagnostic.h" |
40 #include "cgraph.h" | |
41 #include "output.h" | |
40 | 42 |
41 /* Do nothing; in many cases the default hook. */ | 43 /* Do nothing; in many cases the default hook. */ |
42 | 44 |
43 void | 45 void |
44 lhd_do_nothing (void) | 46 lhd_do_nothing (void) |
48 /* Do nothing (tree). */ | 50 /* Do nothing (tree). */ |
49 | 51 |
50 void | 52 void |
51 lhd_do_nothing_t (tree ARG_UNUSED (t)) | 53 lhd_do_nothing_t (tree ARG_UNUSED (t)) |
52 { | 54 { |
55 } | |
56 | |
57 /* Pass through (tree). */ | |
58 tree | |
59 lhd_pass_through_t (tree t) | |
60 { | |
61 return t; | |
53 } | 62 } |
54 | 63 |
55 /* Do nothing (int). */ | 64 /* Do nothing (int). */ |
56 | 65 |
57 void | 66 void |
103 /* The default post options hook. */ | 112 /* The default post options hook. */ |
104 | 113 |
105 bool | 114 bool |
106 lhd_post_options (const char ** ARG_UNUSED (pfilename)) | 115 lhd_post_options (const char ** ARG_UNUSED (pfilename)) |
107 { | 116 { |
117 /* Excess precision other than "fast" requires front-end | |
118 support. */ | |
119 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; | |
108 return false; | 120 return false; |
109 } | 121 } |
110 | 122 |
111 /* Called from by print-tree.c. */ | 123 /* Called from by print-tree.c. */ |
112 | 124 |
113 void | 125 void |
114 lhd_print_tree_nothing (FILE * ARG_UNUSED (file), | 126 lhd_print_tree_nothing (FILE * ARG_UNUSED (file), |
115 tree ARG_UNUSED (node), | 127 tree ARG_UNUSED (node), |
116 int ARG_UNUSED (indent)) | 128 int ARG_UNUSED (indent)) |
117 { | 129 { |
118 } | |
119 | |
120 /* Called from staticp. */ | |
121 | |
122 tree | |
123 lhd_staticp (tree ARG_UNUSED (exp)) | |
124 { | |
125 return NULL; | |
126 } | 130 } |
127 | 131 |
128 /* Called from check_global_declarations. */ | 132 /* Called from check_global_declarations. */ |
129 | 133 |
130 bool | 134 bool |
156 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL | 160 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL |
157 || (TREE_CODE (decl) == VAR_DECL | 161 || (TREE_CODE (decl) == VAR_DECL |
158 && (TREE_STATIC (decl) | 162 && (TREE_STATIC (decl) |
159 || DECL_EXTERNAL (decl) | 163 || DECL_EXTERNAL (decl) |
160 || TREE_PUBLIC (decl)))); | 164 || TREE_PUBLIC (decl)))); |
161 | 165 |
162 /* By default, assume the name to use in assembly code is the same | 166 /* By default, assume the name to use in assembly code is the same |
163 as that used in the source language. (That's correct for C, and | 167 as that used in the source language. (That's correct for C, and |
164 GCC used to set DECL_ASSEMBLER_NAME to the same value as | 168 GCC used to set DECL_ASSEMBLER_NAME to the same value as |
165 DECL_NAME in build_decl, so this choice provides backwards | 169 DECL_NAME in build_decl, so this choice provides backwards |
166 compatibility with existing front-ends. This assumption is wrapped | 170 compatibility with existing front-ends. This assumption is wrapped |
167 in a target hook, to allow for target-specific modification of the | 171 in a target hook, to allow for target-specific modification of the |
168 identifier. | 172 identifier. |
169 | 173 |
170 Can't use just the variable's own name for a variable whose scope | 174 Can't use just the variable's own name for a variable whose scope |
171 is less than the whole compilation. Concatenate a distinguishing | 175 is less than the whole compilation. Concatenate a distinguishing |
172 number - we use the DECL_UID. */ | 176 number - we use the DECL_UID. */ |
173 | 177 |
174 if (TREE_PUBLIC (decl) || DECL_CONTEXT (decl) == NULL_TREE) | 178 if (TREE_PUBLIC (decl) || DECL_CONTEXT (decl) == NULL_TREE) |
175 id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl)); | 179 id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl)); |
176 else | 180 else |
177 { | 181 { |
178 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); | 182 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); |
179 char *label; | 183 char *label; |
180 | 184 |
181 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); | 185 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); |
182 id = get_identifier (label); | 186 id = get_identifier (label); |
183 } | 187 } |
184 SET_DECL_ASSEMBLER_NAME (decl, id); | 188 SET_DECL_ASSEMBLER_NAME (decl, id); |
185 | 189 |
214 lhd_get_alias_set (tree ARG_UNUSED (t)) | 218 lhd_get_alias_set (tree ARG_UNUSED (t)) |
215 { | 219 { |
216 return -1; | 220 return -1; |
217 } | 221 } |
218 | 222 |
219 /* This is the default expand_expr function. */ | |
220 | |
221 rtx | |
222 lhd_expand_expr (tree ARG_UNUSED (t), rtx ARG_UNUSED (r), | |
223 enum machine_mode ARG_UNUSED (mm), | |
224 int ARG_UNUSED (em), | |
225 rtx * ARG_UNUSED (a)) | |
226 { | |
227 gcc_unreachable (); | |
228 } | |
229 | |
230 /* This is the default decl_printable_name function. */ | 223 /* This is the default decl_printable_name function. */ |
231 | 224 |
232 const char * | 225 const char * |
233 lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity)) | 226 lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity)) |
234 { | 227 { |
271 | 264 |
272 int | 265 int |
273 lhd_tree_dump_type_quals (const_tree t) | 266 lhd_tree_dump_type_quals (const_tree t) |
274 { | 267 { |
275 return TYPE_QUALS (t); | 268 return TYPE_QUALS (t); |
276 } | |
277 | |
278 /* lang_hooks.expr_size: Determine the size of the value of an expression T | |
279 in a language-specific way. Returns a tree for the size in bytes. */ | |
280 | |
281 tree | |
282 lhd_expr_size (const_tree exp) | |
283 { | |
284 if (DECL_P (exp) | |
285 && DECL_SIZE_UNIT (exp) != 0) | |
286 return DECL_SIZE_UNIT (exp); | |
287 else | |
288 return size_in_bytes (TREE_TYPE (exp)); | |
289 } | 269 } |
290 | 270 |
291 /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form. */ | 271 /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form. */ |
292 | 272 |
293 int | 273 int |
314 lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED) | 294 lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED) |
315 { | 295 { |
316 return true; | 296 return true; |
317 } | 297 } |
318 | 298 |
319 /* Return the COMDAT group into which DECL should be placed. */ | |
320 | |
321 const char * | |
322 lhd_comdat_group (tree decl) | |
323 { | |
324 return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
325 } | |
326 | |
327 /* lang_hooks.decls.final_write_globals: perform final processing on | 299 /* lang_hooks.decls.final_write_globals: perform final processing on |
328 global variables. */ | 300 global variables. */ |
329 void | 301 void |
330 write_global_declarations (void) | 302 write_global_declarations (void) |
331 { | 303 { |
304 tree globals, decl, *vec; | |
305 int len, i; | |
306 | |
307 /* This lang hook is dual-purposed, and also finalizes the | |
308 compilation unit. */ | |
309 cgraph_finalize_compilation_unit (); | |
310 | |
332 /* Really define vars that have had only a tentative definition. | 311 /* Really define vars that have had only a tentative definition. |
333 Really output inline functions that must actually be callable | 312 Really output inline functions that must actually be callable |
334 and have not been output so far. */ | 313 and have not been output so far. */ |
335 | 314 |
336 tree globals = lang_hooks.decls.getdecls (); | 315 globals = lang_hooks.decls.getdecls (); |
337 int len = list_length (globals); | 316 len = list_length (globals); |
338 tree *vec = XNEWVEC (tree, len); | 317 vec = XNEWVEC (tree, len); |
339 int i; | |
340 tree decl; | |
341 | 318 |
342 /* Process the decls in reverse order--earliest first. | 319 /* Process the decls in reverse order--earliest first. |
343 Put them into VEC from back to front, then take out from front. */ | 320 Put them into VEC from back to front, then take out from front. */ |
344 | 321 |
345 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) | 322 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) |
394 fndecl = current_function_decl; | 371 fndecl = current_function_decl; |
395 | 372 |
396 if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE) | 373 if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE) |
397 pp_printf | 374 pp_printf |
398 (context->printer, _("In member function %qs"), | 375 (context->printer, _("In member function %qs"), |
399 lang_hooks.decl_printable_name (fndecl, 2)); | 376 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); |
400 else | 377 else |
401 pp_printf | 378 pp_printf |
402 (context->printer, _("In function %qs"), | 379 (context->printer, _("In function %qs"), |
403 lang_hooks.decl_printable_name (fndecl, 2)); | 380 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); |
404 | 381 |
405 while (abstract_origin) | 382 while (abstract_origin) |
406 { | 383 { |
407 location_t *locus; | 384 location_t *locus; |
408 tree block = abstract_origin; | 385 tree block = abstract_origin; |
446 expanded_location s = expand_location (*locus); | 423 expanded_location s = expand_location (*locus); |
447 pp_character (context->printer, ','); | 424 pp_character (context->printer, ','); |
448 pp_newline (context->printer); | 425 pp_newline (context->printer); |
449 if (s.file != NULL) | 426 if (s.file != NULL) |
450 { | 427 { |
451 if (flag_show_column && s.column != 0) | 428 if (flag_show_column) |
452 pp_printf (context->printer, | 429 pp_printf (context->printer, |
453 _(" inlined from %qs at %s:%d:%d"), | 430 _(" inlined from %qs at %s:%d:%d"), |
454 lang_hooks.decl_printable_name (fndecl, 2), | 431 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)), |
455 s.file, s.line, s.column); | 432 s.file, s.line, s.column); |
456 else | 433 else |
457 pp_printf (context->printer, | 434 pp_printf (context->printer, |
458 _(" inlined from %qs at %s:%d"), | 435 _(" inlined from %qs at %s:%d"), |
459 lang_hooks.decl_printable_name (fndecl, 2), | 436 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)), |
460 s.file, s.line); | 437 s.file, s.line); |
461 | 438 |
462 } | 439 } |
463 else | 440 else |
464 pp_printf (context->printer, _(" inlined from %qs"), | 441 pp_printf (context->printer, _(" inlined from %qs"), |
465 lang_hooks.decl_printable_name (fndecl, 2)); | 442 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); |
466 } | 443 } |
467 } | 444 } |
468 pp_character (context->printer, ':'); | 445 pp_character (context->printer, ':'); |
469 } | 446 } |
470 | 447 |
538 const char *library_name, | 515 const char *library_name, |
539 tree attrs, | 516 tree attrs, |
540 tree (*hook) (tree)) | 517 tree (*hook) (tree)) |
541 { | 518 { |
542 tree id = get_identifier (name); | 519 tree id = get_identifier (name); |
543 tree decl = build_decl (FUNCTION_DECL, id, type); | 520 tree decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, id, type); |
544 | 521 |
545 TREE_PUBLIC (decl) = 1; | 522 TREE_PUBLIC (decl) = 1; |
546 DECL_EXTERNAL (decl) = 1; | 523 DECL_EXTERNAL (decl) = 1; |
547 DECL_BUILT_IN_CLASS (decl) = cl; | 524 DECL_BUILT_IN_CLASS (decl) = cl; |
548 | 525 |
549 DECL_FUNCTION_CODE (decl) = -1; | 526 DECL_FUNCTION_CODE (decl) = (enum built_in_function) function_code; |
550 gcc_assert (DECL_FUNCTION_CODE (decl) >= function_code); | 527 |
551 DECL_FUNCTION_CODE (decl) = function_code; | 528 /* DECL_FUNCTION_CODE is a bitfield; verify that the value fits. */ |
529 gcc_assert (DECL_FUNCTION_CODE (decl) == function_code); | |
552 | 530 |
553 if (library_name) | 531 if (library_name) |
554 { | 532 { |
555 tree libname = get_identifier (library_name); | 533 tree libname = get_identifier (library_name); |
556 SET_DECL_ASSEMBLER_NAME (decl, libname); | 534 SET_DECL_ASSEMBLER_NAME (decl, libname); |
605 lhd_builtin_function (tree decl) | 583 lhd_builtin_function (tree decl) |
606 { | 584 { |
607 lang_hooks.decls.pushdecl (decl); | 585 lang_hooks.decls.pushdecl (decl); |
608 return decl; | 586 return decl; |
609 } | 587 } |
588 | |
589 /* LTO hooks. */ | |
590 | |
591 /* Used to save and restore any previously active section. */ | |
592 static section *saved_section; | |
593 | |
594 | |
595 /* Begin a new LTO output section named NAME. This default implementation | |
596 saves the old section and emits assembly code to switch to the new | |
597 section. */ | |
598 | |
599 void | |
600 lhd_begin_section (const char *name) | |
601 { | |
602 section *section; | |
603 | |
604 /* Save the old section so we can restore it in lto_end_asm_section. */ | |
605 gcc_assert (!saved_section); | |
606 saved_section = in_section; | |
607 if (!saved_section) | |
608 saved_section = text_section; | |
609 | |
610 /* Create a new section and switch to it. */ | |
611 section = get_section (name, SECTION_DEBUG, NULL); | |
612 switch_to_section (section); | |
613 } | |
614 | |
615 | |
616 /* Write DATA of length LEN to the current LTO output section. This default | |
617 implementation just calls assemble_string and frees BLOCK. */ | |
618 | |
619 void | |
620 lhd_append_data (const void *data, size_t len, void *block) | |
621 { | |
622 if (data) | |
623 assemble_string ((const char *)data, len); | |
624 free (block); | |
625 } | |
626 | |
627 | |
628 /* Finish the current LTO output section. This default implementation emits | |
629 assembly code to switch to any section previously saved by | |
630 lhd_begin_section. */ | |
631 | |
632 void | |
633 lhd_end_section (void) | |
634 { | |
635 if (saved_section) | |
636 { | |
637 switch_to_section (saved_section); | |
638 saved_section = NULL; | |
639 } | |
640 } |