xfs: remove unused full argument from bmap
[linux/fpc-iii.git] / scripts / gcc-plugins / gcc-common.h
blob12262c0cc6914e6a5eebac1b887b129a15fb7466
1 #ifndef GCC_COMMON_H_INCLUDED
2 #define GCC_COMMON_H_INCLUDED
4 #include "bversion.h"
5 #if BUILDING_GCC_VERSION >= 6000
6 #include "gcc-plugin.h"
7 #else
8 #include "plugin.h"
9 #endif
10 #include "plugin-version.h"
11 #include "config.h"
12 #include "system.h"
13 #include "coretypes.h"
14 #include "tm.h"
15 #include "line-map.h"
16 #include "input.h"
17 #include "tree.h"
19 #include "tree-inline.h"
20 #include "version.h"
21 #include "rtl.h"
22 #include "tm_p.h"
23 #include "flags.h"
24 #include "hard-reg-set.h"
25 #include "output.h"
26 #include "except.h"
27 #include "function.h"
28 #include "toplev.h"
29 #include "basic-block.h"
30 #include "intl.h"
31 #include "ggc.h"
32 #include "timevar.h"
34 #include "params.h"
36 #if BUILDING_GCC_VERSION <= 4009
37 #include "pointer-set.h"
38 #else
39 #include "hash-map.h"
40 #endif
42 #if BUILDING_GCC_VERSION >= 7000
43 #include "memmodel.h"
44 #endif
45 #include "emit-rtl.h"
46 #include "debug.h"
47 #include "target.h"
48 #include "langhooks.h"
49 #include "cfgloop.h"
50 #include "cgraph.h"
51 #include "opts.h"
53 #if BUILDING_GCC_VERSION == 4005
54 #include <sys/mman.h>
55 #endif
57 #if BUILDING_GCC_VERSION >= 4007
58 #include "tree-pretty-print.h"
59 #include "gimple-pretty-print.h"
60 #endif
62 #if BUILDING_GCC_VERSION >= 4006
63 #include "c-family/c-common.h"
64 #else
65 #include "c-common.h"
66 #endif
68 #if BUILDING_GCC_VERSION <= 4008
69 #include "tree-flow.h"
70 #else
71 #include "tree-cfgcleanup.h"
72 #include "tree-ssa-operands.h"
73 #include "tree-into-ssa.h"
74 #endif
76 #if BUILDING_GCC_VERSION >= 4008
77 #include "is-a.h"
78 #endif
80 #include "diagnostic.h"
81 #include "tree-dump.h"
82 #include "tree-pass.h"
83 #include "predict.h"
84 #include "ipa-utils.h"
86 #if BUILDING_GCC_VERSION >= 4009
87 #include "attribs.h"
88 #include "varasm.h"
89 #include "stor-layout.h"
90 #include "internal-fn.h"
91 #include "gimple-expr.h"
92 #include "gimple-fold.h"
93 #include "context.h"
94 #include "tree-ssa-alias.h"
95 #include "tree-ssa.h"
96 #include "stringpool.h"
97 #if BUILDING_GCC_VERSION >= 7000
98 #include "tree-vrp.h"
99 #endif
100 #include "tree-ssanames.h"
101 #include "print-tree.h"
102 #include "tree-eh.h"
103 #include "stmt.h"
104 #include "gimplify.h"
105 #endif
107 #include "gimple.h"
109 #if BUILDING_GCC_VERSION >= 4009
110 #include "tree-ssa-operands.h"
111 #include "tree-phinodes.h"
112 #include "tree-cfg.h"
113 #include "gimple-iterator.h"
114 #include "gimple-ssa.h"
115 #include "ssa-iterators.h"
116 #endif
118 #if BUILDING_GCC_VERSION >= 5000
119 #include "builtins.h"
120 #endif
122 /* #include "expr.h" where are you... */
123 extern rtx emit_move_insn(rtx x, rtx y);
125 /* missing from basic_block.h... */
126 extern void debug_dominance_info(enum cdi_direction dir);
127 extern void debug_dominance_tree(enum cdi_direction dir, basic_block root);
129 #if BUILDING_GCC_VERSION == 4006
130 extern void debug_gimple_stmt(gimple);
131 extern void debug_gimple_seq(gimple_seq);
132 extern void print_gimple_seq(FILE *, gimple_seq, int, int);
133 extern void print_gimple_stmt(FILE *, gimple, int, int);
134 extern void print_gimple_expr(FILE *, gimple, int, int);
135 extern void dump_gimple_stmt(pretty_printer *, gimple, int, int);
136 #endif
138 #define __unused __attribute__((__unused__))
139 #define __visible __attribute__((visibility("default")))
141 #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
142 #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
143 #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
144 #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
146 /* should come from c-tree.h if only it were installed for gcc 4.5... */
147 #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
149 #if BUILDING_GCC_VERSION == 4005
150 #define FOR_EACH_LOCAL_DECL(FUN, I, D) \
151 for (tree vars = (FUN)->local_decls, (I) = 0; \
152 vars && ((D) = TREE_VALUE(vars)); \
153 vars = TREE_CHAIN(vars), (I)++)
154 #define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
155 #define FOR_EACH_VEC_ELT(T, V, I, P) \
156 for (I = 0; VEC_iterate(T, (V), (I), (P)); ++(I))
157 #define TODO_rebuild_cgraph_edges 0
158 #define SCOPE_FILE_SCOPE_P(EXP) (!(EXP))
160 #ifndef O_BINARY
161 #define O_BINARY 0
162 #endif
164 typedef struct varpool_node *varpool_node_ptr;
166 static inline bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
168 tree fndecl;
170 if (!is_gimple_call(stmt))
171 return false;
172 fndecl = gimple_call_fndecl(stmt);
173 if (!fndecl || DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
174 return false;
175 return DECL_FUNCTION_CODE(fndecl) == code;
178 static inline bool is_simple_builtin(tree decl)
180 if (decl && DECL_BUILT_IN_CLASS(decl) != BUILT_IN_NORMAL)
181 return false;
183 switch (DECL_FUNCTION_CODE(decl)) {
184 /* Builtins that expand to constants. */
185 case BUILT_IN_CONSTANT_P:
186 case BUILT_IN_EXPECT:
187 case BUILT_IN_OBJECT_SIZE:
188 case BUILT_IN_UNREACHABLE:
189 /* Simple register moves or loads from stack. */
190 case BUILT_IN_RETURN_ADDRESS:
191 case BUILT_IN_EXTRACT_RETURN_ADDR:
192 case BUILT_IN_FROB_RETURN_ADDR:
193 case BUILT_IN_RETURN:
194 case BUILT_IN_AGGREGATE_INCOMING_ADDRESS:
195 case BUILT_IN_FRAME_ADDRESS:
196 case BUILT_IN_VA_END:
197 case BUILT_IN_STACK_SAVE:
198 case BUILT_IN_STACK_RESTORE:
199 /* Exception state returns or moves registers around. */
200 case BUILT_IN_EH_FILTER:
201 case BUILT_IN_EH_POINTER:
202 case BUILT_IN_EH_COPY_VALUES:
203 return true;
205 default:
206 return false;
210 static inline void add_local_decl(struct function *fun, tree d)
212 gcc_assert(TREE_CODE(d) == VAR_DECL);
213 fun->local_decls = tree_cons(NULL_TREE, d, fun->local_decls);
215 #endif
217 #if BUILDING_GCC_VERSION <= 4006
218 #define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
219 #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4(EXP)
220 #define EDGE_PRESERVE 0ULL
221 #define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x"
222 #define flag_fat_lto_objects true
224 #define get_random_seed(noinit) ({ \
225 unsigned HOST_WIDE_INT seed; \
226 sscanf(get_random_seed(noinit), "%" HOST_WIDE_INT_PRINT "x", &seed); \
227 seed * seed; })
229 #define int_const_binop(code, arg1, arg2) \
230 int_const_binop((code), (arg1), (arg2), 0)
232 static inline bool gimple_clobber_p(gimple s __unused)
234 return false;
237 static inline bool gimple_asm_clobbers_memory_p(const_gimple stmt)
239 unsigned i;
241 for (i = 0; i < gimple_asm_nclobbers(stmt); i++) {
242 tree op = gimple_asm_clobber_op(stmt, i);
244 if (!strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "memory"))
245 return true;
248 return false;
251 static inline tree builtin_decl_implicit(enum built_in_function fncode)
253 return implicit_built_in_decls[fncode];
256 static inline int ipa_reverse_postorder(struct cgraph_node **order)
258 return cgraph_postorder(order);
261 static inline struct cgraph_node *cgraph_create_node(tree decl)
263 return cgraph_node(decl);
266 static inline struct cgraph_node *cgraph_get_create_node(tree decl)
268 struct cgraph_node *node = cgraph_get_node(decl);
270 return node ? node : cgraph_node(decl);
273 static inline bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
275 return node->analyzed && !node->thunk.thunk_p && !node->alias;
278 static inline struct cgraph_node *cgraph_first_function_with_gimple_body(void)
280 struct cgraph_node *node;
282 for (node = cgraph_nodes; node; node = node->next)
283 if (cgraph_function_with_gimple_body_p(node))
284 return node;
285 return NULL;
288 static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
290 for (node = node->next; node; node = node->next)
291 if (cgraph_function_with_gimple_body_p(node))
292 return node;
293 return NULL;
296 static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
298 cgraph_node_ptr alias;
300 if (callback(node, data))
301 return true;
303 for (alias = node->same_body; alias; alias = alias->next) {
304 if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE)
305 if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable))
306 return true;
309 return false;
312 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
313 for ((node) = cgraph_first_function_with_gimple_body(); (node); \
314 (node) = cgraph_next_function_with_gimple_body(node))
316 static inline void varpool_add_new_variable(tree decl)
318 varpool_finalize_decl(decl);
320 #endif
322 #if BUILDING_GCC_VERSION <= 4007
323 #define FOR_EACH_FUNCTION(node) \
324 for (node = cgraph_nodes; node; node = node->next)
325 #define FOR_EACH_VARIABLE(node) \
326 for (node = varpool_nodes; node; node = node->next)
327 #define PROP_loops 0
328 #define NODE_SYMBOL(node) (node)
329 #define NODE_DECL(node) (node)->decl
330 #define INSN_LOCATION(INSN) RTL_LOCATION(INSN)
331 #define vNULL NULL
333 static inline int bb_loop_depth(const_basic_block bb)
335 return bb->loop_father ? loop_depth(bb->loop_father) : 0;
338 static inline bool gimple_store_p(gimple gs)
340 tree lhs = gimple_get_lhs(gs);
342 return lhs && !is_gimple_reg(lhs);
345 static inline void gimple_init_singleton(gimple g __unused)
348 #endif
350 #if BUILDING_GCC_VERSION == 4007 || BUILDING_GCC_VERSION == 4008
351 static inline struct cgraph_node *cgraph_alias_target(struct cgraph_node *n)
353 return cgraph_alias_aliased_node(n);
355 #endif
357 #if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION <= 4009
358 #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
359 cgraph_create_edge((caller), (callee), (call_stmt), (count), (freq))
360 #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
361 cgraph_create_edge_including_clones((caller), (callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
362 #endif
364 #if BUILDING_GCC_VERSION <= 4008
365 #define ENTRY_BLOCK_PTR_FOR_FN(FN) ENTRY_BLOCK_PTR_FOR_FUNCTION(FN)
366 #define EXIT_BLOCK_PTR_FOR_FN(FN) EXIT_BLOCK_PTR_FOR_FUNCTION(FN)
367 #define basic_block_info_for_fn(FN) ((FN)->cfg->x_basic_block_info)
368 #define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks)
369 #define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges)
370 #define last_basic_block_for_fn(FN) ((FN)->cfg->x_last_basic_block)
371 #define label_to_block_map_for_fn(FN) ((FN)->cfg->x_label_to_block_map)
372 #define profile_status_for_fn(FN) ((FN)->cfg->x_profile_status)
373 #define BASIC_BLOCK_FOR_FN(FN, N) BASIC_BLOCK_FOR_FUNCTION((FN), (N))
374 #define NODE_IMPLICIT_ALIAS(node) (node)->same_body_alias
375 #define VAR_P(NODE) (TREE_CODE(NODE) == VAR_DECL)
377 static inline bool tree_fits_shwi_p(const_tree t)
379 if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
380 return false;
382 if (TREE_INT_CST_HIGH(t) == 0 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) >= 0)
383 return true;
385 if (TREE_INT_CST_HIGH(t) == -1 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) < 0 && !TYPE_UNSIGNED(TREE_TYPE(t)))
386 return true;
388 return false;
391 static inline bool tree_fits_uhwi_p(const_tree t)
393 if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
394 return false;
396 return TREE_INT_CST_HIGH(t) == 0;
399 static inline HOST_WIDE_INT tree_to_shwi(const_tree t)
401 gcc_assert(tree_fits_shwi_p(t));
402 return TREE_INT_CST_LOW(t);
405 static inline unsigned HOST_WIDE_INT tree_to_uhwi(const_tree t)
407 gcc_assert(tree_fits_uhwi_p(t));
408 return TREE_INT_CST_LOW(t);
411 static inline const char *get_tree_code_name(enum tree_code code)
413 gcc_assert(code < MAX_TREE_CODES);
414 return tree_code_name[code];
417 #define ipa_remove_stmt_references(cnode, stmt)
419 typedef union gimple_statement_d gasm;
420 typedef union gimple_statement_d gassign;
421 typedef union gimple_statement_d gcall;
422 typedef union gimple_statement_d gcond;
423 typedef union gimple_statement_d gdebug;
424 typedef union gimple_statement_d ggoto;
425 typedef union gimple_statement_d gphi;
426 typedef union gimple_statement_d greturn;
428 static inline gasm *as_a_gasm(gimple stmt)
430 return stmt;
433 static inline const gasm *as_a_const_gasm(const_gimple stmt)
435 return stmt;
438 static inline gassign *as_a_gassign(gimple stmt)
440 return stmt;
443 static inline const gassign *as_a_const_gassign(const_gimple stmt)
445 return stmt;
448 static inline gcall *as_a_gcall(gimple stmt)
450 return stmt;
453 static inline const gcall *as_a_const_gcall(const_gimple stmt)
455 return stmt;
458 static inline gcond *as_a_gcond(gimple stmt)
460 return stmt;
463 static inline const gcond *as_a_const_gcond(const_gimple stmt)
465 return stmt;
468 static inline gdebug *as_a_gdebug(gimple stmt)
470 return stmt;
473 static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
475 return stmt;
478 static inline ggoto *as_a_ggoto(gimple stmt)
480 return stmt;
483 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
485 return stmt;
488 static inline gphi *as_a_gphi(gimple stmt)
490 return stmt;
493 static inline const gphi *as_a_const_gphi(const_gimple stmt)
495 return stmt;
498 static inline greturn *as_a_greturn(gimple stmt)
500 return stmt;
503 static inline const greturn *as_a_const_greturn(const_gimple stmt)
505 return stmt;
507 #endif
509 #if BUILDING_GCC_VERSION == 4008
510 #define NODE_SYMBOL(node) (&(node)->symbol)
511 #define NODE_DECL(node) (node)->symbol.decl
512 #endif
514 #if BUILDING_GCC_VERSION >= 4008
515 #define add_referenced_var(var)
516 #define mark_sym_for_renaming(var)
517 #define varpool_mark_needed_node(node)
518 #define create_var_ann(var)
519 #define TODO_dump_func 0
520 #define TODO_dump_cgraph 0
521 #endif
523 #if BUILDING_GCC_VERSION <= 4009
524 #define TODO_verify_il 0
525 #define AVAIL_INTERPOSABLE AVAIL_OVERWRITABLE
527 #define section_name_prefix LTO_SECTION_NAME_PREFIX
528 #define fatal_error(loc, gmsgid, ...) fatal_error((gmsgid), __VA_ARGS__)
530 typedef struct rtx_def rtx_insn;
532 static inline const char *get_decl_section_name(const_tree decl)
534 if (DECL_SECTION_NAME(decl) == NULL_TREE)
535 return NULL;
537 return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
540 static inline void set_decl_section_name(tree node, const char *value)
542 if (value)
543 DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value);
544 else
545 DECL_SECTION_NAME(node) = NULL;
547 #endif
549 #if BUILDING_GCC_VERSION == 4009
550 typedef struct gimple_statement_asm gasm;
551 typedef struct gimple_statement_base gassign;
552 typedef struct gimple_statement_call gcall;
553 typedef struct gimple_statement_base gcond;
554 typedef struct gimple_statement_base gdebug;
555 typedef struct gimple_statement_base ggoto;
556 typedef struct gimple_statement_phi gphi;
557 typedef struct gimple_statement_base greturn;
559 static inline gasm *as_a_gasm(gimple stmt)
561 return as_a<gasm>(stmt);
564 static inline const gasm *as_a_const_gasm(const_gimple stmt)
566 return as_a<const gasm>(stmt);
569 static inline gassign *as_a_gassign(gimple stmt)
571 return stmt;
574 static inline const gassign *as_a_const_gassign(const_gimple stmt)
576 return stmt;
579 static inline gcall *as_a_gcall(gimple stmt)
581 return as_a<gcall>(stmt);
584 static inline const gcall *as_a_const_gcall(const_gimple stmt)
586 return as_a<const gcall>(stmt);
589 static inline gcond *as_a_gcond(gimple stmt)
591 return stmt;
594 static inline const gcond *as_a_const_gcond(const_gimple stmt)
596 return stmt;
599 static inline gdebug *as_a_gdebug(gimple stmt)
601 return stmt;
604 static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
606 return stmt;
609 static inline ggoto *as_a_ggoto(gimple stmt)
611 return stmt;
614 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
616 return stmt;
619 static inline gphi *as_a_gphi(gimple stmt)
621 return as_a<gphi>(stmt);
624 static inline const gphi *as_a_const_gphi(const_gimple stmt)
626 return as_a<const gphi>(stmt);
629 static inline greturn *as_a_greturn(gimple stmt)
631 return stmt;
634 static inline const greturn *as_a_const_greturn(const_gimple stmt)
636 return stmt;
638 #endif
640 #if BUILDING_GCC_VERSION >= 4009
641 #define TODO_ggc_collect 0
642 #define NODE_SYMBOL(node) (node)
643 #define NODE_DECL(node) (node)->decl
644 #define cgraph_node_name(node) (node)->name()
645 #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
646 #endif
648 #if BUILDING_GCC_VERSION >= 5000 && BUILDING_GCC_VERSION < 6000
649 /* gimple related */
650 template <>
651 template <>
652 inline bool is_a_helper<const gassign *>::test(const_gimple gs)
654 return gs->code == GIMPLE_ASSIGN;
656 #endif
658 #if BUILDING_GCC_VERSION >= 5000
659 #define TODO_verify_ssa TODO_verify_il
660 #define TODO_verify_flow TODO_verify_il
661 #define TODO_verify_stmts TODO_verify_il
662 #define TODO_verify_rtl_sharing TODO_verify_il
664 #define INSN_DELETED_P(insn) (insn)->deleted()
666 static inline const char *get_decl_section_name(const_tree decl)
668 return DECL_SECTION_NAME(decl);
671 /* symtab/cgraph related */
672 #define debug_cgraph_node(node) (node)->debug()
673 #define cgraph_get_node(decl) cgraph_node::get(decl)
674 #define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
675 #define cgraph_create_node(decl) cgraph_node::create(decl)
676 #define cgraph_n_nodes symtab->cgraph_count
677 #define cgraph_max_uid symtab->cgraph_max_uid
678 #define varpool_get_node(decl) varpool_node::get(decl)
679 #define dump_varpool_node(file, node) (node)->dump(file)
681 #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
682 (caller)->create_edge((callee), (call_stmt), (count), (freq))
683 #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
684 (caller)->create_edge_including_clones((callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
686 typedef struct cgraph_node *cgraph_node_ptr;
687 typedef struct cgraph_edge *cgraph_edge_p;
688 typedef struct varpool_node *varpool_node_ptr;
690 static inline void change_decl_assembler_name(tree decl, tree name)
692 symtab->change_decl_assembler_name(decl, name);
695 static inline void varpool_finalize_decl(tree decl)
697 varpool_node::finalize_decl(decl);
700 static inline void varpool_add_new_variable(tree decl)
702 varpool_node::add(decl);
705 static inline unsigned int rebuild_cgraph_edges(void)
707 return cgraph_edge::rebuild_edges();
710 static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
712 return node->function_symbol(availability);
715 static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
717 return node->ultimate_alias_target(availability);
720 static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
722 return node->only_called_directly_p();
725 static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
727 return node->get_availability();
730 static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
732 return node->get_alias_target();
735 static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
737 return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
740 static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
742 return symtab->add_cgraph_insertion_hook(hook, data);
745 static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
747 symtab->remove_cgraph_insertion_hook(entry);
750 static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
752 return symtab->add_cgraph_removal_hook(hook, data);
755 static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
757 symtab->remove_cgraph_removal_hook(entry);
760 static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
762 return symtab->add_cgraph_duplication_hook(hook, data);
765 static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
767 symtab->remove_cgraph_duplication_hook(entry);
770 static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
772 symtab->call_cgraph_duplication_hooks(node, node2);
775 static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
777 symtab->call_edge_duplication_hooks(cs1, cs2);
780 #if BUILDING_GCC_VERSION >= 6000
781 typedef gimple *gimple_ptr;
782 typedef const gimple *const_gimple_ptr;
783 #define gimple gimple_ptr
784 #define const_gimple const_gimple_ptr
785 #undef CONST_CAST_GIMPLE
786 #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X))
787 #endif
789 /* gimple related */
790 static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
792 return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
795 template <>
796 template <>
797 inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
799 return gs->code == GIMPLE_GOTO;
802 template <>
803 template <>
804 inline bool is_a_helper<const greturn *>::test(const_gimple gs)
806 return gs->code == GIMPLE_RETURN;
809 static inline gasm *as_a_gasm(gimple stmt)
811 return as_a<gasm *>(stmt);
814 static inline const gasm *as_a_const_gasm(const_gimple stmt)
816 return as_a<const gasm *>(stmt);
819 static inline gassign *as_a_gassign(gimple stmt)
821 return as_a<gassign *>(stmt);
824 static inline const gassign *as_a_const_gassign(const_gimple stmt)
826 return as_a<const gassign *>(stmt);
829 static inline gcall *as_a_gcall(gimple stmt)
831 return as_a<gcall *>(stmt);
834 static inline const gcall *as_a_const_gcall(const_gimple stmt)
836 return as_a<const gcall *>(stmt);
839 static inline ggoto *as_a_ggoto(gimple stmt)
841 return as_a<ggoto *>(stmt);
844 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
846 return as_a<const ggoto *>(stmt);
849 static inline gphi *as_a_gphi(gimple stmt)
851 return as_a<gphi *>(stmt);
854 static inline const gphi *as_a_const_gphi(const_gimple stmt)
856 return as_a<const gphi *>(stmt);
859 static inline greturn *as_a_greturn(gimple stmt)
861 return as_a<greturn *>(stmt);
864 static inline const greturn *as_a_const_greturn(const_gimple stmt)
866 return as_a<const greturn *>(stmt);
869 /* IPA/LTO related */
870 #define ipa_ref_list_referring_iterate(L, I, P) \
871 (L)->referring.iterate((I), &(P))
872 #define ipa_ref_list_reference_iterate(L, I, P) \
873 (L)->reference.iterate((I), &(P))
875 static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
877 return dyn_cast<cgraph_node_ptr>(ref->referring);
880 static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
882 referring_node->remove_stmt_references(stmt);
884 #endif
886 #if BUILDING_GCC_VERSION < 6000
887 #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
888 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning)
889 #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1))
890 #endif
892 #if BUILDING_GCC_VERSION >= 6000
893 #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
894 #endif
896 #ifdef __cplusplus
897 static inline void debug_tree(const_tree t)
899 debug_tree(CONST_CAST_TREE(t));
902 static inline void debug_gimple_stmt(const_gimple s)
904 debug_gimple_stmt(CONST_CAST_GIMPLE(s));
906 #else
907 #define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
908 #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
909 #endif
911 #if BUILDING_GCC_VERSION >= 7000
912 #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
913 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
914 #endif
916 #endif