Mercurial > hg > CbC > CbC_gcc
comparison gcc/langhooks.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* The lang_hooks data structure. | 1 /* The lang_hooks data structure. |
2 Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 2 Copyright (C) 2001-2017 Free Software Foundation, Inc. |
3 Free Software Foundation, Inc. | |
4 | 3 |
5 This file is part of GCC. | 4 This file is part of GCC. |
6 | 5 |
7 GCC is free software; you can redistribute it and/or modify | 6 GCC is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
19 <http://www.gnu.org/licenses/>. */ | 18 <http://www.gnu.org/licenses/>. */ |
20 | 19 |
21 #ifndef GCC_LANG_HOOKS_H | 20 #ifndef GCC_LANG_HOOKS_H |
22 #define GCC_LANG_HOOKS_H | 21 #define GCC_LANG_HOOKS_H |
23 | 22 |
24 /* This file should be #include-d after tree.h. */ | 23 /* FIXME: This file should be #include-d after tree.h (for enum tree_code). */ |
25 | 24 |
26 struct diagnostic_info; | 25 struct diagnostic_info; |
27 | 26 |
28 struct gimplify_omp_ctx; | 27 struct gimplify_omp_ctx; |
29 | 28 |
32 /* A print hook for print_tree (). */ | 31 /* A print hook for print_tree (). */ |
33 typedef void (*lang_print_tree_hook) (FILE *, tree, int indent); | 32 typedef void (*lang_print_tree_hook) (FILE *, tree, int indent); |
34 | 33 |
35 enum classify_record | 34 enum classify_record |
36 { RECORD_IS_STRUCT, RECORD_IS_CLASS, RECORD_IS_INTERFACE }; | 35 { RECORD_IS_STRUCT, RECORD_IS_CLASS, RECORD_IS_INTERFACE }; |
36 | |
37 class substring_loc; | |
37 | 38 |
38 /* The following hooks are documented in langhooks.c. Must not be | 39 /* The following hooks are documented in langhooks.c. Must not be |
39 NULL. */ | 40 NULL. */ |
40 | 41 |
41 struct lang_hooks_for_tree_inlining | 42 struct lang_hooks_for_tree_inlining |
42 { | 43 { |
43 bool (*var_mod_type_p) (tree, tree); | 44 bool (*var_mod_type_p) (tree, tree); |
44 }; | |
45 | |
46 struct lang_hooks_for_callgraph | |
47 { | |
48 /* The node passed is a language-specific tree node. If its contents | |
49 are relevant to use of other declarations, mark them. */ | |
50 tree (*analyze_expr) (tree *, int *); | |
51 }; | 45 }; |
52 | 46 |
53 /* The following hooks are used by tree-dump.c. */ | 47 /* The following hooks are used by tree-dump.c. */ |
54 | 48 |
55 struct lang_hooks_for_tree_dump | 49 struct lang_hooks_for_tree_dump |
75 be structures. */ | 69 be structures. */ |
76 enum classify_record (*classify_record) (tree); | 70 enum classify_record (*classify_record) (tree); |
77 | 71 |
78 /* Given MODE and UNSIGNEDP, return a suitable type-tree with that | 72 /* Given MODE and UNSIGNEDP, return a suitable type-tree with that |
79 mode. */ | 73 mode. */ |
80 tree (*type_for_mode) (enum machine_mode, int); | 74 tree (*type_for_mode) (machine_mode, int); |
81 | 75 |
82 /* Given PRECISION and UNSIGNEDP, return a suitable type-tree for an | 76 /* Given PRECISION and UNSIGNEDP, return a suitable type-tree for an |
83 integer type with at least that precision. */ | 77 integer type with at least that precision. */ |
84 tree (*type_for_size) (unsigned, int); | 78 tree (*type_for_size) (unsigned, int); |
85 | 79 |
106 void (*register_builtin_type) (tree, const char *); | 100 void (*register_builtin_type) (tree, const char *); |
107 | 101 |
108 /* This routine is called in tree.c to print an error message for | 102 /* This routine is called in tree.c to print an error message for |
109 invalid use of an incomplete type. VALUE is the expression that | 103 invalid use of an incomplete type. VALUE is the expression that |
110 was used (or 0 if that isn't known) and TYPE is the type that was | 104 was used (or 0 if that isn't known) and TYPE is the type that was |
111 invalid. */ | 105 invalid. LOC is the location of the use. */ |
112 void (*incomplete_type_error) (const_tree value, const_tree type); | 106 void (*incomplete_type_error) (location_t loc, const_tree value, |
107 const_tree type); | |
113 | 108 |
114 /* Called from assign_temp to return the maximum size, if there is one, | 109 /* Called from assign_temp to return the maximum size, if there is one, |
115 for a type. */ | 110 for a type. */ |
116 tree (*max_size) (const_tree); | 111 tree (*max_size) (const_tree); |
117 | 112 |
118 /* Register language specific type size variables as potentially OpenMP | 113 /* Register language specific type size variables as potentially OpenMP |
119 firstprivate variables. */ | 114 firstprivate variables. */ |
120 void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree); | 115 void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree); |
121 | 116 |
117 /* Return true if TYPE is a mappable type. */ | |
118 bool (*omp_mappable_type) (tree type); | |
119 | |
122 /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes. | 120 /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes. |
123 Called only after doing all language independent checks. | 121 Called only after doing all language independent checks. |
124 At present, this function is only called when both TYPE1 and TYPE2 are | 122 At present, this function is only called when both TYPE1 and TYPE2 are |
125 FUNCTION_TYPEs. */ | 123 FUNCTION_TYPE or METHOD_TYPE. */ |
126 bool (*type_hash_eq) (const_tree, const_tree); | 124 bool (*type_hash_eq) (const_tree, const_tree); |
125 | |
126 /* If non-NULL, return TYPE1 with any language-specific modifiers copied from | |
127 TYPE2. */ | |
128 tree (*copy_lang_qualifiers) (const_tree, const_tree); | |
127 | 129 |
128 /* Return TRUE if TYPE uses a hidden descriptor and fills in information | 130 /* Return TRUE if TYPE uses a hidden descriptor and fills in information |
129 for the debugger about the array bounds, strides, etc. */ | 131 for the debugger about the array bounds, strides, etc. */ |
130 bool (*get_array_descr_info) (const_tree, struct array_descr_info *); | 132 bool (*get_array_descr_info) (const_tree, struct array_descr_info *); |
131 | 133 |
132 /* Fill in information for the debugger about the bounds of TYPE. */ | 134 /* Fill in information for the debugger about the bounds of TYPE. */ |
133 void (*get_subrange_bounds) (const_tree, tree *, tree *); | 135 void (*get_subrange_bounds) (const_tree, tree *, tree *); |
136 | |
137 /* Called on INTEGER_TYPEs. Return NULL_TREE for non-biased types. For | |
138 biased types, return as an INTEGER_CST node the value that is represented | |
139 by a physical zero. */ | |
140 tree (*get_type_bias) (const_tree); | |
141 | |
142 /* A type descriptive of TYPE's complex layout generated to help the | |
143 debugger to decode variable-length or self-referential constructs. | |
144 This is only used for the AT_GNAT_descriptive_type DWARF attribute. */ | |
145 tree (*descriptive_type) (const_tree); | |
134 | 146 |
135 /* If we requested a pointer to a vector, build up the pointers that | 147 /* If we requested a pointer to a vector, build up the pointers that |
136 we stripped off while looking for the inner type. Similarly for | 148 we stripped off while looking for the inner type. Similarly for |
137 return values from functions. The argument TYPE is the top of the | 149 return values from functions. The argument TYPE is the top of the |
138 chain, and BOTTOM is the new type which we will point to. */ | 150 chain, and BOTTOM is the new type which we will point to. */ |
139 tree (*reconstruct_complex_type) (tree, tree); | 151 tree (*reconstruct_complex_type) (tree, tree); |
152 | |
153 /* Returns the tree that represents the underlying data type used to | |
154 implement the enumeration. The default implementation will just use | |
155 type_for_size. Used in dwarf2out.c to add a DW_AT_type base type | |
156 reference to a DW_TAG_enumeration. */ | |
157 tree (*enum_underlying_base_type) (const_tree); | |
158 | |
159 /* Return a type to use in the debug info instead of TYPE, or NULL_TREE to | |
160 keep TYPE. This is useful to keep a single "source type" when the | |
161 middle-end uses specialized types, for instance constrained discriminated | |
162 types in Ada. */ | |
163 tree (*get_debug_type) (const_tree); | |
164 | |
165 /* Return TRUE if TYPE implements a fixed point type and fills in information | |
166 for the debugger about scale factor, etc. */ | |
167 bool (*get_fixed_point_type_info) (const_tree, | |
168 struct fixed_point_type_info *); | |
169 | |
170 /* Returns -1 if dwarf ATTR shouldn't be added for TYPE, or the attribute | |
171 value otherwise. */ | |
172 int (*type_dwarf_attribute) (const_tree, int); | |
173 | |
174 /* Returns a tree for the unit size of T excluding tail padding that | |
175 might be used by objects inheriting from T. */ | |
176 tree (*unit_size_without_reusable_padding) (tree); | |
140 }; | 177 }; |
141 | 178 |
142 /* Language hooks related to decls and the symbol table. */ | 179 /* Language hooks related to decls and the symbol table. */ |
143 | 180 |
144 struct lang_hooks_for_decls | 181 struct lang_hooks_for_decls |
145 { | 182 { |
146 /* Returns nonzero if we are in the global binding level. Ada | 183 /* Return true if we are in the global binding level. This hook is really |
147 returns -1 for an undocumented reason used in stor-layout.c. */ | 184 needed only if the language supports variable-sized types at the global |
148 int (*global_bindings_p) (void); | 185 level, i.e. declared outside subprograms. */ |
186 bool (*global_bindings_p) (void); | |
149 | 187 |
150 /* Function to add a decl to the current scope level. Takes one | 188 /* Function to add a decl to the current scope level. Takes one |
151 argument, a decl to add. Returns that decl, or, if the same | 189 argument, a decl to add. Returns that decl, or, if the same |
152 symbol is already declared, may return a different decl for that | 190 symbol is already declared, may return a different decl for that |
153 name. */ | 191 name. */ |
154 tree (*pushdecl) (tree); | 192 tree (*pushdecl) (tree); |
155 | 193 |
156 /* Returns the chain of decls so far in the current scope level. */ | 194 /* Returns the chain of decls so far in the current scope level. */ |
157 tree (*getdecls) (void); | 195 tree (*getdecls) (void); |
158 | 196 |
159 /* Returns true if DECL is explicit member function. */ | 197 /* Returns -1 if dwarf ATTR shouldn't be added for DECL, or the attribute |
160 bool (*function_decl_explicit_p) (tree); | 198 value otherwise. */ |
199 int (*decl_dwarf_attribute) (const_tree, int); | |
161 | 200 |
162 /* Returns True if the parameter is a generic parameter decl | 201 /* Returns True if the parameter is a generic parameter decl |
163 of a generic type, e.g a template template parameter for the C++ FE. */ | 202 of a generic type, e.g a template template parameter for the C++ FE. */ |
164 bool (*generic_generic_parameter_decl_p) (const_tree); | 203 bool (*generic_generic_parameter_decl_p) (const_tree); |
165 | 204 |
172 | 211 |
173 /* Returns true when we should warn for an unused global DECL. | 212 /* Returns true when we should warn for an unused global DECL. |
174 We will already have checked that it has static binding. */ | 213 We will already have checked that it has static binding. */ |
175 bool (*warn_unused_global) (const_tree); | 214 bool (*warn_unused_global) (const_tree); |
176 | 215 |
177 /* Obtain a list of globals and do final output on them at end | 216 /* Perform any post compilation-proper parser cleanups and |
178 of compilation */ | 217 processing. This is currently only needed for the C++ parser, |
179 void (*final_write_globals) (void); | 218 which hopefully can be cleaned up so this hook is no longer |
219 necessary. */ | |
220 void (*post_compilation_parsing_cleanups) (void); | |
180 | 221 |
181 /* True if this decl may be called via a sibcall. */ | 222 /* True if this decl may be called via a sibcall. */ |
182 bool (*ok_for_sibcall) (const_tree); | 223 bool (*ok_for_sibcall) (const_tree); |
183 | 224 |
184 /* True if OpenMP should privatize what this DECL points to rather | 225 /* True if OpenMP should privatize what this DECL points to rather |
216 tree (*omp_clause_copy_ctor) (tree clause, tree dst, tree src); | 257 tree (*omp_clause_copy_ctor) (tree clause, tree dst, tree src); |
217 | 258 |
218 /* Similarly, except use an assignment operator instead. */ | 259 /* Similarly, except use an assignment operator instead. */ |
219 tree (*omp_clause_assign_op) (tree clause, tree dst, tree src); | 260 tree (*omp_clause_assign_op) (tree clause, tree dst, tree src); |
220 | 261 |
262 /* Build and return code for a constructor of DST that sets it to | |
263 SRC + ADD. */ | |
264 tree (*omp_clause_linear_ctor) (tree clause, tree dst, tree src, tree add); | |
265 | |
221 /* Build and return code destructing DECL. Return NULL if nothing | 266 /* Build and return code destructing DECL. Return NULL if nothing |
222 to be done. */ | 267 to be done. */ |
223 tree (*omp_clause_dtor) (tree clause, tree decl); | 268 tree (*omp_clause_dtor) (tree clause, tree decl); |
224 | 269 |
225 /* Do language specific checking on an implicitly determined clause. */ | 270 /* Do language specific checking on an implicitly determined clause. */ |
226 void (*omp_finish_clause) (tree clause); | 271 void (*omp_finish_clause) (tree clause, gimple_seq *pre_p); |
272 | |
273 /* Return true if DECL is a scalar variable (for the purpose of | |
274 implicit firstprivatization). */ | |
275 bool (*omp_scalar_p) (tree decl); | |
227 }; | 276 }; |
228 | 277 |
229 /* Language hooks related to LTO serialization. */ | 278 /* Language hooks related to LTO serialization. */ |
230 | 279 |
231 struct lang_hooks_for_lto | 280 struct lang_hooks_for_lto |
245 | 294 |
246 /* Language-specific hooks. See langhooks-def.h for defaults. */ | 295 /* Language-specific hooks. See langhooks-def.h for defaults. */ |
247 | 296 |
248 struct lang_hooks | 297 struct lang_hooks |
249 { | 298 { |
250 /* String identifying the front end. e.g. "GNU C++". */ | 299 /* String identifying the front end and optionally language standard |
300 version, e.g. "GNU C++98". */ | |
251 const char *name; | 301 const char *name; |
252 | 302 |
253 /* sizeof (struct lang_identifier), so make_node () creates | 303 /* sizeof (struct lang_identifier), so make_node () creates |
254 identifier nodes long enough for the language-specific slots. */ | 304 identifier nodes long enough for the language-specific slots. */ |
255 size_t identifier_size; | 305 size_t identifier_size; |
256 | 306 |
257 /* Remove any parts of the tree that are used only by the FE. */ | 307 /* Remove any parts of the tree that are used only by the FE. */ |
258 void (*free_lang_data) (tree); | 308 void (*free_lang_data) (tree); |
259 | 309 |
260 /* Determines the size of any language-specific tcc_constant or | 310 /* Determines the size of any language-specific tcc_constant, |
261 tcc_exceptional nodes. Since it is called from make_node, the | 311 tcc_exceptional or tcc_type nodes. Since it is called from |
262 only information available is the tree code. Expected to die | 312 make_node, the only information available is the tree code. |
263 on unrecognized codes. */ | 313 Expected to die on unrecognized codes. */ |
264 size_t (*tree_size) (enum tree_code); | 314 size_t (*tree_size) (enum tree_code); |
265 | 315 |
266 /* Return the language mask used for converting argv into a sequence | 316 /* Return the language mask used for converting argv into a sequence |
267 of options. */ | 317 of options. */ |
268 unsigned int (*option_lang_mask) (void); | 318 unsigned int (*option_lang_mask) (void); |
277 struct cl_decoded_option *decoded_options); | 327 struct cl_decoded_option *decoded_options); |
278 | 328 |
279 /* Callback used to perform language-specific initialization for the | 329 /* Callback used to perform language-specific initialization for the |
280 global diagnostic context structure. */ | 330 global diagnostic context structure. */ |
281 void (*initialize_diagnostics) (diagnostic_context *); | 331 void (*initialize_diagnostics) (diagnostic_context *); |
332 | |
333 /* Register language-specific dumps. */ | |
334 void (*register_dumps) (gcc::dump_manager *); | |
282 | 335 |
283 /* Return true if a warning should be given about option OPTION, | 336 /* Return true if a warning should be given about option OPTION, |
284 which is for the wrong language, false if it should be quietly | 337 which is for the wrong language, false if it should be quietly |
285 ignored. */ | 338 ignored. */ |
286 bool (*complain_wrong_lang_p) (const struct cl_option *option); | 339 bool (*complain_wrong_lang_p) (const struct cl_option *option); |
399 const struct attribute_spec *common_attribute_table; | 452 const struct attribute_spec *common_attribute_table; |
400 const struct attribute_spec *format_attribute_table; | 453 const struct attribute_spec *format_attribute_table; |
401 | 454 |
402 struct lang_hooks_for_tree_inlining tree_inlining; | 455 struct lang_hooks_for_tree_inlining tree_inlining; |
403 | 456 |
404 struct lang_hooks_for_callgraph callgraph; | |
405 | |
406 struct lang_hooks_for_tree_dump tree_dump; | 457 struct lang_hooks_for_tree_dump tree_dump; |
407 | 458 |
408 struct lang_hooks_for_decls decls; | 459 struct lang_hooks_for_decls decls; |
409 | 460 |
410 struct lang_hooks_for_types types; | 461 struct lang_hooks_for_types types; |
411 | 462 |
412 struct lang_hooks_for_lto lto; | 463 struct lang_hooks_for_lto lto; |
413 | 464 |
414 /* Returns the generic parameters of an instantiation of | 465 /* Returns a TREE_VEC of the generic parameters of an instantiation of |
415 a generic type or decl, e.g. C++ template instantiation. */ | 466 a generic type or decl, e.g. C++ template instantiation. If |
467 TREE_CHAIN of the return value is set, it is an INTEGER_CST | |
468 indicating how many of the elements are non-default. */ | |
416 tree (*get_innermost_generic_parms) (const_tree); | 469 tree (*get_innermost_generic_parms) (const_tree); |
417 | 470 |
418 /* Returns the TREE_VEC of arguments of an instantiation | 471 /* Returns the TREE_VEC of arguments of an instantiation |
419 of a generic type of decl, e.g. C++ template instantiation. */ | 472 of a generic type of decl, e.g. C++ template instantiation. */ |
420 tree (*get_innermost_generic_args) (const_tree); | 473 tree (*get_innermost_generic_args) (const_tree); |
457 during stack unwinding is required to result in a call to | 510 during stack unwinding is required to result in a call to |
458 `std::terminate', so the C++ version of this function returns a | 511 `std::terminate', so the C++ version of this function returns a |
459 FUNCTION_DECL for `std::terminate'. */ | 512 FUNCTION_DECL for `std::terminate'. */ |
460 tree (*eh_protect_cleanup_actions) (void); | 513 tree (*eh_protect_cleanup_actions) (void); |
461 | 514 |
515 /* Return true if a stmt can fallthru. Used by block_may_fallthru | |
516 to possibly handle language trees. */ | |
517 bool (*block_may_fallthru) (const_tree); | |
518 | |
462 /* True if this language uses __cxa_end_cleanup when the ARM EABI | 519 /* True if this language uses __cxa_end_cleanup when the ARM EABI |
463 is enabled. */ | 520 is enabled. */ |
464 bool eh_use_cxa_end_cleanup; | 521 bool eh_use_cxa_end_cleanup; |
465 | 522 |
466 /* True if this language requires deep unsharing of tree nodes prior to | 523 /* True if this language requires deep unsharing of tree nodes prior to |
467 gimplification. */ | 524 gimplification. */ |
468 bool deep_unsharing; | 525 bool deep_unsharing; |
469 | 526 |
527 /* True if this language may use custom descriptors for nested functions | |
528 instead of trampolines. */ | |
529 bool custom_function_descriptors; | |
530 | |
531 /* Run all lang-specific selftests. */ | |
532 void (*run_lang_selftests) (void); | |
533 | |
534 /* Attempt to determine the source location of the substring. | |
535 If successful, return NULL and write the source location to *OUT_LOC. | |
536 Otherwise return an error message. Error messages are intended | |
537 for GCC developers (to help debugging) rather than for end-users. */ | |
538 const char *(*get_substring_location) (const substring_loc &, | |
539 location_t *out_loc); | |
540 | |
470 /* Whenever you add entries here, make sure you adjust langhooks-def.h | 541 /* Whenever you add entries here, make sure you adjust langhooks-def.h |
471 and langhooks.c accordingly. */ | 542 and langhooks.c accordingly. */ |
472 }; | 543 }; |
473 | 544 |
474 /* Each front end provides its own. */ | 545 /* Each front end provides its own. */ |
475 extern struct lang_hooks lang_hooks; | 546 extern struct lang_hooks lang_hooks; |
547 | |
476 extern tree add_builtin_function (const char *name, tree type, | 548 extern tree add_builtin_function (const char *name, tree type, |
477 int function_code, enum built_in_class cl, | 549 int function_code, enum built_in_class cl, |
478 const char *library_name, | 550 const char *library_name, |
479 tree attrs); | 551 tree attrs); |
480 | 552 |
481 extern tree add_builtin_function_ext_scope (const char *name, tree type, | 553 extern tree add_builtin_function_ext_scope (const char *name, tree type, |
482 int function_code, | 554 int function_code, |
483 enum built_in_class cl, | 555 enum built_in_class cl, |
484 const char *library_name, | 556 const char *library_name, |
485 tree attrs); | 557 tree attrs); |
558 extern tree add_builtin_type (const char *name, tree type); | |
559 | |
560 /* Language helper functions. */ | |
561 | |
562 extern bool lang_GNU_C (void); | |
563 extern bool lang_GNU_CXX (void); | |
564 extern bool lang_GNU_Fortran (void); | |
565 extern bool lang_GNU_OBJC (void); | |
486 | 566 |
487 #endif /* GCC_LANG_HOOKS_H */ | 567 #endif /* GCC_LANG_HOOKS_H */ |