ipa-ref.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* IPA reference lists.
  2. Copyright (C) 2010-2015 Free Software Foundation, Inc.
  3. Contributed by Jan Hubicka
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef GCC_IPA_REF_H
  17. #define GCC_IPA_REF_H
  18. struct cgraph_node;
  19. class varpool_node;
  20. class symtab_node;
  21. /* How the reference is done. */
  22. enum GTY(()) ipa_ref_use
  23. {
  24. IPA_REF_LOAD,
  25. IPA_REF_STORE,
  26. IPA_REF_ADDR,
  27. IPA_REF_ALIAS,
  28. IPA_REF_CHKP
  29. };
  30. /* Record of reference in callgraph or varpool. */
  31. struct GTY(()) ipa_ref
  32. {
  33. public:
  34. /* Remove reference. */
  35. void remove_reference ();
  36. /* Return true when execution of reference can lead to return from
  37. function. */
  38. bool cannot_lead_to_return ();
  39. /* Return true if refernece may be used in address compare. */
  40. bool address_matters_p ();
  41. /* Return reference list this reference is in. */
  42. struct ipa_ref_list * referring_ref_list (void);
  43. /* Return reference list this reference is in. */
  44. struct ipa_ref_list * referred_ref_list (void);
  45. symtab_node *referring;
  46. symtab_node *referred;
  47. gimple stmt;
  48. unsigned int lto_stmt_uid;
  49. unsigned int referred_index;
  50. ENUM_BITFIELD (ipa_ref_use) use:3;
  51. unsigned int speculative:1;
  52. };
  53. typedef struct ipa_ref ipa_ref_t;
  54. typedef struct ipa_ref *ipa_ref_ptr;
  55. /* List of references. This is stored in both callgraph and varpool nodes. */
  56. struct GTY(()) ipa_ref_list
  57. {
  58. public:
  59. /* Return first reference in list or NULL if empty. */
  60. struct ipa_ref *first_reference (void)
  61. {
  62. if (!vec_safe_length (references))
  63. return NULL;
  64. return &(*references)[0];
  65. }
  66. /* Return first referring ref in list or NULL if empty. */
  67. struct ipa_ref *first_referring (void)
  68. {
  69. if (!referring.length ())
  70. return NULL;
  71. return referring[0];
  72. }
  73. /* Return first referring alias. */
  74. struct ipa_ref *first_alias (void)
  75. {
  76. struct ipa_ref *r = first_referring ();
  77. return r && r->use == IPA_REF_ALIAS ? r : NULL;
  78. }
  79. /* Return last referring alias. */
  80. struct ipa_ref *last_alias (void)
  81. {
  82. unsigned int i = 0;
  83. for(i = 0; i < referring.length (); i++)
  84. if (referring[i]->use != IPA_REF_ALIAS)
  85. break;
  86. return i == 0 ? NULL : referring[i - 1];
  87. }
  88. /* Return true if the symbol has an alias. */
  89. bool inline has_aliases_p (void)
  90. {
  91. return first_alias ();
  92. }
  93. /* Clear reference list. */
  94. void clear (void)
  95. {
  96. referring.create (0);
  97. references = NULL;
  98. }
  99. /* Return number of references. */
  100. unsigned int nreferences (void)
  101. {
  102. return vec_safe_length (references);
  103. }
  104. /* Store actual references in references vector. */
  105. vec<ipa_ref_t, va_gc> *references;
  106. /* Referring is vector of pointers to references. It must not live in GGC space
  107. or GGC will try to mark middle of references vectors. */
  108. vec<ipa_ref_ptr> GTY((skip)) referring;
  109. };
  110. #endif /* GCC_IPA_REF_H */