gcc/
[official-gcc.git] / gcc / valtrack.h
blob7223a4319894288ac94f16ed4ff95e747937dd9a
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>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_VALTRACK_H
23 #define GCC_VALTRACK_H
25 #include "bitmap.h"
26 #include "df.h"
27 #include "rtl.h"
29 /* Debug uses of dead regs. */
31 /* Entry that maps a dead pseudo (REG) used in a debug insns that dies
32 at different blocks to the debug temp (DTEMP) it was replaced
33 with. */
35 struct dead_debug_global_entry
37 rtx reg;
38 rtx dtemp;
41 /* Descriptor for hash_table to hash by dead_debug_global_entry's REG
42 and map to DTEMP. */
44 struct dead_debug_hash_descr : free_ptr_hash <dead_debug_global_entry>
46 /* Hash on the pseudo number. */
47 static inline hashval_t hash (const dead_debug_global_entry *my);
48 /* Entries are identical if they refer to the same pseudo. */
49 static inline bool equal (const dead_debug_global_entry *my,
50 const dead_debug_global_entry *other);
53 /* Hash on the pseudo number. */
54 inline hashval_t
55 dead_debug_hash_descr::hash (const dead_debug_global_entry *my)
57 return REGNO (my->reg);
60 /* Entries are identical if they refer to the same pseudo. */
61 inline bool
62 dead_debug_hash_descr::equal (const dead_debug_global_entry *my,
63 const dead_debug_global_entry *other)
65 return my->reg == other->reg;
68 /* Maintain a global table of pseudos used in debug insns after their
69 deaths in other blocks, and debug temps their deathpoint values are
70 to be bound to. */
72 struct dead_debug_global
74 /* This hash table that maps pseudos to debug temps. */
75 hash_table<dead_debug_hash_descr> *htab;
76 /* For each entry in htab, the bit corresponding to its REGNO will
77 be set. */
78 bitmap used;
81 /* Node of a linked list of uses of dead REGs in debug insns. */
83 struct dead_debug_use
85 df_ref use;
86 struct dead_debug_use *next;
89 /* Linked list of the above, with a bitmap of the REGs in the
90 list. */
92 struct dead_debug_local
94 /* The first dead_debug_use entry in the list. */
95 struct dead_debug_use *head;
96 /* A pointer to the global tracking data structure. */
97 struct dead_debug_global *global;
98 /* A bitmap that has bits set for each REG used in the
99 dead_debug_use list, and for each entry in the global hash
100 table. */
101 bitmap used;
102 /* A bitmap that has bits set for each INSN that is to be
103 rescanned. */
104 bitmap to_rescan;
107 /* This type controls the behavior of dead_debug_insert_temp WRT
108 UREGNO and INSN. */
110 enum debug_temp_where
112 /* Bind a newly-created debug temporary to a REG for UREGNO, and
113 insert the debug insn before INSN. REG is expected to die at
114 INSN. */
115 DEBUG_TEMP_BEFORE_WITH_REG = -1,
116 /* Bind a newly-created debug temporary to the value INSN stores
117 in REG, and insert the debug insn before INSN. */
118 DEBUG_TEMP_BEFORE_WITH_VALUE = 0,
119 /* Bind a newly-created debug temporary to a REG for UREGNO, and
120 insert the debug insn after INSN. REG is expected to be set at
121 INSN. */
122 DEBUG_TEMP_AFTER_WITH_REG = 1,
123 /* Like DEBUG_TEMP_AFTER_WITH_REG, but force addition of a debug
124 temporary even if there is just a single debug use. This is used
125 on regs that are becoming REG_DEAD on INSN and so uses of the
126 reg later on are invalid. */
127 DEBUG_TEMP_AFTER_WITH_REG_FORCE = 2
130 extern void dead_debug_global_init (struct dead_debug_global *, bitmap);
131 extern void dead_debug_global_finish (struct dead_debug_global *, bitmap);
132 extern void dead_debug_local_init (struct dead_debug_local *, bitmap,
133 struct dead_debug_global *);
134 extern void dead_debug_local_finish (struct dead_debug_local *, bitmap);
135 extern void dead_debug_add (struct dead_debug_local *, df_ref, unsigned int);
136 extern int dead_debug_insert_temp (struct dead_debug_local *,
137 unsigned int uregno, rtx_insn *insn,
138 enum debug_temp_where);
140 extern void propagate_for_debug (rtx_insn *, rtx_insn *, rtx, rtx, basic_block);
143 #endif /* GCC_VALTRACK_H */