Linux Audio

Check our new training course

Loading...
v4.17
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef GCC_COMMON_H_INCLUDED
  3#define GCC_COMMON_H_INCLUDED
  4
  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"
 19
 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"
 37
 
 38#include "params.h"
 
 39
 40#if BUILDING_GCC_VERSION <= 4009
 41#include "pointer-set.h"
 42#else
 43#include "hash-map.h"
 44#endif
 45
 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"
 56
 57#if BUILDING_GCC_VERSION == 4005
 58#include <sys/mman.h>
 59#endif
 60
 61#if BUILDING_GCC_VERSION >= 4007
 62#include "tree-pretty-print.h"
 63#include "gimple-pretty-print.h"
 64#endif
 65
 66#if BUILDING_GCC_VERSION >= 4006
 67/*
 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/
 73 */
 74#include "c-family/c-common.h"
 75#else
 76#include "c-common.h"
 77#endif
 78
 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
 86
 87#if BUILDING_GCC_VERSION >= 4008
 88#include "is-a.h"
 89#endif
 90
 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"
 99
100#if BUILDING_GCC_VERSION >= 8000
101#include "stringpool.h"
102#endif
103
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
124
125#include "gimple.h"
126
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
135
136#if BUILDING_GCC_VERSION >= 5000
137#include "builtins.h"
138#endif
139
140/* missing from basic_block.h... */
141void debug_dominance_info(enum cdi_direction dir);
142void debug_dominance_tree(enum cdi_direction dir, basic_block root);
143
144#if BUILDING_GCC_VERSION == 4006
145void debug_gimple_stmt(gimple);
146void debug_gimple_seq(gimple_seq);
147void print_gimple_seq(FILE *, gimple_seq, int, int);
148void print_gimple_stmt(FILE *, gimple, int, int);
149void print_gimple_expr(FILE *, gimple, int, int);
150void dump_gimple_stmt(pretty_printer *, gimple, int, int);
151#endif
152
153#define __unused __attribute__((__unused__))
 
 
154#define __visible __attribute__((visibility("default")))
 
155
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))
160
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)
163
164static inline tree build_const_char_string(int len, const char *str)
165{
166	tree cstr, elem, index, type;
167
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;
177}
178
179#define PASS_INFO(NAME, REF, ID, POS)		\
180struct 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,				\
185}
186
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))
197
198#ifndef O_BINARY
199#define O_BINARY 0
200#endif
201
202typedef struct varpool_node *varpool_node_ptr;
203
204static inline bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
205{
206	tree fndecl;
207
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;
214}
215
216static inline bool is_simple_builtin(tree decl)
217{
218	if (decl && DECL_BUILT_IN_CLASS(decl) != BUILT_IN_NORMAL)
219		return false;
220
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;
242
243	default:
244	return false;
245	}
246}
247
248static inline void add_local_decl(struct function *fun, tree d)
249{
250	gcc_assert(TREE_CODE(d) == VAR_DECL);
251	fun->local_decls = tree_cons(NULL_TREE, d, fun->local_decls);
252}
253#endif
254
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
261
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; })
266
267#define int_const_binop(code, arg1, arg2)	\
268	int_const_binop((code), (arg1), (arg2), 0)
269
270static inline bool gimple_clobber_p(gimple s __unused)
271{
272	return false;
273}
274
275static inline bool gimple_asm_clobbers_memory_p(const_gimple stmt)
276{
277	unsigned i;
278
279	for (i = 0; i < gimple_asm_nclobbers(stmt); i++) {
280		tree op = gimple_asm_clobber_op(stmt, i);
281
282		if (!strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "memory"))
283			return true;
284	}
285
286	return false;
287}
288
289static inline tree builtin_decl_implicit(enum built_in_function fncode)
290{
291	return implicit_built_in_decls[fncode];
292}
293
294static inline int ipa_reverse_postorder(struct cgraph_node **order)
295{
296	return cgraph_postorder(order);
297}
298
299static inline struct cgraph_node *cgraph_create_node(tree decl)
300{
301	return cgraph_node(decl);
302}
303
304static inline struct cgraph_node *cgraph_get_create_node(tree decl)
305{
306	struct cgraph_node *node = cgraph_get_node(decl);
307
308	return node ? node : cgraph_node(decl);
309}
310
311static inline bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
312{
313	return node->analyzed && !node->thunk.thunk_p && !node->alias;
314}
315
316static inline struct cgraph_node *cgraph_first_function_with_gimple_body(void)
317{
318	struct cgraph_node *node;
319
320	for (node = cgraph_nodes; node; node = node->next)
321		if (cgraph_function_with_gimple_body_p(node))
322			return node;
323	return NULL;
324}
325
326static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
327{
328	for (node = node->next; node; node = node->next)
329		if (cgraph_function_with_gimple_body_p(node))
330			return node;
331	return NULL;
332}
333
334static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
335{
336	cgraph_node_ptr alias;
337
338	if (callback(node, data))
339		return true;
340
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;
345	}
346
347	return false;
348}
349
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))
353
354static inline void varpool_add_new_variable(tree decl)
355{
356	varpool_finalize_decl(decl);
357}
358#endif
359
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
370
371static inline int bb_loop_depth(const_basic_block bb)
372{
373	return bb->loop_father ? loop_depth(bb->loop_father) : 0;
374}
375
376static inline bool gimple_store_p(gimple gs)
377{
378	tree lhs = gimple_get_lhs(gs);
379
380	return lhs && !is_gimple_reg(lhs);
381}
382
383static inline void gimple_init_singleton(gimple g __unused)
384{
385}
386#endif
387
388#if BUILDING_GCC_VERSION == 4007 || BUILDING_GCC_VERSION == 4008
389static inline struct cgraph_node *cgraph_alias_target(struct cgraph_node *n)
390{
391	return cgraph_alias_aliased_node(n);
392}
393#endif
394
395#if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION <= 4009
396#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
397	cgraph_create_edge((caller), (callee), (call_stmt), (count), (freq))
398#define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
399	cgraph_create_edge_including_clones((caller), (callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
400#endif
401
402#if BUILDING_GCC_VERSION <= 4008
403#define ENTRY_BLOCK_PTR_FOR_FN(FN)	ENTRY_BLOCK_PTR_FOR_FUNCTION(FN)
404#define EXIT_BLOCK_PTR_FOR_FN(FN)	EXIT_BLOCK_PTR_FOR_FUNCTION(FN)
405#define basic_block_info_for_fn(FN)	((FN)->cfg->x_basic_block_info)
406#define n_basic_blocks_for_fn(FN)	((FN)->cfg->x_n_basic_blocks)
407#define n_edges_for_fn(FN)		((FN)->cfg->x_n_edges)
408#define last_basic_block_for_fn(FN)	((FN)->cfg->x_last_basic_block)
409#define label_to_block_map_for_fn(FN)	((FN)->cfg->x_label_to_block_map)
410#define profile_status_for_fn(FN)	((FN)->cfg->x_profile_status)
411#define BASIC_BLOCK_FOR_FN(FN, N)	BASIC_BLOCK_FOR_FUNCTION((FN), (N))
412#define NODE_IMPLICIT_ALIAS(node)	(node)->same_body_alias
413#define VAR_P(NODE)			(TREE_CODE(NODE) == VAR_DECL)
414
415static inline bool tree_fits_shwi_p(const_tree t)
416{
417	if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
418		return false;
419
420	if (TREE_INT_CST_HIGH(t) == 0 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) >= 0)
421		return true;
422
423	if (TREE_INT_CST_HIGH(t) == -1 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) < 0 && !TYPE_UNSIGNED(TREE_TYPE(t)))
424		return true;
425
426	return false;
427}
428
429static inline bool tree_fits_uhwi_p(const_tree t)
430{
431	if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
432		return false;
433
434	return TREE_INT_CST_HIGH(t) == 0;
435}
436
437static inline HOST_WIDE_INT tree_to_shwi(const_tree t)
438{
439	gcc_assert(tree_fits_shwi_p(t));
440	return TREE_INT_CST_LOW(t);
441}
442
443static inline unsigned HOST_WIDE_INT tree_to_uhwi(const_tree t)
444{
445	gcc_assert(tree_fits_uhwi_p(t));
446	return TREE_INT_CST_LOW(t);
447}
448
449static inline const char *get_tree_code_name(enum tree_code code)
450{
451	gcc_assert(code < MAX_TREE_CODES);
452	return tree_code_name[code];
453}
454
455#define ipa_remove_stmt_references(cnode, stmt)
456
457typedef union gimple_statement_d gasm;
458typedef union gimple_statement_d gassign;
459typedef union gimple_statement_d gcall;
460typedef union gimple_statement_d gcond;
461typedef union gimple_statement_d gdebug;
462typedef union gimple_statement_d ggoto;
463typedef union gimple_statement_d gphi;
464typedef union gimple_statement_d greturn;
465
466static inline gasm *as_a_gasm(gimple stmt)
467{
468	return stmt;
469}
470
471static inline const gasm *as_a_const_gasm(const_gimple stmt)
472{
473	return stmt;
474}
475
476static inline gassign *as_a_gassign(gimple stmt)
477{
478	return stmt;
479}
480
481static inline const gassign *as_a_const_gassign(const_gimple stmt)
482{
483	return stmt;
484}
485
486static inline gcall *as_a_gcall(gimple stmt)
487{
488	return stmt;
489}
490
491static inline const gcall *as_a_const_gcall(const_gimple stmt)
492{
493	return stmt;
494}
495
496static inline gcond *as_a_gcond(gimple stmt)
497{
498	return stmt;
499}
500
501static inline const gcond *as_a_const_gcond(const_gimple stmt)
502{
503	return stmt;
504}
505
506static inline gdebug *as_a_gdebug(gimple stmt)
507{
508	return stmt;
509}
510
511static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
512{
513	return stmt;
514}
515
516static inline ggoto *as_a_ggoto(gimple stmt)
517{
518	return stmt;
519}
520
521static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
522{
523	return stmt;
524}
525
526static inline gphi *as_a_gphi(gimple stmt)
527{
528	return stmt;
529}
530
531static inline const gphi *as_a_const_gphi(const_gimple stmt)
532{
533	return stmt;
534}
535
536static inline greturn *as_a_greturn(gimple stmt)
537{
538	return stmt;
539}
540
541static inline const greturn *as_a_const_greturn(const_gimple stmt)
542{
543	return stmt;
544}
545#endif
546
547#if BUILDING_GCC_VERSION == 4008
548#define NODE_SYMBOL(node) (&(node)->symbol)
549#define NODE_DECL(node) (node)->symbol.decl
550#endif
551
552#if BUILDING_GCC_VERSION >= 4008
553#define add_referenced_var(var)
554#define mark_sym_for_renaming(var)
555#define varpool_mark_needed_node(node)
556#define create_var_ann(var)
557#define TODO_dump_func 0
558#define TODO_dump_cgraph 0
559#endif
560
561#if BUILDING_GCC_VERSION <= 4009
562#define TODO_verify_il 0
563#define AVAIL_INTERPOSABLE AVAIL_OVERWRITABLE
564
565#define section_name_prefix LTO_SECTION_NAME_PREFIX
566#define fatal_error(loc, gmsgid, ...) fatal_error((gmsgid), __VA_ARGS__)
567
568rtx emit_move_insn(rtx x, rtx y);
569
570typedef struct rtx_def rtx_insn;
571
572static inline const char *get_decl_section_name(const_tree decl)
573{
574	if (DECL_SECTION_NAME(decl) == NULL_TREE)
575		return NULL;
576
577	return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
578}
579
580static inline void set_decl_section_name(tree node, const char *value)
581{
582	if (value)
583		DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value);
584	else
585		DECL_SECTION_NAME(node) = NULL;
586}
587#endif
588
589#if BUILDING_GCC_VERSION == 4009
590typedef struct gimple_statement_asm gasm;
591typedef struct gimple_statement_base gassign;
592typedef struct gimple_statement_call gcall;
593typedef struct gimple_statement_base gcond;
594typedef struct gimple_statement_base gdebug;
595typedef struct gimple_statement_base ggoto;
596typedef struct gimple_statement_phi gphi;
597typedef struct gimple_statement_base greturn;
598
599static inline gasm *as_a_gasm(gimple stmt)
600{
601	return as_a<gasm>(stmt);
602}
603
604static inline const gasm *as_a_const_gasm(const_gimple stmt)
605{
606	return as_a<const gasm>(stmt);
607}
608
609static inline gassign *as_a_gassign(gimple stmt)
610{
611	return stmt;
612}
613
614static inline const gassign *as_a_const_gassign(const_gimple stmt)
615{
616	return stmt;
617}
618
619static inline gcall *as_a_gcall(gimple stmt)
620{
621	return as_a<gcall>(stmt);
622}
623
624static inline const gcall *as_a_const_gcall(const_gimple stmt)
625{
626	return as_a<const gcall>(stmt);
627}
628
629static inline gcond *as_a_gcond(gimple stmt)
630{
631	return stmt;
632}
633
634static inline const gcond *as_a_const_gcond(const_gimple stmt)
635{
636	return stmt;
637}
638
639static inline gdebug *as_a_gdebug(gimple stmt)
640{
641	return stmt;
642}
643
644static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
645{
646	return stmt;
647}
648
649static inline ggoto *as_a_ggoto(gimple stmt)
650{
651	return stmt;
652}
653
654static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
655{
656	return stmt;
657}
658
659static inline gphi *as_a_gphi(gimple stmt)
660{
661	return as_a<gphi>(stmt);
662}
663
664static inline const gphi *as_a_const_gphi(const_gimple stmt)
665{
666	return as_a<const gphi>(stmt);
667}
668
669static inline greturn *as_a_greturn(gimple stmt)
670{
671	return stmt;
672}
673
674static inline const greturn *as_a_const_greturn(const_gimple stmt)
675{
676	return stmt;
677}
678#endif
679
680#if BUILDING_GCC_VERSION >= 4009
681#define TODO_ggc_collect 0
682#define NODE_SYMBOL(node) (node)
683#define NODE_DECL(node) (node)->decl
684#define cgraph_node_name(node) (node)->name()
685#define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
686
687static inline opt_pass *get_pass_for_id(int id)
688{
689	return g->get_passes()->get_pass_for_id(id);
690}
691#endif
692
693#if BUILDING_GCC_VERSION >= 5000 && BUILDING_GCC_VERSION < 6000
694/* gimple related */
695template <>
696template <>
697inline bool is_a_helper<const gassign *>::test(const_gimple gs)
698{
699	return gs->code == GIMPLE_ASSIGN;
700}
701#endif
702
703#if BUILDING_GCC_VERSION >= 5000
704#define TODO_verify_ssa TODO_verify_il
705#define TODO_verify_flow TODO_verify_il
706#define TODO_verify_stmts TODO_verify_il
707#define TODO_verify_rtl_sharing TODO_verify_il
708
709#define INSN_DELETED_P(insn) (insn)->deleted()
710
711static inline const char *get_decl_section_name(const_tree decl)
712{
713	return DECL_SECTION_NAME(decl);
714}
715
716/* symtab/cgraph related */
717#define debug_cgraph_node(node) (node)->debug()
718#define cgraph_get_node(decl) cgraph_node::get(decl)
719#define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
720#define cgraph_create_node(decl) cgraph_node::create(decl)
721#define cgraph_n_nodes symtab->cgraph_count
722#define cgraph_max_uid symtab->cgraph_max_uid
723#define varpool_get_node(decl) varpool_node::get(decl)
724#define dump_varpool_node(file, node) (node)->dump(file)
725
726#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
 
 
 
 
 
 
 
 
 
727	(caller)->create_edge((callee), (call_stmt), (count), (freq))
728#define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
729	(caller)->create_edge_including_clones((callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
 
 
 
 
730
731typedef struct cgraph_node *cgraph_node_ptr;
732typedef struct cgraph_edge *cgraph_edge_p;
733typedef struct varpool_node *varpool_node_ptr;
734
735static inline void change_decl_assembler_name(tree decl, tree name)
736{
737	symtab->change_decl_assembler_name(decl, name);
738}
739
740static inline void varpool_finalize_decl(tree decl)
741{
742	varpool_node::finalize_decl(decl);
743}
744
745static inline void varpool_add_new_variable(tree decl)
746{
747	varpool_node::add(decl);
748}
749
750static inline unsigned int rebuild_cgraph_edges(void)
751{
752	return cgraph_edge::rebuild_edges();
753}
754
755static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
756{
757	return node->function_symbol(availability);
758}
759
760static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
761{
762	return node->ultimate_alias_target(availability);
763}
764
765static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
766{
767	return node->only_called_directly_p();
768}
769
770static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
771{
772	return node->get_availability();
773}
774
775static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
776{
777	return node->get_alias_target();
778}
779
780static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
781{
782	return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
783}
784
785static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
786{
787	return symtab->add_cgraph_insertion_hook(hook, data);
788}
789
790static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
791{
792	symtab->remove_cgraph_insertion_hook(entry);
793}
794
795static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
796{
797	return symtab->add_cgraph_removal_hook(hook, data);
798}
799
800static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
801{
802	symtab->remove_cgraph_removal_hook(entry);
803}
804
805static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
806{
807	return symtab->add_cgraph_duplication_hook(hook, data);
808}
809
810static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
811{
812	symtab->remove_cgraph_duplication_hook(entry);
813}
814
815static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
816{
817	symtab->call_cgraph_duplication_hooks(node, node2);
818}
819
820static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
821{
822	symtab->call_edge_duplication_hooks(cs1, cs2);
823}
824
825#if BUILDING_GCC_VERSION >= 6000
826typedef gimple *gimple_ptr;
827typedef const gimple *const_gimple_ptr;
828#define gimple gimple_ptr
829#define const_gimple const_gimple_ptr
830#undef CONST_CAST_GIMPLE
831#define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X))
832#endif
833
834/* gimple related */
835static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
836{
837	return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
838}
839
 
840template <>
841template <>
842inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
843{
844	return gs->code == GIMPLE_GOTO;
845}
846
847template <>
848template <>
849inline bool is_a_helper<const greturn *>::test(const_gimple gs)
850{
851	return gs->code == GIMPLE_RETURN;
852}
 
853
854static inline gasm *as_a_gasm(gimple stmt)
855{
856	return as_a<gasm *>(stmt);
857}
858
859static inline const gasm *as_a_const_gasm(const_gimple stmt)
860{
861	return as_a<const gasm *>(stmt);
862}
863
864static inline gassign *as_a_gassign(gimple stmt)
865{
866	return as_a<gassign *>(stmt);
867}
868
869static inline const gassign *as_a_const_gassign(const_gimple stmt)
870{
871	return as_a<const gassign *>(stmt);
872}
873
874static inline gcall *as_a_gcall(gimple stmt)
875{
876	return as_a<gcall *>(stmt);
877}
878
879static inline const gcall *as_a_const_gcall(const_gimple stmt)
880{
881	return as_a<const gcall *>(stmt);
882}
883
884static inline ggoto *as_a_ggoto(gimple stmt)
885{
886	return as_a<ggoto *>(stmt);
887}
888
889static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
890{
891	return as_a<const ggoto *>(stmt);
892}
893
894static inline gphi *as_a_gphi(gimple stmt)
895{
896	return as_a<gphi *>(stmt);
897}
898
899static inline const gphi *as_a_const_gphi(const_gimple stmt)
900{
901	return as_a<const gphi *>(stmt);
902}
903
904static inline greturn *as_a_greturn(gimple stmt)
905{
906	return as_a<greturn *>(stmt);
907}
908
909static inline const greturn *as_a_const_greturn(const_gimple stmt)
910{
911	return as_a<const greturn *>(stmt);
912}
913
914/* IPA/LTO related */
915#define ipa_ref_list_referring_iterate(L, I, P)	\
916	(L)->referring.iterate((I), &(P))
917#define ipa_ref_list_reference_iterate(L, I, P)	\
918	(L)->reference.iterate((I), &(P))
919
920static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
921{
922	return dyn_cast<cgraph_node_ptr>(ref->referring);
923}
924
925static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
926{
927	referring_node->remove_stmt_references(stmt);
928}
929#endif
930
931#if BUILDING_GCC_VERSION < 6000
932#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\
933	get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning)
934#define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1))
935#endif
936
937#if BUILDING_GCC_VERSION >= 6000
938#define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
939#endif
940
941#ifdef __cplusplus
942static inline void debug_tree(const_tree t)
943{
944	debug_tree(CONST_CAST_TREE(t));
945}
946
947static inline void debug_gimple_stmt(const_gimple s)
948{
949	debug_gimple_stmt(CONST_CAST_GIMPLE(s));
950}
951#else
952#define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
953#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
954#endif
955
956#if BUILDING_GCC_VERSION >= 7000
957#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\
958	get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
959#endif
960
961#if BUILDING_GCC_VERSION < 7000
962#define SET_DECL_ALIGN(decl, align)	DECL_ALIGN(decl) = (align)
963#define SET_DECL_MODE(decl, mode)	DECL_MODE(decl) = (mode)
 
 
 
 
964#endif
965
966#endif
v6.8
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef GCC_COMMON_H_INCLUDED
  3#define GCC_COMMON_H_INCLUDED
  4
  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"
 19
 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#include "expr.h"
 
 31#include "basic-block.h"
 32#include "intl.h"
 33#include "ggc.h"
 34#include "timevar.h"
 35
 36#if BUILDING_GCC_VERSION < 10000
 37#include "params.h"
 38#endif
 39
 
 
 
 40#include "hash-map.h"
 
 41
 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"
 
 
 
 
 
 
 52#include "tree-pretty-print.h"
 53#include "gimple-pretty-print.h"
 
 
 
 
 
 
 
 
 
 
 54#include "c-family/c-common.h"
 
 
 
 
 
 
 
 55#include "tree-cfgcleanup.h"
 56#include "tree-ssa-operands.h"
 57#include "tree-into-ssa.h"
 
 
 
 58#include "is-a.h"
 
 
 59#include "diagnostic.h"
 60#include "tree-dump.h"
 61#include "tree-pass.h"
 
 62#include "pass_manager.h"
 
 63#include "predict.h"
 64#include "ipa-utils.h"
 65
 66#if BUILDING_GCC_VERSION >= 8000
 67#include "stringpool.h"
 68#endif
 69
 
 70#include "attribs.h"
 71#include "varasm.h"
 72#include "stor-layout.h"
 73#include "internal-fn.h"
 74#include "gimple.h"
 75#include "gimple-expr.h"
 76#include "gimple-iterator.h"
 77#include "gimple-fold.h"
 78#include "context.h"
 79#include "tree-ssa-alias.h"
 80#include "tree-ssa.h"
 81#include "stringpool.h"
 82#if BUILDING_GCC_VERSION >= 7000
 83#include "tree-vrp.h"
 84#endif
 85#include "tree-ssanames.h"
 86#include "print-tree.h"
 87#include "tree-eh.h"
 88#include "stmt.h"
 89#include "gimplify.h"
 
 
 
 
 
 
 90#include "tree-phinodes.h"
 91#include "tree-cfg.h"
 
 92#include "gimple-ssa.h"
 93#include "ssa-iterators.h"
 
 94
 
 95#include "builtins.h"
 
 96
 97/* missing from basic_block.h... */
 98void debug_dominance_info(enum cdi_direction dir);
 99void debug_dominance_tree(enum cdi_direction dir, basic_block root);
100
101#ifndef __unused
 
 
 
 
 
 
 
 
102#define __unused __attribute__((__unused__))
103#endif
104#ifndef __visible
105#define __visible __attribute__((visibility("default")))
106#endif
107
108#define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
109#define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
110#define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
111#define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
112
113/* should come from c-tree.h if only it were installed for gcc 4.5... */
114#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
115
116static inline tree build_const_char_string(int len, const char *str)
117{
118	tree cstr, elem, index, type;
119
120	cstr = build_string(len, str);
121	elem = build_type_variant(char_type_node, 1, 0);
122	index = build_index_type(size_int(len - 1));
123	type = build_array_type(elem, index);
124	TREE_TYPE(cstr) = type;
125	TREE_CONSTANT(cstr) = 1;
126	TREE_READONLY(cstr) = 1;
127	TREE_STATIC(cstr) = 1;
128	return cstr;
129}
130
131#define PASS_INFO(NAME, REF, ID, POS)		\
132struct register_pass_info NAME##_pass_info = {	\
133	.pass = make_##NAME##_pass(),		\
134	.reference_pass_name = REF,		\
135	.ref_pass_instance_number = ID,		\
136	.pos_op = POS,				\
137}
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139#define add_referenced_var(var)
140#define mark_sym_for_renaming(var)
141#define varpool_mark_needed_node(node)
142#define create_var_ann(var)
143#define TODO_dump_func 0
144#define TODO_dump_cgraph 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146#define TODO_ggc_collect 0
147#define NODE_SYMBOL(node) (node)
148#define NODE_DECL(node) (node)->decl
149#define cgraph_node_name(node) (node)->name()
150#define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
151
152static inline opt_pass *get_pass_for_id(int id)
153{
154	return g->get_passes()->get_pass_for_id(id);
155}
 
156
157#if BUILDING_GCC_VERSION < 6000
158/* gimple related */
159template <>
160template <>
161inline bool is_a_helper<const gassign *>::test(const_gimple gs)
162{
163	return gs->code == GIMPLE_ASSIGN;
164}
165#endif
166
 
167#define TODO_verify_ssa TODO_verify_il
168#define TODO_verify_flow TODO_verify_il
169#define TODO_verify_stmts TODO_verify_il
170#define TODO_verify_rtl_sharing TODO_verify_il
171
172#define INSN_DELETED_P(insn) (insn)->deleted()
173
174static inline const char *get_decl_section_name(const_tree decl)
175{
176	return DECL_SECTION_NAME(decl);
177}
178
179/* symtab/cgraph related */
180#define debug_cgraph_node(node) (node)->debug()
181#define cgraph_get_node(decl) cgraph_node::get(decl)
182#define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
183#define cgraph_create_node(decl) cgraph_node::create(decl)
184#define cgraph_n_nodes symtab->cgraph_count
185#define cgraph_max_uid symtab->cgraph_max_uid
186#define varpool_get_node(decl) varpool_node::get(decl)
187#define dump_varpool_node(file, node) (node)->dump(file)
188
189#if BUILDING_GCC_VERSION >= 8000
190#define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
191	(caller)->create_edge((callee), (call_stmt), (count))
192
193#define cgraph_create_edge_including_clones(caller, callee,	\
194		old_call_stmt, call_stmt, count, freq, reason)	\
195	(caller)->create_edge_including_clones((callee),	\
196		(old_call_stmt), (call_stmt), (count), (reason))
197#else
198#define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
199	(caller)->create_edge((callee), (call_stmt), (count), (freq))
200
201#define cgraph_create_edge_including_clones(caller, callee,	\
202		old_call_stmt, call_stmt, count, freq, reason)	\
203	(caller)->create_edge_including_clones((callee),	\
204		(old_call_stmt), (call_stmt), (count), (freq), (reason))
205#endif
206
207typedef struct cgraph_node *cgraph_node_ptr;
208typedef struct cgraph_edge *cgraph_edge_p;
209typedef struct varpool_node *varpool_node_ptr;
210
211static inline void change_decl_assembler_name(tree decl, tree name)
212{
213	symtab->change_decl_assembler_name(decl, name);
214}
215
216static inline void varpool_finalize_decl(tree decl)
217{
218	varpool_node::finalize_decl(decl);
219}
220
221static inline void varpool_add_new_variable(tree decl)
222{
223	varpool_node::add(decl);
224}
225
226static inline unsigned int rebuild_cgraph_edges(void)
227{
228	return cgraph_edge::rebuild_edges();
229}
230
231static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
232{
233	return node->function_symbol(availability);
234}
235
236static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
237{
238	return node->ultimate_alias_target(availability);
239}
240
241static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
242{
243	return node->only_called_directly_p();
244}
245
246static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
247{
248	return node->get_availability();
249}
250
251static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
252{
253	return node->get_alias_target();
254}
255
256static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
257{
258	return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
259}
260
261static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
262{
263	return symtab->add_cgraph_insertion_hook(hook, data);
264}
265
266static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
267{
268	symtab->remove_cgraph_insertion_hook(entry);
269}
270
271static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
272{
273	return symtab->add_cgraph_removal_hook(hook, data);
274}
275
276static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
277{
278	symtab->remove_cgraph_removal_hook(entry);
279}
280
281static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
282{
283	return symtab->add_cgraph_duplication_hook(hook, data);
284}
285
286static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
287{
288	symtab->remove_cgraph_duplication_hook(entry);
289}
290
291static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
292{
293	symtab->call_cgraph_duplication_hooks(node, node2);
294}
295
296static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
297{
298	symtab->call_edge_duplication_hooks(cs1, cs2);
299}
300
301#if BUILDING_GCC_VERSION >= 6000
302typedef gimple *gimple_ptr;
303typedef const gimple *const_gimple_ptr;
304#define gimple gimple_ptr
305#define const_gimple const_gimple_ptr
306#undef CONST_CAST_GIMPLE
307#define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X))
308#endif
309
310/* gimple related */
311static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
312{
313	return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
314}
315
316#if BUILDING_GCC_VERSION < 10000
317template <>
318template <>
319inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
320{
321	return gs->code == GIMPLE_GOTO;
322}
323
324template <>
325template <>
326inline bool is_a_helper<const greturn *>::test(const_gimple gs)
327{
328	return gs->code == GIMPLE_RETURN;
329}
330#endif
331
332static inline gasm *as_a_gasm(gimple stmt)
333{
334	return as_a<gasm *>(stmt);
335}
336
337static inline const gasm *as_a_const_gasm(const_gimple stmt)
338{
339	return as_a<const gasm *>(stmt);
340}
341
342static inline gassign *as_a_gassign(gimple stmt)
343{
344	return as_a<gassign *>(stmt);
345}
346
347static inline const gassign *as_a_const_gassign(const_gimple stmt)
348{
349	return as_a<const gassign *>(stmt);
350}
351
352static inline gcall *as_a_gcall(gimple stmt)
353{
354	return as_a<gcall *>(stmt);
355}
356
357static inline const gcall *as_a_const_gcall(const_gimple stmt)
358{
359	return as_a<const gcall *>(stmt);
360}
361
362static inline ggoto *as_a_ggoto(gimple stmt)
363{
364	return as_a<ggoto *>(stmt);
365}
366
367static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
368{
369	return as_a<const ggoto *>(stmt);
370}
371
372static inline gphi *as_a_gphi(gimple stmt)
373{
374	return as_a<gphi *>(stmt);
375}
376
377static inline const gphi *as_a_const_gphi(const_gimple stmt)
378{
379	return as_a<const gphi *>(stmt);
380}
381
382static inline greturn *as_a_greturn(gimple stmt)
383{
384	return as_a<greturn *>(stmt);
385}
386
387static inline const greturn *as_a_const_greturn(const_gimple stmt)
388{
389	return as_a<const greturn *>(stmt);
390}
391
392/* IPA/LTO related */
393#define ipa_ref_list_referring_iterate(L, I, P)	\
394	(L)->referring.iterate((I), &(P))
395#define ipa_ref_list_reference_iterate(L, I, P)	\
396	(L)->reference.iterate((I), &(P))
397
398static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
399{
400	return dyn_cast<cgraph_node_ptr>(ref->referring);
401}
402
403static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
404{
405	referring_node->remove_stmt_references(stmt);
406}
 
407
408#if BUILDING_GCC_VERSION < 6000
409#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\
410	get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning)
411#define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1))
412#endif
413
414#if BUILDING_GCC_VERSION >= 6000
415#define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
416#endif
417
418#ifdef __cplusplus
419static inline void debug_tree(const_tree t)
420{
421	debug_tree(CONST_CAST_TREE(t));
422}
423
424static inline void debug_gimple_stmt(const_gimple s)
425{
426	debug_gimple_stmt(CONST_CAST_GIMPLE(s));
427}
428#else
429#define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
430#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
431#endif
432
433#if BUILDING_GCC_VERSION >= 7000
434#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\
435	get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
436#endif
437
438#if BUILDING_GCC_VERSION < 7000
439#define SET_DECL_ALIGN(decl, align)	DECL_ALIGN(decl) = (align)
440#define SET_DECL_MODE(decl, mode)	DECL_MODE(decl) = (mode)
441#endif
442
443#if BUILDING_GCC_VERSION >= 14000
444#define last_stmt(x)			last_nondebug_stmt(x)
445#endif
446
447#endif