16b90bd4bSEmese Revfy #ifndef GCC_COMMON_H_INCLUDED 26b90bd4bSEmese Revfy #define GCC_COMMON_H_INCLUDED 36b90bd4bSEmese Revfy 46b90bd4bSEmese Revfy #include "bversion.h" 56b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000 66b90bd4bSEmese Revfy #include "gcc-plugin.h" 76b90bd4bSEmese Revfy #else 86b90bd4bSEmese Revfy #include "plugin.h" 96b90bd4bSEmese Revfy #endif 106b90bd4bSEmese Revfy #include "plugin-version.h" 116b90bd4bSEmese Revfy #include "config.h" 126b90bd4bSEmese Revfy #include "system.h" 136b90bd4bSEmese Revfy #include "coretypes.h" 146b90bd4bSEmese Revfy #include "tm.h" 156b90bd4bSEmese Revfy #include "line-map.h" 166b90bd4bSEmese Revfy #include "input.h" 176b90bd4bSEmese Revfy #include "tree.h" 186b90bd4bSEmese Revfy 196b90bd4bSEmese Revfy #include "tree-inline.h" 206b90bd4bSEmese Revfy #include "version.h" 216b90bd4bSEmese Revfy #include "rtl.h" 226b90bd4bSEmese Revfy #include "tm_p.h" 236b90bd4bSEmese Revfy #include "flags.h" 246b90bd4bSEmese Revfy #include "hard-reg-set.h" 256b90bd4bSEmese Revfy #include "output.h" 266b90bd4bSEmese Revfy #include "except.h" 276b90bd4bSEmese Revfy #include "function.h" 286b90bd4bSEmese Revfy #include "toplev.h" 298d4973a1SKees Cook #if BUILDING_GCC_VERSION >= 5000 308d4973a1SKees Cook #include "expr.h" 318d4973a1SKees Cook #endif 326b90bd4bSEmese Revfy #include "basic-block.h" 336b90bd4bSEmese Revfy #include "intl.h" 346b90bd4bSEmese Revfy #include "ggc.h" 356b90bd4bSEmese Revfy #include "timevar.h" 366b90bd4bSEmese Revfy 376b90bd4bSEmese Revfy #include "params.h" 386b90bd4bSEmese Revfy 396b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION <= 4009 406b90bd4bSEmese Revfy #include "pointer-set.h" 416b90bd4bSEmese Revfy #else 426b90bd4bSEmese Revfy #include "hash-map.h" 436b90bd4bSEmese Revfy #endif 446b90bd4bSEmese Revfy 4581d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000 4681d873a8SKees Cook #include "memmodel.h" 4781d873a8SKees Cook #endif 486b90bd4bSEmese Revfy #include "emit-rtl.h" 496b90bd4bSEmese Revfy #include "debug.h" 506b90bd4bSEmese Revfy #include "target.h" 516b90bd4bSEmese Revfy #include "langhooks.h" 526b90bd4bSEmese Revfy #include "cfgloop.h" 536b90bd4bSEmese Revfy #include "cgraph.h" 546b90bd4bSEmese Revfy #include "opts.h" 556b90bd4bSEmese Revfy 566b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION == 4005 576b90bd4bSEmese Revfy #include <sys/mman.h> 586b90bd4bSEmese Revfy #endif 596b90bd4bSEmese Revfy 606b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4007 616b90bd4bSEmese Revfy #include "tree-pretty-print.h" 626b90bd4bSEmese Revfy #include "gimple-pretty-print.h" 636b90bd4bSEmese Revfy #endif 646b90bd4bSEmese Revfy 656b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4006 661132e1e4SKees Cook /* 671132e1e4SKees Cook * The c-family headers were moved into a subdirectory in GCC version 681132e1e4SKees Cook * 4.7, but most plugin-building users of GCC 4.6 are using the Debian 691132e1e4SKees Cook * or Ubuntu package, which has an out-of-tree patch to move this to the 701132e1e4SKees Cook * same location as found in 4.7 and later: 711132e1e4SKees Cook * https://sources.debian.net/src/gcc-4.6/4.6.3-14/debian/patches/pr45078.diff/ 721132e1e4SKees Cook */ 736b90bd4bSEmese Revfy #include "c-family/c-common.h" 746b90bd4bSEmese Revfy #else 756b90bd4bSEmese Revfy #include "c-common.h" 766b90bd4bSEmese Revfy #endif 776b90bd4bSEmese Revfy 786b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION <= 4008 796b90bd4bSEmese Revfy #include "tree-flow.h" 806b90bd4bSEmese Revfy #else 816b90bd4bSEmese Revfy #include "tree-cfgcleanup.h" 826b90bd4bSEmese Revfy #include "tree-ssa-operands.h" 836b90bd4bSEmese Revfy #include "tree-into-ssa.h" 846b90bd4bSEmese Revfy #endif 856b90bd4bSEmese Revfy 866b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4008 876b90bd4bSEmese Revfy #include "is-a.h" 886b90bd4bSEmese Revfy #endif 896b90bd4bSEmese Revfy 906b90bd4bSEmese Revfy #include "diagnostic.h" 916b90bd4bSEmese Revfy #include "tree-dump.h" 926b90bd4bSEmese Revfy #include "tree-pass.h" 938d4973a1SKees Cook #if BUILDING_GCC_VERSION >= 4009 948d4973a1SKees Cook #include "pass_manager.h" 958d4973a1SKees Cook #endif 966b90bd4bSEmese Revfy #include "predict.h" 976b90bd4bSEmese Revfy #include "ipa-utils.h" 986b90bd4bSEmese Revfy 996b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4009 1006b90bd4bSEmese Revfy #include "attribs.h" 1016b90bd4bSEmese Revfy #include "varasm.h" 1026b90bd4bSEmese Revfy #include "stor-layout.h" 1036b90bd4bSEmese Revfy #include "internal-fn.h" 1046b90bd4bSEmese Revfy #include "gimple-expr.h" 1056b90bd4bSEmese Revfy #include "gimple-fold.h" 1066b90bd4bSEmese Revfy #include "context.h" 1076b90bd4bSEmese Revfy #include "tree-ssa-alias.h" 1086b90bd4bSEmese Revfy #include "tree-ssa.h" 1096b90bd4bSEmese Revfy #include "stringpool.h" 11081d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000 11181d873a8SKees Cook #include "tree-vrp.h" 11281d873a8SKees Cook #endif 1136b90bd4bSEmese Revfy #include "tree-ssanames.h" 1146b90bd4bSEmese Revfy #include "print-tree.h" 1156b90bd4bSEmese Revfy #include "tree-eh.h" 1166b90bd4bSEmese Revfy #include "stmt.h" 1176b90bd4bSEmese Revfy #include "gimplify.h" 1186b90bd4bSEmese Revfy #endif 1196b90bd4bSEmese Revfy 1206b90bd4bSEmese Revfy #include "gimple.h" 1216b90bd4bSEmese Revfy 1226b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4009 1236b90bd4bSEmese Revfy #include "tree-ssa-operands.h" 1246b90bd4bSEmese Revfy #include "tree-phinodes.h" 1256b90bd4bSEmese Revfy #include "tree-cfg.h" 1266b90bd4bSEmese Revfy #include "gimple-iterator.h" 1276b90bd4bSEmese Revfy #include "gimple-ssa.h" 1286b90bd4bSEmese Revfy #include "ssa-iterators.h" 1296b90bd4bSEmese Revfy #endif 1306b90bd4bSEmese Revfy 1316b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 5000 1326b90bd4bSEmese Revfy #include "builtins.h" 1336b90bd4bSEmese Revfy #endif 1346b90bd4bSEmese Revfy 1356b90bd4bSEmese Revfy /* missing from basic_block.h... */ 1368d4973a1SKees Cook void debug_dominance_info(enum cdi_direction dir); 1378d4973a1SKees Cook void debug_dominance_tree(enum cdi_direction dir, basic_block root); 1386b90bd4bSEmese Revfy 1396b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION == 4006 1408d4973a1SKees Cook void debug_gimple_stmt(gimple); 1418d4973a1SKees Cook void debug_gimple_seq(gimple_seq); 1428d4973a1SKees Cook void print_gimple_seq(FILE *, gimple_seq, int, int); 1438d4973a1SKees Cook void print_gimple_stmt(FILE *, gimple, int, int); 1448d4973a1SKees Cook void print_gimple_expr(FILE *, gimple, int, int); 1458d4973a1SKees Cook void dump_gimple_stmt(pretty_printer *, gimple, int, int); 1466b90bd4bSEmese Revfy #endif 1476b90bd4bSEmese Revfy 1486b90bd4bSEmese Revfy #define __unused __attribute__((__unused__)) 149da7389acSKees Cook #define __visible __attribute__((visibility("default"))) 1506b90bd4bSEmese Revfy 1516b90bd4bSEmese Revfy #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node)) 1526b90bd4bSEmese Revfy #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node)) 1536b90bd4bSEmese Revfy #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node)) 1546b90bd4bSEmese Revfy #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node)) 1556b90bd4bSEmese Revfy 1566b90bd4bSEmese Revfy /* should come from c-tree.h if only it were installed for gcc 4.5... */ 1576b90bd4bSEmese Revfy #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE) 1586b90bd4bSEmese Revfy 1598d4973a1SKees Cook static inline tree build_const_char_string(int len, const char *str) 1608d4973a1SKees Cook { 1618d4973a1SKees Cook tree cstr, elem, index, type; 1628d4973a1SKees Cook 1638d4973a1SKees Cook cstr = build_string(len, str); 1648d4973a1SKees Cook elem = build_type_variant(char_type_node, 1, 0); 1658d4973a1SKees Cook index = build_index_type(size_int(len - 1)); 1668d4973a1SKees Cook type = build_array_type(elem, index); 1678d4973a1SKees Cook TREE_TYPE(cstr) = type; 1688d4973a1SKees Cook TREE_CONSTANT(cstr) = 1; 1698d4973a1SKees Cook TREE_READONLY(cstr) = 1; 1708d4973a1SKees Cook TREE_STATIC(cstr) = 1; 1718d4973a1SKees Cook return cstr; 1728d4973a1SKees Cook } 1738d4973a1SKees Cook 1748d4973a1SKees Cook #define PASS_INFO(NAME, REF, ID, POS) \ 1758d4973a1SKees Cook struct register_pass_info NAME##_pass_info = { \ 1768d4973a1SKees Cook .pass = make_##NAME##_pass(), \ 1778d4973a1SKees Cook .reference_pass_name = REF, \ 1788d4973a1SKees Cook .ref_pass_instance_number = ID, \ 1798d4973a1SKees Cook .pos_op = POS, \ 1808d4973a1SKees Cook } 1818d4973a1SKees Cook 1826b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION == 4005 1836b90bd4bSEmese Revfy #define FOR_EACH_LOCAL_DECL(FUN, I, D) \ 1846b90bd4bSEmese Revfy for (tree vars = (FUN)->local_decls, (I) = 0; \ 1856b90bd4bSEmese Revfy vars && ((D) = TREE_VALUE(vars)); \ 1866b90bd4bSEmese Revfy vars = TREE_CHAIN(vars), (I)++) 1876b90bd4bSEmese Revfy #define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE))) 1886b90bd4bSEmese Revfy #define FOR_EACH_VEC_ELT(T, V, I, P) \ 1896b90bd4bSEmese Revfy for (I = 0; VEC_iterate(T, (V), (I), (P)); ++(I)) 1906b90bd4bSEmese Revfy #define TODO_rebuild_cgraph_edges 0 1916b90bd4bSEmese Revfy #define SCOPE_FILE_SCOPE_P(EXP) (!(EXP)) 1926b90bd4bSEmese Revfy 1936b90bd4bSEmese Revfy #ifndef O_BINARY 1946b90bd4bSEmese Revfy #define O_BINARY 0 1956b90bd4bSEmese Revfy #endif 1966b90bd4bSEmese Revfy 1976b90bd4bSEmese Revfy typedef struct varpool_node *varpool_node_ptr; 1986b90bd4bSEmese Revfy 1996b90bd4bSEmese Revfy static inline bool gimple_call_builtin_p(gimple stmt, enum built_in_function code) 2006b90bd4bSEmese Revfy { 2016b90bd4bSEmese Revfy tree fndecl; 2026b90bd4bSEmese Revfy 2036b90bd4bSEmese Revfy if (!is_gimple_call(stmt)) 2046b90bd4bSEmese Revfy return false; 2056b90bd4bSEmese Revfy fndecl = gimple_call_fndecl(stmt); 2066b90bd4bSEmese Revfy if (!fndecl || DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL) 2076b90bd4bSEmese Revfy return false; 2086b90bd4bSEmese Revfy return DECL_FUNCTION_CODE(fndecl) == code; 2096b90bd4bSEmese Revfy } 2106b90bd4bSEmese Revfy 2116b90bd4bSEmese Revfy static inline bool is_simple_builtin(tree decl) 2126b90bd4bSEmese Revfy { 2136b90bd4bSEmese Revfy if (decl && DECL_BUILT_IN_CLASS(decl) != BUILT_IN_NORMAL) 2146b90bd4bSEmese Revfy return false; 2156b90bd4bSEmese Revfy 2166b90bd4bSEmese Revfy switch (DECL_FUNCTION_CODE(decl)) { 2176b90bd4bSEmese Revfy /* Builtins that expand to constants. */ 2186b90bd4bSEmese Revfy case BUILT_IN_CONSTANT_P: 2196b90bd4bSEmese Revfy case BUILT_IN_EXPECT: 2206b90bd4bSEmese Revfy case BUILT_IN_OBJECT_SIZE: 2216b90bd4bSEmese Revfy case BUILT_IN_UNREACHABLE: 2226b90bd4bSEmese Revfy /* Simple register moves or loads from stack. */ 2236b90bd4bSEmese Revfy case BUILT_IN_RETURN_ADDRESS: 2246b90bd4bSEmese Revfy case BUILT_IN_EXTRACT_RETURN_ADDR: 2256b90bd4bSEmese Revfy case BUILT_IN_FROB_RETURN_ADDR: 2266b90bd4bSEmese Revfy case BUILT_IN_RETURN: 2276b90bd4bSEmese Revfy case BUILT_IN_AGGREGATE_INCOMING_ADDRESS: 2286b90bd4bSEmese Revfy case BUILT_IN_FRAME_ADDRESS: 2296b90bd4bSEmese Revfy case BUILT_IN_VA_END: 2306b90bd4bSEmese Revfy case BUILT_IN_STACK_SAVE: 2316b90bd4bSEmese Revfy case BUILT_IN_STACK_RESTORE: 2326b90bd4bSEmese Revfy /* Exception state returns or moves registers around. */ 2336b90bd4bSEmese Revfy case BUILT_IN_EH_FILTER: 2346b90bd4bSEmese Revfy case BUILT_IN_EH_POINTER: 2356b90bd4bSEmese Revfy case BUILT_IN_EH_COPY_VALUES: 2366b90bd4bSEmese Revfy return true; 2376b90bd4bSEmese Revfy 2386b90bd4bSEmese Revfy default: 2396b90bd4bSEmese Revfy return false; 2406b90bd4bSEmese Revfy } 2416b90bd4bSEmese Revfy } 2426b90bd4bSEmese Revfy 2436b90bd4bSEmese Revfy static inline void add_local_decl(struct function *fun, tree d) 2446b90bd4bSEmese Revfy { 2456b90bd4bSEmese Revfy gcc_assert(TREE_CODE(d) == VAR_DECL); 2466b90bd4bSEmese Revfy fun->local_decls = tree_cons(NULL_TREE, d, fun->local_decls); 2476b90bd4bSEmese Revfy } 2486b90bd4bSEmese Revfy #endif 2496b90bd4bSEmese Revfy 2506b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION <= 4006 2516b90bd4bSEmese Revfy #define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN) 2526b90bd4bSEmese Revfy #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4(EXP) 2536b90bd4bSEmese Revfy #define EDGE_PRESERVE 0ULL 2546b90bd4bSEmese Revfy #define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x" 2556b90bd4bSEmese Revfy #define flag_fat_lto_objects true 2566b90bd4bSEmese Revfy 2576b90bd4bSEmese Revfy #define get_random_seed(noinit) ({ \ 2586b90bd4bSEmese Revfy unsigned HOST_WIDE_INT seed; \ 2596b90bd4bSEmese Revfy sscanf(get_random_seed(noinit), "%" HOST_WIDE_INT_PRINT "x", &seed); \ 2606b90bd4bSEmese Revfy seed * seed; }) 2616b90bd4bSEmese Revfy 2626b90bd4bSEmese Revfy #define int_const_binop(code, arg1, arg2) \ 2636b90bd4bSEmese Revfy int_const_binop((code), (arg1), (arg2), 0) 2646b90bd4bSEmese Revfy 2656b90bd4bSEmese Revfy static inline bool gimple_clobber_p(gimple s __unused) 2666b90bd4bSEmese Revfy { 2676b90bd4bSEmese Revfy return false; 2686b90bd4bSEmese Revfy } 2696b90bd4bSEmese Revfy 2706b90bd4bSEmese Revfy static inline bool gimple_asm_clobbers_memory_p(const_gimple stmt) 2716b90bd4bSEmese Revfy { 2726b90bd4bSEmese Revfy unsigned i; 2736b90bd4bSEmese Revfy 2746b90bd4bSEmese Revfy for (i = 0; i < gimple_asm_nclobbers(stmt); i++) { 2756b90bd4bSEmese Revfy tree op = gimple_asm_clobber_op(stmt, i); 2766b90bd4bSEmese Revfy 2776b90bd4bSEmese Revfy if (!strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "memory")) 2786b90bd4bSEmese Revfy return true; 2796b90bd4bSEmese Revfy } 2806b90bd4bSEmese Revfy 2816b90bd4bSEmese Revfy return false; 2826b90bd4bSEmese Revfy } 2836b90bd4bSEmese Revfy 2846b90bd4bSEmese Revfy static inline tree builtin_decl_implicit(enum built_in_function fncode) 2856b90bd4bSEmese Revfy { 2866b90bd4bSEmese Revfy return implicit_built_in_decls[fncode]; 2876b90bd4bSEmese Revfy } 2886b90bd4bSEmese Revfy 2896b90bd4bSEmese Revfy static inline int ipa_reverse_postorder(struct cgraph_node **order) 2906b90bd4bSEmese Revfy { 2916b90bd4bSEmese Revfy return cgraph_postorder(order); 2926b90bd4bSEmese Revfy } 2936b90bd4bSEmese Revfy 2946b90bd4bSEmese Revfy static inline struct cgraph_node *cgraph_create_node(tree decl) 2956b90bd4bSEmese Revfy { 2966b90bd4bSEmese Revfy return cgraph_node(decl); 2976b90bd4bSEmese Revfy } 2986b90bd4bSEmese Revfy 2996b90bd4bSEmese Revfy static inline struct cgraph_node *cgraph_get_create_node(tree decl) 3006b90bd4bSEmese Revfy { 3016b90bd4bSEmese Revfy struct cgraph_node *node = cgraph_get_node(decl); 3026b90bd4bSEmese Revfy 3036b90bd4bSEmese Revfy return node ? node : cgraph_node(decl); 3046b90bd4bSEmese Revfy } 3056b90bd4bSEmese Revfy 3066b90bd4bSEmese Revfy static inline bool cgraph_function_with_gimple_body_p(struct cgraph_node *node) 3076b90bd4bSEmese Revfy { 3086b90bd4bSEmese Revfy return node->analyzed && !node->thunk.thunk_p && !node->alias; 3096b90bd4bSEmese Revfy } 3106b90bd4bSEmese Revfy 3116b90bd4bSEmese Revfy static inline struct cgraph_node *cgraph_first_function_with_gimple_body(void) 3126b90bd4bSEmese Revfy { 3136b90bd4bSEmese Revfy struct cgraph_node *node; 3146b90bd4bSEmese Revfy 3156b90bd4bSEmese Revfy for (node = cgraph_nodes; node; node = node->next) 3166b90bd4bSEmese Revfy if (cgraph_function_with_gimple_body_p(node)) 3176b90bd4bSEmese Revfy return node; 3186b90bd4bSEmese Revfy return NULL; 3196b90bd4bSEmese Revfy } 3206b90bd4bSEmese Revfy 3216b90bd4bSEmese Revfy static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node) 3226b90bd4bSEmese Revfy { 3236b90bd4bSEmese Revfy for (node = node->next; node; node = node->next) 3246b90bd4bSEmese Revfy if (cgraph_function_with_gimple_body_p(node)) 3256b90bd4bSEmese Revfy return node; 3266b90bd4bSEmese Revfy return NULL; 3276b90bd4bSEmese Revfy } 3286b90bd4bSEmese Revfy 32981d873a8SKees Cook static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable) 33081d873a8SKees Cook { 33181d873a8SKees Cook cgraph_node_ptr alias; 33281d873a8SKees Cook 33381d873a8SKees Cook if (callback(node, data)) 33481d873a8SKees Cook return true; 33581d873a8SKees Cook 33681d873a8SKees Cook for (alias = node->same_body; alias; alias = alias->next) { 33781d873a8SKees Cook if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE) 33881d873a8SKees Cook if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable)) 33981d873a8SKees Cook return true; 34081d873a8SKees Cook } 34181d873a8SKees Cook 34281d873a8SKees Cook return false; 34381d873a8SKees Cook } 34481d873a8SKees Cook 3456b90bd4bSEmese Revfy #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \ 3466b90bd4bSEmese Revfy for ((node) = cgraph_first_function_with_gimple_body(); (node); \ 3476b90bd4bSEmese Revfy (node) = cgraph_next_function_with_gimple_body(node)) 3486b90bd4bSEmese Revfy 3496b90bd4bSEmese Revfy static inline void varpool_add_new_variable(tree decl) 3506b90bd4bSEmese Revfy { 3516b90bd4bSEmese Revfy varpool_finalize_decl(decl); 3526b90bd4bSEmese Revfy } 3536b90bd4bSEmese Revfy #endif 3546b90bd4bSEmese Revfy 3556b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION <= 4007 3566b90bd4bSEmese Revfy #define FOR_EACH_FUNCTION(node) \ 3576b90bd4bSEmese Revfy for (node = cgraph_nodes; node; node = node->next) 3586b90bd4bSEmese Revfy #define FOR_EACH_VARIABLE(node) \ 3596b90bd4bSEmese Revfy for (node = varpool_nodes; node; node = node->next) 3606b90bd4bSEmese Revfy #define PROP_loops 0 3616b90bd4bSEmese Revfy #define NODE_SYMBOL(node) (node) 3626b90bd4bSEmese Revfy #define NODE_DECL(node) (node)->decl 3636b90bd4bSEmese Revfy #define INSN_LOCATION(INSN) RTL_LOCATION(INSN) 3646b90bd4bSEmese Revfy #define vNULL NULL 3656b90bd4bSEmese Revfy 3666b90bd4bSEmese Revfy static inline int bb_loop_depth(const_basic_block bb) 3676b90bd4bSEmese Revfy { 3686b90bd4bSEmese Revfy return bb->loop_father ? loop_depth(bb->loop_father) : 0; 3696b90bd4bSEmese Revfy } 3706b90bd4bSEmese Revfy 3716b90bd4bSEmese Revfy static inline bool gimple_store_p(gimple gs) 3726b90bd4bSEmese Revfy { 3736b90bd4bSEmese Revfy tree lhs = gimple_get_lhs(gs); 3746b90bd4bSEmese Revfy 3756b90bd4bSEmese Revfy return lhs && !is_gimple_reg(lhs); 3766b90bd4bSEmese Revfy } 3776b90bd4bSEmese Revfy 3786b90bd4bSEmese Revfy static inline void gimple_init_singleton(gimple g __unused) 3796b90bd4bSEmese Revfy { 3806b90bd4bSEmese Revfy } 3816b90bd4bSEmese Revfy #endif 3826b90bd4bSEmese Revfy 3836b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION == 4007 || BUILDING_GCC_VERSION == 4008 3846b90bd4bSEmese Revfy static inline struct cgraph_node *cgraph_alias_target(struct cgraph_node *n) 3856b90bd4bSEmese Revfy { 3866b90bd4bSEmese Revfy return cgraph_alias_aliased_node(n); 3876b90bd4bSEmese Revfy } 3886b90bd4bSEmese Revfy #endif 3896b90bd4bSEmese Revfy 3906b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION <= 4009 3916b90bd4bSEmese Revfy #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \ 3926b90bd4bSEmese Revfy cgraph_create_edge((caller), (callee), (call_stmt), (count), (freq)) 3936b90bd4bSEmese Revfy #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \ 3946b90bd4bSEmese Revfy cgraph_create_edge_including_clones((caller), (callee), (old_call_stmt), (call_stmt), (count), (freq), (reason)) 3956b90bd4bSEmese Revfy #endif 3966b90bd4bSEmese Revfy 3976b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION <= 4008 3986b90bd4bSEmese Revfy #define ENTRY_BLOCK_PTR_FOR_FN(FN) ENTRY_BLOCK_PTR_FOR_FUNCTION(FN) 3996b90bd4bSEmese Revfy #define EXIT_BLOCK_PTR_FOR_FN(FN) EXIT_BLOCK_PTR_FOR_FUNCTION(FN) 4006b90bd4bSEmese Revfy #define basic_block_info_for_fn(FN) ((FN)->cfg->x_basic_block_info) 4016b90bd4bSEmese Revfy #define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks) 4026b90bd4bSEmese Revfy #define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges) 4036b90bd4bSEmese Revfy #define last_basic_block_for_fn(FN) ((FN)->cfg->x_last_basic_block) 4046b90bd4bSEmese Revfy #define label_to_block_map_for_fn(FN) ((FN)->cfg->x_label_to_block_map) 4056b90bd4bSEmese Revfy #define profile_status_for_fn(FN) ((FN)->cfg->x_profile_status) 4066b90bd4bSEmese Revfy #define BASIC_BLOCK_FOR_FN(FN, N) BASIC_BLOCK_FOR_FUNCTION((FN), (N)) 4076b90bd4bSEmese Revfy #define NODE_IMPLICIT_ALIAS(node) (node)->same_body_alias 4086b90bd4bSEmese Revfy #define VAR_P(NODE) (TREE_CODE(NODE) == VAR_DECL) 4096b90bd4bSEmese Revfy 4106b90bd4bSEmese Revfy static inline bool tree_fits_shwi_p(const_tree t) 4116b90bd4bSEmese Revfy { 4126b90bd4bSEmese Revfy if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST) 4136b90bd4bSEmese Revfy return false; 4146b90bd4bSEmese Revfy 4156b90bd4bSEmese Revfy if (TREE_INT_CST_HIGH(t) == 0 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) >= 0) 4166b90bd4bSEmese Revfy return true; 4176b90bd4bSEmese Revfy 4186b90bd4bSEmese Revfy if (TREE_INT_CST_HIGH(t) == -1 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) < 0 && !TYPE_UNSIGNED(TREE_TYPE(t))) 4196b90bd4bSEmese Revfy return true; 4206b90bd4bSEmese Revfy 4216b90bd4bSEmese Revfy return false; 4226b90bd4bSEmese Revfy } 4236b90bd4bSEmese Revfy 4246b90bd4bSEmese Revfy static inline bool tree_fits_uhwi_p(const_tree t) 4256b90bd4bSEmese Revfy { 4266b90bd4bSEmese Revfy if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST) 4276b90bd4bSEmese Revfy return false; 4286b90bd4bSEmese Revfy 4296b90bd4bSEmese Revfy return TREE_INT_CST_HIGH(t) == 0; 4306b90bd4bSEmese Revfy } 4316b90bd4bSEmese Revfy 4326b90bd4bSEmese Revfy static inline HOST_WIDE_INT tree_to_shwi(const_tree t) 4336b90bd4bSEmese Revfy { 4346b90bd4bSEmese Revfy gcc_assert(tree_fits_shwi_p(t)); 4356b90bd4bSEmese Revfy return TREE_INT_CST_LOW(t); 4366b90bd4bSEmese Revfy } 4376b90bd4bSEmese Revfy 4386b90bd4bSEmese Revfy static inline unsigned HOST_WIDE_INT tree_to_uhwi(const_tree t) 4396b90bd4bSEmese Revfy { 4406b90bd4bSEmese Revfy gcc_assert(tree_fits_uhwi_p(t)); 4416b90bd4bSEmese Revfy return TREE_INT_CST_LOW(t); 4426b90bd4bSEmese Revfy } 4436b90bd4bSEmese Revfy 4446b90bd4bSEmese Revfy static inline const char *get_tree_code_name(enum tree_code code) 4456b90bd4bSEmese Revfy { 4466b90bd4bSEmese Revfy gcc_assert(code < MAX_TREE_CODES); 4476b90bd4bSEmese Revfy return tree_code_name[code]; 4486b90bd4bSEmese Revfy } 4496b90bd4bSEmese Revfy 4506b90bd4bSEmese Revfy #define ipa_remove_stmt_references(cnode, stmt) 4516b90bd4bSEmese Revfy 4526b90bd4bSEmese Revfy typedef union gimple_statement_d gasm; 4536b90bd4bSEmese Revfy typedef union gimple_statement_d gassign; 4546b90bd4bSEmese Revfy typedef union gimple_statement_d gcall; 4556b90bd4bSEmese Revfy typedef union gimple_statement_d gcond; 4566b90bd4bSEmese Revfy typedef union gimple_statement_d gdebug; 45781d873a8SKees Cook typedef union gimple_statement_d ggoto; 4586b90bd4bSEmese Revfy typedef union gimple_statement_d gphi; 4596b90bd4bSEmese Revfy typedef union gimple_statement_d greturn; 4606b90bd4bSEmese Revfy 4616b90bd4bSEmese Revfy static inline gasm *as_a_gasm(gimple stmt) 4626b90bd4bSEmese Revfy { 4636b90bd4bSEmese Revfy return stmt; 4646b90bd4bSEmese Revfy } 4656b90bd4bSEmese Revfy 4666b90bd4bSEmese Revfy static inline const gasm *as_a_const_gasm(const_gimple stmt) 4676b90bd4bSEmese Revfy { 4686b90bd4bSEmese Revfy return stmt; 4696b90bd4bSEmese Revfy } 4706b90bd4bSEmese Revfy 4716b90bd4bSEmese Revfy static inline gassign *as_a_gassign(gimple stmt) 4726b90bd4bSEmese Revfy { 4736b90bd4bSEmese Revfy return stmt; 4746b90bd4bSEmese Revfy } 4756b90bd4bSEmese Revfy 4766b90bd4bSEmese Revfy static inline const gassign *as_a_const_gassign(const_gimple stmt) 4776b90bd4bSEmese Revfy { 4786b90bd4bSEmese Revfy return stmt; 4796b90bd4bSEmese Revfy } 4806b90bd4bSEmese Revfy 4816b90bd4bSEmese Revfy static inline gcall *as_a_gcall(gimple stmt) 4826b90bd4bSEmese Revfy { 4836b90bd4bSEmese Revfy return stmt; 4846b90bd4bSEmese Revfy } 4856b90bd4bSEmese Revfy 4866b90bd4bSEmese Revfy static inline const gcall *as_a_const_gcall(const_gimple stmt) 4876b90bd4bSEmese Revfy { 4886b90bd4bSEmese Revfy return stmt; 4896b90bd4bSEmese Revfy } 4906b90bd4bSEmese Revfy 4916b90bd4bSEmese Revfy static inline gcond *as_a_gcond(gimple stmt) 4926b90bd4bSEmese Revfy { 4936b90bd4bSEmese Revfy return stmt; 4946b90bd4bSEmese Revfy } 4956b90bd4bSEmese Revfy 4966b90bd4bSEmese Revfy static inline const gcond *as_a_const_gcond(const_gimple stmt) 4976b90bd4bSEmese Revfy { 4986b90bd4bSEmese Revfy return stmt; 4996b90bd4bSEmese Revfy } 5006b90bd4bSEmese Revfy 5016b90bd4bSEmese Revfy static inline gdebug *as_a_gdebug(gimple stmt) 5026b90bd4bSEmese Revfy { 5036b90bd4bSEmese Revfy return stmt; 5046b90bd4bSEmese Revfy } 5056b90bd4bSEmese Revfy 5066b90bd4bSEmese Revfy static inline const gdebug *as_a_const_gdebug(const_gimple stmt) 5076b90bd4bSEmese Revfy { 5086b90bd4bSEmese Revfy return stmt; 5096b90bd4bSEmese Revfy } 5106b90bd4bSEmese Revfy 51181d873a8SKees Cook static inline ggoto *as_a_ggoto(gimple stmt) 51281d873a8SKees Cook { 51381d873a8SKees Cook return stmt; 51481d873a8SKees Cook } 51581d873a8SKees Cook 51681d873a8SKees Cook static inline const ggoto *as_a_const_ggoto(const_gimple stmt) 51781d873a8SKees Cook { 51881d873a8SKees Cook return stmt; 51981d873a8SKees Cook } 52081d873a8SKees Cook 5216b90bd4bSEmese Revfy static inline gphi *as_a_gphi(gimple stmt) 5226b90bd4bSEmese Revfy { 5236b90bd4bSEmese Revfy return stmt; 5246b90bd4bSEmese Revfy } 5256b90bd4bSEmese Revfy 5266b90bd4bSEmese Revfy static inline const gphi *as_a_const_gphi(const_gimple stmt) 5276b90bd4bSEmese Revfy { 5286b90bd4bSEmese Revfy return stmt; 5296b90bd4bSEmese Revfy } 5306b90bd4bSEmese Revfy 5316b90bd4bSEmese Revfy static inline greturn *as_a_greturn(gimple stmt) 5326b90bd4bSEmese Revfy { 5336b90bd4bSEmese Revfy return stmt; 5346b90bd4bSEmese Revfy } 5356b90bd4bSEmese Revfy 5366b90bd4bSEmese Revfy static inline const greturn *as_a_const_greturn(const_gimple stmt) 5376b90bd4bSEmese Revfy { 5386b90bd4bSEmese Revfy return stmt; 5396b90bd4bSEmese Revfy } 5406b90bd4bSEmese Revfy #endif 5416b90bd4bSEmese Revfy 5426b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION == 4008 5436b90bd4bSEmese Revfy #define NODE_SYMBOL(node) (&(node)->symbol) 5446b90bd4bSEmese Revfy #define NODE_DECL(node) (node)->symbol.decl 5456b90bd4bSEmese Revfy #endif 5466b90bd4bSEmese Revfy 5476b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4008 5486b90bd4bSEmese Revfy #define add_referenced_var(var) 5496b90bd4bSEmese Revfy #define mark_sym_for_renaming(var) 5506b90bd4bSEmese Revfy #define varpool_mark_needed_node(node) 5516b90bd4bSEmese Revfy #define create_var_ann(var) 5526b90bd4bSEmese Revfy #define TODO_dump_func 0 5536b90bd4bSEmese Revfy #define TODO_dump_cgraph 0 5546b90bd4bSEmese Revfy #endif 5556b90bd4bSEmese Revfy 5566b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION <= 4009 5576b90bd4bSEmese Revfy #define TODO_verify_il 0 5586b90bd4bSEmese Revfy #define AVAIL_INTERPOSABLE AVAIL_OVERWRITABLE 5596b90bd4bSEmese Revfy 5606b90bd4bSEmese Revfy #define section_name_prefix LTO_SECTION_NAME_PREFIX 5616b90bd4bSEmese Revfy #define fatal_error(loc, gmsgid, ...) fatal_error((gmsgid), __VA_ARGS__) 5626b90bd4bSEmese Revfy 5638d4973a1SKees Cook rtx emit_move_insn(rtx x, rtx y); 5648d4973a1SKees Cook 5656b90bd4bSEmese Revfy typedef struct rtx_def rtx_insn; 5666b90bd4bSEmese Revfy 56781d873a8SKees Cook static inline const char *get_decl_section_name(const_tree decl) 56881d873a8SKees Cook { 56981d873a8SKees Cook if (DECL_SECTION_NAME(decl) == NULL_TREE) 57081d873a8SKees Cook return NULL; 57181d873a8SKees Cook 57281d873a8SKees Cook return TREE_STRING_POINTER(DECL_SECTION_NAME(decl)); 57381d873a8SKees Cook } 57481d873a8SKees Cook 5756b90bd4bSEmese Revfy static inline void set_decl_section_name(tree node, const char *value) 5766b90bd4bSEmese Revfy { 5776b90bd4bSEmese Revfy if (value) 5786b90bd4bSEmese Revfy DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value); 5796b90bd4bSEmese Revfy else 5806b90bd4bSEmese Revfy DECL_SECTION_NAME(node) = NULL; 5816b90bd4bSEmese Revfy } 5826b90bd4bSEmese Revfy #endif 5836b90bd4bSEmese Revfy 5846b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION == 4009 5856b90bd4bSEmese Revfy typedef struct gimple_statement_asm gasm; 5866b90bd4bSEmese Revfy typedef struct gimple_statement_base gassign; 5876b90bd4bSEmese Revfy typedef struct gimple_statement_call gcall; 5886b90bd4bSEmese Revfy typedef struct gimple_statement_base gcond; 5896b90bd4bSEmese Revfy typedef struct gimple_statement_base gdebug; 59081d873a8SKees Cook typedef struct gimple_statement_base ggoto; 5916b90bd4bSEmese Revfy typedef struct gimple_statement_phi gphi; 5926b90bd4bSEmese Revfy typedef struct gimple_statement_base greturn; 5936b90bd4bSEmese Revfy 5946b90bd4bSEmese Revfy static inline gasm *as_a_gasm(gimple stmt) 5956b90bd4bSEmese Revfy { 5966b90bd4bSEmese Revfy return as_a<gasm>(stmt); 5976b90bd4bSEmese Revfy } 5986b90bd4bSEmese Revfy 5996b90bd4bSEmese Revfy static inline const gasm *as_a_const_gasm(const_gimple stmt) 6006b90bd4bSEmese Revfy { 6016b90bd4bSEmese Revfy return as_a<const gasm>(stmt); 6026b90bd4bSEmese Revfy } 6036b90bd4bSEmese Revfy 6046b90bd4bSEmese Revfy static inline gassign *as_a_gassign(gimple stmt) 6056b90bd4bSEmese Revfy { 6066b90bd4bSEmese Revfy return stmt; 6076b90bd4bSEmese Revfy } 6086b90bd4bSEmese Revfy 6096b90bd4bSEmese Revfy static inline const gassign *as_a_const_gassign(const_gimple stmt) 6106b90bd4bSEmese Revfy { 6116b90bd4bSEmese Revfy return stmt; 6126b90bd4bSEmese Revfy } 6136b90bd4bSEmese Revfy 6146b90bd4bSEmese Revfy static inline gcall *as_a_gcall(gimple stmt) 6156b90bd4bSEmese Revfy { 6166b90bd4bSEmese Revfy return as_a<gcall>(stmt); 6176b90bd4bSEmese Revfy } 6186b90bd4bSEmese Revfy 6196b90bd4bSEmese Revfy static inline const gcall *as_a_const_gcall(const_gimple stmt) 6206b90bd4bSEmese Revfy { 6216b90bd4bSEmese Revfy return as_a<const gcall>(stmt); 6226b90bd4bSEmese Revfy } 6236b90bd4bSEmese Revfy 6246b90bd4bSEmese Revfy static inline gcond *as_a_gcond(gimple stmt) 6256b90bd4bSEmese Revfy { 6266b90bd4bSEmese Revfy return stmt; 6276b90bd4bSEmese Revfy } 6286b90bd4bSEmese Revfy 6296b90bd4bSEmese Revfy static inline const gcond *as_a_const_gcond(const_gimple stmt) 6306b90bd4bSEmese Revfy { 6316b90bd4bSEmese Revfy return stmt; 6326b90bd4bSEmese Revfy } 6336b90bd4bSEmese Revfy 6346b90bd4bSEmese Revfy static inline gdebug *as_a_gdebug(gimple stmt) 6356b90bd4bSEmese Revfy { 6366b90bd4bSEmese Revfy return stmt; 6376b90bd4bSEmese Revfy } 6386b90bd4bSEmese Revfy 6396b90bd4bSEmese Revfy static inline const gdebug *as_a_const_gdebug(const_gimple stmt) 6406b90bd4bSEmese Revfy { 6416b90bd4bSEmese Revfy return stmt; 6426b90bd4bSEmese Revfy } 6436b90bd4bSEmese Revfy 64481d873a8SKees Cook static inline ggoto *as_a_ggoto(gimple stmt) 64581d873a8SKees Cook { 64681d873a8SKees Cook return stmt; 64781d873a8SKees Cook } 64881d873a8SKees Cook 64981d873a8SKees Cook static inline const ggoto *as_a_const_ggoto(const_gimple stmt) 65081d873a8SKees Cook { 65181d873a8SKees Cook return stmt; 65281d873a8SKees Cook } 65381d873a8SKees Cook 6546b90bd4bSEmese Revfy static inline gphi *as_a_gphi(gimple stmt) 6556b90bd4bSEmese Revfy { 6566b90bd4bSEmese Revfy return as_a<gphi>(stmt); 6576b90bd4bSEmese Revfy } 6586b90bd4bSEmese Revfy 6596b90bd4bSEmese Revfy static inline const gphi *as_a_const_gphi(const_gimple stmt) 6606b90bd4bSEmese Revfy { 6616b90bd4bSEmese Revfy return as_a<const gphi>(stmt); 6626b90bd4bSEmese Revfy } 6636b90bd4bSEmese Revfy 6646b90bd4bSEmese Revfy static inline greturn *as_a_greturn(gimple stmt) 6656b90bd4bSEmese Revfy { 6666b90bd4bSEmese Revfy return stmt; 6676b90bd4bSEmese Revfy } 6686b90bd4bSEmese Revfy 6696b90bd4bSEmese Revfy static inline const greturn *as_a_const_greturn(const_gimple stmt) 6706b90bd4bSEmese Revfy { 6716b90bd4bSEmese Revfy return stmt; 6726b90bd4bSEmese Revfy } 6736b90bd4bSEmese Revfy #endif 6746b90bd4bSEmese Revfy 6756b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 4009 6766b90bd4bSEmese Revfy #define TODO_ggc_collect 0 6776b90bd4bSEmese Revfy #define NODE_SYMBOL(node) (node) 6786b90bd4bSEmese Revfy #define NODE_DECL(node) (node)->decl 6796b90bd4bSEmese Revfy #define cgraph_node_name(node) (node)->name() 6806b90bd4bSEmese Revfy #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias 6818d4973a1SKees Cook 6828d4973a1SKees Cook static inline opt_pass *get_pass_for_id(int id) 6838d4973a1SKees Cook { 6848d4973a1SKees Cook return g->get_passes()->get_pass_for_id(id); 6858d4973a1SKees Cook } 6866b90bd4bSEmese Revfy #endif 6876b90bd4bSEmese Revfy 6886b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 5000 && BUILDING_GCC_VERSION < 6000 6896b90bd4bSEmese Revfy /* gimple related */ 6906b90bd4bSEmese Revfy template <> 6916b90bd4bSEmese Revfy template <> 6926b90bd4bSEmese Revfy inline bool is_a_helper<const gassign *>::test(const_gimple gs) 6936b90bd4bSEmese Revfy { 6946b90bd4bSEmese Revfy return gs->code == GIMPLE_ASSIGN; 6956b90bd4bSEmese Revfy } 6966b90bd4bSEmese Revfy #endif 6976b90bd4bSEmese Revfy 6986b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 5000 6996b90bd4bSEmese Revfy #define TODO_verify_ssa TODO_verify_il 7006b90bd4bSEmese Revfy #define TODO_verify_flow TODO_verify_il 7016b90bd4bSEmese Revfy #define TODO_verify_stmts TODO_verify_il 7026b90bd4bSEmese Revfy #define TODO_verify_rtl_sharing TODO_verify_il 7036b90bd4bSEmese Revfy 7046b90bd4bSEmese Revfy #define INSN_DELETED_P(insn) (insn)->deleted() 7056b90bd4bSEmese Revfy 70681d873a8SKees Cook static inline const char *get_decl_section_name(const_tree decl) 70781d873a8SKees Cook { 70881d873a8SKees Cook return DECL_SECTION_NAME(decl); 70981d873a8SKees Cook } 71081d873a8SKees Cook 7116b90bd4bSEmese Revfy /* symtab/cgraph related */ 7126b90bd4bSEmese Revfy #define debug_cgraph_node(node) (node)->debug() 7136b90bd4bSEmese Revfy #define cgraph_get_node(decl) cgraph_node::get(decl) 7146b90bd4bSEmese Revfy #define cgraph_get_create_node(decl) cgraph_node::get_create(decl) 7156b90bd4bSEmese Revfy #define cgraph_create_node(decl) cgraph_node::create(decl) 7166b90bd4bSEmese Revfy #define cgraph_n_nodes symtab->cgraph_count 7176b90bd4bSEmese Revfy #define cgraph_max_uid symtab->cgraph_max_uid 7186b90bd4bSEmese Revfy #define varpool_get_node(decl) varpool_node::get(decl) 71981d873a8SKees Cook #define dump_varpool_node(file, node) (node)->dump(file) 7206b90bd4bSEmese Revfy 7216b90bd4bSEmese Revfy #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \ 7226b90bd4bSEmese Revfy (caller)->create_edge((callee), (call_stmt), (count), (freq)) 7236b90bd4bSEmese Revfy #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \ 7246b90bd4bSEmese Revfy (caller)->create_edge_including_clones((callee), (old_call_stmt), (call_stmt), (count), (freq), (reason)) 7256b90bd4bSEmese Revfy 7266b90bd4bSEmese Revfy typedef struct cgraph_node *cgraph_node_ptr; 7276b90bd4bSEmese Revfy typedef struct cgraph_edge *cgraph_edge_p; 7286b90bd4bSEmese Revfy typedef struct varpool_node *varpool_node_ptr; 7296b90bd4bSEmese Revfy 7306b90bd4bSEmese Revfy static inline void change_decl_assembler_name(tree decl, tree name) 7316b90bd4bSEmese Revfy { 7326b90bd4bSEmese Revfy symtab->change_decl_assembler_name(decl, name); 7336b90bd4bSEmese Revfy } 7346b90bd4bSEmese Revfy 7356b90bd4bSEmese Revfy static inline void varpool_finalize_decl(tree decl) 7366b90bd4bSEmese Revfy { 7376b90bd4bSEmese Revfy varpool_node::finalize_decl(decl); 7386b90bd4bSEmese Revfy } 7396b90bd4bSEmese Revfy 7406b90bd4bSEmese Revfy static inline void varpool_add_new_variable(tree decl) 7416b90bd4bSEmese Revfy { 7426b90bd4bSEmese Revfy varpool_node::add(decl); 7436b90bd4bSEmese Revfy } 7446b90bd4bSEmese Revfy 7456b90bd4bSEmese Revfy static inline unsigned int rebuild_cgraph_edges(void) 7466b90bd4bSEmese Revfy { 7476b90bd4bSEmese Revfy return cgraph_edge::rebuild_edges(); 7486b90bd4bSEmese Revfy } 7496b90bd4bSEmese Revfy 7506b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability) 7516b90bd4bSEmese Revfy { 7526b90bd4bSEmese Revfy return node->function_symbol(availability); 7536b90bd4bSEmese Revfy } 7546b90bd4bSEmese Revfy 7556b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL) 7566b90bd4bSEmese Revfy { 7576b90bd4bSEmese Revfy return node->ultimate_alias_target(availability); 7586b90bd4bSEmese Revfy } 7596b90bd4bSEmese Revfy 7606b90bd4bSEmese Revfy static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node) 7616b90bd4bSEmese Revfy { 7626b90bd4bSEmese Revfy return node->only_called_directly_p(); 7636b90bd4bSEmese Revfy } 7646b90bd4bSEmese Revfy 7656b90bd4bSEmese Revfy static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node) 7666b90bd4bSEmese Revfy { 7676b90bd4bSEmese Revfy return node->get_availability(); 7686b90bd4bSEmese Revfy } 7696b90bd4bSEmese Revfy 7706b90bd4bSEmese Revfy static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node) 7716b90bd4bSEmese Revfy { 7726b90bd4bSEmese Revfy return node->get_alias_target(); 7736b90bd4bSEmese Revfy } 7746b90bd4bSEmese Revfy 77581d873a8SKees Cook static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable) 77681d873a8SKees Cook { 77781d873a8SKees Cook return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable); 77881d873a8SKees Cook } 77981d873a8SKees Cook 7806b90bd4bSEmese Revfy static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data) 7816b90bd4bSEmese Revfy { 7826b90bd4bSEmese Revfy return symtab->add_cgraph_insertion_hook(hook, data); 7836b90bd4bSEmese Revfy } 7846b90bd4bSEmese Revfy 7856b90bd4bSEmese Revfy static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry) 7866b90bd4bSEmese Revfy { 7876b90bd4bSEmese Revfy symtab->remove_cgraph_insertion_hook(entry); 7886b90bd4bSEmese Revfy } 7896b90bd4bSEmese Revfy 7906b90bd4bSEmese Revfy static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data) 7916b90bd4bSEmese Revfy { 7926b90bd4bSEmese Revfy return symtab->add_cgraph_removal_hook(hook, data); 7936b90bd4bSEmese Revfy } 7946b90bd4bSEmese Revfy 7956b90bd4bSEmese Revfy static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry) 7966b90bd4bSEmese Revfy { 7976b90bd4bSEmese Revfy symtab->remove_cgraph_removal_hook(entry); 7986b90bd4bSEmese Revfy } 7996b90bd4bSEmese Revfy 8006b90bd4bSEmese Revfy static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data) 8016b90bd4bSEmese Revfy { 8026b90bd4bSEmese Revfy return symtab->add_cgraph_duplication_hook(hook, data); 8036b90bd4bSEmese Revfy } 8046b90bd4bSEmese Revfy 8056b90bd4bSEmese Revfy static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry) 8066b90bd4bSEmese Revfy { 8076b90bd4bSEmese Revfy symtab->remove_cgraph_duplication_hook(entry); 8086b90bd4bSEmese Revfy } 8096b90bd4bSEmese Revfy 8106b90bd4bSEmese Revfy static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2) 8116b90bd4bSEmese Revfy { 8126b90bd4bSEmese Revfy symtab->call_cgraph_duplication_hooks(node, node2); 8136b90bd4bSEmese Revfy } 8146b90bd4bSEmese Revfy 8156b90bd4bSEmese Revfy static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2) 8166b90bd4bSEmese Revfy { 8176b90bd4bSEmese Revfy symtab->call_edge_duplication_hooks(cs1, cs2); 8186b90bd4bSEmese Revfy } 8196b90bd4bSEmese Revfy 8206b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000 8216b90bd4bSEmese Revfy typedef gimple *gimple_ptr; 8226b90bd4bSEmese Revfy typedef const gimple *const_gimple_ptr; 8236b90bd4bSEmese Revfy #define gimple gimple_ptr 8246b90bd4bSEmese Revfy #define const_gimple const_gimple_ptr 8256b90bd4bSEmese Revfy #undef CONST_CAST_GIMPLE 8266b90bd4bSEmese Revfy #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X)) 8276b90bd4bSEmese Revfy #endif 8286b90bd4bSEmese Revfy 8296b90bd4bSEmese Revfy /* gimple related */ 8306b90bd4bSEmese Revfy static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL) 8316b90bd4bSEmese Revfy { 8326b90bd4bSEmese Revfy return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT); 8336b90bd4bSEmese Revfy } 8346b90bd4bSEmese Revfy 8356b90bd4bSEmese Revfy template <> 8366b90bd4bSEmese Revfy template <> 83781d873a8SKees Cook inline bool is_a_helper<const ggoto *>::test(const_gimple gs) 83881d873a8SKees Cook { 83981d873a8SKees Cook return gs->code == GIMPLE_GOTO; 84081d873a8SKees Cook } 84181d873a8SKees Cook 84281d873a8SKees Cook template <> 84381d873a8SKees Cook template <> 8446b90bd4bSEmese Revfy inline bool is_a_helper<const greturn *>::test(const_gimple gs) 8456b90bd4bSEmese Revfy { 8466b90bd4bSEmese Revfy return gs->code == GIMPLE_RETURN; 8476b90bd4bSEmese Revfy } 8486b90bd4bSEmese Revfy 8496b90bd4bSEmese Revfy static inline gasm *as_a_gasm(gimple stmt) 8506b90bd4bSEmese Revfy { 8516b90bd4bSEmese Revfy return as_a<gasm *>(stmt); 8526b90bd4bSEmese Revfy } 8536b90bd4bSEmese Revfy 8546b90bd4bSEmese Revfy static inline const gasm *as_a_const_gasm(const_gimple stmt) 8556b90bd4bSEmese Revfy { 8566b90bd4bSEmese Revfy return as_a<const gasm *>(stmt); 8576b90bd4bSEmese Revfy } 8586b90bd4bSEmese Revfy 8596b90bd4bSEmese Revfy static inline gassign *as_a_gassign(gimple stmt) 8606b90bd4bSEmese Revfy { 8616b90bd4bSEmese Revfy return as_a<gassign *>(stmt); 8626b90bd4bSEmese Revfy } 8636b90bd4bSEmese Revfy 8646b90bd4bSEmese Revfy static inline const gassign *as_a_const_gassign(const_gimple stmt) 8656b90bd4bSEmese Revfy { 8666b90bd4bSEmese Revfy return as_a<const gassign *>(stmt); 8676b90bd4bSEmese Revfy } 8686b90bd4bSEmese Revfy 8696b90bd4bSEmese Revfy static inline gcall *as_a_gcall(gimple stmt) 8706b90bd4bSEmese Revfy { 8716b90bd4bSEmese Revfy return as_a<gcall *>(stmt); 8726b90bd4bSEmese Revfy } 8736b90bd4bSEmese Revfy 8746b90bd4bSEmese Revfy static inline const gcall *as_a_const_gcall(const_gimple stmt) 8756b90bd4bSEmese Revfy { 8766b90bd4bSEmese Revfy return as_a<const gcall *>(stmt); 8776b90bd4bSEmese Revfy } 8786b90bd4bSEmese Revfy 87981d873a8SKees Cook static inline ggoto *as_a_ggoto(gimple stmt) 88081d873a8SKees Cook { 88181d873a8SKees Cook return as_a<ggoto *>(stmt); 88281d873a8SKees Cook } 88381d873a8SKees Cook 88481d873a8SKees Cook static inline const ggoto *as_a_const_ggoto(const_gimple stmt) 88581d873a8SKees Cook { 88681d873a8SKees Cook return as_a<const ggoto *>(stmt); 88781d873a8SKees Cook } 88881d873a8SKees Cook 8896b90bd4bSEmese Revfy static inline gphi *as_a_gphi(gimple stmt) 8906b90bd4bSEmese Revfy { 8916b90bd4bSEmese Revfy return as_a<gphi *>(stmt); 8926b90bd4bSEmese Revfy } 8936b90bd4bSEmese Revfy 8946b90bd4bSEmese Revfy static inline const gphi *as_a_const_gphi(const_gimple stmt) 8956b90bd4bSEmese Revfy { 8966b90bd4bSEmese Revfy return as_a<const gphi *>(stmt); 8976b90bd4bSEmese Revfy } 8986b90bd4bSEmese Revfy 8996b90bd4bSEmese Revfy static inline greturn *as_a_greturn(gimple stmt) 9006b90bd4bSEmese Revfy { 9016b90bd4bSEmese Revfy return as_a<greturn *>(stmt); 9026b90bd4bSEmese Revfy } 9036b90bd4bSEmese Revfy 9046b90bd4bSEmese Revfy static inline const greturn *as_a_const_greturn(const_gimple stmt) 9056b90bd4bSEmese Revfy { 9066b90bd4bSEmese Revfy return as_a<const greturn *>(stmt); 9076b90bd4bSEmese Revfy } 9086b90bd4bSEmese Revfy 9096b90bd4bSEmese Revfy /* IPA/LTO related */ 9106b90bd4bSEmese Revfy #define ipa_ref_list_referring_iterate(L, I, P) \ 9116b90bd4bSEmese Revfy (L)->referring.iterate((I), &(P)) 9126b90bd4bSEmese Revfy #define ipa_ref_list_reference_iterate(L, I, P) \ 9136b90bd4bSEmese Revfy (L)->reference.iterate((I), &(P)) 9146b90bd4bSEmese Revfy 9156b90bd4bSEmese Revfy static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref) 9166b90bd4bSEmese Revfy { 9176b90bd4bSEmese Revfy return dyn_cast<cgraph_node_ptr>(ref->referring); 9186b90bd4bSEmese Revfy } 9196b90bd4bSEmese Revfy 9206b90bd4bSEmese Revfy static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt) 9216b90bd4bSEmese Revfy { 9226b90bd4bSEmese Revfy referring_node->remove_stmt_references(stmt); 9236b90bd4bSEmese Revfy } 9246b90bd4bSEmese Revfy #endif 9256b90bd4bSEmese Revfy 9266b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION < 6000 9276b90bd4bSEmese Revfy #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \ 9286b90bd4bSEmese Revfy get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning) 9296b90bd4bSEmese Revfy #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1)) 9306b90bd4bSEmese Revfy #endif 9316b90bd4bSEmese Revfy 9326b90bd4bSEmese Revfy #if BUILDING_GCC_VERSION >= 6000 9336b90bd4bSEmese Revfy #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1)) 9346b90bd4bSEmese Revfy #endif 9356b90bd4bSEmese Revfy 9366b90bd4bSEmese Revfy #ifdef __cplusplus 9376b90bd4bSEmese Revfy static inline void debug_tree(const_tree t) 9386b90bd4bSEmese Revfy { 9396b90bd4bSEmese Revfy debug_tree(CONST_CAST_TREE(t)); 9406b90bd4bSEmese Revfy } 9416b90bd4bSEmese Revfy 9426b90bd4bSEmese Revfy static inline void debug_gimple_stmt(const_gimple s) 9436b90bd4bSEmese Revfy { 9446b90bd4bSEmese Revfy debug_gimple_stmt(CONST_CAST_GIMPLE(s)); 9456b90bd4bSEmese Revfy } 9466b90bd4bSEmese Revfy #else 9476b90bd4bSEmese Revfy #define debug_tree(t) debug_tree(CONST_CAST_TREE(t)) 9486b90bd4bSEmese Revfy #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) 9496b90bd4bSEmese Revfy #endif 9506b90bd4bSEmese Revfy 95181d873a8SKees Cook #if BUILDING_GCC_VERSION >= 7000 95281d873a8SKees Cook #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \ 95381d873a8SKees Cook get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep) 95481d873a8SKees Cook #endif 95581d873a8SKees Cook 956313dd1b6SKees Cook #if BUILDING_GCC_VERSION < 7000 957313dd1b6SKees Cook #define SET_DECL_ALIGN(decl, align) DECL_ALIGN(decl) = (align) 958313dd1b6SKees Cook #define SET_DECL_MODE(decl, mode) DECL_MODE(decl) = (mode) 959313dd1b6SKees Cook #endif 960313dd1b6SKees Cook 9616b90bd4bSEmese Revfy #endif 962