| 1 |
|
| 2 | #ifndef GCC_COMMON_H_INCLUDED
|
| 3 | #define GCC_COMMON_H_INCLUDED
|
| 4 |
|
| 5 | #include "bversion.h"
|
| 6 | #include "gcc-plugin.h"
|
| 7 | #include "plugin-version.h"
|
| 8 | #include "config.h"
|
| 9 | #include "system.h"
|
| 10 | #include "coretypes.h"
|
| 11 | #include "tm.h"
|
| 12 | #include "line-map.h"
|
| 13 | #include "input.h"
|
| 14 | #include "tree.h"
|
| 15 |
|
| 16 | #include "tree-inline.h"
|
| 17 | #include "version.h"
|
| 18 | #include "rtl.h"
|
| 19 | #include "tm_p.h"
|
| 20 | #include "flags.h"
|
| 21 | #include "hard-reg-set.h"
|
| 22 | #include "output.h"
|
| 23 | #include "except.h"
|
| 24 | #include "function.h"
|
| 25 | #include "toplev.h"
|
| 26 | #include "expr.h"
|
| 27 | #include "basic-block.h"
|
| 28 | #include "intl.h"
|
| 29 | #include "ggc.h"
|
| 30 | #include "timevar.h"
|
| 31 |
|
| 32 | #if BUILDING_GCC_VERSION < 10000
|
| 33 | #include "params.h"
|
| 34 | #endif
|
| 35 |
|
| 36 | #include "hash-map.h"
|
| 37 |
|
| 38 | #include "memmodel.h"
|
| 39 | #include "emit-rtl.h"
|
| 40 | #include "debug.h"
|
| 41 | #include "target.h"
|
| 42 | #include "langhooks.h"
|
| 43 | #include "cfgloop.h"
|
| 44 | #include "cgraph.h"
|
| 45 | #include "opts.h"
|
| 46 | #include "tree-pretty-print.h"
|
| 47 | #include "gimple-pretty-print.h"
|
| 48 | #include "c-family/c-common.h"
|
| 49 | #include "tree-cfgcleanup.h"
|
| 50 | #include "tree-ssa-operands.h"
|
| 51 | #include "tree-into-ssa.h"
|
| 52 | #include "is-a.h"
|
| 53 | #include "diagnostic.h"
|
| 54 | #include "tree-dump.h"
|
| 55 | #include "tree-pass.h"
|
| 56 | #include "pass_manager.h"
|
| 57 | #include "predict.h"
|
| 58 | #include "ipa-utils.h"
|
| 59 | #include "stringpool.h"
|
| 60 | #include "attribs.h"
|
| 61 | #include "varasm.h"
|
| 62 | #include "stor-layout.h"
|
| 63 | #include "internal-fn.h"
|
| 64 | #include "gimple.h"
|
| 65 | #include "gimple-expr.h"
|
| 66 | #include "gimple-iterator.h"
|
| 67 | #include "gimple-fold.h"
|
| 68 | #include "context.h"
|
| 69 | #include "tree-ssa-alias.h"
|
| 70 | #include "tree-ssa.h"
|
| 71 | #include "tree-vrp.h"
|
| 72 | #include "tree-ssanames.h"
|
| 73 | #include "print-tree.h"
|
| 74 | #include "tree-eh.h"
|
| 75 | #include "stmt.h"
|
| 76 | #include "gimplify.h"
|
| 77 | #include "tree-phinodes.h"
|
| 78 | #include "tree-cfg.h"
|
| 79 | #include "gimple-ssa.h"
|
| 80 | #include "ssa-iterators.h"
|
| 81 |
|
| 82 | #include "builtins.h"
|
| 83 |
|
| 84 |
|
| 85 | void debug_dominance_info(enum cdi_direction dir);
|
| 86 | void debug_dominance_tree(enum cdi_direction dir, basic_block root);
|
| 87 |
|
| 88 | #ifndef __unused
|
| 89 | #define __unused __attribute__((__unused__))
|
| 90 | #endif
|
| 91 | #ifndef __visible
|
| 92 | #define __visible __attribute__((visibility("default")))
|
| 93 | #endif
|
| 94 |
|
| 95 | #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
|
| 96 | #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
|
| 97 | #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
|
| 98 | #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
|
| 99 |
|
| 100 |
|
| 101 | #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
|
| 102 |
|
| 103 | static inline tree build_const_char_string(int len, const char *str)
|
| 104 | {
|
| 105 | tree cstr, elem, index, type;
|
| 106 |
|
| 107 | cstr = build_string(len, str);
|
| 108 | elem = build_type_variant(char_type_node, 1, 0);
|
| 109 | index = build_index_type(size_int(len - 1));
|
| 110 | type = build_array_type(elem, index);
|
| 111 | TREE_TYPE(cstr) = type;
|
| 112 | TREE_CONSTANT(cstr) = 1;
|
| 113 | TREE_READONLY(cstr) = 1;
|
| 114 | TREE_STATIC(cstr) = 1;
|
| 115 | return cstr;
|
| 116 | }
|
| 117 |
|
| 118 | static inline void __add_type_attr(tree type, const char *attr, tree args)
|
| 119 | {
|
| 120 | tree oldattr;
|
| 121 |
|
| 122 | if (type == NULL_TREE)
|
| 123 | return;
|
| 124 | oldattr = lookup_attribute(attr, TYPE_ATTRIBUTES(type));
|
| 125 | if (oldattr != NULL_TREE) {
|
| 126 | gcc_assert(TREE_VALUE(oldattr) == args || TREE_VALUE(TREE_VALUE(oldattr)) == TREE_VALUE(args));
|
| 127 | return;
|
| 128 | }
|
| 129 |
|
| 130 | TYPE_ATTRIBUTES(type) = copy_list(TYPE_ATTRIBUTES(type));
|
| 131 | TYPE_ATTRIBUTES(type) = tree_cons(get_identifier(attr), args, TYPE_ATTRIBUTES(type));
|
| 132 | }
|
| 133 |
|
| 134 | static inline void add_type_attr(tree type, const char *attr, tree args)
|
| 135 | {
|
| 136 | tree main_variant = TYPE_MAIN_VARIANT(type);
|
| 137 |
|
| 138 | __add_type_attr(TYPE_CANONICAL(type), attr, args);
|
| 139 | __add_type_attr(TYPE_CANONICAL(main_variant), attr, args);
|
| 140 | __add_type_attr(main_variant, attr, args);
|
| 141 |
|
| 142 | for (type = TYPE_NEXT_VARIANT(main_variant); type; type = TYPE_NEXT_VARIANT(type)) {
|
| 143 | if (!lookup_attribute(attr, TYPE_ATTRIBUTES(type)))
|
| 144 | TYPE_ATTRIBUTES(type) = TYPE_ATTRIBUTES(main_variant);
|
| 145 |
|
| 146 | __add_type_attr(TYPE_CANONICAL(type), attr, args);
|
| 147 | }
|
| 148 | }
|
| 149 |
|
| 150 | #define PASS_INFO(NAME, REF, ID, POS) \
|
| 151 | struct register_pass_info NAME##_pass_info = { \
|
| 152 | .pass = make_##NAME##_pass(), \
|
| 153 | .reference_pass_name = REF, \
|
| 154 | .ref_pass_instance_number = ID, \
|
| 155 | .pos_op = POS, \
|
| 156 | }
|
| 157 |
|
| 158 | #define add_referenced_var(var)
|
| 159 | #define mark_sym_for_renaming(var)
|
| 160 | #define varpool_mark_needed_node(node)
|
| 161 | #define create_var_ann(var)
|
| 162 | #define TODO_dump_func 0
|
| 163 | #define TODO_dump_cgraph 0
|
| 164 |
|
| 165 | #define TODO_ggc_collect 0
|
| 166 | #define NODE_SYMBOL(node) (node)
|
| 167 | #define NODE_DECL(node) (node)->decl
|
| 168 | #define cgraph_node_name(node) (node)->name()
|
| 169 | #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
|
| 170 |
|
| 171 | static inline opt_pass *get_pass_for_id(int id)
|
| 172 | {
|
| 173 | return g->get_passes()->get_pass_for_id(id);
|
| 174 | }
|
| 175 |
|
| 176 | #if BUILDING_GCC_VERSION < 16000
|
| 177 | #define TODO_verify_ssa TODO_verify_il
|
| 178 | #define TODO_verify_flow TODO_verify_il
|
| 179 | #define TODO_verify_stmts TODO_verify_il
|
| 180 | #define TODO_verify_rtl_sharing TODO_verify_il
|
| 181 | #else
|
| 182 | #define TODO_verify_ssa 0
|
| 183 | #define TODO_verify_flow 0
|
| 184 | #define TODO_verify_stmts 0
|
| 185 | #define TODO_verify_rtl_sharing 0
|
| 186 | #endif
|
| 187 |
|
| 188 | #define INSN_DELETED_P(insn) (insn)->deleted()
|
| 189 |
|
| 190 | static inline const char *get_decl_section_name(const_tree decl)
|
| 191 | {
|
| 192 | return DECL_SECTION_NAME(decl);
|
| 193 | }
|
| 194 |
|
| 195 |
|
| 196 | #define debug_cgraph_node(node) (node)->debug()
|
| 197 | #define cgraph_get_node(decl) cgraph_node::get(decl)
|
| 198 | #define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
|
| 199 | #define cgraph_create_node(decl) cgraph_node::create(decl)
|
| 200 | #define cgraph_n_nodes symtab->cgraph_count
|
| 201 | #define cgraph_max_uid symtab->cgraph_max_uid
|
| 202 | #define varpool_get_node(decl) varpool_node::get(decl)
|
| 203 | #define dump_varpool_node(file, node) (node)->dump(file)
|
| 204 |
|
| 205 | #define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
|
| 206 | (caller)->create_edge((callee), (call_stmt), (count))
|
| 207 |
|
| 208 | #define cgraph_create_edge_including_clones(caller, callee, \
|
| 209 | old_call_stmt, call_stmt, count, freq, reason) \
|
| 210 | (caller)->create_edge_including_clones((callee), \
|
| 211 | (old_call_stmt), (call_stmt), (count), (reason))
|
| 212 |
|
| 213 | typedef struct cgraph_node *cgraph_node_ptr;
|
| 214 | typedef struct cgraph_edge *cgraph_edge_p;
|
| 215 | typedef struct varpool_node *varpool_node_ptr;
|
| 216 |
|
| 217 | static inline void change_decl_assembler_name(tree decl, tree name)
|
| 218 | {
|
| 219 | symtab->change_decl_assembler_name(decl, name);
|
| 220 | }
|
| 221 |
|
| 222 | static inline void varpool_finalize_decl(tree decl)
|
| 223 | {
|
| 224 | varpool_node::finalize_decl(decl);
|
| 225 | }
|
| 226 |
|
| 227 | static inline void varpool_add_new_variable(tree decl)
|
| 228 | {
|
| 229 | varpool_node::add(decl);
|
| 230 | }
|
| 231 |
|
| 232 | static inline unsigned int rebuild_cgraph_edges(void)
|
| 233 | {
|
| 234 | return cgraph_edge::rebuild_edges();
|
| 235 | }
|
| 236 |
|
| 237 | static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
|
| 238 | {
|
| 239 | return node->function_symbol(availability);
|
| 240 | }
|
| 241 |
|
| 242 | static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
|
| 243 | {
|
| 244 | return node->ultimate_alias_target(availability);
|
| 245 | }
|
| 246 |
|
| 247 | static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
|
| 248 | {
|
| 249 | return node->only_called_directly_p();
|
| 250 | }
|
| 251 |
|
| 252 | static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
|
| 253 | {
|
| 254 | return node->get_availability();
|
| 255 | }
|
| 256 |
|
| 257 | static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
|
| 258 | {
|
| 259 | return node->get_alias_target();
|
| 260 | }
|
| 261 |
|
| 262 | static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
|
| 263 | {
|
| 264 | return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
|
| 265 | }
|
| 266 |
|
| 267 | static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
|
| 268 | {
|
| 269 | return symtab->add_cgraph_insertion_hook(hook, data);
|
| 270 | }
|
| 271 |
|
| 272 | static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
|
| 273 | {
|
| 274 | symtab->remove_cgraph_insertion_hook(entry);
|
| 275 | }
|
| 276 |
|
| 277 | static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
|
| 278 | {
|
| 279 | return symtab->add_cgraph_removal_hook(hook, data);
|
| 280 | }
|
| 281 |
|
| 282 | static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
|
| 283 | {
|
| 284 | symtab->remove_cgraph_removal_hook(entry);
|
| 285 | }
|
| 286 |
|
| 287 | static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
|
| 288 | {
|
| 289 | return symtab->add_cgraph_duplication_hook(hook, data);
|
| 290 | }
|
| 291 |
|
| 292 | static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
|
| 293 | {
|
| 294 | symtab->remove_cgraph_duplication_hook(entry);
|
| 295 | }
|
| 296 |
|
| 297 | static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
|
| 298 | {
|
| 299 | symtab->call_cgraph_duplication_hooks(node, node2);
|
| 300 | }
|
| 301 |
|
| 302 | static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
|
| 303 | {
|
| 304 | symtab->call_edge_duplication_hooks(cs1, cs2);
|
| 305 | }
|
| 306 |
|
| 307 | typedef gimple *gimple_ptr;
|
| 308 | typedef const gimple *const_gimple_ptr;
|
| 309 | #define gimple gimple_ptr
|
| 310 | #define const_gimple const_gimple_ptr
|
| 311 | #undef CONST_CAST_GIMPLE
|
| 312 | #define CONST_CAST_GIMPLE(X) const_cast<gimple>((X))
|
| 313 | #undef CONST_CAST_TREE
|
| 314 | #define CONST_CAST_TREE(X) const_cast<tree>((X))
|
| 315 |
|
| 316 |
|
| 317 | static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
|
| 318 | {
|
| 319 | return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
|
| 320 | }
|
| 321 |
|
| 322 | #if BUILDING_GCC_VERSION < 10000
|
| 323 | template <>
|
| 324 | template <>
|
| 325 | inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
|
| 326 | {
|
| 327 | return gs->code == GIMPLE_GOTO;
|
| 328 | }
|
| 329 |
|
| 330 | template <>
|
| 331 | template <>
|
| 332 | inline bool is_a_helper<const greturn *>::test(const_gimple gs)
|
| 333 | {
|
| 334 | return gs->code == GIMPLE_RETURN;
|
| 335 | }
|
| 336 | #endif
|
| 337 |
|
| 338 | static inline gasm *as_a_gasm(gimple stmt)
|
| 339 | {
|
| 340 | return as_a<gasm *>(stmt);
|
| 341 | }
|
| 342 |
|
| 343 | static inline const gasm *as_a_const_gasm(const_gimple stmt)
|
| 344 | {
|
| 345 | return as_a<const gasm *>(stmt);
|
| 346 | }
|
| 347 |
|
| 348 | static inline gassign *as_a_gassign(gimple stmt)
|
| 349 | {
|
| 350 | return as_a<gassign *>(stmt);
|
| 351 | }
|
| 352 |
|
| 353 | static inline const gassign *as_a_const_gassign(const_gimple stmt)
|
| 354 | {
|
| 355 | return as_a<const gassign *>(stmt);
|
| 356 | }
|
| 357 |
|
| 358 | static inline gcall *as_a_gcall(gimple stmt)
|
| 359 | {
|
| 360 | return as_a<gcall *>(stmt);
|
| 361 | }
|
| 362 |
|
| 363 | static inline const gcall *as_a_const_gcall(const_gimple stmt)
|
| 364 | {
|
| 365 | return as_a<const gcall *>(stmt);
|
| 366 | }
|
| 367 |
|
| 368 | static inline ggoto *as_a_ggoto(gimple stmt)
|
| 369 | {
|
| 370 | return as_a<ggoto *>(stmt);
|
| 371 | }
|
| 372 |
|
| 373 | static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
|
| 374 | {
|
| 375 | return as_a<const ggoto *>(stmt);
|
| 376 | }
|
| 377 |
|
| 378 | static inline gphi *as_a_gphi(gimple stmt)
|
| 379 | {
|
| 380 | return as_a<gphi *>(stmt);
|
| 381 | }
|
| 382 |
|
| 383 | static inline const gphi *as_a_const_gphi(const_gimple stmt)
|
| 384 | {
|
| 385 | return as_a<const gphi *>(stmt);
|
| 386 | }
|
| 387 |
|
| 388 | static inline greturn *as_a_greturn(gimple stmt)
|
| 389 | {
|
| 390 | return as_a<greturn *>(stmt);
|
| 391 | }
|
| 392 |
|
| 393 | static inline const greturn *as_a_const_greturn(const_gimple stmt)
|
| 394 | {
|
| 395 | return as_a<const greturn *>(stmt);
|
| 396 | }
|
| 397 |
|
| 398 |
|
| 399 | #define ipa_ref_list_referring_iterate(L, I, P) \
|
| 400 | (L)->referring.iterate((I), &(P))
|
| 401 | #define ipa_ref_list_reference_iterate(L, I, P) \
|
| 402 | (L)->reference.iterate((I), &(P))
|
| 403 |
|
| 404 | static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
|
| 405 | {
|
| 406 | return dyn_cast<cgraph_node_ptr>(ref->referring);
|
| 407 | }
|
| 408 |
|
| 409 | static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
|
| 410 | {
|
| 411 | referring_node->remove_stmt_references(stmt);
|
| 412 | }
|
| 413 |
|
| 414 | #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
|
| 415 |
|
| 416 | #ifdef __cplusplus
|
| 417 | static inline void debug_tree(const_tree t)
|
| 418 | {
|
| 419 | debug_tree(CONST_CAST_TREE(t));
|
| 420 | }
|
| 421 |
|
| 422 | static inline void debug_gimple_stmt(const_gimple s)
|
| 423 | {
|
| 424 | debug_gimple_stmt(CONST_CAST_GIMPLE(s));
|
| 425 | }
|
| 426 | #else
|
| 427 | #define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
|
| 428 | #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
|
| 429 | #endif
|
| 430 |
|
| 431 | #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
|
| 432 | get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
|
| 433 |
|
| 434 | #if BUILDING_GCC_VERSION >= 14000
|
| 435 | #define last_stmt(x) last_nondebug_stmt(x)
|
| 436 | #endif
|
| 437 |
|
| 438 | #endif
|