drm/msm/dpu: use encoder type to identify display type
[linux/fpc-iii.git] / scripts / gcc-plugins / gcc-common.h
blob552d5efd7cb7524b221272cb1c14f6da222b324c
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef GCC_COMMON_H_INCLUDED
3 #define GCC_COMMON_H_INCLUDED
5 #include "bversion.h"
6 #if BUILDING_GCC_VERSION >= 6000
7 #include "gcc-plugin.h"
8 #else
9 #include "plugin.h"
10 #endif
11 #include "plugin-version.h"
12 #include "config.h"
13 #include "system.h"
14 #include "coretypes.h"
15 #include "tm.h"
16 #include "line-map.h"
17 #include "input.h"
18 #include "tree.h"
20 #include "tree-inline.h"
21 #include "version.h"
22 #include "rtl.h"
23 #include "tm_p.h"
24 #include "flags.h"
25 #include "hard-reg-set.h"
26 #include "output.h"
27 #include "except.h"
28 #include "function.h"
29 #include "toplev.h"
30 #if BUILDING_GCC_VERSION >= 5000
31 #include "expr.h"
32 #endif
33 #include "basic-block.h"
34 #include "intl.h"
35 #include "ggc.h"
36 #include "timevar.h"
38 #include "params.h"
40 #if BUILDING_GCC_VERSION <= 4009
41 #include "pointer-set.h"
42 #else
43 #include "hash-map.h"
44 #endif
46 #if BUILDING_GCC_VERSION >= 7000
47 #include "memmodel.h"
48 #endif
49 #include "emit-rtl.h"
50 #include "debug.h"
51 #include "target.h"
52 #include "langhooks.h"
53 #include "cfgloop.h"
54 #include "cgraph.h"
55 #include "opts.h"
57 #if BUILDING_GCC_VERSION == 4005
58 #include <sys/mman.h>
59 #endif
61 #if BUILDING_GCC_VERSION >= 4007
62 #include "tree-pretty-print.h"
63 #include "gimple-pretty-print.h"
64 #endif
66 #if BUILDING_GCC_VERSION >= 4006
68 * The c-family headers were moved into a subdirectory in GCC version
69 * 4.7, but most plugin-building users of GCC 4.6 are using the Debian
70 * or Ubuntu package, which has an out-of-tree patch to move this to the
71 * same location as found in 4.7 and later:
72 * https://sources.debian.net/src/gcc-4.6/4.6.3-14/debian/patches/pr45078.diff/
74 #include "c-family/c-common.h"
75 #else
76 #include "c-common.h"
77 #endif
79 #if BUILDING_GCC_VERSION <= 4008
80 #include "tree-flow.h"
81 #else
82 #include "tree-cfgcleanup.h"
83 #include "tree-ssa-operands.h"
84 #include "tree-into-ssa.h"
85 #endif
87 #if BUILDING_GCC_VERSION >= 4008
88 #include "is-a.h"
89 #endif
91 #include "diagnostic.h"
92 #include "tree-dump.h"
93 #include "tree-pass.h"
94 #if BUILDING_GCC_VERSION >= 4009
95 #include "pass_manager.h"
96 #endif
97 #include "predict.h"
98 #include "ipa-utils.h"
100 #if BUILDING_GCC_VERSION >= 8000
101 #include "stringpool.h"
102 #endif
104 #if BUILDING_GCC_VERSION >= 4009
105 #include "attribs.h"
106 #include "varasm.h"
107 #include "stor-layout.h"
108 #include "internal-fn.h"
109 #include "gimple-expr.h"
110 #include "gimple-fold.h"
111 #include "context.h"
112 #include "tree-ssa-alias.h"
113 #include "tree-ssa.h"
114 #include "stringpool.h"
115 #if BUILDING_GCC_VERSION >= 7000
116 #include "tree-vrp.h"
117 #endif
118 #include "tree-ssanames.h"
119 #include "print-tree.h"
120 #include "tree-eh.h"
121 #include "stmt.h"
122 #include "gimplify.h"
123 #endif
125 #include "gimple.h"
127 #if BUILDING_GCC_VERSION >= 4009
128 #include "tree-ssa-operands.h"
129 #include "tree-phinodes.h"
130 #include "tree-cfg.h"
131 #include "gimple-iterator.h"
132 #include "gimple-ssa.h"
133 #include "ssa-iterators.h"
134 #endif
136 #if BUILDING_GCC_VERSION >= 5000
137 #include "builtins.h"
138 #endif
140 /* missing from basic_block.h... */
141 void debug_dominance_info(enum cdi_direction dir);
142 void debug_dominance_tree(enum cdi_direction dir, basic_block root);
144 #if BUILDING_GCC_VERSION == 4006
145 void debug_gimple_stmt(gimple);
146 void debug_gimple_seq(gimple_seq);
147 void print_gimple_seq(FILE *, gimple_seq, int, int);
148 void print_gimple_stmt(FILE *, gimple, int, int);
149 void print_gimple_expr(FILE *, gimple, int, int);
150 void dump_gimple_stmt(pretty_printer *, gimple, int, int);
151 #endif
153 #define __unused __attribute__((__unused__))
154 #define __visible __attribute__((visibility("default")))
156 #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
157 #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
158 #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
159 #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
161 /* should come from c-tree.h if only it were installed for gcc 4.5... */
162 #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
164 static inline tree build_const_char_string(int len, const char *str)
166 tree cstr, elem, index, type;
168 cstr = build_string(len, str);
169 elem = build_type_variant(char_type_node, 1, 0);
170 index = build_index_type(size_int(len - 1));
171 type = build_array_type(elem, index);
172 TREE_TYPE(cstr) = type;
173 TREE_CONSTANT(cstr) = 1;
174 TREE_READONLY(cstr) = 1;
175 TREE_STATIC(cstr) = 1;
176 return cstr;
179 #define PASS_INFO(NAME, REF, ID, POS) \
180 struct register_pass_info NAME##_pass_info = { \
181 .pass = make_##NAME##_pass(), \
182 .reference_pass_name = REF, \
183 .ref_pass_instance_number = ID, \
184 .pos_op = POS, \
187 #if BUILDING_GCC_VERSION == 4005
188 #define FOR_EACH_LOCAL_DECL(FUN, I, D) \
189 for (tree vars = (FUN)->local_decls, (I) = 0; \
190 vars && ((D) = TREE_VALUE(vars)); \
191 vars = TREE_CHAIN(vars), (I)++)
192 #define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
193 #define FOR_EACH_VEC_ELT(T, V, I, P) \
194 for (I = 0; VEC_iterate(T, (V), (I), (P)); ++(I))
195 #define TODO_rebuild_cgraph_edges 0
196 #define SCOPE_FILE_SCOPE_P(EXP) (!(EXP))
198 #ifndef O_BINARY
199 #define O_BINARY 0
200 #endif
202 typedef struct varpool_node *varpool_node_ptr;
204 static inline bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
206 tree fndecl;
208 if (!is_gimple_call(stmt))
209 return false;
210 fndecl = gimple_call_fndecl(stmt);
211 if (!fndecl || DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
212 return false;
213 return DECL_FUNCTION_CODE(fndecl) == code;
216 static inline bool is_simple_builtin(tree decl)
218 if (decl && DECL_BUILT_IN_CLASS(decl) != BUILT_IN_NORMAL)
219 return false;
221 switch (DECL_FUNCTION_CODE(decl)) {
222 /* Builtins that expand to constants. */
223 case BUILT_IN_CONSTANT_P:
224 case BUILT_IN_EXPECT:
225 case BUILT_IN_OBJECT_SIZE:
226 case BUILT_IN_UNREACHABLE:
227 /* Simple register moves or loads from stack. */
228 case BUILT_IN_RETURN_ADDRESS:
229 case BUILT_IN_EXTRACT_RETURN_ADDR:
230 case BUILT_IN_FROB_RETURN_ADDR:
231 case BUILT_IN_RETURN:
232 case BUILT_IN_AGGREGATE_INCOMING_ADDRESS:
233 case BUILT_IN_FRAME_ADDRESS:
234 case BUILT_IN_VA_END:
235 case BUILT_IN_STACK_SAVE:
236 case BUILT_IN_STACK_RESTORE:
237 /* Exception state returns or moves registers around. */
238 case BUILT_IN_EH_FILTER:
239 case BUILT_IN_EH_POINTER:
240 case BUILT_IN_EH_COPY_VALUES:
241 return true;
243 default:
244 return false;
248 static inline void add_local_decl(struct function *fun, tree d)
250 gcc_assert(TREE_CODE(d) == VAR_DECL);
251 fun->local_decls = tree_cons(NULL_TREE, d, fun->local_decls);
253 #endif
255 #if BUILDING_GCC_VERSION <= 4006
256 #define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
257 #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4(EXP)
258 #define EDGE_PRESERVE 0ULL
259 #define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x"
260 #define flag_fat_lto_objects true
262 #define get_random_seed(noinit) ({ \
263 unsigned HOST_WIDE_INT seed; \
264 sscanf(get_random_seed(noinit), "%" HOST_WIDE_INT_PRINT "x", &seed); \
265 seed * seed; })
267 #define int_const_binop(code, arg1, arg2) \
268 int_const_binop((code), (arg1), (arg2), 0)
270 static inline bool gimple_clobber_p(gimple s __unused)
272 return false;
275 static inline bool gimple_asm_clobbers_memory_p(const_gimple stmt)
277 unsigned i;
279 for (i = 0; i < gimple_asm_nclobbers(stmt); i++) {
280 tree op = gimple_asm_clobber_op(stmt, i);
282 if (!strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "memory"))
283 return true;
286 return false;
289 static inline tree builtin_decl_implicit(enum built_in_function fncode)
291 return implicit_built_in_decls[fncode];
294 static inline int ipa_reverse_postorder(struct cgraph_node **order)
296 return cgraph_postorder(order);
299 static inline struct cgraph_node *cgraph_create_node(tree decl)
301 return cgraph_node(decl);
304 static inline struct cgraph_node *cgraph_get_create_node(tree decl)
306 struct cgraph_node *node = cgraph_get_node(decl);
308 return node ? node : cgraph_node(decl);
311 static inline bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
313 return node->analyzed && !node->thunk.thunk_p && !node->alias;
316 static inline struct cgraph_node *cgraph_first_function_with_gimple_body(void)
318 struct cgraph_node *node;
320 for (node = cgraph_nodes; node; node = node->next)
321 if (cgraph_function_with_gimple_body_p(node))
322 return node;
323 return NULL;
326 static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
328 for (node = node->next; node; node = node->next)
329 if (cgraph_function_with_gimple_body_p(node))
330 return node;
331 return NULL;
334 static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
336 cgraph_node_ptr alias;
338 if (callback(node, data))
339 return true;
341 for (alias = node->same_body; alias; alias = alias->next) {
342 if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE)
343 if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable))
344 return true;
347 return false;
350 #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
351 for ((node) = cgraph_first_function_with_gimple_body(); (node); \
352 (node) = cgraph_next_function_with_gimple_body(node))
354 static inline void varpool_add_new_variable(tree decl)
356 varpool_finalize_decl(decl);
358 #endif
360 #if BUILDING_GCC_VERSION <= 4007
361 #define FOR_EACH_FUNCTION(node) \
362 for (node = cgraph_nodes; node; node = node->next)
363 #define FOR_EACH_VARIABLE(node) \
364 for (node = varpool_nodes; node; node = node->next)
365 #define PROP_loops 0
366 #define NODE_SYMBOL(node) (node)
367 #define NODE_DECL(node) (node)->decl
368 #define INSN_LOCATION(INSN) RTL_LOCATION(INSN)
369 #define vNULL NULL
371 static inline int bb_loop_depth(const_basic_block bb)
373 return bb->loop_father ? loop_depth(bb->loop_father) : 0;
376 static inline bool gimple_store_p(gimple gs)
378 tree lhs = gimple_get_lhs(gs);
380 return lhs && !is_gimple_reg(lhs);
383 static inline void gimple_init_singleton(gimple g __unused)
386 #endif
388 #if BUILDING_GCC_VERSION == 4007 || BUILDING_GCC_VERSION == 4008
389 static inline struct cgraph_node *cgraph_alias_target(struct cgraph_node *n)
391 return cgraph_alias_aliased_node(n);
393 #endif
395 #if BUILDING_GCC_VERSION <= 4008
396 #define ENTRY_BLOCK_PTR_FOR_FN(FN) ENTRY_BLOCK_PTR_FOR_FUNCTION(FN)
397 #define EXIT_BLOCK_PTR_FOR_FN(FN) EXIT_BLOCK_PTR_FOR_FUNCTION(FN)
398 #define basic_block_info_for_fn(FN) ((FN)->cfg->x_basic_block_info)
399 #define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks)
400 #define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges)
401 #define last_basic_block_for_fn(FN) ((FN)->cfg->x_last_basic_block)
402 #define label_to_block_map_for_fn(FN) ((FN)->cfg->x_label_to_block_map)
403 #define profile_status_for_fn(FN) ((FN)->cfg->x_profile_status)
404 #define BASIC_BLOCK_FOR_FN(FN, N) BASIC_BLOCK_FOR_FUNCTION((FN), (N))
405 #define NODE_IMPLICIT_ALIAS(node) (node)->same_body_alias
406 #define VAR_P(NODE) (TREE_CODE(NODE) == VAR_DECL)
408 static inline bool tree_fits_shwi_p(const_tree t)
410 if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
411 return false;
413 if (TREE_INT_CST_HIGH(t) == 0 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) >= 0)
414 return true;
416 if (TREE_INT_CST_HIGH(t) == -1 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) < 0 && !TYPE_UNSIGNED(TREE_TYPE(t)))
417 return true;
419 return false;
422 static inline bool tree_fits_uhwi_p(const_tree t)
424 if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
425 return false;
427 return TREE_INT_CST_HIGH(t) == 0;
430 static inline HOST_WIDE_INT tree_to_shwi(const_tree t)
432 gcc_assert(tree_fits_shwi_p(t));
433 return TREE_INT_CST_LOW(t);
436 static inline unsigned HOST_WIDE_INT tree_to_uhwi(const_tree t)
438 gcc_assert(tree_fits_uhwi_p(t));
439 return TREE_INT_CST_LOW(t);
442 static inline const char *get_tree_code_name(enum tree_code code)
444 gcc_assert(code < MAX_TREE_CODES);
445 return tree_code_name[code];
448 #define ipa_remove_stmt_references(cnode, stmt)
450 typedef union gimple_statement_d gasm;
451 typedef union gimple_statement_d gassign;
452 typedef union gimple_statement_d gcall;
453 typedef union gimple_statement_d gcond;
454 typedef union gimple_statement_d gdebug;
455 typedef union gimple_statement_d ggoto;
456 typedef union gimple_statement_d gphi;
457 typedef union gimple_statement_d greturn;
459 static inline gasm *as_a_gasm(gimple stmt)
461 return stmt;
464 static inline const gasm *as_a_const_gasm(const_gimple stmt)
466 return stmt;
469 static inline gassign *as_a_gassign(gimple stmt)
471 return stmt;
474 static inline const gassign *as_a_const_gassign(const_gimple stmt)
476 return stmt;
479 static inline gcall *as_a_gcall(gimple stmt)
481 return stmt;
484 static inline const gcall *as_a_const_gcall(const_gimple stmt)
486 return stmt;
489 static inline gcond *as_a_gcond(gimple stmt)
491 return stmt;
494 static inline const gcond *as_a_const_gcond(const_gimple stmt)
496 return stmt;
499 static inline gdebug *as_a_gdebug(gimple stmt)
501 return stmt;
504 static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
506 return stmt;
509 static inline ggoto *as_a_ggoto(gimple stmt)
511 return stmt;
514 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
516 return stmt;
519 static inline gphi *as_a_gphi(gimple stmt)
521 return stmt;
524 static inline const gphi *as_a_const_gphi(const_gimple stmt)
526 return stmt;
529 static inline greturn *as_a_greturn(gimple stmt)
531 return stmt;
534 static inline const greturn *as_a_const_greturn(const_gimple stmt)
536 return stmt;
538 #endif
540 #if BUILDING_GCC_VERSION == 4008
541 #define NODE_SYMBOL(node) (&(node)->symbol)
542 #define NODE_DECL(node) (node)->symbol.decl
543 #endif
545 #if BUILDING_GCC_VERSION >= 4008
546 #define add_referenced_var(var)
547 #define mark_sym_for_renaming(var)
548 #define varpool_mark_needed_node(node)
549 #define create_var_ann(var)
550 #define TODO_dump_func 0
551 #define TODO_dump_cgraph 0
552 #endif
554 #if BUILDING_GCC_VERSION <= 4009
555 #define TODO_verify_il 0
556 #define AVAIL_INTERPOSABLE AVAIL_OVERWRITABLE
558 #define section_name_prefix LTO_SECTION_NAME_PREFIX
559 #define fatal_error(loc, gmsgid, ...) fatal_error((gmsgid), __VA_ARGS__)
561 rtx emit_move_insn(rtx x, rtx y);
563 typedef struct rtx_def rtx_insn;
565 static inline const char *get_decl_section_name(const_tree decl)
567 if (DECL_SECTION_NAME(decl) == NULL_TREE)
568 return NULL;
570 return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
573 static inline void set_decl_section_name(tree node, const char *value)
575 if (value)
576 DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value);
577 else
578 DECL_SECTION_NAME(node) = NULL;
580 #endif
582 #if BUILDING_GCC_VERSION == 4009
583 typedef struct gimple_statement_asm gasm;
584 typedef struct gimple_statement_base gassign;
585 typedef struct gimple_statement_call gcall;
586 typedef struct gimple_statement_base gcond;
587 typedef struct gimple_statement_base gdebug;
588 typedef struct gimple_statement_base ggoto;
589 typedef struct gimple_statement_phi gphi;
590 typedef struct gimple_statement_base greturn;
592 static inline gasm *as_a_gasm(gimple stmt)
594 return as_a<gasm>(stmt);
597 static inline const gasm *as_a_const_gasm(const_gimple stmt)
599 return as_a<const gasm>(stmt);
602 static inline gassign *as_a_gassign(gimple stmt)
604 return stmt;
607 static inline const gassign *as_a_const_gassign(const_gimple stmt)
609 return stmt;
612 static inline gcall *as_a_gcall(gimple stmt)
614 return as_a<gcall>(stmt);
617 static inline const gcall *as_a_const_gcall(const_gimple stmt)
619 return as_a<const gcall>(stmt);
622 static inline gcond *as_a_gcond(gimple stmt)
624 return stmt;
627 static inline const gcond *as_a_const_gcond(const_gimple stmt)
629 return stmt;
632 static inline gdebug *as_a_gdebug(gimple stmt)
634 return stmt;
637 static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
639 return stmt;
642 static inline ggoto *as_a_ggoto(gimple stmt)
644 return stmt;
647 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
649 return stmt;
652 static inline gphi *as_a_gphi(gimple stmt)
654 return as_a<gphi>(stmt);
657 static inline const gphi *as_a_const_gphi(const_gimple stmt)
659 return as_a<const gphi>(stmt);
662 static inline greturn *as_a_greturn(gimple stmt)
664 return stmt;
667 static inline const greturn *as_a_const_greturn(const_gimple stmt)
669 return stmt;
671 #endif
673 #if BUILDING_GCC_VERSION >= 4009
674 #define TODO_ggc_collect 0
675 #define NODE_SYMBOL(node) (node)
676 #define NODE_DECL(node) (node)->decl
677 #define cgraph_node_name(node) (node)->name()
678 #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
680 static inline opt_pass *get_pass_for_id(int id)
682 return g->get_passes()->get_pass_for_id(id);
684 #endif
686 #if BUILDING_GCC_VERSION >= 5000 && BUILDING_GCC_VERSION < 6000
687 /* gimple related */
688 template <>
689 template <>
690 inline bool is_a_helper<const gassign *>::test(const_gimple gs)
692 return gs->code == GIMPLE_ASSIGN;
694 #endif
696 #if BUILDING_GCC_VERSION >= 5000
697 #define TODO_verify_ssa TODO_verify_il
698 #define TODO_verify_flow TODO_verify_il
699 #define TODO_verify_stmts TODO_verify_il
700 #define TODO_verify_rtl_sharing TODO_verify_il
702 #define INSN_DELETED_P(insn) (insn)->deleted()
704 static inline const char *get_decl_section_name(const_tree decl)
706 return DECL_SECTION_NAME(decl);
709 /* symtab/cgraph related */
710 #define debug_cgraph_node(node) (node)->debug()
711 #define cgraph_get_node(decl) cgraph_node::get(decl)
712 #define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
713 #define cgraph_create_node(decl) cgraph_node::create(decl)
714 #define cgraph_n_nodes symtab->cgraph_count
715 #define cgraph_max_uid symtab->cgraph_max_uid
716 #define varpool_get_node(decl) varpool_node::get(decl)
717 #define dump_varpool_node(file, node) (node)->dump(file)
719 #if BUILDING_GCC_VERSION >= 8000
720 #define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
721 (caller)->create_edge((callee), (call_stmt), (count))
723 #define cgraph_create_edge_including_clones(caller, callee, \
724 old_call_stmt, call_stmt, count, freq, reason) \
725 (caller)->create_edge_including_clones((callee), \
726 (old_call_stmt), (call_stmt), (count), (reason))
727 #else
728 #define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
729 (caller)->create_edge((callee), (call_stmt), (count), (freq))
731 #define cgraph_create_edge_including_clones(caller, callee, \
732 old_call_stmt, call_stmt, count, freq, reason) \
733 (caller)->create_edge_including_clones((callee), \
734 (old_call_stmt), (call_stmt), (count), (freq), (reason))
735 #endif
737 typedef struct cgraph_node *cgraph_node_ptr;
738 typedef struct cgraph_edge *cgraph_edge_p;
739 typedef struct varpool_node *varpool_node_ptr;
741 static inline void change_decl_assembler_name(tree decl, tree name)
743 symtab->change_decl_assembler_name(decl, name);
746 static inline void varpool_finalize_decl(tree decl)
748 varpool_node::finalize_decl(decl);
751 static inline void varpool_add_new_variable(tree decl)
753 varpool_node::add(decl);
756 static inline unsigned int rebuild_cgraph_edges(void)
758 return cgraph_edge::rebuild_edges();
761 static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
763 return node->function_symbol(availability);
766 static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
768 return node->ultimate_alias_target(availability);
771 static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
773 return node->only_called_directly_p();
776 static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
778 return node->get_availability();
781 static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
783 return node->get_alias_target();
786 static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
788 return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
791 static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
793 return symtab->add_cgraph_insertion_hook(hook, data);
796 static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
798 symtab->remove_cgraph_insertion_hook(entry);
801 static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
803 return symtab->add_cgraph_removal_hook(hook, data);
806 static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
808 symtab->remove_cgraph_removal_hook(entry);
811 static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
813 return symtab->add_cgraph_duplication_hook(hook, data);
816 static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
818 symtab->remove_cgraph_duplication_hook(entry);
821 static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
823 symtab->call_cgraph_duplication_hooks(node, node2);
826 static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
828 symtab->call_edge_duplication_hooks(cs1, cs2);
831 #if BUILDING_GCC_VERSION >= 6000
832 typedef gimple *gimple_ptr;
833 typedef const gimple *const_gimple_ptr;
834 #define gimple gimple_ptr
835 #define const_gimple const_gimple_ptr
836 #undef CONST_CAST_GIMPLE
837 #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X))
838 #endif
840 /* gimple related */
841 static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
843 return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
846 template <>
847 template <>
848 inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
850 return gs->code == GIMPLE_GOTO;
853 template <>
854 template <>
855 inline bool is_a_helper<const greturn *>::test(const_gimple gs)
857 return gs->code == GIMPLE_RETURN;
860 static inline gasm *as_a_gasm(gimple stmt)
862 return as_a<gasm *>(stmt);
865 static inline const gasm *as_a_const_gasm(const_gimple stmt)
867 return as_a<const gasm *>(stmt);
870 static inline gassign *as_a_gassign(gimple stmt)
872 return as_a<gassign *>(stmt);
875 static inline const gassign *as_a_const_gassign(const_gimple stmt)
877 return as_a<const gassign *>(stmt);
880 static inline gcall *as_a_gcall(gimple stmt)
882 return as_a<gcall *>(stmt);
885 static inline const gcall *as_a_const_gcall(const_gimple stmt)
887 return as_a<const gcall *>(stmt);
890 static inline ggoto *as_a_ggoto(gimple stmt)
892 return as_a<ggoto *>(stmt);
895 static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
897 return as_a<const ggoto *>(stmt);
900 static inline gphi *as_a_gphi(gimple stmt)
902 return as_a<gphi *>(stmt);
905 static inline const gphi *as_a_const_gphi(const_gimple stmt)
907 return as_a<const gphi *>(stmt);
910 static inline greturn *as_a_greturn(gimple stmt)
912 return as_a<greturn *>(stmt);
915 static inline const greturn *as_a_const_greturn(const_gimple stmt)
917 return as_a<const greturn *>(stmt);
920 /* IPA/LTO related */
921 #define ipa_ref_list_referring_iterate(L, I, P) \
922 (L)->referring.iterate((I), &(P))
923 #define ipa_ref_list_reference_iterate(L, I, P) \
924 (L)->reference.iterate((I), &(P))
926 static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
928 return dyn_cast<cgraph_node_ptr>(ref->referring);
931 static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
933 referring_node->remove_stmt_references(stmt);
935 #endif
937 #if BUILDING_GCC_VERSION < 6000
938 #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
939 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning)
940 #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1))
941 #endif
943 #if BUILDING_GCC_VERSION >= 6000
944 #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
945 #endif
947 #ifdef __cplusplus
948 static inline void debug_tree(const_tree t)
950 debug_tree(CONST_CAST_TREE(t));
953 static inline void debug_gimple_stmt(const_gimple s)
955 debug_gimple_stmt(CONST_CAST_GIMPLE(s));
957 #else
958 #define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
959 #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
960 #endif
962 #if BUILDING_GCC_VERSION >= 7000
963 #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
964 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
965 #endif
967 #if BUILDING_GCC_VERSION < 7000
968 #define SET_DECL_ALIGN(decl, align) DECL_ALIGN(decl) = (align)
969 #define SET_DECL_MODE(decl, mode) DECL_MODE(decl) = (mode)
970 #endif
972 #endif