valtrack.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Infrastructure for tracking user variable locations and values
  2. throughout compilation.
  3. Copyright (C) 2010-2019 Free Software Foundation, Inc.
  4. Contributed by Alexandre Oliva <aoliva@redhat.com>.
  5. This file is part of GCC.
  6. GCC is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 3, or (at your option) any later
  9. version.
  10. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GCC; see the file COPYING3. If not see
  16. <http://www.gnu.org/licenses/>. */
  17. #ifndef GCC_VALTRACK_H
  18. #define GCC_VALTRACK_H
  19. /* Debug uses of dead regs. */
  20. /* Entry that maps a dead pseudo (REG) used in a debug insns that dies
  21. at different blocks to the debug temp (DTEMP) it was replaced
  22. with. */
  23. struct dead_debug_global_entry
  24. {
  25. rtx reg;
  26. rtx dtemp;
  27. };
  28. /* Descriptor for hash_table to hash by dead_debug_global_entry's REG
  29. and map to DTEMP. */
  30. struct dead_debug_hash_descr : free_ptr_hash <dead_debug_global_entry>
  31. {
  32. /* Hash on the pseudo number. */
  33. static inline hashval_t hash (const dead_debug_global_entry *my);
  34. /* Entries are identical if they refer to the same pseudo. */
  35. static inline bool equal (const dead_debug_global_entry *my,
  36. const dead_debug_global_entry *other);
  37. };
  38. /* Hash on the pseudo number. */
  39. inline hashval_t
  40. dead_debug_hash_descr::hash (const dead_debug_global_entry *my)
  41. {
  42. return REGNO (my->reg);
  43. }
  44. /* Entries are identical if they refer to the same pseudo. */
  45. inline bool
  46. dead_debug_hash_descr::equal (const dead_debug_global_entry *my,
  47. const dead_debug_global_entry *other)
  48. {
  49. return my->reg == other->reg;
  50. }
  51. /* Maintain a global table of pseudos used in debug insns after their
  52. deaths in other blocks, and debug temps their deathpoint values are
  53. to be bound to. */
  54. struct dead_debug_global
  55. {
  56. /* This hash table that maps pseudos to debug temps. */
  57. hash_table<dead_debug_hash_descr> *htab;
  58. /* For each entry in htab, the bit corresponding to its REGNO will
  59. be set. */
  60. bitmap used;
  61. };
  62. /* Node of a linked list of uses of dead REGs in debug insns. */
  63. struct dead_debug_use
  64. {
  65. df_ref use;
  66. struct dead_debug_use *next;
  67. };
  68. /* Linked list of the above, with a bitmap of the REGs in the
  69. list. */
  70. struct dead_debug_local
  71. {
  72. /* The first dead_debug_use entry in the list. */
  73. struct dead_debug_use *head;
  74. /* A pointer to the global tracking data structure. */
  75. struct dead_debug_global *global;
  76. /* A bitmap that has bits set for each REG used in the
  77. dead_debug_use list, and for each entry in the global hash
  78. table. */
  79. bitmap used;
  80. /* A bitmap that has bits set for each INSN that is to be
  81. rescanned. */
  82. bitmap to_rescan;
  83. };
  84. /* This type controls the behavior of dead_debug_insert_temp WRT
  85. UREGNO and INSN. */
  86. enum debug_temp_where
  87. {
  88. /* Bind a newly-created debug temporary to a REG for UREGNO, and
  89. insert the debug insn before INSN. REG is expected to die at
  90. INSN. */
  91. DEBUG_TEMP_BEFORE_WITH_REG = -1,
  92. /* Bind a newly-created debug temporary to the value INSN stores
  93. in REG, and insert the debug insn before INSN. */
  94. DEBUG_TEMP_BEFORE_WITH_VALUE = 0,
  95. /* Bind a newly-created debug temporary to a REG for UREGNO, and
  96. insert the debug insn after INSN. REG is expected to be set at
  97. INSN. */
  98. DEBUG_TEMP_AFTER_WITH_REG = 1,
  99. /* Like DEBUG_TEMP_AFTER_WITH_REG, but force addition of a debug
  100. temporary even if there is just a single debug use. This is used
  101. on regs that are becoming REG_DEAD on INSN and so uses of the
  102. reg later on are invalid. */
  103. DEBUG_TEMP_AFTER_WITH_REG_FORCE = 2
  104. };
  105. extern void dead_debug_global_init (struct dead_debug_global *, bitmap);
  106. extern void dead_debug_global_finish (struct dead_debug_global *, bitmap);
  107. extern void dead_debug_local_init (struct dead_debug_local *, bitmap,
  108. struct dead_debug_global *);
  109. extern void dead_debug_local_finish (struct dead_debug_local *, bitmap);
  110. extern void dead_debug_add (struct dead_debug_local *, df_ref, unsigned int);
  111. extern int dead_debug_insert_temp (struct dead_debug_local *,
  112. unsigned int uregno, rtx_insn *insn,
  113. enum debug_temp_where);
  114. extern void propagate_for_debug (rtx_insn *, rtx_insn *, rtx, rtx, basic_block);
  115. #endif /* GCC_VALTRACK_H */