Mercurial > hg > CbC > CbC_gcc
diff gcc/ipa-ref.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
line wrap: on
line diff
--- a/gcc/ipa-ref.h Sun Aug 21 07:07:55 2011 +0900 +++ b/gcc/ipa-ref.h Fri Oct 27 22:46:09 2017 +0900 @@ -1,6 +1,5 @@ /* IPA reference lists. - Copyright (C) 2010 - Free Software Foundation, Inc. + Copyright (C) 2010-2017 Free Software Foundation, Inc. Contributed by Jan Hubicka This file is part of GCC. @@ -19,74 +18,121 @@ along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ +#ifndef GCC_IPA_REF_H +#define GCC_IPA_REF_H + struct cgraph_node; -struct varpool_node; +class varpool_node; +class symtab_node; + /* How the reference is done. */ enum GTY(()) ipa_ref_use { IPA_REF_LOAD, IPA_REF_STORE, - IPA_REF_ADDR -}; - -/* Type of refering or refered type. */ -enum GTY(()) ipa_ref_type -{ - IPA_REF_CGRAPH, - IPA_REF_VARPOOL -}; - -/* We can have references spanning both callgraph and varpool, - so all pointers needs to be of both types. */ -union GTY(()) ipa_ref_ptr_u -{ - struct cgraph_node * GTY((tag ("IPA_REF_CGRAPH"))) cgraph_node; - struct varpool_node * GTY((tag ("IPA_REF_VARPOOL"))) varpool_node; + IPA_REF_ADDR, + IPA_REF_ALIAS, + IPA_REF_CHKP }; /* Record of reference in callgraph or varpool. */ struct GTY(()) ipa_ref { - union ipa_ref_ptr_u GTY ((desc ("%1.refering_type"))) refering; - union ipa_ref_ptr_u GTY ((desc ("%1.refered_type"))) refered; - gimple stmt; - unsigned int refered_index; - ENUM_BITFIELD (ipa_ref_type) refering_type:1; - ENUM_BITFIELD (ipa_ref_type) refered_type:1; - ENUM_BITFIELD (ipa_ref_use) use:2; +public: + /* Remove reference. */ + void remove_reference (); + + /* Return true when execution of reference can lead to return from + function. */ + bool cannot_lead_to_return (); + + /* Return true if refernece may be used in address compare. */ + bool address_matters_p (); + + /* Return reference list this reference is in. */ + struct ipa_ref_list * referring_ref_list (void); + + /* Return reference list this reference is in. */ + struct ipa_ref_list * referred_ref_list (void); + + symtab_node *referring; + symtab_node *referred; + gimple *stmt; + unsigned int lto_stmt_uid; + unsigned int referred_index; + ENUM_BITFIELD (ipa_ref_use) use:3; + unsigned int speculative:1; }; typedef struct ipa_ref ipa_ref_t; typedef struct ipa_ref *ipa_ref_ptr; -DEF_VEC_O(ipa_ref_t); -DEF_VEC_ALLOC_O(ipa_ref_t,gc); -DEF_VEC_P(ipa_ref_ptr); -DEF_VEC_ALLOC_P(ipa_ref_ptr,heap); /* List of references. This is stored in both callgraph and varpool nodes. */ struct GTY(()) ipa_ref_list { +public: + /* Return first reference in list or NULL if empty. */ + struct ipa_ref *first_reference (void) + { + if (!vec_safe_length (references)) + return NULL; + return &(*references)[0]; + } + + /* Return first referring ref in list or NULL if empty. */ + struct ipa_ref *first_referring (void) + { + if (!referring.length ()) + return NULL; + return referring[0]; + } + + /* Return first referring alias. */ + struct ipa_ref *first_alias (void) + { + struct ipa_ref *r = first_referring (); + + return r && r->use == IPA_REF_ALIAS ? r : NULL; + } + + /* Return last referring alias. */ + struct ipa_ref *last_alias (void) + { + unsigned int i = 0; + + for(i = 0; i < referring.length (); i++) + if (referring[i]->use != IPA_REF_ALIAS) + break; + + return i == 0 ? NULL : referring[i - 1]; + } + + /* Return true if the symbol has an alias. */ + bool inline has_aliases_p (void) + { + return first_alias (); + } + + /* Clear reference list. */ + void clear (void) + { + referring.create (0); + references = NULL; + } + + /* Return number of references. */ + unsigned int nreferences (void) + { + return vec_safe_length (references); + } + /* Store actual references in references vector. */ - VEC(ipa_ref_t,gc) *references; - /* Refering is vector of pointers to references. It must not live in GGC space + vec<ipa_ref_t, va_gc> *references; + /* Referring is vector of pointers to references. It must not live in GGC space or GGC will try to mark middle of references vectors. */ - VEC(ipa_ref_ptr,heap) * GTY((skip)) refering; + vec<ipa_ref_ptr> GTY((skip)) referring; }; -struct ipa_ref * ipa_record_reference (struct cgraph_node *, - struct varpool_node *, - struct cgraph_node *, - struct varpool_node *, - enum ipa_ref_use, gimple); - -void ipa_remove_reference (struct ipa_ref *); -void ipa_remove_all_references (struct ipa_ref_list *); -void ipa_remove_all_refering (struct ipa_ref_list *); -void ipa_dump_references (FILE *, struct ipa_ref_list *); -void ipa_dump_refering (FILE *, struct ipa_ref_list *); -void ipa_clone_references (struct cgraph_node *, struct varpool_node *, struct ipa_ref_list *); -void ipa_clone_refering (struct cgraph_node *, struct varpool_node *, struct ipa_ref_list *); -bool ipa_ref_cannot_lead_to_return (struct ipa_ref *); - +#endif /* GCC_IPA_REF_H */