ipv6: flowlabel: fl6_sock_lookup() must use atomic_inc_not_zero
[linux/fpc-iii.git] / scripts / gcc-plugins / gcc-common.h
blob08fe09c28bd279b54aa6bf644f95165b6a0cc40e
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 #ifndef __unused
139 #define __unused __attribute__((__unused__))
140 #endif
141 #ifndef __visible
142 #define __visible __attribute__((visibility("default")))
143 #endif
145 #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
146 #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
147 #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
148 #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
150 /* should come from c-tree.h if only it were installed for gcc 4.5... */
151 #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
153 #if BUILDING_GCC_VERSION == 4005
154 #define FOR_EACH_LOCAL_DECL(FUN, I, D) \
155 for (tree vars = (FUN)->local_decls, (I) = 0; \
156 vars && ((D) = TREE_VALUE(vars)); \
157 vars = TREE_CHAIN(vars), (I)++)
158 #define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
159 #define FOR_EACH_VEC_ELT(T, V, I, P) \
160 for (I = 0; VEC_iterate(T, (V), (I), (P)); ++(I))
161 #define TODO_rebuild_cgraph_edges 0
162 #define SCOPE_FILE_SCOPE_P(EXP) (!(EXP))
164 #ifndef O_BINARY
165 #define O_BINARY 0
166 #endif
168 typedef struct varpool_node *varpool_node_ptr;
170 static inline bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
172 tree fndecl;
174 if (!is_gimple_call(stmt))
175 return false;
176 fndecl = gimple_call_fndecl(stmt);
177 if (!fndecl || DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
178 return false;
179 return DECL_FUNCTION_CODE(fndecl) == code;
182 static inline bool is_simple_builtin(tree decl)
184 if (decl && DECL_BUILT_IN_CLASS(decl) != BUILT_IN_NORMAL)
185 return false;
187 switch (DECL_FUNCTION_CODE(decl)) {
188 /* Builtins that expand to constants. */
189 case BUILT_IN_CONSTANT_P:
190 case BUILT_IN_EXPECT:
191 case BUILT_IN_OBJECT_SIZE:
192 case BUILT_IN_UNREACHABLE:
193 /* Simple register moves or loads from stack. */
194 case BUILT_IN_RETURN_ADDRESS:
195 case BUILT_IN_EXTRACT_RETURN_ADDR:
196 case BUILT_IN_FROB_RETURN_ADDR:
197 case BUILT_IN_RETURN:
198 case BUILT_IN_AGGREGATE_INCOMING_ADDRESS:
199 case BUILT_IN_FRAME_ADDRESS:
200 case BUILT_IN_VA_END:
201 case BUILT_IN_STACK_SAVE:
202 case BUILT_IN_STACK_RESTORE:
203 /* Exception state returns or moves registers around. */
204 case BUILT_IN_EH_FILTER:
205 case BUILT_IN_EH_POINTER:
206 case BUILT_IN_EH_COPY_VALUES:
207 return true;
209 default:
210 return false;
214 static inline void add_local_decl(struct function *fun, tree d)
216 gcc_assert(TREE_CODE(d) == VAR_DECL);
217 fun->local_decls = tree_cons(NULL_TREE, d, fun->local_decls);
219 #endif
221 #if BUILDING_GCC_VERSION <= 4006
222 #define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
223 #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4(EXP)
224 #define EDGE_PRESERVE 0ULL
225 #define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x"
226 #define flag_fat_lto_objects true
228 #define get_random_seed(noinit) ({ \
229 unsigned HOST_WIDE_INT seed; \
230 sscanf(get_random_seed(noinit), "%" HOST_WIDE_INT_PRINT "x", &seed); \
231 seed * seed; })
233 #define int_const_binop(code, arg1, arg2) \
234 int_const_binop((code), (arg1), (arg2), 0)
236 static inline bool gimple_clobber_p(gimple s __unused)
238 return false;
241 static inline bool gimple_asm_clobbers_memory_p(const_gimple stmt)
243 unsigned i;
245 for (i = 0; i < gimple_asm_nclobbers(stmt); i++) {
246 tree op = gimple_asm_clobber_op(stmt, i);
248 if (!strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "memory"))
249 return true;
252 return false;
255 static inline tree builtin_decl_implicit(enum built_in_function fncode)
257 return implicit_built_in_decls[fncode];
260 static inline int ipa_reverse_postorder(struct cgraph_node **order)
262 return cgraph_postorder(order);
265 static inline struct cgraph_node *cgraph_create_node(tree decl)
267 return cgraph_node(decl);
270 static inline struct cgraph_node *cgraph_get_create_node(tree decl)
272 struct cgraph_node *node = cgraph_get_node(decl);
274 return node ? node : cgraph_node(decl);
277 static inline bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
279 return node->analyzed && !node->thunk.thunk_p && !node->alias;
282 static inline struct cgraph_node *cgraph_first_function_with_gimple_body(void)
284 struct cgraph_node *node;
286 for (node = cgraph_nodes; node; node = node->next)
287 if (cgraph_function_with_gimple_body_p(node))
288 return node;
289 return NULL;
292 static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
294 for (node = node->next; node; node = node->next)
295 if (cgraph_function_with_gimple_body_p(node))
296 return node;
297 return NULL;
300 static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
302 cgraph_node_ptr alias;
304 if (callback(node, data))
305 return true;
307 for (alias = node->same_body; alias; alias = alias->next) {
308 if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE)
309 if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable))
310 return true;
313 return false;
316 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
317 for ((node) = cgraph_first_function_with_gimple_body(); (node); \
318 (node) = cgraph_next_function_with_gimple_body(node))
320 static inline void varpool_add_new_variable(tree decl)
322 varpool_finalize_decl(decl);
324 #endif
326 #if BUILDING_GCC_VERSION <= 4007
327 #define FOR_EACH_FUNCTION(node) \
328 for (node = cgraph_nodes; node; node = node->next)
329 #define FOR_EACH_VARIABLE(node) \
330 for (node = varpool_nodes; node; node = node->next)
331 #define PROP_loops 0
332 #define NODE_SYMBOL(node) (node)
333 #define NODE_DECL(node) (node)->decl
334 #define INSN_LOCATION(INSN) RTL_LOCATION(INSN)
335 #define vNULL NULL
337 static inline int bb_loop_depth(const_basic_block bb)
339 return bb->loop_father ? loop_depth(bb->loop_father) : 0;
342 static inline bool gimple_store_p(gimple gs)
344 tree lhs = gimple_get_lhs(gs);
346 return lhs && !is_gimple_reg(lhs);
349 static inline void gimple_init_singleton(gimple g __unused)
352 #endif
354 #if BUILDING_GCC_VERSION == 4007 || BUILDING_GCC_VERSION == 4008
355 static inline struct cgraph_node *cgraph_alias_target(struct cgraph_node *n)
357 return cgraph_alias_aliased_node(n);
359 #endif
361 #if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION <= 4009
362 #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
363 cgraph_create_edge((caller), (callee), (call_stmt), (count), (freq))
364 #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
365 cgraph_create_edge_including_clones((caller), (callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
366 #endif
368 #if BUILDING_GCC_VERSION <= 4008
369 #define ENTRY_BLOCK_PTR_FOR_FN(FN) ENTRY_BLOCK_PTR_FOR_FUNCTION(FN)
370 #define EXIT_BLOCK_PTR_FOR_FN(FN) EXIT_BLOCK_PTR_FOR_FUNCTION(FN)
371 #define basic_block_info_for_fn(FN) ((FN)->cfg->x_basic_block_info)
372 #define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks)
373 #define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges)
374 #define last_basic_block_for_fn(FN) ((FN)->cfg->x_last_basic_block)
375 #define label_to_block_map_for_fn(FN) ((FN)->cfg->x_label_to_block_map)
376 #define profile_status_for_fn(FN) ((FN)->cfg->x_profile_status)
377 #define BASIC_BLOCK_FOR_FN(FN, N) BASIC_BLOCK_FOR_FUNCTION((FN), (N))
378 #define NODE_IMPLICIT_ALIAS(node) (node)->same_body_alias
379 #define VAR_P(NODE) (TREE_CODE(NODE) == VAR_DECL)
381 static inline bool tree_fits_shwi_p(const_tree t)
383 if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
384 return false;
386 if (TREE_INT_CST_HIGH(t) == 0 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) >= 0)
387 return true;
389 if (TREE_INT_CST_HIGH(t) == -1 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) < 0 && !TYPE_UNSIGNED(TREE_TYPE(t)))
390 return true;
392 return false;
395 static inline bool tree_fits_uhwi_p(const_tree t)
397 if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
398 return false;
400 return TREE_INT_CST_HIGH(t) == 0;
403 static inline HOST_WIDE_INT tree_to_shwi(const_tree t)
405 gcc_assert(tree_fits_shwi_p(t));
406 return TREE_INT_CST_LOW(t);
409 static inline unsigned HOST_WIDE_INT tree_to_uhwi(const_tree t)
411 gcc_assert(tree_fits_uhwi_p(t));
412 return TREE_INT_CST_LOW(t);
415 static inline const char *get_tree_code_name(enum tree_code code)
417 gcc_assert(code < MAX_TREE_CODES);
418 return tree_code_name[code];
421 #define ipa_remove_stmt_references(cnode, stmt)
423 typedef union gimple_statement_d gasm;
424 typedef union gimple_statement_d gassign;
425 typedef union gimple_statement_d gcall;
426 typedef union gimple_statement_d gcond;
427 typedef union gimple_statement_d gdebug;
428 typedef union gimple_statement_d ggoto;
429 typedef union gimple_statement_d gphi;
430 typedef union gimple_statement_d greturn;
432 static inline gasm *as_a_gasm(gimple stmt)
434 return stmt;
437 static inline const gasm *as_a_const_gasm(const_gimple stmt)
439 return stmt;
442 static inline gassign *as_a_gassign(gimple stmt)
444 return stmt;
447 static inline const gassign *as_a_const_gassign(const_gimple stmt)
449 return stmt;
452 static inline gcall *as_a_gcall(gimple stmt)
454 return stmt;
457 static inline const gcall *as_a_const_gcall(const_gimple stmt)
459 return stmt;
462 static inline gcond *as_a_gcond(gimple stmt)
464 return stmt;
467 static inline const gcond *as_a_const_gcond(const_gimple stmt)
469 return stmt;
472 static inline gdebug *as_a_gdebug(gimple stmt)
474 return stmt;
477 static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
479 return stmt;
482 static inline ggoto *as_a_ggoto(gimple stmt)
484 return stmt;
487 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
489 return stmt;
492 static inline gphi *as_a_gphi(gimple stmt)
494 return stmt;
497 static inline const gphi *as_a_const_gphi(const_gimple stmt)
499 return stmt;
502 static inline greturn *as_a_greturn(gimple stmt)
504 return stmt;
507 static inline const greturn *as_a_const_greturn(const_gimple stmt)
509 return stmt;
511 #endif
513 #if BUILDING_GCC_VERSION == 4008
514 #define NODE_SYMBOL(node) (&(node)->symbol)
515 #define NODE_DECL(node) (node)->symbol.decl
516 #endif
518 #if BUILDING_GCC_VERSION >= 4008
519 #define add_referenced_var(var)
520 #define mark_sym_for_renaming(var)
521 #define varpool_mark_needed_node(node)
522 #define create_var_ann(var)
523 #define TODO_dump_func 0
524 #define TODO_dump_cgraph 0
525 #endif
527 #if BUILDING_GCC_VERSION <= 4009
528 #define TODO_verify_il 0
529 #define AVAIL_INTERPOSABLE AVAIL_OVERWRITABLE
531 #define section_name_prefix LTO_SECTION_NAME_PREFIX
532 #define fatal_error(loc, gmsgid, ...) fatal_error((gmsgid), __VA_ARGS__)
534 typedef struct rtx_def rtx_insn;
536 static inline const char *get_decl_section_name(const_tree decl)
538 if (DECL_SECTION_NAME(decl) == NULL_TREE)
539 return NULL;
541 return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
544 static inline void set_decl_section_name(tree node, const char *value)
546 if (value)
547 DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value);
548 else
549 DECL_SECTION_NAME(node) = NULL;
551 #endif
553 #if BUILDING_GCC_VERSION == 4009
554 typedef struct gimple_statement_asm gasm;
555 typedef struct gimple_statement_base gassign;
556 typedef struct gimple_statement_call gcall;
557 typedef struct gimple_statement_base gcond;
558 typedef struct gimple_statement_base gdebug;
559 typedef struct gimple_statement_base ggoto;
560 typedef struct gimple_statement_phi gphi;
561 typedef struct gimple_statement_base greturn;
563 static inline gasm *as_a_gasm(gimple stmt)
565 return as_a<gasm>(stmt);
568 static inline const gasm *as_a_const_gasm(const_gimple stmt)
570 return as_a<const gasm>(stmt);
573 static inline gassign *as_a_gassign(gimple stmt)
575 return stmt;
578 static inline const gassign *as_a_const_gassign(const_gimple stmt)
580 return stmt;
583 static inline gcall *as_a_gcall(gimple stmt)
585 return as_a<gcall>(stmt);
588 static inline const gcall *as_a_const_gcall(const_gimple stmt)
590 return as_a<const gcall>(stmt);
593 static inline gcond *as_a_gcond(gimple stmt)
595 return stmt;
598 static inline const gcond *as_a_const_gcond(const_gimple stmt)
600 return stmt;
603 static inline gdebug *as_a_gdebug(gimple stmt)
605 return stmt;
608 static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
610 return stmt;
613 static inline ggoto *as_a_ggoto(gimple stmt)
615 return stmt;
618 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
620 return stmt;
623 static inline gphi *as_a_gphi(gimple stmt)
625 return as_a<gphi>(stmt);
628 static inline const gphi *as_a_const_gphi(const_gimple stmt)
630 return as_a<const gphi>(stmt);
633 static inline greturn *as_a_greturn(gimple stmt)
635 return stmt;
638 static inline const greturn *as_a_const_greturn(const_gimple stmt)
640 return stmt;
642 #endif
644 #if BUILDING_GCC_VERSION >= 4009
645 #define TODO_ggc_collect 0
646 #define NODE_SYMBOL(node) (node)
647 #define NODE_DECL(node) (node)->decl
648 #define cgraph_node_name(node) (node)->name()
649 #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
650 #endif
652 #if BUILDING_GCC_VERSION >= 5000 && BUILDING_GCC_VERSION < 6000
653 /* gimple related */
654 template <>
655 template <>
656 inline bool is_a_helper<const gassign *>::test(const_gimple gs)
658 return gs->code == GIMPLE_ASSIGN;
660 #endif
662 #if BUILDING_GCC_VERSION >= 5000
663 #define TODO_verify_ssa TODO_verify_il
664 #define TODO_verify_flow TODO_verify_il
665 #define TODO_verify_stmts TODO_verify_il
666 #define TODO_verify_rtl_sharing TODO_verify_il
668 #define INSN_DELETED_P(insn) (insn)->deleted()
670 static inline const char *get_decl_section_name(const_tree decl)
672 return DECL_SECTION_NAME(decl);
675 /* symtab/cgraph related */
676 #define debug_cgraph_node(node) (node)->debug()
677 #define cgraph_get_node(decl) cgraph_node::get(decl)
678 #define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
679 #define cgraph_create_node(decl) cgraph_node::create(decl)
680 #define cgraph_n_nodes symtab->cgraph_count
681 #define cgraph_max_uid symtab->cgraph_max_uid
682 #define varpool_get_node(decl) varpool_node::get(decl)
683 #define dump_varpool_node(file, node) (node)->dump(file)
685 #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
686 (caller)->create_edge((callee), (call_stmt), (count), (freq))
687 #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
688 (caller)->create_edge_including_clones((callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
690 typedef struct cgraph_node *cgraph_node_ptr;
691 typedef struct cgraph_edge *cgraph_edge_p;
692 typedef struct varpool_node *varpool_node_ptr;
694 static inline void change_decl_assembler_name(tree decl, tree name)
696 symtab->change_decl_assembler_name(decl, name);
699 static inline void varpool_finalize_decl(tree decl)
701 varpool_node::finalize_decl(decl);
704 static inline void varpool_add_new_variable(tree decl)
706 varpool_node::add(decl);
709 static inline unsigned int rebuild_cgraph_edges(void)
711 return cgraph_edge::rebuild_edges();
714 static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
716 return node->function_symbol(availability);
719 static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
721 return node->ultimate_alias_target(availability);
724 static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
726 return node->only_called_directly_p();
729 static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
731 return node->get_availability();
734 static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
736 return node->get_alias_target();
739 static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
741 return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
744 static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
746 return symtab->add_cgraph_insertion_hook(hook, data);
749 static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
751 symtab->remove_cgraph_insertion_hook(entry);
754 static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
756 return symtab->add_cgraph_removal_hook(hook, data);
759 static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
761 symtab->remove_cgraph_removal_hook(entry);
764 static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
766 return symtab->add_cgraph_duplication_hook(hook, data);
769 static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
771 symtab->remove_cgraph_duplication_hook(entry);
774 static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
776 symtab->call_cgraph_duplication_hooks(node, node2);
779 static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
781 symtab->call_edge_duplication_hooks(cs1, cs2);
784 #if BUILDING_GCC_VERSION >= 6000
785 typedef gimple *gimple_ptr;
786 typedef const gimple *const_gimple_ptr;
787 #define gimple gimple_ptr
788 #define const_gimple const_gimple_ptr
789 #undef CONST_CAST_GIMPLE
790 #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X))
791 #endif
793 /* gimple related */
794 static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
796 return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
799 template <>
800 template <>
801 inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
803 return gs->code == GIMPLE_GOTO;
806 template <>
807 template <>
808 inline bool is_a_helper<const greturn *>::test(const_gimple gs)
810 return gs->code == GIMPLE_RETURN;
813 static inline gasm *as_a_gasm(gimple stmt)
815 return as_a<gasm *>(stmt);
818 static inline const gasm *as_a_const_gasm(const_gimple stmt)
820 return as_a<const gasm *>(stmt);
823 static inline gassign *as_a_gassign(gimple stmt)
825 return as_a<gassign *>(stmt);
828 static inline const gassign *as_a_const_gassign(const_gimple stmt)
830 return as_a<const gassign *>(stmt);
833 static inline gcall *as_a_gcall(gimple stmt)
835 return as_a<gcall *>(stmt);
838 static inline const gcall *as_a_const_gcall(const_gimple stmt)
840 return as_a<const gcall *>(stmt);
843 static inline ggoto *as_a_ggoto(gimple stmt)
845 return as_a<ggoto *>(stmt);
848 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
850 return as_a<const ggoto *>(stmt);
853 static inline gphi *as_a_gphi(gimple stmt)
855 return as_a<gphi *>(stmt);
858 static inline const gphi *as_a_const_gphi(const_gimple stmt)
860 return as_a<const gphi *>(stmt);
863 static inline greturn *as_a_greturn(gimple stmt)
865 return as_a<greturn *>(stmt);
868 static inline const greturn *as_a_const_greturn(const_gimple stmt)
870 return as_a<const greturn *>(stmt);
873 /* IPA/LTO related */
874 #define ipa_ref_list_referring_iterate(L, I, P) \
875 (L)->referring.iterate((I), &(P))
876 #define ipa_ref_list_reference_iterate(L, I, P) \
877 (L)->reference.iterate((I), &(P))
879 static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
881 return dyn_cast<cgraph_node_ptr>(ref->referring);
884 static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
886 referring_node->remove_stmt_references(stmt);
888 #endif
890 #if BUILDING_GCC_VERSION < 6000
891 #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
892 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning)
893 #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1))
894 #endif
896 #if BUILDING_GCC_VERSION >= 6000
897 #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
898 #endif
900 #ifdef __cplusplus
901 static inline void debug_tree(const_tree t)
903 debug_tree(CONST_CAST_TREE(t));
906 static inline void debug_gimple_stmt(const_gimple s)
908 debug_gimple_stmt(CONST_CAST_GIMPLE(s));
910 #else
911 #define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
912 #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
913 #endif
915 #if BUILDING_GCC_VERSION >= 7000
916 #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
917 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
918 #endif
920 #endif