df.h revision 169689
1/* Form lists of pseudo register references for autoinc optimization
2   for GNU compiler.  This is part of flow optimization.
3   Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006
4   Free Software Foundation, Inc.
5   Originally contributed by Michael P. Hayes
6             (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com)
7   Major rewrite contributed by Danny Berlin (dberlin@dberlin.org)
8             and Kenneth Zadeck (zadeck@naturalbridge.com).
9
10This file is part of GCC.
11
12GCC is free software; you can redistribute it and/or modify it under
13the terms of the GNU General Public License as published by the Free
14Software Foundation; either version 2, or (at your option) any later
15version.
16
17GCC is distributed in the hope that it will be useful, but WITHOUT ANY
18WARRANTY; without even the implied warranty of MERCHANTABILITY or
19FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20for more details.
21
22You should have received a copy of the GNU General Public License
23along with GCC; see the file COPYING.  If not, write to the Free
24Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2502110-1301, USA.  */
26
27#ifndef GCC_DF_H
28#define GCC_DF_H
29
30#include "bitmap.h"
31#include "basic-block.h"
32#include "alloc-pool.h"
33
34struct dataflow;
35struct df;
36struct df_problem;
37struct df_link;
38
39/* Data flow problems.  All problems must have a unique here.  */
40/* Scanning is not really a dataflow problem, but it is useful to have
41   the basic block functions in the vector so that things get done in
42   a uniform manner.  */
43#define DF_SCAN  0
44#define DF_RU    1      /* Reaching Uses. */
45#define DF_RD    2      /* Reaching Defs. */
46#define DF_LR    3      /* Live Registers. */
47#define DF_UR    4      /* Uninitialized Registers. */
48#define DF_UREC  5      /* Uninitialized Registers with Early Clobber. */
49#define DF_CHAIN 6      /* Def-Use and/or Use-Def Chains. */
50#define DF_RI    7      /* Register Info. */
51#define DF_LAST_PROBLEM_PLUS1 (DF_RI + 1)
52
53
54/* Dataflow direction.  */
55enum df_flow_dir
56  {
57    DF_NONE,
58    DF_FORWARD,
59    DF_BACKWARD
60  };
61
62
63/* The first of these is a set of a register.  The remaining three are
64   all uses of a register (the mem_load and mem_store relate to how
65   the register as an addressing operand).  */
66enum df_ref_type {DF_REF_REG_DEF, DF_REF_REG_USE, DF_REF_REG_MEM_LOAD,
67		  DF_REF_REG_MEM_STORE};
68
69#define DF_REF_TYPE_NAMES {"def", "use", "mem load", "mem store"}
70
71enum df_ref_flags
72  {
73    /* Read-modify-write refs generate both a use and a def and
74       these are marked with this flag to show that they are not
75       independent.  */
76    DF_REF_READ_WRITE = 1,
77
78    /* This flag is set, if we stripped the subreg from the reference.
79       In this case we must make conservative guesses, at what the
80       outer mode was.  */
81    DF_REF_STRIPPED = 2,
82
83    /* If this flag is set, this is not a real definition/use, but an
84       artificial one created to model always live registers, eh uses, etc.  */
85    DF_REF_ARTIFICIAL = 4,
86
87
88    /* If this flag is set for an artificial use or def, that ref
89       logically happens at the top of the block.  If it is not set
90       for an artificial use or def, that ref logically happens at the
91       bottom of the block.  This is never set for regular refs.  */
92    DF_REF_AT_TOP = 8,
93
94    /* This flag is set if the use is inside a REG_EQUAL note.  */
95    DF_REF_IN_NOTE = 16,
96
97    /* This flag is set if this ref, generally a def, may clobber the
98       referenced register.  This is generally only set for hard
99       registers that cross a call site.  With better information
100       about calls, some of these could be changed in the future to
101       DF_REF_MUST_CLOBBER.  */
102    DF_REF_MAY_CLOBBER = 32,
103
104    /* This flag is set if this ref, generally a def, is a real
105       clobber. This is not currently set for registers live across a
106       call because that clobbering may or may not happen.
107
108       Most of the uses of this are with sets that have a
109       GET_CODE(..)==CLOBBER.  Note that this is set even if the
110       clobber is to a subreg.  So in order to tell if the clobber
111       wipes out the entire register, it is necessary to also check
112       the DF_REF_PARTIAL flag.  */
113    DF_REF_MUST_CLOBBER = 64,
114
115    /* This bit is true if this ref is part of a multiword hardreg.  */
116    DF_REF_MW_HARDREG = 128,
117
118    /* This flag is set if this ref is a partial use or def of the
119       associated register.  */
120    DF_REF_PARTIAL = 256
121  };
122
123
124/* Function prototypes added to df_problem instance.  */
125
126/* Allocate the problem specific data.  */
127typedef void (*df_alloc_function) (struct dataflow *, bitmap, bitmap);
128
129/* This function is called if the problem has global data that needs
130   to be cleared when ever the set of blocks changes.  The bitmap
131   contains the set of blocks that may require special attention.
132   This call is only made if some of the blocks are going to change.
133   If everything is to be deleted, the wholesale deletion mechanisms
134   apply. */
135typedef void (*df_reset_function) (struct dataflow *, bitmap);
136
137/* Free the basic block info.  Called from the block reordering code
138   to get rid of the blocks that have been squished down.   */
139typedef void (*df_free_bb_function) (struct dataflow *, basic_block, void *);
140
141/* Local compute function.  */
142typedef void (*df_local_compute_function) (struct dataflow *, bitmap, bitmap);
143
144/* Init the solution specific data.  */
145typedef void (*df_init_function) (struct dataflow *, bitmap);
146
147/* Iterative dataflow function.  */
148typedef void (*df_dataflow_function) (struct dataflow *, bitmap, bitmap,
149				   int *, int, bool);
150
151/* Confluence operator for blocks with 0 out (or in) edges.  */
152typedef void (*df_confluence_function_0) (struct dataflow *, basic_block);
153
154/* Confluence operator for blocks with 1 or more out (or in) edges.  */
155typedef void (*df_confluence_function_n) (struct dataflow *, edge);
156
157/* Transfer function for blocks.  */
158typedef bool (*df_transfer_function) (struct dataflow *, int);
159
160/* Function to massage the information after the problem solving.  */
161typedef void (*df_finalizer_function) (struct dataflow*, bitmap);
162
163/* Function to free all of the problem specific datastructures.  */
164typedef void (*df_free_function) (struct dataflow *);
165
166/* Function to dump results to FILE.  */
167typedef void (*df_dump_problem_function) (struct dataflow *, FILE *);
168
169/* Function to add problem a dataflow problem that must be solved
170   before this problem can be solved.  */
171typedef struct dataflow * (*df_dependent_problem_function) (struct df *, int);
172
173/* The static description of a dataflow problem to solve.  See above
174   typedefs for doc for the function fields.  */
175
176struct df_problem {
177  /* The unique id of the problem.  This is used it index into
178     df->defined_problems to make accessing the problem data easy.  */
179  unsigned int id;
180  enum df_flow_dir dir;			/* Dataflow direction.  */
181  df_alloc_function alloc_fun;
182  df_reset_function reset_fun;
183  df_free_bb_function free_bb_fun;
184  df_local_compute_function local_compute_fun;
185  df_init_function init_fun;
186  df_dataflow_function dataflow_fun;
187  df_confluence_function_0 con_fun_0;
188  df_confluence_function_n con_fun_n;
189  df_transfer_function trans_fun;
190  df_finalizer_function finalize_fun;
191  df_free_function free_fun;
192  df_dump_problem_function dump_fun;
193  df_dependent_problem_function dependent_problem_fun;
194
195  /* Flags can be changed after analysis starts.  */
196  int changeable_flags;
197};
198
199
200/* The specific instance of the problem to solve.  */
201struct dataflow
202{
203  struct df *df;                        /* Instance of df we are working in.  */
204  struct df_problem *problem;           /* The problem to be solved.  */
205
206  /* Communication between iterative_dataflow and hybrid_search. */
207  sbitmap visited, pending, considered;
208
209  /* Array indexed by bb->index, that contains basic block problem and
210     solution specific information.  */
211  void **block_info;
212  unsigned int block_info_size;
213
214  /* The pool to allocate the block_info from. */
215  alloc_pool block_pool;
216
217  /* Problem specific control information.  */
218
219  /* Scanning flags.  */
220#define DF_HARD_REGS	     1	/* Mark hard registers.  */
221#define DF_EQUIV_NOTES	     2	/* Mark uses present in EQUIV/EQUAL notes.  */
222#define DF_SUBREGS	     4	/* Return subregs rather than the inner reg.  */
223  /* Flags that control the building of chains.  */
224#define DF_DU_CHAIN          1    /* Build DU chains.  */
225#define DF_UD_CHAIN          2    /* Build UD chains.  */
226  /* Flag to control the building of register info.  */
227#define DF_RI_LIFE           1    /* Build register info.  */
228
229  int flags;
230
231  /* Other problem specific data that is not on a per basic block
232     basis.  The structure is generally defined privately for the
233     problem.  The exception being the scanning problem where it is
234     fully public.  */
235  void *problem_data;
236};
237
238
239/* The set of multiword hardregs used as operands to this
240   instruction. These are factored into individual uses and defs but
241   the aggregate is still needed to service the REG_DEAD and
242   REG_UNUSED notes.  */
243struct df_mw_hardreg
244{
245  rtx mw_reg;                   /* The multiword hardreg.  */
246  enum df_ref_type type;        /* Used to see if the ref is read or write.  */
247  enum df_ref_flags flags;	/* Various flags.  */
248  struct df_link *regs;         /* The individual regs that make up
249				   this hardreg.  */
250  struct df_mw_hardreg *next;   /* The next mw_hardreg in this insn.  */
251};
252
253
254/* One of these structures is allocated for every insn.  */
255struct df_insn_info
256{
257  struct df_ref *defs;	        /* Head of insn-def chain.  */
258  struct df_ref *uses;	        /* Head of insn-use chain.  */
259  struct df_mw_hardreg *mw_hardregs;
260  /* ???? The following luid field should be considered private so that
261     we can change it on the fly to accommodate new insns?  */
262  int luid;			/* Logical UID.  */
263  bool contains_asm;            /* Contains an asm instruction.  */
264};
265
266
267/* Two of these structures are allocated for every pseudo reg, one for
268   the uses and one for the defs.  */
269struct df_reg_info
270{
271  struct df_ref *reg_chain;     /* Head of reg-use or def chain.  */
272  unsigned int begin;           /* First def_index for this pseudo.  */
273  unsigned int n_refs;          /* Number of refs or defs for this pseudo.  */
274};
275
276/* Define a register reference structure.  One of these is allocated
277   for every register reference (use or def).  Note some register
278   references (e.g., post_inc, subreg) generate both a def and a use.  */
279struct df_ref
280{
281  rtx reg;			/* The register referenced.  */
282  unsigned int regno;           /* The register number referenced.  */
283  basic_block bb;               /* Basic block containing the instruction. */
284
285  /* Insn containing ref. This will be null if this is an artificial
286     reference.  */
287  rtx insn;
288  rtx *loc;			/* The location of the reg.  */
289  struct df_link *chain;	/* Head of def-use, use-def.  */
290  unsigned int id;		/* Location in table.  */
291  enum df_ref_type type;	/* Type of ref.  */
292  enum df_ref_flags flags;	/* Various flags.  */
293
294  /* For each regno, there are two chains of refs, one for the uses
295     and one for the defs.  These chains go thru the refs themselves
296     rather than using an external structure.  */
297  struct df_ref *next_reg;     /* Next ref with same regno and type.  */
298  struct df_ref *prev_reg;     /* Prev ref with same regno and type.  */
299
300  /* Each insn has two lists, one for the uses and one for the
301     defs. This is the next field in either of these chains. */
302  struct df_ref *next_ref;
303  void *data;			/* The data assigned to it by user.  */
304};
305
306/* These links are used for two purposes:
307   1) def-use or use-def chains.
308   2) Multiword hard registers that underly a single hardware register.  */
309struct df_link
310{
311  struct df_ref *ref;
312  struct df_link *next;
313};
314
315/* Two of these structures are allocated, one for the uses and one for
316   the defs.  */
317struct df_ref_info
318{
319  struct df_reg_info **regs;    /* Array indexed by pseudo regno. */
320  unsigned int regs_size;       /* Size of currently allocated regs table.  */
321  unsigned int regs_inited;     /* Number of regs with reg_infos allocated.  */
322  struct df_ref **refs;         /* Ref table, indexed by id.  */
323  unsigned int refs_size;       /* Size of currently allocated refs table.  */
324  unsigned int bitmap_size;	/* Number of refs seen.  */
325
326  /* True if refs table is organized so that every reference for a
327     pseudo is contiguous.  */
328  bool refs_organized;
329  /* True if the next refs should be added immediately or false to
330     defer to later to reorganize the table.  */
331  bool add_refs_inline;
332};
333
334
335/*----------------------------------------------------------------------------
336   Problem data for the scanning dataflow problem.  Unlike the other
337   dataflow problems, the problem data for scanning is fully exposed and
338   used by owners of the problem.
339----------------------------------------------------------------------------*/
340
341struct df
342{
343
344  /* The set of problems to be solved is stored in two arrays.  In
345     PROBLEMS_IN_ORDER, the problems are stored in the order that they
346     are solved.  This is an internally dense array that may have
347     nulls at the end of it.  In PROBLEMS_BY_INDEX, the problem is
348     stored by the value in df_problem.id.  These are used to access
349     the problem local data without having to search the first
350     array.  */
351
352  struct dataflow *problems_in_order [DF_LAST_PROBLEM_PLUS1];
353  struct dataflow *problems_by_index [DF_LAST_PROBLEM_PLUS1];
354  int num_problems_defined;
355
356  /* Set after calls to df_scan_blocks, this contains all of the
357     blocks that higher level problems must rescan before solving the
358     dataflow equations.  If this is NULL, the blocks_to_analyze is
359     used. */
360  bitmap blocks_to_scan;
361
362  /* If not NULL, the subset of blocks of the program to be considered
363     for analysis.  */
364  bitmap blocks_to_analyze;
365
366  /* The following information is really the problem data for the
367     scanning instance but it is used too often by the other problems
368     to keep getting it from there.  */
369  struct df_ref_info def_info;   /* Def info.  */
370  struct df_ref_info use_info;   /* Use info.  */
371  struct df_insn_info **insns;   /* Insn table, indexed by insn UID.  */
372  unsigned int insns_size;       /* Size of insn table.  */
373  bitmap hardware_regs_used;     /* The set of hardware registers used.  */
374  bitmap entry_block_defs;       /* The set of hardware registers live on entry to the function.  */
375  bitmap exit_block_uses;        /* The set of hardware registers used in exit block.  */
376};
377
378#define DF_SCAN_BB_INFO(DF, BB) (df_scan_get_bb_info((DF)->problems_by_index[DF_SCAN],(BB)->index))
379#define DF_RU_BB_INFO(DF, BB) (df_ru_get_bb_info((DF)->problems_by_index[DF_RU],(BB)->index))
380#define DF_RD_BB_INFO(DF, BB) (df_rd_get_bb_info((DF)->problems_by_index[DF_RD],(BB)->index))
381#define DF_LR_BB_INFO(DF, BB) (df_lr_get_bb_info((DF)->problems_by_index[DF_LR],(BB)->index))
382#define DF_UR_BB_INFO(DF, BB) (df_ur_get_bb_info((DF)->problems_by_index[DF_UR],(BB)->index))
383#define DF_UREC_BB_INFO(DF, BB) (df_urec_get_bb_info((DF)->problems_by_index[DF_UREC],(BB)->index))
384
385/* Most transformations that wish to use live register analysis will
386   use these macros.  The DF_UPWARD_LIVE* macros are only half of the
387   solution.  */
388#define DF_LIVE_IN(DF, BB) (DF_UR_BB_INFO(DF, BB)->in)
389#define DF_LIVE_OUT(DF, BB) (DF_UR_BB_INFO(DF, BB)->out)
390
391
392/* Live in for register allocation also takes into account several other factors.  */
393#define DF_RA_LIVE_IN(DF, BB) (DF_UREC_BB_INFO(DF, BB)->in)
394#define DF_RA_LIVE_OUT(DF, BB) (DF_UREC_BB_INFO(DF, BB)->out)
395
396/* These macros are currently used by only reg-stack since it is not
397   tolerant of uninitialized variables.  This intolerance should be
398   fixed because it causes other problems.  */
399#define DF_UPWARD_LIVE_IN(DF, BB) (DF_LR_BB_INFO(DF, BB)->in)
400#define DF_UPWARD_LIVE_OUT(DF, BB) (DF_LR_BB_INFO(DF, BB)->out)
401
402
403/* Macros to access the elements within the ref structure.  */
404
405
406#define DF_REF_REAL_REG(REF) (GET_CODE ((REF)->reg) == SUBREG \
407				? SUBREG_REG ((REF)->reg) : ((REF)->reg))
408#define DF_REF_REGNO(REF) ((REF)->regno)
409#define DF_REF_REAL_LOC(REF) (GET_CODE ((REF)->reg) == SUBREG \
410			        ? &SUBREG_REG ((REF)->reg) : ((REF)->loc))
411#define DF_REF_REG(REF) ((REF)->reg)
412#define DF_REF_LOC(REF) ((REF)->loc)
413#define DF_REF_BB(REF) ((REF)->bb)
414#define DF_REF_BBNO(REF) (DF_REF_BB (REF)->index)
415#define DF_REF_INSN(REF) ((REF)->insn)
416#define DF_REF_INSN_UID(REF) (INSN_UID ((REF)->insn))
417#define DF_REF_TYPE(REF) ((REF)->type)
418#define DF_REF_CHAIN(REF) ((REF)->chain)
419#define DF_REF_ID(REF) ((REF)->id)
420#define DF_REF_FLAGS(REF) ((REF)->flags)
421#define DF_REF_NEXT_REG(REF) ((REF)->next_reg)
422#define DF_REF_PREV_REG(REF) ((REF)->prev_reg)
423#define DF_REF_NEXT_REF(REF) ((REF)->next_ref)
424#define DF_REF_DATA(REF) ((REF)->data)
425
426/* Macros to determine the reference type.  */
427
428#define DF_REF_REG_DEF_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_DEF)
429#define DF_REF_REG_USE_P(REF) ((REF) && !DF_REF_REG_DEF_P (REF))
430#define DF_REF_REG_MEM_STORE_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_STORE)
431#define DF_REF_REG_MEM_LOAD_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_LOAD)
432#define DF_REF_REG_MEM_P(REF) (DF_REF_REG_MEM_STORE_P (REF) \
433                               || DF_REF_REG_MEM_LOAD_P (REF))
434
435/* Macros to get the refs out of def_info or use_info refs table.  */
436#define DF_DEFS_SIZE(DF) ((DF)->def_info.bitmap_size)
437#define DF_DEFS_GET(DF,ID) ((DF)->def_info.refs[(ID)])
438#define DF_DEFS_SET(DF,ID,VAL) ((DF)->def_info.refs[(ID)]=(VAL))
439#define DF_USES_SIZE(DF) ((DF)->use_info.bitmap_size)
440#define DF_USES_GET(DF,ID) ((DF)->use_info.refs[(ID)])
441#define DF_USES_SET(DF,ID,VAL) ((DF)->use_info.refs[(ID)]=(VAL))
442
443/* Macros to access the register information from scan dataflow record.  */
444
445#define DF_REG_SIZE(DF) ((DF)->def_info.regs_inited)
446#define DF_REG_DEF_GET(DF, REG) ((DF)->def_info.regs[(REG)])
447#define DF_REG_DEF_SET(DF, REG, VAL) ((DF)->def_info.regs[(REG)]=(VAL))
448#define DF_REG_DEF_COUNT(DF, REG) ((DF)->def_info.regs[(REG)]->n_refs)
449#define DF_REG_USE_GET(DF, REG) ((DF)->use_info.regs[(REG)])
450#define DF_REG_USE_SET(DF, REG, VAL) ((DF)->use_info.regs[(REG)]=(VAL))
451#define DF_REG_USE_COUNT(DF, REG) ((DF)->use_info.regs[(REG)]->n_refs)
452
453/* Macros to access the elements within the reg_info structure table.  */
454
455#define DF_REGNO_FIRST_DEF(DF, REGNUM) \
456(DF_REG_DEF_GET(DF, REGNUM) ? DF_REG_DEF_GET(DF, REGNUM) : 0)
457#define DF_REGNO_LAST_USE(DF, REGNUM) \
458(DF_REG_USE_GET(DF, REGNUM) ? DF_REG_USE_GET(DF, REGNUM) : 0)
459
460/* Macros to access the elements within the insn_info structure table.  */
461
462#define DF_INSN_SIZE(DF) ((DF)->insns_size)
463#define DF_INSN_GET(DF,INSN) ((DF)->insns[(INSN_UID(INSN))])
464#define DF_INSN_SET(DF,INSN,VAL) ((DF)->insns[(INSN_UID (INSN))]=(VAL))
465#define DF_INSN_CONTAINS_ASM(DF, INSN) (DF_INSN_GET(DF,INSN)->contains_asm)
466#define DF_INSN_LUID(DF, INSN) (DF_INSN_GET(DF,INSN)->luid)
467#define DF_INSN_DEFS(DF, INSN) (DF_INSN_GET(DF,INSN)->defs)
468#define DF_INSN_USES(DF, INSN) (DF_INSN_GET(DF,INSN)->uses)
469
470#define DF_INSN_UID_GET(DF,UID) ((DF)->insns[(UID)])
471#define DF_INSN_UID_LUID(DF, INSN) (DF_INSN_UID_GET(DF,INSN)->luid)
472#define DF_INSN_UID_DEFS(DF, INSN) (DF_INSN_UID_GET(DF,INSN)->defs)
473#define DF_INSN_UID_USES(DF, INSN) (DF_INSN_UID_GET(DF,INSN)->uses)
474#define DF_INSN_UID_MWS(DF, INSN) (DF_INSN_UID_GET(DF,INSN)->mw_hardregs)
475
476/* This is a bitmap copy of regs_invalidated_by_call so that we can
477   easily add it into bitmaps, etc. */
478
479extern bitmap df_invalidated_by_call;
480
481
482/* One of these structures is allocated for every basic block.  */
483struct df_scan_bb_info
484{
485  /* Defs at the start of a basic block that is the target of an
486     exception edge.  */
487  struct df_ref *artificial_defs;
488
489  /* Uses of hard registers that are live at every block.  */
490  struct df_ref *artificial_uses;
491};
492
493
494/* Reaching uses.  All bitmaps are indexed by the id field of the ref
495   except sparse_kill (see below).  */
496struct df_ru_bb_info
497{
498  /* Local sets to describe the basic blocks.  */
499  /* The kill set is the set of uses that are killed in this block.
500     However, if the number of uses for this register is greater than
501     DF_SPARSE_THRESHOLD, the sparse_kill is used instead. In
502     sparse_kill, each register gets a slot and a 1 in this bitvector
503     means that all of the uses of that register are killed.  This is
504     a very useful efficiency hack in that it keeps from having push
505     around big groups of 1s.  This is implemented by the
506     bitmap_clear_range call.  */
507
508  bitmap kill;
509  bitmap sparse_kill;
510  bitmap gen;   /* The set of uses generated in this block.  */
511
512  /* The results of the dataflow problem.  */
513  bitmap in;    /* At the top of the block.  */
514  bitmap out;   /* At the bottom of the block.  */
515};
516
517
518/* Reaching definitions.  All bitmaps are indexed by the id field of
519   the ref except sparse_kill (see above).  */
520struct df_rd_bb_info
521{
522  /* Local sets to describe the basic blocks.  See the note in the RU
523     datastructures for kill and sparse_kill.  */
524  bitmap kill;
525  bitmap sparse_kill;
526  bitmap gen;   /* The set of defs generated in this block.  */
527
528  /* The results of the dataflow problem.  */
529  bitmap in;    /* At the top of the block.  */
530  bitmap out;   /* At the bottom of the block.  */
531};
532
533
534/* Live registers.  All bitmaps are referenced by the register number.  */
535struct df_lr_bb_info
536{
537  /* Local sets to describe the basic blocks.  */
538  bitmap def;   /* The set of registers set in this block.  */
539  bitmap use;   /* The set of registers used in this block.  */
540
541  /* The results of the dataflow problem.  */
542  bitmap in;    /* At the top of the block.  */
543  bitmap out;   /* At the bottom of the block.  */
544};
545
546
547/* Uninitialized registers.  All bitmaps are referenced by the register number.  */
548struct df_ur_bb_info
549{
550  /* Local sets to describe the basic blocks.  */
551  bitmap kill;  /* The set of registers unset in this block.  Calls,
552		   for instance, unset registers.  */
553  bitmap gen;   /* The set of registers set in this block.  */
554
555  /* The results of the dataflow problem.  */
556  bitmap in;    /* At the top of the block.  */
557  bitmap out;   /* At the bottom of the block.  */
558};
559
560/* Uninitialized registers.  All bitmaps are referenced by the register number.  */
561struct df_urec_bb_info
562{
563  /* Local sets to describe the basic blocks.  */
564  bitmap earlyclobber;  /* The set of registers that are referenced
565			   with an an early clobber mode.  */
566  /* Kill and gen are defined as in the UR problem.  */
567  bitmap kill;
568  bitmap gen;
569
570  /* The results of the dataflow problem.  */
571  bitmap in;    /* At the top of the block.  */
572  bitmap out;   /* At the bottom of the block.  */
573};
574
575
576#define df_finish(df) {df_finish1(df); df=NULL;}
577
578/* Functions defined in df-core.c.  */
579
580extern struct df *df_init (int);
581extern struct dataflow *df_add_problem (struct df *, struct df_problem *, int);
582extern int df_set_flags (struct dataflow *, int);
583extern int df_clear_flags (struct dataflow *, int);
584extern void df_set_blocks (struct df*, bitmap);
585extern void df_delete_basic_block (struct df *, int);
586extern void df_finish1 (struct df *);
587extern void df_analyze_problem (struct dataflow *, bitmap, bitmap, bitmap, int *, int, bool);
588extern void df_analyze (struct df *);
589extern void df_compact_blocks (struct df *);
590extern void df_bb_replace (struct df *, int, basic_block);
591extern struct df_ref *df_bb_regno_last_use_find (struct df *, basic_block, unsigned int);
592extern struct df_ref *df_bb_regno_first_def_find (struct df *, basic_block, unsigned int);
593extern struct df_ref *df_bb_regno_last_def_find (struct df *, basic_block, unsigned int);
594extern bool df_insn_regno_def_p (struct df *, rtx, unsigned int);
595extern struct df_ref *df_find_def (struct df *, rtx, rtx);
596extern bool df_reg_defined (struct df *, rtx, rtx);
597extern struct df_ref *df_find_use (struct df *, rtx, rtx);
598extern bool df_reg_used (struct df *, rtx, rtx);
599extern void df_iterative_dataflow (struct dataflow *, bitmap, bitmap, int *, int, bool);
600extern void df_dump (struct df *, FILE *);
601extern void df_refs_chain_dump (struct df_ref *, bool, FILE *);
602extern void df_regs_chain_dump (struct df *, struct df_ref *,  FILE *);
603extern void df_insn_debug (struct df *, rtx, bool, FILE *);
604extern void df_insn_debug_regno (struct df *, rtx, FILE *);
605extern void df_regno_debug (struct df *, unsigned int, FILE *);
606extern void df_ref_debug (struct df_ref *, FILE *);
607extern void debug_df_insn (rtx);
608extern void debug_df_regno (unsigned int);
609extern void debug_df_reg (rtx);
610extern void debug_df_defno (unsigned int);
611extern void debug_df_useno (unsigned int);
612extern void debug_df_ref (struct df_ref *);
613extern void debug_df_chain (struct df_link *);
614/* An instance of df that can be shared between passes.  */
615extern struct df *shared_df;
616
617
618/* Functions defined in df-problems.c. */
619
620extern struct df_link *df_chain_create (struct dataflow *, struct df_ref *, struct df_ref *);
621extern void df_chain_unlink (struct dataflow *, struct df_ref *, struct df_link *);
622extern void df_chain_copy (struct dataflow *, struct df_ref *, struct df_link *);
623extern bitmap df_get_live_in (struct df *, basic_block);
624extern bitmap df_get_live_out (struct df *, basic_block);
625extern void df_grow_bb_info (struct dataflow *);
626extern void df_chain_dump (struct df_link *, FILE *);
627extern void df_print_bb_index (basic_block bb, FILE *file);
628extern struct dataflow *df_ru_add_problem (struct df *, int);
629extern struct df_ru_bb_info *df_ru_get_bb_info (struct dataflow *, unsigned int);
630extern struct dataflow *df_rd_add_problem (struct df *, int);
631extern struct df_rd_bb_info *df_rd_get_bb_info (struct dataflow *, unsigned int);
632extern struct dataflow *df_lr_add_problem (struct df *, int);
633extern struct df_lr_bb_info *df_lr_get_bb_info (struct dataflow *, unsigned int);
634extern struct dataflow *df_ur_add_problem (struct df *, int);
635extern struct df_ur_bb_info *df_ur_get_bb_info (struct dataflow *, unsigned int);
636extern struct dataflow *df_urec_add_problem (struct df *, int);
637extern struct df_urec_bb_info *df_urec_get_bb_info (struct dataflow *, unsigned int);
638extern struct dataflow *df_chain_add_problem (struct df *, int);
639extern struct dataflow *df_ri_add_problem (struct df *, int);
640
641
642/* Functions defined in df-scan.c.  */
643
644extern struct df_scan_bb_info *df_scan_get_bb_info (struct dataflow *, unsigned int);
645extern struct dataflow *df_scan_add_problem (struct df *, int);
646extern void df_rescan_blocks (struct df *, bitmap);
647extern struct df_ref *df_ref_create (struct df *, rtx, rtx *, rtx,basic_block,enum df_ref_type, enum df_ref_flags);
648extern struct df_ref *df_get_artificial_defs (struct df *, unsigned int);
649extern struct df_ref *df_get_artificial_uses (struct df *, unsigned int);
650extern void df_reg_chain_create (struct df_reg_info *, struct df_ref *);
651extern struct df_ref *df_reg_chain_unlink (struct dataflow *, struct df_ref *);
652extern void df_ref_remove (struct df *, struct df_ref *);
653extern void df_insn_refs_delete (struct dataflow *, rtx);
654extern void df_bb_refs_delete (struct dataflow *, int);
655extern void df_refs_delete (struct dataflow *, bitmap);
656extern void df_reorganize_refs (struct df_ref_info *);
657extern void df_hard_reg_init (void);
658extern bool df_read_modify_subreg_p (rtx);
659
660
661/* web */
662
663/* This entry is allocated for each reference in the insn stream.  */
664struct web_entry
665{
666  /* Pointer to the parent in the union/find tree.  */
667  struct web_entry *pred;
668  /* Newly assigned register to the entry.  Set only for roots.  */
669  rtx reg;
670  void* extra_info;
671};
672
673extern struct web_entry *unionfind_root (struct web_entry *);
674extern bool unionfind_union (struct web_entry *, struct web_entry *);
675extern void union_defs (struct df *, struct df_ref *,
676                        struct web_entry *, struct web_entry *,
677			bool (*fun) (struct web_entry *, struct web_entry *));
678
679
680#endif /* GCC_DF_H */
681