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" 746b90bd4bSEmese Revfy #include "gimple-expr.h" 756b90bd4bSEmese Revfy #include "gimple-fold.h" 766b90bd4bSEmese Revfy #include "context.h" 776b90bd4bSEmese Revfy #include "tree-ssa-alias.h" 786b90bd4bSEmese Revfy #include "tree-ssa.h" 796b90bd4bSEmese Revfy #include "stringpool.h" 8081d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000 8181d873a8SKees Cook #include "tree-vrp.h" 8281d873a8SKees Cook #endif 836b90bd4bSEmese Revfy #include "tree-ssanames.h" 846b90bd4bSEmese Revfy #include "print-tree.h" 856b90bd4bSEmese Revfy #include "tree-eh.h" 866b90bd4bSEmese Revfy #include "stmt.h" 876b90bd4bSEmese Revfy #include "gimplify.h" 886b90bd4bSEmese Revfy #include "gimple.h" 896b90bd4bSEmese Revfy #include "tree-ssa-operands.h" 906b90bd4bSEmese Revfy #include "tree-phinodes.h" 916b90bd4bSEmese Revfy #include "tree-cfg.h" 926b90bd4bSEmese Revfy #include "gimple-iterator.h" 936b90bd4bSEmese Revfy #include "gimple-ssa.h" 946b90bd4bSEmese Revfy #include "ssa-iterators.h" 956b90bd4bSEmese Revfy 966b90bd4bSEmese Revfy #include "builtins.h" 976b90bd4bSEmese Revfy 986b90bd4bSEmese Revfy /* missing from basic_block.h... */ 998d4973a1SKees Cook void debug_dominance_info(enum cdi_direction dir); 1008d4973a1SKees Cook void debug_dominance_tree(enum cdi_direction dir, basic_block root); 1016b90bd4bSEmese Revfy 1027210e060SKees Cook #ifndef __unused 1036b90bd4bSEmese Revfy #define __unused __attribute__((__unused__)) 1047210e060SKees Cook #endif 1057210e060SKees Cook #ifndef __visible 106da7389acSKees Cook #define __visible __attribute__((visibility("default"))) 1077210e060SKees Cook #endif 1086b90bd4bSEmese Revfy 1096b90bd4bSEmese Revfy #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node)) 1106b90bd4bSEmese Revfy #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node)) 1116b90bd4bSEmese Revfy #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node)) 1126b90bd4bSEmese Revfy #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node)) 1136b90bd4bSEmese Revfy 1146b90bd4bSEmese Revfy /* should come from c-tree.h if only it were installed for gcc 4.5... */ 1156b90bd4bSEmese Revfy #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE) 1166b90bd4bSEmese Revfy 1178d4973a1SKees Cook static inline tree build_const_char_string(int len, const char *str) 1188d4973a1SKees Cook { 1198d4973a1SKees Cook tree cstr, elem, index, type; 1208d4973a1SKees Cook 1218d4973a1SKees Cook cstr = build_string(len, str); 1228d4973a1SKees Cook elem = build_type_variant(char_type_node, 1, 0); 1238d4973a1SKees Cook index = build_index_type(size_int(len - 1)); 1248d4973a1SKees Cook type = build_array_type(elem, index); 1258d4973a1SKees Cook TREE_TYPE(cstr) = type; 1268d4973a1SKees Cook TREE_CONSTANT(cstr) = 1; 1278d4973a1SKees Cook TREE_READONLY(cstr) = 1; 1288d4973a1SKees Cook TREE_STATIC(cstr) = 1; 1298d4973a1SKees Cook return cstr; 1308d4973a1SKees Cook } 1318d4973a1SKees Cook 1328d4973a1SKees Cook #define PASS_INFO(NAME, REF, ID, POS) \ 1338d4973a1SKees Cook struct register_pass_info NAME##_pass_info = { \ 1348d4973a1SKees Cook .pass = make_##NAME##_pass(), \ 1358d4973a1SKees Cook .reference_pass_name = REF, \ 1368d4973a1SKees Cook .ref_pass_instance_number = ID, \ 1378d4973a1SKees Cook .pos_op = POS, \ 1388d4973a1SKees Cook } 1398d4973a1SKees Cook 1406b90bd4bSEmese Revfy #define add_referenced_var(var) 1416b90bd4bSEmese Revfy #define mark_sym_for_renaming(var) 1426b90bd4bSEmese Revfy #define varpool_mark_needed_node(node) 1436b90bd4bSEmese Revfy #define create_var_ann(var) 1446b90bd4bSEmese Revfy #define TODO_dump_func 0 1456b90bd4bSEmese Revfy #define TODO_dump_cgraph 0 1466b90bd4bSEmese Revfy 1476b90bd4bSEmese Revfy #define TODO_ggc_collect 0 1486b90bd4bSEmese Revfy #define NODE_SYMBOL(node) (node) 1496b90bd4bSEmese Revfy #define NODE_DECL(node) (node)->decl 1506b90bd4bSEmese Revfy #define cgraph_node_name(node) (node)->name() 1516b90bd4bSEmese Revfy #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias 1528d4973a1SKees Cook 1538d4973a1SKees Cook static inline opt_pass *get_pass_for_id(int id) 1548d4973a1SKees Cook { 1558d4973a1SKees Cook return g->get_passes()->get_pass_for_id(id); 1568d4973a1SKees Cook } 1576b90bd4bSEmese Revfy 158*4c78c727SArd Biesheuvel #if BUILDING_GCC_VERSION < 6000 1596b90bd4bSEmese Revfy /* gimple related */ 1606b90bd4bSEmese Revfy template <> 1616b90bd4bSEmese Revfy template <> 1626b90bd4bSEmese Revfy inline bool is_a_helper<const gassign *>::test(const_gimple gs) 1636b90bd4bSEmese Revfy { 1646b90bd4bSEmese Revfy return gs->code == GIMPLE_ASSIGN; 1656b90bd4bSEmese Revfy } 1666b90bd4bSEmese Revfy #endif 1676b90bd4bSEmese Revfy 1686b90bd4bSEmese Revfy #define TODO_verify_ssa TODO_verify_il 1696b90bd4bSEmese Revfy #define TODO_verify_flow TODO_verify_il 1706b90bd4bSEmese Revfy #define TODO_verify_stmts TODO_verify_il 1716b90bd4bSEmese Revfy #define TODO_verify_rtl_sharing TODO_verify_il 1726b90bd4bSEmese Revfy 1736b90bd4bSEmese Revfy #define INSN_DELETED_P(insn) (insn)->deleted() 1746b90bd4bSEmese Revfy 17581d873a8SKees Cook static inline const char *get_decl_section_name(const_tree decl) 17681d873a8SKees Cook { 17781d873a8SKees Cook return DECL_SECTION_NAME(decl); 17881d873a8SKees Cook } 17981d873a8SKees Cook 1806b90bd4bSEmese Revfy /* symtab/cgraph related */ 1816b90bd4bSEmese Revfy #define debug_cgraph_node(node) (node)->debug() 1826b90bd4bSEmese Revfy #define cgraph_get_node(decl) cgraph_node::get(decl) 1836b90bd4bSEmese Revfy #define cgraph_get_create_node(decl) cgraph_node::get_create(decl) 1846b90bd4bSEmese Revfy #define cgraph_create_node(decl) cgraph_node::create(decl) 1856b90bd4bSEmese Revfy #define cgraph_n_nodes symtab->cgraph_count 1866b90bd4bSEmese Revfy #define cgraph_max_uid symtab->cgraph_max_uid 1876b90bd4bSEmese Revfy #define varpool_get_node(decl) varpool_node::get(decl) 18881d873a8SKees Cook #define dump_varpool_node(file, node) (node)->dump(file) 1896b90bd4bSEmese Revfy 19045d9a1e3SAlexander Popov #if BUILDING_GCC_VERSION >= 8000 19145d9a1e3SAlexander Popov #define cgraph_create_edge(caller, callee, call_stmt, count, freq) \ 19245d9a1e3SAlexander Popov (caller)->create_edge((callee), (call_stmt), (count)) 19345d9a1e3SAlexander Popov 19445d9a1e3SAlexander Popov #define cgraph_create_edge_including_clones(caller, callee, \ 19545d9a1e3SAlexander Popov old_call_stmt, call_stmt, count, freq, reason) \ 19645d9a1e3SAlexander Popov (caller)->create_edge_including_clones((callee), \ 19745d9a1e3SAlexander Popov (old_call_stmt), (call_stmt), (count), (reason)) 19845d9a1e3SAlexander Popov #else 19945d9a1e3SAlexander Popov #define cgraph_create_edge(caller, callee, call_stmt, count, freq) \ 2006b90bd4bSEmese Revfy (caller)->create_edge((callee), (call_stmt), (count), (freq)) 20145d9a1e3SAlexander Popov 20245d9a1e3SAlexander Popov #define cgraph_create_edge_including_clones(caller, callee, \ 20345d9a1e3SAlexander Popov old_call_stmt, call_stmt, count, freq, reason) \ 20445d9a1e3SAlexander Popov (caller)->create_edge_including_clones((callee), \ 20545d9a1e3SAlexander Popov (old_call_stmt), (call_stmt), (count), (freq), (reason)) 20645d9a1e3SAlexander Popov #endif 2076b90bd4bSEmese Revfy 2086b90bd4bSEmese Revfy typedef struct cgraph_node *cgraph_node_ptr; 2096b90bd4bSEmese Revfy typedef struct cgraph_edge *cgraph_edge_p; 2106b90bd4bSEmese Revfy typedef struct varpool_node *varpool_node_ptr; 2116b90bd4bSEmese Revfy 2126b90bd4bSEmese Revfy static inline void change_decl_assembler_name(tree decl, tree name) 2136b90bd4bSEmese Revfy { 2146b90bd4bSEmese Revfy symtab->change_decl_assembler_name(decl, name); 2156b90bd4bSEmese Revfy } 2166b90bd4bSEmese Revfy 2176b90bd4bSEmese Revfy static inline void varpool_finalize_decl(tree decl) 2186b90bd4bSEmese Revfy { 2196b90bd4bSEmese Revfy varpool_node::finalize_decl(decl); 2206b90bd4bSEmese Revfy } 2216b90bd4bSEmese Revfy 2226b90bd4bSEmese Revfy static inline void varpool_add_new_variable(tree decl) 2236b90bd4bSEmese Revfy { 2246b90bd4bSEmese Revfy varpool_node::add(decl); 2256b90bd4bSEmese Revfy } 2266b90bd4bSEmese Revfy 2276b90bd4bSEmese Revfy static inline unsigned int rebuild_cgraph_edges(void) 2286b90bd4bSEmese Revfy { 2296b90bd4bSEmese Revfy return cgraph_edge::rebuild_edges(); 2306b90bd4bSEmese Revfy } 2316b90bd4bSEmese Revfy 2326b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability) 2336b90bd4bSEmese Revfy { 2346b90bd4bSEmese Revfy return node->function_symbol(availability); 2356b90bd4bSEmese Revfy } 2366b90bd4bSEmese Revfy 2376b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL) 2386b90bd4bSEmese Revfy { 2396b90bd4bSEmese Revfy return node->ultimate_alias_target(availability); 2406b90bd4bSEmese Revfy } 2416b90bd4bSEmese Revfy 2426b90bd4bSEmese Revfy static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node) 2436b90bd4bSEmese Revfy { 2446b90bd4bSEmese Revfy return node->only_called_directly_p(); 2456b90bd4bSEmese Revfy } 2466b90bd4bSEmese Revfy 2476b90bd4bSEmese Revfy static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node) 2486b90bd4bSEmese Revfy { 2496b90bd4bSEmese Revfy return node->get_availability(); 2506b90bd4bSEmese Revfy } 2516b90bd4bSEmese Revfy 2526b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node) 2536b90bd4bSEmese Revfy { 2546b90bd4bSEmese Revfy return node->get_alias_target(); 2556b90bd4bSEmese Revfy } 2566b90bd4bSEmese Revfy 25781d873a8SKees Cook static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable) 25881d873a8SKees Cook { 25981d873a8SKees Cook return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable); 26081d873a8SKees Cook } 26181d873a8SKees Cook 2626b90bd4bSEmese Revfy static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data) 2636b90bd4bSEmese Revfy { 2646b90bd4bSEmese Revfy return symtab->add_cgraph_insertion_hook(hook, data); 2656b90bd4bSEmese Revfy } 2666b90bd4bSEmese Revfy 2676b90bd4bSEmese Revfy static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry) 2686b90bd4bSEmese Revfy { 2696b90bd4bSEmese Revfy symtab->remove_cgraph_insertion_hook(entry); 2706b90bd4bSEmese Revfy } 2716b90bd4bSEmese Revfy 2726b90bd4bSEmese Revfy static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data) 2736b90bd4bSEmese Revfy { 2746b90bd4bSEmese Revfy return symtab->add_cgraph_removal_hook(hook, data); 2756b90bd4bSEmese Revfy } 2766b90bd4bSEmese Revfy 2776b90bd4bSEmese Revfy static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry) 2786b90bd4bSEmese Revfy { 2796b90bd4bSEmese Revfy symtab->remove_cgraph_removal_hook(entry); 2806b90bd4bSEmese Revfy } 2816b90bd4bSEmese Revfy 2826b90bd4bSEmese Revfy static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data) 2836b90bd4bSEmese Revfy { 2846b90bd4bSEmese Revfy return symtab->add_cgraph_duplication_hook(hook, data); 2856b90bd4bSEmese Revfy } 2866b90bd4bSEmese Revfy 2876b90bd4bSEmese Revfy static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry) 2886b90bd4bSEmese Revfy { 2896b90bd4bSEmese Revfy symtab->remove_cgraph_duplication_hook(entry); 2906b90bd4bSEmese Revfy } 2916b90bd4bSEmese Revfy 2926b90bd4bSEmese Revfy static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2) 2936b90bd4bSEmese Revfy { 2946b90bd4bSEmese Revfy symtab->call_cgraph_duplication_hooks(node, node2); 2956b90bd4bSEmese Revfy } 2966b90bd4bSEmese Revfy 2976b90bd4bSEmese Revfy static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2) 2986b90bd4bSEmese Revfy { 2996b90bd4bSEmese Revfy symtab->call_edge_duplication_hooks(cs1, cs2); 3006b90bd4bSEmese Revfy } 3016b90bd4bSEmese Revfy 3026b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000 3036b90bd4bSEmese Revfy typedef gimple *gimple_ptr; 3046b90bd4bSEmese Revfy typedef const gimple *const_gimple_ptr; 3056b90bd4bSEmese Revfy #define gimple gimple_ptr 3066b90bd4bSEmese Revfy #define const_gimple const_gimple_ptr 3076b90bd4bSEmese Revfy #undef CONST_CAST_GIMPLE 3086b90bd4bSEmese Revfy #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X)) 3096b90bd4bSEmese Revfy #endif 3106b90bd4bSEmese Revfy 3116b90bd4bSEmese Revfy /* gimple related */ 3126b90bd4bSEmese Revfy static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL) 3136b90bd4bSEmese Revfy { 3146b90bd4bSEmese Revfy return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT); 3156b90bd4bSEmese Revfy } 3166b90bd4bSEmese Revfy 317c7527373SFrédéric Pierret (fepitre) #if BUILDING_GCC_VERSION < 10000 3186b90bd4bSEmese Revfy template <> 3196b90bd4bSEmese Revfy template <> 32081d873a8SKees Cook inline bool is_a_helper<const ggoto *>::test(const_gimple gs) 32181d873a8SKees Cook { 32281d873a8SKees Cook return gs->code == GIMPLE_GOTO; 32381d873a8SKees Cook } 32481d873a8SKees Cook 32581d873a8SKees Cook template <> 32681d873a8SKees Cook template <> 3276b90bd4bSEmese Revfy inline bool is_a_helper<const greturn *>::test(const_gimple gs) 3286b90bd4bSEmese Revfy { 3296b90bd4bSEmese Revfy return gs->code == GIMPLE_RETURN; 3306b90bd4bSEmese Revfy } 331c7527373SFrédéric Pierret (fepitre) #endif 3326b90bd4bSEmese Revfy 3336b90bd4bSEmese Revfy static inline gasm *as_a_gasm(gimple stmt) 3346b90bd4bSEmese Revfy { 3356b90bd4bSEmese Revfy return as_a<gasm *>(stmt); 3366b90bd4bSEmese Revfy } 3376b90bd4bSEmese Revfy 3386b90bd4bSEmese Revfy static inline const gasm *as_a_const_gasm(const_gimple stmt) 3396b90bd4bSEmese Revfy { 3406b90bd4bSEmese Revfy return as_a<const gasm *>(stmt); 3416b90bd4bSEmese Revfy } 3426b90bd4bSEmese Revfy 3436b90bd4bSEmese Revfy static inline gassign *as_a_gassign(gimple stmt) 3446b90bd4bSEmese Revfy { 3456b90bd4bSEmese Revfy return as_a<gassign *>(stmt); 3466b90bd4bSEmese Revfy } 3476b90bd4bSEmese Revfy 3486b90bd4bSEmese Revfy static inline const gassign *as_a_const_gassign(const_gimple stmt) 3496b90bd4bSEmese Revfy { 3506b90bd4bSEmese Revfy return as_a<const gassign *>(stmt); 3516b90bd4bSEmese Revfy } 3526b90bd4bSEmese Revfy 3536b90bd4bSEmese Revfy static inline gcall *as_a_gcall(gimple stmt) 3546b90bd4bSEmese Revfy { 3556b90bd4bSEmese Revfy return as_a<gcall *>(stmt); 3566b90bd4bSEmese Revfy } 3576b90bd4bSEmese Revfy 3586b90bd4bSEmese Revfy static inline const gcall *as_a_const_gcall(const_gimple stmt) 3596b90bd4bSEmese Revfy { 3606b90bd4bSEmese Revfy return as_a<const gcall *>(stmt); 3616b90bd4bSEmese Revfy } 3626b90bd4bSEmese Revfy 36381d873a8SKees Cook static inline ggoto *as_a_ggoto(gimple stmt) 36481d873a8SKees Cook { 36581d873a8SKees Cook return as_a<ggoto *>(stmt); 36681d873a8SKees Cook } 36781d873a8SKees Cook 36881d873a8SKees Cook static inline const ggoto *as_a_const_ggoto(const_gimple stmt) 36981d873a8SKees Cook { 37081d873a8SKees Cook return as_a<const ggoto *>(stmt); 37181d873a8SKees Cook } 37281d873a8SKees Cook 3736b90bd4bSEmese Revfy static inline gphi *as_a_gphi(gimple stmt) 3746b90bd4bSEmese Revfy { 3756b90bd4bSEmese Revfy return as_a<gphi *>(stmt); 3766b90bd4bSEmese Revfy } 3776b90bd4bSEmese Revfy 3786b90bd4bSEmese Revfy static inline const gphi *as_a_const_gphi(const_gimple stmt) 3796b90bd4bSEmese Revfy { 3806b90bd4bSEmese Revfy return as_a<const gphi *>(stmt); 3816b90bd4bSEmese Revfy } 3826b90bd4bSEmese Revfy 3836b90bd4bSEmese Revfy static inline greturn *as_a_greturn(gimple stmt) 3846b90bd4bSEmese Revfy { 3856b90bd4bSEmese Revfy return as_a<greturn *>(stmt); 3866b90bd4bSEmese Revfy } 3876b90bd4bSEmese Revfy 3886b90bd4bSEmese Revfy static inline const greturn *as_a_const_greturn(const_gimple stmt) 3896b90bd4bSEmese Revfy { 3906b90bd4bSEmese Revfy return as_a<const greturn *>(stmt); 3916b90bd4bSEmese Revfy } 3926b90bd4bSEmese Revfy 3936b90bd4bSEmese Revfy /* IPA/LTO related */ 3946b90bd4bSEmese Revfy #define ipa_ref_list_referring_iterate(L, I, P) \ 3956b90bd4bSEmese Revfy (L)->referring.iterate((I), &(P)) 3966b90bd4bSEmese Revfy #define ipa_ref_list_reference_iterate(L, I, P) \ 3976b90bd4bSEmese Revfy (L)->reference.iterate((I), &(P)) 3986b90bd4bSEmese Revfy 3996b90bd4bSEmese Revfy static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref) 4006b90bd4bSEmese Revfy { 4016b90bd4bSEmese Revfy return dyn_cast<cgraph_node_ptr>(ref->referring); 4026b90bd4bSEmese Revfy } 4036b90bd4bSEmese Revfy 4046b90bd4bSEmese Revfy static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt) 4056b90bd4bSEmese Revfy { 4066b90bd4bSEmese Revfy referring_node->remove_stmt_references(stmt); 4076b90bd4bSEmese Revfy } 4086b90bd4bSEmese Revfy 4096b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION < 6000 4106b90bd4bSEmese Revfy #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \ 4116b90bd4bSEmese Revfy get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning) 4126b90bd4bSEmese Revfy #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1)) 4136b90bd4bSEmese Revfy #endif 4146b90bd4bSEmese Revfy 4156b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000 4166b90bd4bSEmese Revfy #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1)) 4176b90bd4bSEmese Revfy #endif 4186b90bd4bSEmese Revfy 4196b90bd4bSEmese Revfy #ifdef __cplusplus 4206b90bd4bSEmese Revfy static inline void debug_tree(const_tree t) 4216b90bd4bSEmese Revfy { 4226b90bd4bSEmese Revfy debug_tree(CONST_CAST_TREE(t)); 4236b90bd4bSEmese Revfy } 4246b90bd4bSEmese Revfy 4256b90bd4bSEmese Revfy static inline void debug_gimple_stmt(const_gimple s) 4266b90bd4bSEmese Revfy { 4276b90bd4bSEmese Revfy debug_gimple_stmt(CONST_CAST_GIMPLE(s)); 4286b90bd4bSEmese Revfy } 4296b90bd4bSEmese Revfy #else 4306b90bd4bSEmese Revfy #define debug_tree(t) debug_tree(CONST_CAST_TREE(t)) 4316b90bd4bSEmese Revfy #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) 4326b90bd4bSEmese Revfy #endif 4336b90bd4bSEmese Revfy 43481d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000 43581d873a8SKees Cook #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \ 43681d873a8SKees Cook get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep) 43781d873a8SKees Cook #endif 43881d873a8SKees Cook 439313dd1b6SKees Cook #if BUILDING_GCC_VERSION < 7000 440313dd1b6SKees Cook #define SET_DECL_ALIGN(decl, align) DECL_ALIGN(decl) = (align) 441313dd1b6SKees Cook #define SET_DECL_MODE(decl, mode) DECL_MODE(decl) = (mode) 442313dd1b6SKees Cook #endif 443313dd1b6SKees Cook 4446b90bd4bSEmese Revfy #endif 445