aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gcc-plugins/gcc-common.h
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gcc-plugins/gcc-common.h')
-rw-r--r--scripts/gcc-plugins/gcc-common.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
index 950fd2e64bb7..12262c0cc691 100644
--- a/scripts/gcc-plugins/gcc-common.h
+++ b/scripts/gcc-plugins/gcc-common.h
@@ -39,6 +39,9 @@
39#include "hash-map.h" 39#include "hash-map.h"
40#endif 40#endif
41 41
42#if BUILDING_GCC_VERSION >= 7000
43#include "memmodel.h"
44#endif
42#include "emit-rtl.h" 45#include "emit-rtl.h"
43#include "debug.h" 46#include "debug.h"
44#include "target.h" 47#include "target.h"
@@ -91,6 +94,9 @@
91#include "tree-ssa-alias.h" 94#include "tree-ssa-alias.h"
92#include "tree-ssa.h" 95#include "tree-ssa.h"
93#include "stringpool.h" 96#include "stringpool.h"
97#if BUILDING_GCC_VERSION >= 7000
98#include "tree-vrp.h"
99#endif
94#include "tree-ssanames.h" 100#include "tree-ssanames.h"
95#include "print-tree.h" 101#include "print-tree.h"
96#include "tree-eh.h" 102#include "tree-eh.h"
@@ -287,6 +293,22 @@ static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct c
287 return NULL; 293 return NULL;
288} 294}
289 295
296static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
297{
298 cgraph_node_ptr alias;
299
300 if (callback(node, data))
301 return true;
302
303 for (alias = node->same_body; alias; alias = alias->next) {
304 if (include_overwritable || cgraph_function_body_availability(alias) > AVAIL_OVERWRITABLE)
305 if (cgraph_for_node_and_aliases(alias, callback, data, include_overwritable))
306 return true;
307 }
308
309 return false;
310}
311
290#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \ 312#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
291 for ((node) = cgraph_first_function_with_gimple_body(); (node); \ 313 for ((node) = cgraph_first_function_with_gimple_body(); (node); \
292 (node) = cgraph_next_function_with_gimple_body(node)) 314 (node) = cgraph_next_function_with_gimple_body(node))
@@ -399,6 +421,7 @@ typedef union gimple_statement_d gassign;
399typedef union gimple_statement_d gcall; 421typedef union gimple_statement_d gcall;
400typedef union gimple_statement_d gcond; 422typedef union gimple_statement_d gcond;
401typedef union gimple_statement_d gdebug; 423typedef union gimple_statement_d gdebug;
424typedef union gimple_statement_d ggoto;
402typedef union gimple_statement_d gphi; 425typedef union gimple_statement_d gphi;
403typedef union gimple_statement_d greturn; 426typedef union gimple_statement_d greturn;
404 427
@@ -452,6 +475,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
452 return stmt; 475 return stmt;
453} 476}
454 477
478static inline ggoto *as_a_ggoto(gimple stmt)
479{
480 return stmt;
481}
482
483static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
484{
485 return stmt;
486}
487
455static inline gphi *as_a_gphi(gimple stmt) 488static inline gphi *as_a_gphi(gimple stmt)
456{ 489{
457 return stmt; 490 return stmt;
@@ -496,6 +529,14 @@ static inline const greturn *as_a_const_greturn(const_gimple stmt)
496 529
497typedef struct rtx_def rtx_insn; 530typedef struct rtx_def rtx_insn;
498 531
532static inline const char *get_decl_section_name(const_tree decl)
533{
534 if (DECL_SECTION_NAME(decl) == NULL_TREE)
535 return NULL;
536
537 return TREE_STRING_POINTER(DECL_SECTION_NAME(decl));
538}
539
499static inline void set_decl_section_name(tree node, const char *value) 540static inline void set_decl_section_name(tree node, const char *value)
500{ 541{
501 if (value) 542 if (value)
@@ -511,6 +552,7 @@ typedef struct gimple_statement_base gassign;
511typedef struct gimple_statement_call gcall; 552typedef struct gimple_statement_call gcall;
512typedef struct gimple_statement_base gcond; 553typedef struct gimple_statement_base gcond;
513typedef struct gimple_statement_base gdebug; 554typedef struct gimple_statement_base gdebug;
555typedef struct gimple_statement_base ggoto;
514typedef struct gimple_statement_phi gphi; 556typedef struct gimple_statement_phi gphi;
515typedef struct gimple_statement_base greturn; 557typedef struct gimple_statement_base greturn;
516 558
@@ -564,6 +606,16 @@ static inline const gdebug *as_a_const_gdebug(const_gimple stmt)
564 return stmt; 606 return stmt;
565} 607}
566 608
609static inline ggoto *as_a_ggoto(gimple stmt)
610{
611 return stmt;
612}
613
614static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
615{
616 return stmt;
617}
618
567static inline gphi *as_a_gphi(gimple stmt) 619static inline gphi *as_a_gphi(gimple stmt)
568{ 620{
569 return as_a<gphi>(stmt); 621 return as_a<gphi>(stmt);
@@ -611,6 +663,11 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs)
611 663
612#define INSN_DELETED_P(insn) (insn)->deleted() 664#define INSN_DELETED_P(insn) (insn)->deleted()
613 665
666static inline const char *get_decl_section_name(const_tree decl)
667{
668 return DECL_SECTION_NAME(decl);
669}
670
614/* symtab/cgraph related */ 671/* symtab/cgraph related */
615#define debug_cgraph_node(node) (node)->debug() 672#define debug_cgraph_node(node) (node)->debug()
616#define cgraph_get_node(decl) cgraph_node::get(decl) 673#define cgraph_get_node(decl) cgraph_node::get(decl)
@@ -619,6 +676,7 @@ inline bool is_a_helper<const gassign *>::test(const_gimple gs)
619#define cgraph_n_nodes symtab->cgraph_count 676#define cgraph_n_nodes symtab->cgraph_count
620#define cgraph_max_uid symtab->cgraph_max_uid 677#define cgraph_max_uid symtab->cgraph_max_uid
621#define varpool_get_node(decl) varpool_node::get(decl) 678#define varpool_get_node(decl) varpool_node::get(decl)
679#define dump_varpool_node(file, node) (node)->dump(file)
622 680
623#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \ 681#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
624 (caller)->create_edge((callee), (call_stmt), (count), (freq)) 682 (caller)->create_edge((callee), (call_stmt), (count), (freq))
@@ -674,6 +732,11 @@ static inline cgraph_node_ptr cgraph_alias_target(cgraph_node_ptr node)
674 return node->get_alias_target(); 732 return node->get_alias_target();
675} 733}
676 734
735static inline bool cgraph_for_node_and_aliases(cgraph_node_ptr node, bool (*callback)(cgraph_node_ptr, void *), void *data, bool include_overwritable)
736{
737 return node->call_for_symbol_thunks_and_aliases(callback, data, include_overwritable);
738}
739
677static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data) 740static inline struct cgraph_node_hook_list *cgraph_add_function_insertion_hook(cgraph_node_hook hook, void *data)
678{ 741{
679 return symtab->add_cgraph_insertion_hook(hook, data); 742 return symtab->add_cgraph_insertion_hook(hook, data);
@@ -731,6 +794,13 @@ static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, tree l
731 794
732template <> 795template <>
733template <> 796template <>
797inline bool is_a_helper<const ggoto *>::test(const_gimple gs)
798{
799 return gs->code == GIMPLE_GOTO;
800}
801
802template <>
803template <>
734inline bool is_a_helper<const greturn *>::test(const_gimple gs) 804inline bool is_a_helper<const greturn *>::test(const_gimple gs)
735{ 805{
736 return gs->code == GIMPLE_RETURN; 806 return gs->code == GIMPLE_RETURN;
@@ -766,6 +836,16 @@ static inline const gcall *as_a_const_gcall(const_gimple stmt)
766 return as_a<const gcall *>(stmt); 836 return as_a<const gcall *>(stmt);
767} 837}
768 838
839static inline ggoto *as_a_ggoto(gimple stmt)
840{
841 return as_a<ggoto *>(stmt);
842}
843
844static inline const ggoto *as_a_const_ggoto(const_gimple stmt)
845{
846 return as_a<const ggoto *>(stmt);
847}
848
769static inline gphi *as_a_gphi(gimple stmt) 849static inline gphi *as_a_gphi(gimple stmt)
770{ 850{
771 return as_a<gphi *>(stmt); 851 return as_a<gphi *>(stmt);
@@ -828,4 +908,9 @@ static inline void debug_gimple_stmt(const_gimple s)
828#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) 908#define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s))
829#endif 909#endif
830 910
911#if BUILDING_GCC_VERSION >= 7000
912#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
913 get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
914#endif
915
831#endif 916#endif