1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
26b90bd4bSEmese Revfy #ifndef GCC_COMMON_H_INCLUDED
36b90bd4bSEmese Revfy #define GCC_COMMON_H_INCLUDED
46b90bd4bSEmese Revfy 
56b90bd4bSEmese Revfy #include "bversion.h"
66b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000
76b90bd4bSEmese Revfy #include "gcc-plugin.h"
86b90bd4bSEmese Revfy #else
96b90bd4bSEmese Revfy #include "plugin.h"
106b90bd4bSEmese Revfy #endif
116b90bd4bSEmese Revfy #include "plugin-version.h"
126b90bd4bSEmese Revfy #include "config.h"
136b90bd4bSEmese Revfy #include "system.h"
146b90bd4bSEmese Revfy #include "coretypes.h"
156b90bd4bSEmese Revfy #include "tm.h"
166b90bd4bSEmese Revfy #include "line-map.h"
176b90bd4bSEmese Revfy #include "input.h"
186b90bd4bSEmese Revfy #include "tree.h"
196b90bd4bSEmese Revfy 
206b90bd4bSEmese Revfy #include "tree-inline.h"
216b90bd4bSEmese Revfy #include "version.h"
226b90bd4bSEmese Revfy #include "rtl.h"
236b90bd4bSEmese Revfy #include "tm_p.h"
246b90bd4bSEmese Revfy #include "flags.h"
256b90bd4bSEmese Revfy #include "hard-reg-set.h"
266b90bd4bSEmese Revfy #include "output.h"
276b90bd4bSEmese Revfy #include "except.h"
286b90bd4bSEmese Revfy #include "function.h"
296b90bd4bSEmese Revfy #include "toplev.h"
308d4973a1SKees Cook #include "expr.h"
316b90bd4bSEmese Revfy #include "basic-block.h"
326b90bd4bSEmese Revfy #include "intl.h"
336b90bd4bSEmese Revfy #include "ggc.h"
346b90bd4bSEmese Revfy #include "timevar.h"
356b90bd4bSEmese Revfy 
36c7527373SFrédéric Pierret (fepitre) #if BUILDING_GCC_VERSION < 10000
376b90bd4bSEmese Revfy #include "params.h"
38c7527373SFrédéric Pierret (fepitre) #endif
396b90bd4bSEmese Revfy 
406b90bd4bSEmese Revfy #include "hash-map.h"
416b90bd4bSEmese Revfy 
4281d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000
4381d873a8SKees Cook #include "memmodel.h"
4481d873a8SKees Cook #endif
456b90bd4bSEmese Revfy #include "emit-rtl.h"
466b90bd4bSEmese Revfy #include "debug.h"
476b90bd4bSEmese Revfy #include "target.h"
486b90bd4bSEmese Revfy #include "langhooks.h"
496b90bd4bSEmese Revfy #include "cfgloop.h"
506b90bd4bSEmese Revfy #include "cgraph.h"
516b90bd4bSEmese Revfy #include "opts.h"
526b90bd4bSEmese Revfy #include "tree-pretty-print.h"
536b90bd4bSEmese Revfy #include "gimple-pretty-print.h"
546b90bd4bSEmese Revfy #include "c-family/c-common.h"
556b90bd4bSEmese Revfy #include "tree-cfgcleanup.h"
566b90bd4bSEmese Revfy #include "tree-ssa-operands.h"
576b90bd4bSEmese Revfy #include "tree-into-ssa.h"
586b90bd4bSEmese Revfy #include "is-a.h"
596b90bd4bSEmese Revfy #include "diagnostic.h"
606b90bd4bSEmese Revfy #include "tree-dump.h"
616b90bd4bSEmese Revfy #include "tree-pass.h"
628d4973a1SKees Cook #include "pass_manager.h"
636b90bd4bSEmese Revfy #include "predict.h"
646b90bd4bSEmese Revfy #include "ipa-utils.h"
656b90bd4bSEmese Revfy 
6680d17243Svaldis.kletnieks@vt.edu #if BUILDING_GCC_VERSION >= 8000
6780d17243Svaldis.kletnieks@vt.edu #include "stringpool.h"
6880d17243Svaldis.kletnieks@vt.edu #endif
6980d17243Svaldis.kletnieks@vt.edu 
706b90bd4bSEmese Revfy #include "attribs.h"
716b90bd4bSEmese Revfy #include "varasm.h"
726b90bd4bSEmese Revfy #include "stor-layout.h"
736b90bd4bSEmese Revfy #include "internal-fn.h"
74e6a71160SKees Cook #include "gimple.h"
756b90bd4bSEmese Revfy #include "gimple-expr.h"
76e6a71160SKees Cook #include "gimple-iterator.h"
776b90bd4bSEmese Revfy #include "gimple-fold.h"
786b90bd4bSEmese Revfy #include "context.h"
796b90bd4bSEmese Revfy #include "tree-ssa-alias.h"
806b90bd4bSEmese Revfy #include "tree-ssa.h"
816b90bd4bSEmese Revfy #include "stringpool.h"
8281d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000
8381d873a8SKees Cook #include "tree-vrp.h"
8481d873a8SKees Cook #endif
856b90bd4bSEmese Revfy #include "tree-ssanames.h"
866b90bd4bSEmese Revfy #include "print-tree.h"
876b90bd4bSEmese Revfy #include "tree-eh.h"
886b90bd4bSEmese Revfy #include "stmt.h"
896b90bd4bSEmese Revfy #include "gimplify.h"
906b90bd4bSEmese Revfy #include "tree-phinodes.h"
916b90bd4bSEmese Revfy #include "tree-cfg.h"
926b90bd4bSEmese Revfy #include "gimple-ssa.h"
936b90bd4bSEmese Revfy #include "ssa-iterators.h"
946b90bd4bSEmese Revfy 
956b90bd4bSEmese Revfy #include "builtins.h"
966b90bd4bSEmese Revfy 
976b90bd4bSEmese Revfy /* missing from basic_block.h... */
988d4973a1SKees Cook void debug_dominance_info(enum cdi_direction dir);
998d4973a1SKees Cook void debug_dominance_tree(enum cdi_direction dir, basic_block root);
1006b90bd4bSEmese Revfy 
1017210e060SKees Cook #ifndef __unused
1026b90bd4bSEmese Revfy #define __unused __attribute__((__unused__))
1037210e060SKees Cook #endif
1047210e060SKees Cook #ifndef __visible
105da7389acSKees Cook #define __visible __attribute__((visibility("default")))
1067210e060SKees Cook #endif
1076b90bd4bSEmese Revfy 
1086b90bd4bSEmese Revfy #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
1096b90bd4bSEmese Revfy #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
1106b90bd4bSEmese Revfy #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
1116b90bd4bSEmese Revfy #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
1126b90bd4bSEmese Revfy 
1136b90bd4bSEmese Revfy /* should come from c-tree.h if only it were installed for gcc 4.5... */
1146b90bd4bSEmese Revfy #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
1156b90bd4bSEmese Revfy 
build_const_char_string(int len,const char * str)1168d4973a1SKees Cook static inline tree build_const_char_string(int len, const char *str)
1178d4973a1SKees Cook {
1188d4973a1SKees Cook 	tree cstr, elem, index, type;
1198d4973a1SKees Cook 
1208d4973a1SKees Cook 	cstr = build_string(len, str);
1218d4973a1SKees Cook 	elem = build_type_variant(char_type_node, 1, 0);
1228d4973a1SKees Cook 	index = build_index_type(size_int(len - 1));
1238d4973a1SKees Cook 	type = build_array_type(elem, index);
1248d4973a1SKees Cook 	TREE_TYPE(cstr) = type;
1258d4973a1SKees Cook 	TREE_CONSTANT(cstr) = 1;
1268d4973a1SKees Cook 	TREE_READONLY(cstr) = 1;
1278d4973a1SKees Cook 	TREE_STATIC(cstr) = 1;
1288d4973a1SKees Cook 	return cstr;
1298d4973a1SKees Cook }
1308d4973a1SKees Cook 
1318d4973a1SKees Cook #define PASS_INFO(NAME, REF, ID, POS)		\
1328d4973a1SKees Cook struct register_pass_info NAME##_pass_info = {	\
1338d4973a1SKees Cook 	.pass = make_##NAME##_pass(),		\
1348d4973a1SKees Cook 	.reference_pass_name = REF,		\
1358d4973a1SKees Cook 	.ref_pass_instance_number = ID,		\
1368d4973a1SKees Cook 	.pos_op = POS,				\
1378d4973a1SKees Cook }
1388d4973a1SKees Cook 
1396b90bd4bSEmese Revfy #define add_referenced_var(var)
1406b90bd4bSEmese Revfy #define mark_sym_for_renaming(var)
1416b90bd4bSEmese Revfy #define varpool_mark_needed_node(node)
1426b90bd4bSEmese Revfy #define create_var_ann(var)
1436b90bd4bSEmese Revfy #define TODO_dump_func 0
1446b90bd4bSEmese Revfy #define TODO_dump_cgraph 0
1456b90bd4bSEmese Revfy 
1466b90bd4bSEmese Revfy #define TODO_ggc_collect 0
1476b90bd4bSEmese Revfy #define NODE_SYMBOL(node) (node)
1486b90bd4bSEmese Revfy #define NODE_DECL(node) (node)->decl
1496b90bd4bSEmese Revfy #define cgraph_node_name(node) (node)->name()
1506b90bd4bSEmese Revfy #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
1518d4973a1SKees Cook 
get_pass_for_id(int id)1528d4973a1SKees Cook static inline opt_pass *get_pass_for_id(int id)
1538d4973a1SKees Cook {
1548d4973a1SKees Cook 	return g->get_passes()->get_pass_for_id(id);
1558d4973a1SKees Cook }
1566b90bd4bSEmese Revfy 
1574c78c727SArd Biesheuvel #if BUILDING_GCC_VERSION < 6000
1586b90bd4bSEmese Revfy /* gimple related */
1596b90bd4bSEmese Revfy template <>
1606b90bd4bSEmese Revfy template <>
test(const_gimple gs)1616b90bd4bSEmese Revfy inline bool is_a_helper<const gassign *>::test(const_gimple gs)
1626b90bd4bSEmese Revfy {
1636b90bd4bSEmese Revfy 	return gs->code == GIMPLE_ASSIGN;
1646b90bd4bSEmese Revfy }
1656b90bd4bSEmese Revfy #endif
1666b90bd4bSEmese Revfy 
1676b90bd4bSEmese Revfy #define TODO_verify_ssa TODO_verify_il
1686b90bd4bSEmese Revfy #define TODO_verify_flow TODO_verify_il
1696b90bd4bSEmese Revfy #define TODO_verify_stmts TODO_verify_il
1706b90bd4bSEmese Revfy #define TODO_verify_rtl_sharing TODO_verify_il
1716b90bd4bSEmese Revfy 
1726b90bd4bSEmese Revfy #define INSN_DELETED_P(insn) (insn)->deleted()
1736b90bd4bSEmese Revfy 
get_decl_section_name(const_tree decl)17481d873a8SKees Cook static inline const char *get_decl_section_name(const_tree decl)
17581d873a8SKees Cook {
17681d873a8SKees Cook 	return DECL_SECTION_NAME(decl);
17781d873a8SKees Cook }
17881d873a8SKees Cook 
1796b90bd4bSEmese Revfy /* symtab/cgraph related */
1806b90bd4bSEmese Revfy #define debug_cgraph_node(node) (node)->debug()
1816b90bd4bSEmese Revfy #define cgraph_get_node(decl) cgraph_node::get(decl)
1826b90bd4bSEmese Revfy #define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
1836b90bd4bSEmese Revfy #define cgraph_create_node(decl) cgraph_node::create(decl)
1846b90bd4bSEmese Revfy #define cgraph_n_nodes symtab->cgraph_count
1856b90bd4bSEmese Revfy #define cgraph_max_uid symtab->cgraph_max_uid
1866b90bd4bSEmese Revfy #define varpool_get_node(decl) varpool_node::get(decl)
18781d873a8SKees Cook #define dump_varpool_node(file, node) (node)->dump(file)
1886b90bd4bSEmese Revfy 
18945d9a1e3SAlexander Popov #if BUILDING_GCC_VERSION >= 8000
19045d9a1e3SAlexander Popov #define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
19145d9a1e3SAlexander Popov 	(caller)->create_edge((callee), (call_stmt), (count))
19245d9a1e3SAlexander Popov 
19345d9a1e3SAlexander Popov #define cgraph_create_edge_including_clones(caller, callee,	\
19445d9a1e3SAlexander Popov 		old_call_stmt, call_stmt, count, freq, reason)	\
19545d9a1e3SAlexander Popov 	(caller)->create_edge_including_clones((callee),	\
19645d9a1e3SAlexander Popov 		(old_call_stmt), (call_stmt), (count), (reason))
19745d9a1e3SAlexander Popov #else
19845d9a1e3SAlexander Popov #define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
1996b90bd4bSEmese Revfy 	(caller)->create_edge((callee), (call_stmt), (count), (freq))
20045d9a1e3SAlexander Popov 
20145d9a1e3SAlexander Popov #define cgraph_create_edge_including_clones(caller, callee,	\
20245d9a1e3SAlexander Popov 		old_call_stmt, call_stmt, count, freq, reason)	\
20345d9a1e3SAlexander Popov 	(caller)->create_edge_including_clones((callee),	\
20445d9a1e3SAlexander Popov 		(old_call_stmt), (call_stmt), (count), (freq), (reason))
20545d9a1e3SAlexander Popov #endif
2066b90bd4bSEmese Revfy 
2076b90bd4bSEmese Revfy typedef struct cgraph_node *cgraph_node_ptr;
2086b90bd4bSEmese Revfy typedef struct cgraph_edge *cgraph_edge_p;
2096b90bd4bSEmese Revfy typedef struct varpool_node *varpool_node_ptr;
2106b90bd4bSEmese Revfy 
change_decl_assembler_name(tree decl,tree name)2116b90bd4bSEmese Revfy static inline void change_decl_assembler_name(tree decl, tree name)
2126b90bd4bSEmese Revfy {
2136b90bd4bSEmese Revfy 	symtab->change_decl_assembler_name(decl, name);
2146b90bd4bSEmese Revfy }
2156b90bd4bSEmese Revfy 
varpool_finalize_decl(tree decl)2166b90bd4bSEmese Revfy static inline void varpool_finalize_decl(tree decl)
2176b90bd4bSEmese Revfy {
2186b90bd4bSEmese Revfy 	varpool_node::finalize_decl(decl);
2196b90bd4bSEmese Revfy }
2206b90bd4bSEmese Revfy 
varpool_add_new_variable(tree decl)2216b90bd4bSEmese Revfy static inline void varpool_add_new_variable(tree decl)
2226b90bd4bSEmese Revfy {
2236b90bd4bSEmese Revfy 	varpool_node::add(decl);
2246b90bd4bSEmese Revfy }
2256b90bd4bSEmese Revfy 
rebuild_cgraph_edges(void)2266b90bd4bSEmese Revfy static inline unsigned int rebuild_cgraph_edges(void)
2276b90bd4bSEmese Revfy {
2286b90bd4bSEmese Revfy 	return cgraph_edge::rebuild_edges();
2296b90bd4bSEmese Revfy }
2306b90bd4bSEmese Revfy 
cgraph_function_node(cgraph_node_ptr node,enum availability * availability)2316b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
2326b90bd4bSEmese Revfy {
2336b90bd4bSEmese Revfy 	return node->function_symbol(availability);
2346b90bd4bSEmese Revfy }
2356b90bd4bSEmese Revfy 
2366b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
2376b90bd4bSEmese Revfy {
2386b90bd4bSEmese Revfy 	return node->ultimate_alias_target(availability);
2396b90bd4bSEmese Revfy }
2406b90bd4bSEmese Revfy 
cgraph_only_called_directly_p(cgraph_node_ptr node)2416b90bd4bSEmese Revfy static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
2426b90bd4bSEmese Revfy {
2436b90bd4bSEmese Revfy 	return node->only_called_directly_p();
2446b90bd4bSEmese Revfy }
2456b90bd4bSEmese Revfy 
cgraph_function_body_availability(cgraph_node_ptr node)2466b90bd4bSEmese Revfy static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
2476b90bd4bSEmese Revfy {
2486b90bd4bSEmese Revfy 	return node->get_availability();
2496b90bd4bSEmese Revfy }
2506b90bd4bSEmese Revfy 
cgraph_alias_target(cgraph_node_ptr node)2516b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
2526b90bd4bSEmese Revfy {
2536b90bd4bSEmese Revfy 	return node->get_alias_target();
2546b90bd4bSEmese Revfy }
2556b90bd4bSEmese Revfy 
cgraph_for_node_and_aliases(cgraph_node_ptr node,bool (* callback)(cgraph_node_ptr,void *),void * data,bool include_overwritable)25681d873a8SKees Cook static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
25781d873a8SKees Cook {
25881d873a8SKees Cook 	return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
25981d873a8SKees Cook }
26081d873a8SKees Cook 
cgraph_add_function_insertion_hook(cgraph_node_hook hook,void * data)2616b90bd4bSEmese Revfy static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
2626b90bd4bSEmese Revfy {
2636b90bd4bSEmese Revfy 	return symtab->add_cgraph_insertion_hook(hook, data);
2646b90bd4bSEmese Revfy }
2656b90bd4bSEmese Revfy 
cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list * entry)2666b90bd4bSEmese Revfy static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
2676b90bd4bSEmese Revfy {
2686b90bd4bSEmese Revfy 	symtab->remove_cgraph_insertion_hook(entry);
2696b90bd4bSEmese Revfy }
2706b90bd4bSEmese Revfy 
cgraph_add_node_removal_hook(cgraph_node_hook hook,void * data)2716b90bd4bSEmese Revfy static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
2726b90bd4bSEmese Revfy {
2736b90bd4bSEmese Revfy 	return symtab->add_cgraph_removal_hook(hook, data);
2746b90bd4bSEmese Revfy }
2756b90bd4bSEmese Revfy 
cgraph_remove_node_removal_hook(struct cgraph_node_hook_list * entry)2766b90bd4bSEmese Revfy static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
2776b90bd4bSEmese Revfy {
2786b90bd4bSEmese Revfy 	symtab->remove_cgraph_removal_hook(entry);
2796b90bd4bSEmese Revfy }
2806b90bd4bSEmese Revfy 
cgraph_add_node_duplication_hook(cgraph_2node_hook hook,void * data)2816b90bd4bSEmese Revfy static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
2826b90bd4bSEmese Revfy {
2836b90bd4bSEmese Revfy 	return symtab->add_cgraph_duplication_hook(hook, data);
2846b90bd4bSEmese Revfy }
2856b90bd4bSEmese Revfy 
cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list * entry)2866b90bd4bSEmese Revfy static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
2876b90bd4bSEmese Revfy {
2886b90bd4bSEmese Revfy 	symtab->remove_cgraph_duplication_hook(entry);
2896b90bd4bSEmese Revfy }
2906b90bd4bSEmese Revfy 
cgraph_call_node_duplication_hooks(cgraph_node_ptr node,cgraph_node_ptr node2)2916b90bd4bSEmese Revfy static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
2926b90bd4bSEmese Revfy {
2936b90bd4bSEmese Revfy 	symtab->call_cgraph_duplication_hooks(node, node2);
2946b90bd4bSEmese Revfy }
2956b90bd4bSEmese Revfy 
cgraph_call_edge_duplication_hooks(cgraph_edge * cs1,cgraph_edge * cs2)2966b90bd4bSEmese Revfy static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
2976b90bd4bSEmese Revfy {
2986b90bd4bSEmese Revfy 	symtab->call_edge_duplication_hooks(cs1, cs2);
2996b90bd4bSEmese Revfy }
3006b90bd4bSEmese Revfy 
3016b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000
3026b90bd4bSEmese Revfy typedef gimple *gimple_ptr;
3036b90bd4bSEmese Revfy typedef const gimple *const_gimple_ptr;
3046b90bd4bSEmese Revfy #define gimple gimple_ptr
3056b90bd4bSEmese Revfy #define const_gimple const_gimple_ptr
3066b90bd4bSEmese Revfy #undef CONST_CAST_GIMPLE
3076b90bd4bSEmese Revfy #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X))
3086b90bd4bSEmese Revfy #endif
3096b90bd4bSEmese Revfy 
3106b90bd4bSEmese Revfy /* gimple related */
gimple_build_assign_with_ops(enum tree_code subcode,tree lhs,tree op1,tree op2 MEM_STAT_DECL)3116b90bd4bSEmese Revfy static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
3126b90bd4bSEmese Revfy {
3136b90bd4bSEmese Revfy 	return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
3146b90bd4bSEmese Revfy }
3156b90bd4bSEmese Revfy 
316c7527373SFrédéric Pierret (fepitre) #if BUILDING_GCC_VERSION < 10000
3176b90bd4bSEmese Revfy template <>
3186b90bd4bSEmese Revfy template <>
test(const_gimple gs)31981d873a8SKees Cook inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
32081d873a8SKees Cook {
32181d873a8SKees Cook 	return gs->code == GIMPLE_GOTO;
32281d873a8SKees Cook }
32381d873a8SKees Cook 
32481d873a8SKees Cook template <>
32581d873a8SKees Cook template <>
test(const_gimple gs)3266b90bd4bSEmese Revfy inline bool is_a_helper<const greturn *>::test(const_gimple gs)
3276b90bd4bSEmese Revfy {
3286b90bd4bSEmese Revfy 	return gs->code == GIMPLE_RETURN;
3296b90bd4bSEmese Revfy }
330c7527373SFrédéric Pierret (fepitre) #endif
3316b90bd4bSEmese Revfy 
as_a_gasm(gimple stmt)3326b90bd4bSEmese Revfy static inline gasm *as_a_gasm(gimple stmt)
3336b90bd4bSEmese Revfy {
3346b90bd4bSEmese Revfy 	return as_a<gasm *>(stmt);
3356b90bd4bSEmese Revfy }
3366b90bd4bSEmese Revfy 
as_a_const_gasm(const_gimple stmt)3376b90bd4bSEmese Revfy static inline const gasm *as_a_const_gasm(const_gimple stmt)
3386b90bd4bSEmese Revfy {
3396b90bd4bSEmese Revfy 	return as_a<const gasm *>(stmt);
3406b90bd4bSEmese Revfy }
3416b90bd4bSEmese Revfy 
as_a_gassign(gimple stmt)3426b90bd4bSEmese Revfy static inline gassign *as_a_gassign(gimple stmt)
3436b90bd4bSEmese Revfy {
3446b90bd4bSEmese Revfy 	return as_a<gassign *>(stmt);
3456b90bd4bSEmese Revfy }
3466b90bd4bSEmese Revfy 
as_a_const_gassign(const_gimple stmt)3476b90bd4bSEmese Revfy static inline const gassign *as_a_const_gassign(const_gimple stmt)
3486b90bd4bSEmese Revfy {
3496b90bd4bSEmese Revfy 	return as_a<const gassign *>(stmt);
3506b90bd4bSEmese Revfy }
3516b90bd4bSEmese Revfy 
as_a_gcall(gimple stmt)3526b90bd4bSEmese Revfy static inline gcall *as_a_gcall(gimple stmt)
3536b90bd4bSEmese Revfy {
3546b90bd4bSEmese Revfy 	return as_a<gcall *>(stmt);
3556b90bd4bSEmese Revfy }
3566b90bd4bSEmese Revfy 
as_a_const_gcall(const_gimple stmt)3576b90bd4bSEmese Revfy static inline const gcall *as_a_const_gcall(const_gimple stmt)
3586b90bd4bSEmese Revfy {
3596b90bd4bSEmese Revfy 	return as_a<const gcall *>(stmt);
3606b90bd4bSEmese Revfy }
3616b90bd4bSEmese Revfy 
as_a_ggoto(gimple stmt)36281d873a8SKees Cook static inline ggoto *as_a_ggoto(gimple stmt)
36381d873a8SKees Cook {
36481d873a8SKees Cook 	return as_a<ggoto *>(stmt);
36581d873a8SKees Cook }
36681d873a8SKees Cook 
as_a_const_ggoto(const_gimple stmt)36781d873a8SKees Cook static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
36881d873a8SKees Cook {
36981d873a8SKees Cook 	return as_a<const ggoto *>(stmt);
37081d873a8SKees Cook }
37181d873a8SKees Cook 
as_a_gphi(gimple stmt)3726b90bd4bSEmese Revfy static inline gphi *as_a_gphi(gimple stmt)
3736b90bd4bSEmese Revfy {
3746b90bd4bSEmese Revfy 	return as_a<gphi *>(stmt);
3756b90bd4bSEmese Revfy }
3766b90bd4bSEmese Revfy 
as_a_const_gphi(const_gimple stmt)3776b90bd4bSEmese Revfy static inline const gphi *as_a_const_gphi(const_gimple stmt)
3786b90bd4bSEmese Revfy {
3796b90bd4bSEmese Revfy 	return as_a<const gphi *>(stmt);
3806b90bd4bSEmese Revfy }
3816b90bd4bSEmese Revfy 
as_a_greturn(gimple stmt)3826b90bd4bSEmese Revfy static inline greturn *as_a_greturn(gimple stmt)
3836b90bd4bSEmese Revfy {
3846b90bd4bSEmese Revfy 	return as_a<greturn *>(stmt);
3856b90bd4bSEmese Revfy }
3866b90bd4bSEmese Revfy 
as_a_const_greturn(const_gimple stmt)3876b90bd4bSEmese Revfy static inline const greturn *as_a_const_greturn(const_gimple stmt)
3886b90bd4bSEmese Revfy {
3896b90bd4bSEmese Revfy 	return as_a<const greturn *>(stmt);
3906b90bd4bSEmese Revfy }
3916b90bd4bSEmese Revfy 
3926b90bd4bSEmese Revfy /* IPA/LTO related */
3936b90bd4bSEmese Revfy #define ipa_ref_list_referring_iterate(L, I, P)	\
3946b90bd4bSEmese Revfy 	(L)->referring.iterate((I), &(P))
3956b90bd4bSEmese Revfy #define ipa_ref_list_reference_iterate(L, I, P)	\
3966b90bd4bSEmese Revfy 	(L)->reference.iterate((I), &(P))
3976b90bd4bSEmese Revfy 
ipa_ref_referring_node(struct ipa_ref * ref)3986b90bd4bSEmese Revfy static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
3996b90bd4bSEmese Revfy {
4006b90bd4bSEmese Revfy 	return dyn_cast<cgraph_node_ptr>(ref->referring);
4016b90bd4bSEmese Revfy }
4026b90bd4bSEmese Revfy 
ipa_remove_stmt_references(symtab_node * referring_node,gimple stmt)4036b90bd4bSEmese Revfy static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
4046b90bd4bSEmese Revfy {
4056b90bd4bSEmese Revfy 	referring_node->remove_stmt_references(stmt);
4066b90bd4bSEmese Revfy }
4076b90bd4bSEmese Revfy 
4086b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION < 6000
4096b90bd4bSEmese Revfy #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\
4106b90bd4bSEmese Revfy 	get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning)
4116b90bd4bSEmese Revfy #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1))
4126b90bd4bSEmese Revfy #endif
4136b90bd4bSEmese Revfy 
4146b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000
4156b90bd4bSEmese Revfy #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
4166b90bd4bSEmese Revfy #endif
4176b90bd4bSEmese Revfy 
4186b90bd4bSEmese Revfy #ifdef __cplusplus
debug_tree(const_tree t)4196b90bd4bSEmese Revfy static inline void debug_tree(const_tree t)
4206b90bd4bSEmese Revfy {
4216b90bd4bSEmese Revfy 	debug_tree(CONST_CAST_TREE(t));
4226b90bd4bSEmese Revfy }
4236b90bd4bSEmese Revfy 
debug_gimple_stmt(const_gimple s)4246b90bd4bSEmese Revfy static inline void debug_gimple_stmt(const_gimple s)
4256b90bd4bSEmese Revfy {
4266b90bd4bSEmese Revfy 	debug_gimple_stmt(CONST_CAST_GIMPLE(s));
4276b90bd4bSEmese Revfy }
4286b90bd4bSEmese Revfy #else
4296b90bd4bSEmese Revfy #define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
4306b90bd4bSEmese Revfy #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
4316b90bd4bSEmese Revfy #endif
4326b90bd4bSEmese Revfy 
43381d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000
43481d873a8SKees Cook #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning)	\
43581d873a8SKees Cook 	get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
43681d873a8SKees Cook #endif
43781d873a8SKees Cook 
438313dd1b6SKees Cook #if BUILDING_GCC_VERSION < 7000
439313dd1b6SKees Cook #define SET_DECL_ALIGN(decl, align)	DECL_ALIGN(decl) = (align)
440313dd1b6SKees Cook #define SET_DECL_MODE(decl, mode)	DECL_MODE(decl) = (mode)
441313dd1b6SKees Cook #endif
442313dd1b6SKees Cook 
443*2e3f65ccSKees Cook #if BUILDING_GCC_VERSION >= 14000
444*2e3f65ccSKees Cook #define last_stmt(x)			last_nondebug_stmt(x)
445*2e3f65ccSKees Cook #endif
446*2e3f65ccSKees Cook 
4476b90bd4bSEmese Revfy #endif
448