ipa-ref.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* IPA reference lists.
  2. Copyright (C) 2010-2019 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. };
  29. /* Record of reference in callgraph or varpool. */
  30. struct GTY(()) ipa_ref
  31. {
  32. public:
  33. /* Remove reference. */
  34. void remove_reference ();
  35. /* Return true when execution of reference can lead to return from
  36. function. */
  37. bool cannot_lead_to_return ();
  38. /* Return true if refernece may be used in address compare. */
  39. bool address_matters_p ();
  40. /* Return reference list this reference is in. */
  41. struct ipa_ref_list * referring_ref_list (void);
  42. /* Return reference list this reference is in. */
  43. struct ipa_ref_list * referred_ref_list (void);
  44. symtab_node *referring;
  45. symtab_node *referred;
  46. gimple *stmt;
  47. unsigned int lto_stmt_uid;
  48. unsigned int referred_index;
  49. ENUM_BITFIELD (ipa_ref_use) use:3;
  50. unsigned int speculative:1;
  51. };
  52. typedef struct ipa_ref ipa_ref_t;
  53. typedef struct ipa_ref *ipa_ref_ptr;
  54. /* List of references. This is stored in both callgraph and varpool nodes. */
  55. struct GTY(()) ipa_ref_list
  56. {
  57. public:
  58. /* Return first reference in list or NULL if empty. */
  59. struct ipa_ref *first_reference (void)
  60. {
  61. if (!vec_safe_length (references))
  62. return NULL;
  63. return &(*references)[0];
  64. }
  65. /* Return first referring ref in list or NULL if empty. */
  66. struct ipa_ref *first_referring (void)
  67. {
  68. if (!referring.length ())
  69. return NULL;
  70. return referring[0];
  71. }
  72. /* Return first referring alias. */
  73. struct ipa_ref *first_alias (void)
  74. {
  75. struct ipa_ref *r = first_referring ();
  76. return r && r->use == IPA_REF_ALIAS ? r : NULL;
  77. }
  78. /* Return last referring alias. */
  79. struct ipa_ref *last_alias (void)
  80. {
  81. unsigned int i = 0;
  82. for(i = 0; i < referring.length (); i++)
  83. if (referring[i]->use != IPA_REF_ALIAS)
  84. break;
  85. return i == 0 ? NULL : referring[i - 1];
  86. }
  87. /* Return true if the symbol has an alias. */
  88. bool inline has_aliases_p (void)
  89. {
  90. return first_alias ();
  91. }
  92. /* Clear reference list. */
  93. void clear (void)
  94. {
  95. referring.create (0);
  96. references = NULL;
  97. }
  98. /* Return number of references. */
  99. unsigned int nreferences (void)
  100. {
  101. return vec_safe_length (references);
  102. }
  103. /* Store actual references in references vector. */
  104. vec<ipa_ref_t, va_gc> *references;
  105. /* Referring is vector of pointers to references. It must not live in GGC space
  106. or GGC will try to mark middle of references vectors. */
  107. vec<ipa_ref_ptr> GTY((skip)) referring;
  108. };
  109. #endif /* GCC_IPA_REF_H */