1/* IPA reference lists. 2 Copyright (C) 2010 3 Free Software Foundation, Inc. 4 Contributed by Jan Hubicka 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify it under 9the terms of the GNU General Public License as published by the Free 10Software Foundation; either version 3, or (at your option) any later 11version. 12 13GCC is distributed in the hope that it will be useful, but WITHOUT ANY 14WARRANTY; without even the implied warranty of MERCHANTABILITY or 15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16for more details. 17 18You should have received a copy of the GNU General Public License 19along with GCC; see the file COPYING3. If not see 20<http://www.gnu.org/licenses/>. */ 21 22struct cgraph_node; 23struct varpool_node; 24 25/* How the reference is done. */ 26enum GTY(()) ipa_ref_use 27{ 28 IPA_REF_LOAD, 29 IPA_REF_STORE, 30 IPA_REF_ADDR 31}; 32 33/* Type of refering or refered type. */ 34enum GTY(()) ipa_ref_type 35{ 36 IPA_REF_CGRAPH, 37 IPA_REF_VARPOOL 38}; 39 40/* We can have references spanning both callgraph and varpool, 41 so all pointers needs to be of both types. */ 42union GTY(()) ipa_ref_ptr_u 43{ 44 struct cgraph_node * GTY((tag ("IPA_REF_CGRAPH"))) cgraph_node; 45 struct varpool_node * GTY((tag ("IPA_REF_VARPOOL"))) varpool_node; 46}; 47 48/* Record of reference in callgraph or varpool. */ 49struct GTY(()) ipa_ref 50{ 51 union ipa_ref_ptr_u GTY ((desc ("%1.refering_type"))) refering; 52 union ipa_ref_ptr_u GTY ((desc ("%1.refered_type"))) refered; 53 gimple stmt; 54 unsigned int refered_index; 55 ENUM_BITFIELD (ipa_ref_type) refering_type:1; 56 ENUM_BITFIELD (ipa_ref_type) refered_type:1; 57 ENUM_BITFIELD (ipa_ref_use) use:2; 58}; 59 60typedef struct ipa_ref ipa_ref_t; 61typedef struct ipa_ref *ipa_ref_ptr; 62 63DEF_VEC_O(ipa_ref_t); 64DEF_VEC_ALLOC_O(ipa_ref_t,gc); 65DEF_VEC_P(ipa_ref_ptr); 66DEF_VEC_ALLOC_P(ipa_ref_ptr,heap); 67 68/* List of references. This is stored in both callgraph and varpool nodes. */ 69struct GTY(()) ipa_ref_list 70{ 71 /* Store actual references in references vector. */ 72 VEC(ipa_ref_t,gc) *references; 73 /* Refering is vector of pointers to references. It must not live in GGC space 74 or GGC will try to mark middle of references vectors. */ 75 VEC(ipa_ref_ptr,heap) * GTY((skip)) refering; 76}; 77 78struct ipa_ref * ipa_record_reference (struct cgraph_node *, 79 struct varpool_node *, 80 struct cgraph_node *, 81 struct varpool_node *, 82 enum ipa_ref_use, gimple); 83 84void ipa_remove_reference (struct ipa_ref *); 85void ipa_remove_all_references (struct ipa_ref_list *); 86void ipa_remove_all_refering (struct ipa_ref_list *); 87void ipa_dump_references (FILE *, struct ipa_ref_list *); 88void ipa_dump_refering (FILE *, struct ipa_ref_list *); 89void ipa_clone_references (struct cgraph_node *, struct varpool_node *, struct ipa_ref_list *); 90void ipa_clone_refering (struct cgraph_node *, struct varpool_node *, struct ipa_ref_list *); 91bool ipa_ref_cannot_lead_to_return (struct ipa_ref *); 92 93