gcc-common.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. #ifndef GCC_COMMON_H_INCLUDED
  2. #define GCC_COMMON_H_INCLUDED
  3. #include "bversion.h"
  4. #if BUILDING_GCC_VERSION >= 6000
  5. #include "gcc-plugin.h"
  6. #else
  7. #include "plugin.h"
  8. #endif
  9. #include "plugin-version.h"
  10. #include "config.h"
  11. #include "system.h"
  12. #include "coretypes.h"
  13. #include "tm.h"
  14. #include "line-map.h"
  15. #include "input.h"
  16. #include "tree.h"
  17. #include "tree-inline.h"
  18. #include "version.h"
  19. #include "rtl.h"
  20. #include "tm_p.h"
  21. #include "flags.h"
  22. #include "hard-reg-set.h"
  23. #include "output.h"
  24. #include "except.h"
  25. #include "function.h"
  26. #include "toplev.h"
  27. #include "basic-block.h"
  28. #include "intl.h"
  29. #include "ggc.h"
  30. #include "timevar.h"
  31. #include "params.h"
  32. #if BUILDING_GCC_VERSION <= 4009
  33. #include "pointer-set.h"
  34. #else
  35. #include "hash-map.h"
  36. #endif
  37. #include "emit-rtl.h"
  38. #include "debug.h"
  39. #include "target.h"
  40. #include "langhooks.h"
  41. #include "cfgloop.h"
  42. #include "cgraph.h"
  43. #include "opts.h"
  44. #if BUILDING_GCC_VERSION == 4005
  45. #include <sys/mman.h>
  46. #endif
  47. #if BUILDING_GCC_VERSION >= 4007
  48. #include "tree-pretty-print.h"
  49. #include "gimple-pretty-print.h"
  50. #endif
  51. #if BUILDING_GCC_VERSION >= 4006
  52. #include "c-family/c-common.h"
  53. #else
  54. #include "c-common.h"
  55. #endif
  56. #if BUILDING_GCC_VERSION <= 4008
  57. #include "tree-flow.h"
  58. #else
  59. #include "tree-cfgcleanup.h"
  60. #include "tree-ssa-operands.h"
  61. #include "tree-into-ssa.h"
  62. #endif
  63. #if BUILDING_GCC_VERSION >= 4008
  64. #include "is-a.h"
  65. #endif
  66. #include "diagnostic.h"
  67. #include "tree-dump.h"
  68. #include "tree-pass.h"
  69. #include "predict.h"
  70. #include "ipa-utils.h"
  71. #if BUILDING_GCC_VERSION >= 4009
  72. #include "attribs.h"
  73. #include "varasm.h"
  74. #include "stor-layout.h"
  75. #include "internal-fn.h"
  76. #include "gimple-expr.h"
  77. #include "gimple-fold.h"
  78. #include "context.h"
  79. #include "tree-ssa-alias.h"
  80. #include "tree-ssa.h"
  81. #include "stringpool.h"
  82. #include "tree-ssanames.h"
  83. #include "print-tree.h"
  84. #include "tree-eh.h"
  85. #include "stmt.h"
  86. #include "gimplify.h"
  87. #endif
  88. #include "gimple.h"
  89. #if BUILDING_GCC_VERSION >= 4009
  90. #include "tree-ssa-operands.h"
  91. #include "tree-phinodes.h"
  92. #include "tree-cfg.h"
  93. #include "gimple-iterator.h"
  94. #include "gimple-ssa.h"
  95. #include "ssa-iterators.h"
  96. #endif
  97. #if BUILDING_GCC_VERSION >= 5000
  98. #include "builtins.h"
  99. #endif
  100. /* #include "expr.h" where are you... */
  101. extern rtx emit_move_insn(rtx x, rtx y);
  102. /* missing from basic_block.h... */
  103. extern void debug_dominance_info(enum cdi_direction dir);
  104. extern void debug_dominance_tree(enum cdi_direction dir, basic_block root);
  105. #if BUILDING_GCC_VERSION == 4006
  106. extern void debug_gimple_stmt(gimple);
  107. extern void debug_gimple_seq(gimple_seq);
  108. extern void print_gimple_seq(FILE *, gimple_seq, int, int);
  109. extern void print_gimple_stmt(FILE *, gimple, int, int);
  110. extern void print_gimple_expr(FILE *, gimple, int, int);
  111. extern void dump_gimple_stmt(pretty_printer *, gimple, int, int);
  112. #endif
  113. #define __unused __attribute__((__unused__))
  114. #define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
  115. #define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
  116. #define TYPE_NAME_POINTER(node) IDENTIFIER_POINTER(TYPE_NAME(node))
  117. #define TYPE_NAME_LENGTH(node) IDENTIFIER_LENGTH(TYPE_NAME(node))
  118. /* should come from c-tree.h if only it were installed for gcc 4.5... */
  119. #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
  120. #if BUILDING_GCC_VERSION == 4005
  121. #define FOR_EACH_LOCAL_DECL(FUN, I, D) \
  122. for (tree vars = (FUN)->local_decls, (I) = 0; \
  123. vars && ((D) = TREE_VALUE(vars)); \
  124. vars = TREE_CHAIN(vars), (I)++)
  125. #define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
  126. #define FOR_EACH_VEC_ELT(T, V, I, P) \
  127. for (I = 0; VEC_iterate(T, (V), (I), (P)); ++(I))
  128. #define TODO_rebuild_cgraph_edges 0
  129. #define SCOPE_FILE_SCOPE_P(EXP) (!(EXP))
  130. #ifndef O_BINARY
  131. #define O_BINARY 0
  132. #endif
  133. typedef struct varpool_node *varpool_node_ptr;
  134. static inline bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
  135. {
  136. tree fndecl;
  137. if (!is_gimple_call(stmt))
  138. return false;
  139. fndecl = gimple_call_fndecl(stmt);
  140. if (!fndecl || DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
  141. return false;
  142. return DECL_FUNCTION_CODE(fndecl) == code;
  143. }
  144. static inline bool is_simple_builtin(tree decl)
  145. {
  146. if (decl && DECL_BUILT_IN_CLASS(decl) != BUILT_IN_NORMAL)
  147. return false;
  148. switch (DECL_FUNCTION_CODE(decl)) {
  149. /* Builtins that expand to constants. */
  150. case BUILT_IN_CONSTANT_P:
  151. case BUILT_IN_EXPECT:
  152. case BUILT_IN_OBJECT_SIZE:
  153. case BUILT_IN_UNREACHABLE:
  154. /* Simple register moves or loads from stack. */
  155. case BUILT_IN_RETURN_ADDRESS:
  156. case BUILT_IN_EXTRACT_RETURN_ADDR:
  157. case BUILT_IN_FROB_RETURN_ADDR:
  158. case BUILT_IN_RETURN:
  159. case BUILT_IN_AGGREGATE_INCOMING_ADDRESS:
  160. case BUILT_IN_FRAME_ADDRESS:
  161. case BUILT_IN_VA_END:
  162. case BUILT_IN_STACK_SAVE:
  163. case BUILT_IN_STACK_RESTORE:
  164. /* Exception state returns or moves registers around. */
  165. case BUILT_IN_EH_FILTER:
  166. case BUILT_IN_EH_POINTER:
  167. case BUILT_IN_EH_COPY_VALUES:
  168. return true;
  169. default:
  170. return false;
  171. }
  172. }
  173. static inline void add_local_decl(struct function *fun, tree d)
  174. {
  175. gcc_assert(TREE_CODE(d) == VAR_DECL);
  176. fun->local_decls = tree_cons(NULL_TREE, d, fun->local_decls);
  177. }
  178. #endif
  179. #if BUILDING_GCC_VERSION <= 4006
  180. #define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
  181. #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4(EXP)
  182. #define EDGE_PRESERVE 0ULL
  183. #define HOST_WIDE_INT_PRINT_HEX_PURE "%" HOST_WIDE_INT_PRINT "x"
  184. #define flag_fat_lto_objects true
  185. #define get_random_seed(noinit) ({ \
  186. unsigned HOST_WIDE_INT seed; \
  187. sscanf(get_random_seed(noinit), "%" HOST_WIDE_INT_PRINT "x", &seed); \
  188. seed * seed; })
  189. #define int_const_binop(code, arg1, arg2) \
  190. int_const_binop((code), (arg1), (arg2), 0)
  191. static inline bool gimple_clobber_p(gimple s __unused)
  192. {
  193. return false;
  194. }
  195. static inline bool gimple_asm_clobbers_memory_p(const_gimple stmt)
  196. {
  197. unsigned i;
  198. for (i = 0; i < gimple_asm_nclobbers(stmt); i++) {
  199. tree op = gimple_asm_clobber_op(stmt, i);
  200. if (!strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "memory"))
  201. return true;
  202. }
  203. return false;
  204. }
  205. static inline tree builtin_decl_implicit(enum built_in_function fncode)
  206. {
  207. return implicit_built_in_decls[fncode];
  208. }
  209. static inline int ipa_reverse_postorder(struct cgraph_node **order)
  210. {
  211. return cgraph_postorder(order);
  212. }
  213. static inline struct cgraph_node *cgraph_create_node(tree decl)
  214. {
  215. return cgraph_node(decl);
  216. }
  217. static inline struct cgraph_node *cgraph_get_create_node(tree decl)
  218. {
  219. struct cgraph_node *node = cgraph_get_node(decl);
  220. return node ? node : cgraph_node(decl);
  221. }
  222. static inline bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
  223. {
  224. return node->analyzed && !node->thunk.thunk_p && !node->alias;
  225. }
  226. static inline struct cgraph_node *cgraph_first_function_with_gimple_body(void)
  227. {
  228. struct cgraph_node *node;
  229. for (node = cgraph_nodes; node; node = node->next)
  230. if (cgraph_function_with_gimple_body_p(node))
  231. return node;
  232. return NULL;
  233. }
  234. static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
  235. {
  236. for (node = node->next; node; node = node->next)
  237. if (cgraph_function_with_gimple_body_p(node))
  238. return node;
  239. return NULL;
  240. }
  241. #define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
  242. for ((node) = cgraph_first_function_with_gimple_body(); (node); \
  243. (node) = cgraph_next_function_with_gimple_body(node))
  244. static inline void varpool_add_new_variable(tree decl)
  245. {
  246. varpool_finalize_decl(decl);
  247. }
  248. #endif
  249. #if BUILDING_GCC_VERSION <= 4007
  250. #define FOR_EACH_FUNCTION(node) \
  251. for (node = cgraph_nodes; node; node = node->next)
  252. #define FOR_EACH_VARIABLE(node) \
  253. for (node = varpool_nodes; node; node = node->next)
  254. #define PROP_loops 0
  255. #define NODE_SYMBOL(node) (node)
  256. #define NODE_DECL(node) (node)->decl
  257. #define INSN_LOCATION(INSN) RTL_LOCATION(INSN)
  258. #define vNULL NULL
  259. static inline int bb_loop_depth(const_basic_block bb)
  260. {
  261. return bb->loop_father ? loop_depth(bb->loop_father) : 0;
  262. }
  263. static inline bool gimple_store_p(gimple gs)
  264. {
  265. tree lhs = gimple_get_lhs(gs);
  266. return lhs && !is_gimple_reg(lhs);
  267. }
  268. static inline void gimple_init_singleton(gimple g __unused)
  269. {
  270. }
  271. #endif
  272. #if BUILDING_GCC_VERSION == 4007 || BUILDING_GCC_VERSION == 4008
  273. static inline struct cgraph_node *cgraph_alias_target(struct cgraph_node *n)
  274. {
  275. return cgraph_alias_aliased_node(n);
  276. }
  277. #endif
  278. #if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION <= 4009
  279. #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
  280. cgraph_create_edge((caller), (callee), (call_stmt), (count), (freq))
  281. #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
  282. cgraph_create_edge_including_clones((caller), (callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
  283. #endif
  284. #if BUILDING_GCC_VERSION <= 4008
  285. #define ENTRY_BLOCK_PTR_FOR_FN(FN) ENTRY_BLOCK_PTR_FOR_FUNCTION(FN)
  286. #define EXIT_BLOCK_PTR_FOR_FN(FN) EXIT_BLOCK_PTR_FOR_FUNCTION(FN)
  287. #define basic_block_info_for_fn(FN) ((FN)->cfg->x_basic_block_info)
  288. #define n_basic_blocks_for_fn(FN) ((FN)->cfg->x_n_basic_blocks)
  289. #define n_edges_for_fn(FN) ((FN)->cfg->x_n_edges)
  290. #define last_basic_block_for_fn(FN) ((FN)->cfg->x_last_basic_block)
  291. #define label_to_block_map_for_fn(FN) ((FN)->cfg->x_label_to_block_map)
  292. #define profile_status_for_fn(FN) ((FN)->cfg->x_profile_status)
  293. #define BASIC_BLOCK_FOR_FN(FN, N) BASIC_BLOCK_FOR_FUNCTION((FN), (N))
  294. #define NODE_IMPLICIT_ALIAS(node) (node)->same_body_alias
  295. #define VAR_P(NODE) (TREE_CODE(NODE) == VAR_DECL)
  296. static inline bool tree_fits_shwi_p(const_tree t)
  297. {
  298. if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
  299. return false;
  300. if (TREE_INT_CST_HIGH(t) == 0 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) >= 0)
  301. return true;
  302. if (TREE_INT_CST_HIGH(t) == -1 && (HOST_WIDE_INT)TREE_INT_CST_LOW(t) < 0 && !TYPE_UNSIGNED(TREE_TYPE(t)))
  303. return true;
  304. return false;
  305. }
  306. static inline bool tree_fits_uhwi_p(const_tree t)
  307. {
  308. if (t == NULL_TREE || TREE_CODE(t) != INTEGER_CST)
  309. return false;
  310. return TREE_INT_CST_HIGH(t) == 0;
  311. }
  312. static inline HOST_WIDE_INT tree_to_shwi(const_tree t)
  313. {
  314. gcc_assert(tree_fits_shwi_p(t));
  315. return TREE_INT_CST_LOW(t);
  316. }
  317. static inline unsigned HOST_WIDE_INT tree_to_uhwi(const_tree t)
  318. {
  319. gcc_assert(tree_fits_uhwi_p(t));
  320. return TREE_INT_CST_LOW(t);
  321. }
  322. static inline const char *get_tree_code_name(enum tree_code code)
  323. {
  324. gcc_assert(code < MAX_TREE_CODES);
  325. return tree_code_name[code];
  326. }
  327. #define ipa_remove_stmt_references(cnode, stmt)
  328. typedef union gimple_statement_d gasm;
  329. typedef union gimple_statement_d gassign;
  330. typedef union gimple_statement_d gcall;
  331. typedef union gimple_statement_d gcond;
  332. typedef union gimple_statement_d gdebug;
  333. typedef union gimple_statement_d gphi;
  334. typedef union gimple_statement_d greturn;
  335. static inline gasm *as_a_gasm(gimple stmt)
  336. {
  337. return stmt;
  338. }
  339. static inline const gasm *as_a_const_gasm(const_gimple stmt)
  340. {
  341. return stmt;
  342. }
  343. static inline gassign *as_a_gassign(gimple stmt)
  344. {
  345. return stmt;
  346. }
  347. static inline const gassign *as_a_const_gassign(const_gimple stmt)
  348. {
  349. return stmt;
  350. }
  351. static inline gcall *as_a_gcall(gimple stmt)
  352. {
  353. return stmt;
  354. }
  355. static inline const gcall *as_a_const_gcall(const_gimple stmt)
  356. {
  357. return stmt;
  358. }
  359. static inline gcond *as_a_gcond(gimple stmt)
  360. {
  361. return stmt;
  362. }
  363. static inline const gcond *as_a_const_gcond(const_gimple stmt)
  364. {
  365. return stmt;
  366. }
  367. static inline gdebug *as_a_gdebug(gimple stmt)
  368. {
  369. return stmt;
  370. }
  371. static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
  372. {
  373. return stmt;
  374. }
  375. static inline gphi *as_a_gphi(gimple stmt)
  376. {
  377. return stmt;
  378. }
  379. static inline const gphi *as_a_const_gphi(const_gimple stmt)
  380. {
  381. return stmt;
  382. }
  383. static inline greturn *as_a_greturn(gimple stmt)
  384. {
  385. return stmt;
  386. }
  387. static inline const greturn *as_a_const_greturn(const_gimple stmt)
  388. {
  389. return stmt;
  390. }
  391. #endif
  392. #if BUILDING_GCC_VERSION == 4008
  393. #define NODE_SYMBOL(node) (&(node)->symbol)
  394. #define NODE_DECL(node) (node)->symbol.decl
  395. #endif
  396. #if BUILDING_GCC_VERSION >= 4008
  397. #define add_referenced_var(var)
  398. #define mark_sym_for_renaming(var)
  399. #define varpool_mark_needed_node(node)
  400. #define create_var_ann(var)
  401. #define TODO_dump_func 0
  402. #define TODO_dump_cgraph 0
  403. #endif
  404. #if BUILDING_GCC_VERSION <= 4009
  405. #define TODO_verify_il 0
  406. #define AVAIL_INTERPOSABLE AVAIL_OVERWRITABLE
  407. #define section_name_prefix LTO_SECTION_NAME_PREFIX
  408. #define fatal_error(loc, gmsgid, ...) fatal_error((gmsgid), __VA_ARGS__)
  409. typedef struct rtx_def rtx_insn;
  410. static inline void set_decl_section_name(tree node, const char *value)
  411. {
  412. if (value)
  413. DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value);
  414. else
  415. DECL_SECTION_NAME(node) = NULL;
  416. }
  417. #endif
  418. #if BUILDING_GCC_VERSION == 4009
  419. typedef struct gimple_statement_asm gasm;
  420. typedef struct gimple_statement_base gassign;
  421. typedef struct gimple_statement_call gcall;
  422. typedef struct gimple_statement_base gcond;
  423. typedef struct gimple_statement_base gdebug;
  424. typedef struct gimple_statement_phi gphi;
  425. typedef struct gimple_statement_base greturn;
  426. static inline gasm *as_a_gasm(gimple stmt)
  427. {
  428. return as_a<gasm>(stmt);
  429. }
  430. static inline const gasm *as_a_const_gasm(const_gimple stmt)
  431. {
  432. return as_a<const gasm>(stmt);
  433. }
  434. static inline gassign *as_a_gassign(gimple stmt)
  435. {
  436. return stmt;
  437. }
  438. static inline const gassign *as_a_const_gassign(const_gimple stmt)
  439. {
  440. return stmt;
  441. }
  442. static inline gcall *as_a_gcall(gimple stmt)
  443. {
  444. return as_a<gcall>(stmt);
  445. }
  446. static inline const gcall *as_a_const_gcall(const_gimple stmt)
  447. {
  448. return as_a<const gcall>(stmt);
  449. }
  450. static inline gcond *as_a_gcond(gimple stmt)
  451. {
  452. return stmt;
  453. }
  454. static inline const gcond *as_a_const_gcond(const_gimple stmt)
  455. {
  456. return stmt;
  457. }
  458. static inline gdebug *as_a_gdebug(gimple stmt)
  459. {
  460. return stmt;
  461. }
  462. static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
  463. {
  464. return stmt;
  465. }
  466. static inline gphi *as_a_gphi(gimple stmt)
  467. {
  468. return as_a<gphi>(stmt);
  469. }
  470. static inline const gphi *as_a_const_gphi(const_gimple stmt)
  471. {
  472. return as_a<const gphi>(stmt);
  473. }
  474. static inline greturn *as_a_greturn(gimple stmt)
  475. {
  476. return stmt;
  477. }
  478. static inline const greturn *as_a_const_greturn(const_gimple stmt)
  479. {
  480. return stmt;
  481. }
  482. #endif
  483. #if BUILDING_GCC_VERSION >= 4009
  484. #define TODO_ggc_collect 0
  485. #define NODE_SYMBOL(node) (node)
  486. #define NODE_DECL(node) (node)->decl
  487. #define cgraph_node_name(node) (node)->name()
  488. #define NODE_IMPLICIT_ALIAS(node) (node)->cpp_implicit_alias
  489. #endif
  490. #if BUILDING_GCC_VERSION >= 5000 && BUILDING_GCC_VERSION < 6000
  491. /* gimple related */
  492. template <>
  493. template <>
  494. inline bool is_a_helper<const gassign *>::test(const_gimple gs)
  495. {
  496. return gs->code == GIMPLE_ASSIGN;
  497. }
  498. #endif
  499. #if BUILDING_GCC_VERSION >= 5000
  500. #define TODO_verify_ssa TODO_verify_il
  501. #define TODO_verify_flow TODO_verify_il
  502. #define TODO_verify_stmts TODO_verify_il
  503. #define TODO_verify_rtl_sharing TODO_verify_il
  504. #define INSN_DELETED_P(insn) (insn)->deleted()
  505. /* symtab/cgraph related */
  506. #define debug_cgraph_node(node) (node)->debug()
  507. #define cgraph_get_node(decl) cgraph_node::get(decl)
  508. #define cgraph_get_create_node(decl) cgraph_node::get_create(decl)
  509. #define cgraph_create_node(decl) cgraph_node::create(decl)
  510. #define cgraph_n_nodes symtab->cgraph_count
  511. #define cgraph_max_uid symtab->cgraph_max_uid
  512. #define varpool_get_node(decl) varpool_node::get(decl)
  513. #define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
  514. (caller)->create_edge((callee), (call_stmt), (count), (freq))
  515. #define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
  516. (caller)->create_edge_including_clones((callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
  517. typedef struct cgraph_node *cgraph_node_ptr;
  518. typedef struct cgraph_edge *cgraph_edge_p;
  519. typedef struct varpool_node *varpool_node_ptr;
  520. static inline void change_decl_assembler_name(tree decl, tree name)
  521. {
  522. symtab->change_decl_assembler_name(decl, name);
  523. }
  524. static inline void varpool_finalize_decl(tree decl)
  525. {
  526. varpool_node::finalize_decl(decl);
  527. }
  528. static inline void varpool_add_new_variable(tree decl)
  529. {
  530. varpool_node::add(decl);
  531. }
  532. static inline unsigned int rebuild_cgraph_edges(void)
  533. {
  534. return cgraph_edge::rebuild_edges();
  535. }
  536. static inline cgraph_node_ptr cgraph_function_node(cgraph_node_ptr node, enum availability *availability)
  537. {
  538. return node->function_symbol(availability);
  539. }
  540. static inline cgraph_node_ptr cgraph_function_or_thunk_node(cgraph_node_ptr node, enum availability *availability = NULL)
  541. {
  542. return node->ultimate_alias_target(availability);
  543. }
  544. static inline bool cgraph_only_called_directly_p(cgraph_node_ptr node)
  545. {
  546. return node->only_called_directly_p();
  547. }
  548. static inline enum availability cgraph_function_body_availability(cgraph_node_ptr node)
  549. {
  550. return node->get_availability();
  551. }
  552. static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
  553. {
  554. return node->get_alias_target();
  555. }
  556. static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
  557. {
  558. return symtab->add_cgraph_insertion_hook(hook, data);
  559. }
  560. static inline void cgraph_remove_function_insertion_hook(struct cgraph_node_hook_list *entry)
  561. {
  562. symtab->remove_cgraph_insertion_hook(entry);
  563. }
  564. static inline struct cgraph_node_hook_list *cgraph_add_node_removal_hook(cgraph_node_hook hook, void *data)
  565. {
  566. return symtab->add_cgraph_removal_hook(hook, data);
  567. }
  568. static inline void cgraph_remove_node_removal_hook(struct cgraph_node_hook_list *entry)
  569. {
  570. symtab->remove_cgraph_removal_hook(entry);
  571. }
  572. static inline struct cgraph_2node_hook_list *cgraph_add_node_duplication_hook(cgraph_2node_hook hook, void *data)
  573. {
  574. return symtab->add_cgraph_duplication_hook(hook, data);
  575. }
  576. static inline void cgraph_remove_node_duplication_hook(struct cgraph_2node_hook_list *entry)
  577. {
  578. symtab->remove_cgraph_duplication_hook(entry);
  579. }
  580. static inline void cgraph_call_node_duplication_hooks(cgraph_node_ptr node, cgraph_node_ptr node2)
  581. {
  582. symtab->call_cgraph_duplication_hooks(node, node2);
  583. }
  584. static inline void cgraph_call_edge_duplication_hooks(cgraph_edge *cs1, cgraph_edge *cs2)
  585. {
  586. symtab->call_edge_duplication_hooks(cs1, cs2);
  587. }
  588. #if BUILDING_GCC_VERSION >= 6000
  589. typedef gimple *gimple_ptr;
  590. typedef const gimple *const_gimple_ptr;
  591. #define gimple gimple_ptr
  592. #define const_gimple const_gimple_ptr
  593. #undef CONST_CAST_GIMPLE
  594. #define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X))
  595. #endif
  596. /* gimple related */
  597. static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree lhs, tree op1, tree op2 MEM_STAT_DECL)
  598. {
  599. return gimple_build_assign(lhs, subcode, op1, op2 PASS_MEM_STAT);
  600. }
  601. template <>
  602. template <>
  603. inline bool is_a_helper<const greturn *>::test(const_gimple gs)
  604. {
  605. return gs->code == GIMPLE_RETURN;
  606. }
  607. static inline gasm *as_a_gasm(gimple stmt)
  608. {
  609. return as_a<gasm *>(stmt);
  610. }
  611. static inline const gasm *as_a_const_gasm(const_gimple stmt)
  612. {
  613. return as_a<const gasm *>(stmt);
  614. }
  615. static inline gassign *as_a_gassign(gimple stmt)
  616. {
  617. return as_a<gassign *>(stmt);
  618. }
  619. static inline const gassign *as_a_const_gassign(const_gimple stmt)
  620. {
  621. return as_a<const gassign *>(stmt);
  622. }
  623. static inline gcall *as_a_gcall(gimple stmt)
  624. {
  625. return as_a<gcall *>(stmt);
  626. }
  627. static inline const gcall *as_a_const_gcall(const_gimple stmt)
  628. {
  629. return as_a<const gcall *>(stmt);
  630. }
  631. static inline gphi *as_a_gphi(gimple stmt)
  632. {
  633. return as_a<gphi *>(stmt);
  634. }
  635. static inline const gphi *as_a_const_gphi(const_gimple stmt)
  636. {
  637. return as_a<const gphi *>(stmt);
  638. }
  639. static inline greturn *as_a_greturn(gimple stmt)
  640. {
  641. return as_a<greturn *>(stmt);
  642. }
  643. static inline const greturn *as_a_const_greturn(const_gimple stmt)
  644. {
  645. return as_a<const greturn *>(stmt);
  646. }
  647. /* IPA/LTO related */
  648. #define ipa_ref_list_referring_iterate(L, I, P) \
  649. (L)->referring.iterate((I), &(P))
  650. #define ipa_ref_list_reference_iterate(L, I, P) \
  651. (L)->reference.iterate((I), &(P))
  652. static inline cgraph_node_ptr ipa_ref_referring_node(struct ipa_ref *ref)
  653. {
  654. return dyn_cast<cgraph_node_ptr>(ref->referring);
  655. }
  656. static inline void ipa_remove_stmt_references(symtab_node *referring_node, gimple stmt)
  657. {
  658. referring_node->remove_stmt_references(stmt);
  659. }
  660. #endif
  661. #if BUILDING_GCC_VERSION < 6000
  662. #define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
  663. get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, pvolatilep, keep_aligning)
  664. #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET(VOIDmode, (ARG0), (ARG1))
  665. #endif
  666. #if BUILDING_GCC_VERSION >= 6000
  667. #define gen_rtx_set(ARG0, ARG1) gen_rtx_SET((ARG0), (ARG1))
  668. #endif
  669. #ifdef __cplusplus
  670. static inline void debug_tree(const_tree t)
  671. {
  672. debug_tree(CONST_CAST_TREE(t));
  673. }
  674. static inline void debug_gimple_stmt(const_gimple s)
  675. {
  676. debug_gimple_stmt(CONST_CAST_GIMPLE(s));
  677. }
  678. #else
  679. #define debug_tree(t) debug_tree(CONST_CAST_TREE(t))
  680. #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
  681. #endif
  682. #endif