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