You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.5KB

  1. /* IPA reference lists.
  2. Copyright (C) 2010-2020 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. struct varpool_node;
  20. struct 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 reference 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. /* speculative id is used to link direct calls with their corresponding
  49. IPA_REF_ADDR references when representing speculative calls. */
  50. unsigned int speculative_id : 16;
  51. unsigned int referred_index;
  52. ENUM_BITFIELD (ipa_ref_use) use:3;
  53. unsigned int speculative:1;
  54. };
  55. typedef struct ipa_ref ipa_ref_t;
  56. typedef struct ipa_ref *ipa_ref_ptr;
  57. /* List of references. This is stored in both callgraph and varpool nodes. */
  58. struct GTY(()) ipa_ref_list
  59. {
  60. public:
  61. /* Return first reference in list or NULL if empty. */
  62. struct ipa_ref *first_reference (void)
  63. {
  64. if (!vec_safe_length (references))
  65. return NULL;
  66. return &(*references)[0];
  67. }
  68. /* Return first referring ref in list or NULL if empty. */
  69. struct ipa_ref *first_referring (void)
  70. {
  71. if (!referring.length ())
  72. return NULL;
  73. return referring[0];
  74. }
  75. /* Return first referring alias. */
  76. struct ipa_ref *first_alias (void)
  77. {
  78. struct ipa_ref *r = first_referring ();
  79. return r && r->use == IPA_REF_ALIAS ? r : NULL;
  80. }
  81. /* Return last referring alias. */
  82. struct ipa_ref *last_alias (void)
  83. {
  84. unsigned int i = 0;
  85. for(i = 0; i < referring.length (); i++)
  86. if (referring[i]->use != IPA_REF_ALIAS)
  87. break;
  88. return i == 0 ? NULL : referring[i - 1];
  89. }
  90. /* Return true if the symbol has an alias. */
  91. bool inline has_aliases_p (void)
  92. {
  93. return first_alias ();
  94. }
  95. /* Clear reference list. */
  96. void clear (void)
  97. {
  98. referring.create (0);
  99. references = NULL;
  100. }
  101. /* Return number of references. */
  102. unsigned int nreferences (void)
  103. {
  104. return vec_safe_length (references);
  105. }
  106. /* Store actual references in references vector. */
  107. vec<ipa_ref_t, va_gc> *references;
  108. /* Referring is vector of pointers to references. It must not live in GGC space
  109. or GGC will try to mark middle of references vectors. */
  110. vec<ipa_ref_ptr> GTY((skip)) referring;
  111. };
  112. #endif /* GCC_IPA_REF_H */