valtrack.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* Infrastructure for tracking user variable locations and values
  2. throughout compilation.
  3. Copyright (C) 2010-2015 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. #include "bitmap.h"
  20. #include "df.h"
  21. #include "rtl.h"
  22. #include "hash-table.h"
  23. /* Debug uses of dead regs. */
  24. /* Entry that maps a dead pseudo (REG) used in a debug insns that dies
  25. at different blocks to the debug temp (DTEMP) it was replaced
  26. with. */
  27. struct dead_debug_global_entry
  28. {
  29. rtx reg;
  30. rtx dtemp;
  31. };
  32. /* Descriptor for hash_table to hash by dead_debug_global_entry's REG
  33. and map to DTEMP. */
  34. struct dead_debug_hash_descr
  35. {
  36. /* The hash table contains pointers to entries of this type. */
  37. typedef struct dead_debug_global_entry value_type;
  38. typedef struct dead_debug_global_entry compare_type;
  39. /* Hash on the pseudo number. */
  40. static inline hashval_t hash (const value_type *my);
  41. /* Entries are identical if they refer to the same pseudo. */
  42. static inline bool equal (const value_type *my, const compare_type *other);
  43. /* Release entries when they're removed. */
  44. static inline void remove (value_type *p);
  45. };
  46. /* Hash on the pseudo number. */
  47. inline hashval_t
  48. dead_debug_hash_descr::hash (const value_type *my)
  49. {
  50. return REGNO (my->reg);
  51. }
  52. /* Entries are identical if they refer to the same pseudo. */
  53. inline bool
  54. dead_debug_hash_descr::equal (const value_type *my, const compare_type *other)
  55. {
  56. return my->reg == other->reg;
  57. }
  58. /* Release entries when they're removed. */
  59. inline void
  60. dead_debug_hash_descr::remove (value_type *p)
  61. {
  62. XDELETE (p);
  63. }
  64. /* Maintain a global table of pseudos used in debug insns after their
  65. deaths in other blocks, and debug temps their deathpoint values are
  66. to be bound to. */
  67. struct dead_debug_global
  68. {
  69. /* This hash table that maps pseudos to debug temps. */
  70. hash_table<dead_debug_hash_descr> *htab;
  71. /* For each entry in htab, the bit corresponding to its REGNO will
  72. be set. */
  73. bitmap used;
  74. };
  75. /* Node of a linked list of uses of dead REGs in debug insns. */
  76. struct dead_debug_use
  77. {
  78. df_ref use;
  79. struct dead_debug_use *next;
  80. };
  81. /* Linked list of the above, with a bitmap of the REGs in the
  82. list. */
  83. struct dead_debug_local
  84. {
  85. /* The first dead_debug_use entry in the list. */
  86. struct dead_debug_use *head;
  87. /* A pointer to the global tracking data structure. */
  88. struct dead_debug_global *global;
  89. /* A bitmap that has bits set for each REG used in the
  90. dead_debug_use list, and for each entry in the global hash
  91. table. */
  92. bitmap used;
  93. /* A bitmap that has bits set for each INSN that is to be
  94. rescanned. */
  95. bitmap to_rescan;
  96. };
  97. /* This type controls the behavior of dead_debug_insert_temp WRT
  98. UREGNO and INSN. */
  99. enum debug_temp_where
  100. {
  101. /* Bind a newly-created debug temporary to a REG for UREGNO, and
  102. insert the debug insn before INSN. REG is expected to die at
  103. INSN. */
  104. DEBUG_TEMP_BEFORE_WITH_REG = -1,
  105. /* Bind a newly-created debug temporary to the value INSN stores
  106. in REG, and insert the debug insn before INSN. */
  107. DEBUG_TEMP_BEFORE_WITH_VALUE = 0,
  108. /* Bind a newly-created debug temporary to a REG for UREGNO, and
  109. insert the debug insn after INSN. REG is expected to be set at
  110. INSN. */
  111. DEBUG_TEMP_AFTER_WITH_REG = 1,
  112. /* Like DEBUG_TEMP_AFTER_WITH_REG, but force addition of a debug
  113. temporary even if there is just a single debug use. This is used
  114. on regs that are becoming REG_DEAD on INSN and so uses of the
  115. reg later on are invalid. */
  116. DEBUG_TEMP_AFTER_WITH_REG_FORCE = 2
  117. };
  118. extern void dead_debug_global_init (struct dead_debug_global *, bitmap);
  119. extern void dead_debug_global_finish (struct dead_debug_global *, bitmap);
  120. extern void dead_debug_local_init (struct dead_debug_local *, bitmap,
  121. struct dead_debug_global *);
  122. extern void dead_debug_local_finish (struct dead_debug_local *, bitmap);
  123. extern void dead_debug_add (struct dead_debug_local *, df_ref, unsigned int);
  124. extern int dead_debug_insert_temp (struct dead_debug_local *,
  125. unsigned int uregno, rtx_insn *insn,
  126. enum debug_temp_where);
  127. extern void propagate_for_debug (rtx_insn *, rtx_insn *, rtx, rtx, basic_block);
  128. #endif /* GCC_VALTRACK_H */