diff options
author | Jeff Law <law@gcc.gnu.org> | 2001-06-28 16:11:19 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2001-06-28 16:11:19 -0600 |
commit | 10c4b247fd9f5a610f7a02dc21fa758173ed9aef (patch) | |
tree | f878eace31893b70b0dfb05d8672c204fb07c75f /gcc/df.h | |
parent | 0f40f9f7c68aadde4d52b4fc04d016b72451d238 (diff) | |
download | gcc-10c4b247fd9f5a610f7a02dc21fa758173ed9aef.zip gcc-10c4b247fd9f5a610f7a02dc21fa758173ed9aef.tar.gz gcc-10c4b247fd9f5a610f7a02dc21fa758173ed9aef.tar.bz2 |
Makefile.in (OBJS): Add df.o
* Makefile.in (OBJS): Add df.o
(df.o): Add dependencies.
* basic-block.h (flow_depth_first_order_compute): Declare.
* flow.c (flow_depth_first_order_compute): No longer declare.
Make external.
* df.c, df.h: New files.
* po/POTFILES.in: Update for new files.
From-SVN: r43647
Diffstat (limited to 'gcc/df.h')
-rw-r--r-- | gcc/df.h | 297 |
1 files changed, 297 insertions, 0 deletions
diff --git a/gcc/df.h b/gcc/df.h new file mode 100644 index 0000000..c581c88 --- /dev/null +++ b/gcc/df.h @@ -0,0 +1,297 @@ +/* Form lists of pseudo register references for autoinc optimization + for GNU compiler. This is part of flow optimization. + Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz) + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +#define DF_RD 1 /* Reaching definitions. */ +#define DF_RU 2 /* Reaching uses. */ +#define DF_LR 4 /* Live registers. */ +#define DF_DU_CHAIN 8 /* Def-use chain. */ +#define DF_UD_CHAIN 16 /* Use-def chain. */ +#define DF_REG_INFO 32 /* Register info. */ +#define DF_RD_CHAIN 64 /* Reg-def chain. */ +#define DF_RU_CHAIN 128 /* Reg-use chain. */ +#define DF_ALL 255 +#define DF_HARD_REGS 1024 + +enum df_ref_type {DF_REF_REG_DEF, DF_REF_REG_USE, DF_REF_REG_MEM_LOAD, + DF_REF_REG_MEM_STORE}; + +#define DF_REF_TYPE_NAMES {"def", "use", "mem load", "mem store"} + +/* ???> Perhaps all these data structures should be made private + to enforce the interface. */ + + +/* Link on a def-use or use-def chain. */ +struct df_link +{ + struct df_link *next; + struct ref *ref; +}; + + +/* Define a register reference structure. */ +struct ref +{ + rtx reg; /* The register referenced. */ + basic_block bb; /* BB containing ref. */ + rtx insn; /* Insn containing ref. */ + rtx *loc; /* Loc is the location of the reg. */ + struct df_link *chain; /* Head of def-use or use-def chain. */ + enum df_ref_type type; /* Type of ref. */ + int id; /* Ref index. */ +}; + + +/* One of these structures is allocated for every insn. */ +struct insn_info +{ + struct df_link *defs; /* Head of insn-def chain. */ + struct df_link *uses; /* Head of insn-use chain. */ + /* ???? The following luid field should be considerd private so that + we can change it on the fly to accomodate new insns? */ + int luid; /* Logical UID. */ +#if 0 + rtx insn; /* Backpointer to the insn. */ +#endif +}; + + +/* One of these structures is allocated for every reg. */ +struct reg_info +{ + struct df_link *defs; /* Head of reg-def chain. */ + struct df_link *uses; /* Head of reg-use chain. */ + int lifetime; + int n_defs; + int n_uses; +}; + + +/* One of these structures is allocated for every basic block. */ +struct bb_info +{ + /* Reaching def bitmaps have def_id elements. */ + bitmap rd_kill; + bitmap rd_gen; + bitmap rd_in; + bitmap rd_out; + /* Reaching use bitmaps have use_id elements. */ + bitmap ru_kill; + bitmap ru_gen; + bitmap ru_in; + bitmap ru_out; + /* Live variable bitmaps have n_regs elements. */ + bitmap lr_def; + bitmap lr_use; + bitmap lr_in; + bitmap lr_out; + int rd_valid; + int ru_valid; + int lr_valid; +}; + + +struct df +{ + int flags; /* Indicates what's recorded. */ + struct bb_info *bbs; /* Basic block table. */ + struct ref **defs; /* Def table, indexed by def_id. */ + struct ref **uses; /* Use table, indexed by use_id. */ + struct ref **reg_def_last; /* Indexed by regno. */ + struct reg_info *regs; /* Regs table, index by regno. */ + unsigned int reg_size; /* Size of regs table. */ + struct insn_info *insns; /* Insn table, indexed by insn UID. */ + unsigned int insn_size; /* Size of insn table. */ + unsigned int def_id; /* Next def ID. */ + unsigned int def_size; /* Size of def table. */ + unsigned int n_defs; /* Size of def bitmaps. */ + unsigned int use_id; /* Next use ID. */ + unsigned int use_size; /* Size of use table. */ + unsigned int n_uses; /* Size of use bitmaps. */ + unsigned int n_bbs; /* Number of basic blocks. */ + unsigned int n_regs; /* Number of regs. */ + unsigned int def_id_save; /* Saved next def ID. */ + unsigned int use_id_save; /* Saved next use ID. */ + bitmap insns_modified; /* Insns that (may) have changed. */ + bitmap bbs_modified; /* Blocks that (may) have changed. */ + bitmap all_blocks; /* All blocks in CFG. */ + /* The bitmap vector of dominators or NULL if not computed. + Ideally, this should be a pointer to a CFG object. */ + bitmap *dom; + int * dfs_order; + int * rc_order; +}; + + +struct df_map +{ + rtx old; + rtx new; +}; + + +#define DF_BB_INFO(REFS, BB) (&REFS->bbs[(BB)->index]) + + +/* Macros to access the elements within the ref structure. */ +#define DF_REF_REAL_REG(REF) (GET_CODE ((REF)->reg) == SUBREG \ + ? SUBREG_REG ((REF)->reg) : ((REF)->reg)) +#define DF_REF_REGNO(REF) REGNO (DF_REF_REAL_REG (REF)) +#define DF_REF_REAL_LOC(REF) (GET_CODE ((REF)->reg) == SUBREG \ + ? &SUBREG_REG ((REF)->reg) : ((REF)->loc)) +#ifdef OLD_DF_INTERFACE +#define DF_REF_REG(REF) DF_REF_REAL_REG(REF) +#define DF_REF_LOC(REF) DF_REF_REAL_LOC(REF) +#else +#define DF_REF_REG(REF) ((REF)->reg) +#define DF_REF_LOC(REF) ((REF)->loc) +#endif +#define DF_REF_BB(REF) ((REF)->bb) +#define DF_REF_BBNO(REF) ((REF)->bb->index) +#define DF_REF_INSN(REF) ((REF)->insn) +#define DF_REF_INSN_UID(REF) (INSN_UID ((REF)->insn)) +#define DF_REF_TYPE(REF) ((REF)->type) +#define DF_REF_CHAIN(REF) ((REF)->chain) +#define DF_REF_ID(REF) ((REF)->id) + +/* Macros to determine the reference type. */ + +#define DF_REF_REG_DEF_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_DEF) +#define DF_REF_REG_USE_P(REF) ((REF) && ! DF_REF_REG_DEF_P (REF)) +#define DF_REF_REG_MEM_STORE_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_STORE) +#define DF_REF_REG_MEM_LOAD_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_LOAD) +#define DF_REF_REG_MEM_P(REF) (DF_REF_REG_MEM_STORE_P (REF) \ + || DF_REF_REG_MEM_LOAD_P (REF)) + + +/* Macros to access the elements within the reg_info structure table. */ + +#define DF_REGNO_FIRST_DEF(DF, REGNUM) \ +((DF)->regs[REGNUM].defs ? (DF)->regs[REGNUM].defs->ref : 0) +#define DF_REGNO_LAST_USE(DF, REGNUM) \ +((DF)->regs[REGNUM].uses ? (DF)->regs[REGNUM].uses->ref : 0) + +#define DF_REGNO_FIRST_BB(DF, REGNUM) \ +(DF_REGNO_FIRST_DEF (DF, REGNUM) \ +? DF_REF_BB (DF_REGNO_FIRST_DEF (DF, REGNUM)) : 0) +#define DF_REGNO_LAST_BB(DF, REGNUM) \ +(DF_REGNO_LAST_USE (DF, REGNUM) \ +? DF_REF_BB (DF_REGNO_LAST_USE (DF, REGNUM)) : 0) + + +/* Macros to access the elements within the insn_info structure table. */ + +#define DF_INSN_LUID(DF, INSN) ((DF)->insns[INSN_UID (INSN)].luid) +#define DF_INSN_DEFS(DF, INSN) ((DF)->insns[INSN_UID (INSN)].defs) +#define DF_INSN_USES(DF, INSN) ((DF)->insns[INSN_UID (INSN)].uses) + + +/* Functions to build and analyse dataflow information. */ + +extern struct df *df_init PARAMS ((void)); + +extern int df_analyse PARAMS ((struct df *, bitmap, int)); + +extern void df_finish PARAMS ((struct df *)); + +extern void df_dump PARAMS ((struct df *, int, FILE *)); + +/* Functions to modify insns. */ + +extern void df_insn_modify PARAMS ((struct df *, basic_block, rtx)); + +extern rtx df_insn_delete PARAMS ((struct df *, basic_block, rtx)); + +extern rtx df_pattern_emit_before PARAMS ((struct df *, rtx, + basic_block, rtx)); + +extern rtx df_jump_pattern_emit_after PARAMS ((struct df *, rtx, + basic_block, rtx)); + +extern rtx df_pattern_emit_after PARAMS ((struct df *, rtx, + basic_block, rtx)); + +extern rtx df_insn_move_before PARAMS ((struct df *, basic_block, rtx, + basic_block, rtx)); + +extern int df_reg_replace PARAMS ((struct df *, bitmap, rtx, rtx)); + +extern int df_ref_reg_replace PARAMS ((struct df *, struct ref *, rtx, rtx)); + +extern int df_ref_remove PARAMS ((struct df *, struct ref *)); + +extern int df_insn_reg_replace PARAMS ((struct df *, basic_block, + rtx, rtx, rtx)); + +extern int df_insn_mem_replace PARAMS ((struct df *, basic_block, + rtx, rtx, rtx)); + +extern struct ref *df_bb_def_use_swap PARAMS ((struct df *, basic_block, + rtx, rtx, unsigned int)); + + +/* Functions to query dataflow information. */ + +extern basic_block df_regno_bb PARAMS((struct df *, unsigned int)); + +extern int df_reg_lifetime PARAMS ((struct df *, rtx)); + +extern int df_reg_global_p PARAMS ((struct df *, rtx)); + +extern int df_insn_regno_def_p PARAMS ((struct df *, + basic_block, rtx, unsigned int)); + +extern int df_insn_dominates_all_uses_p PARAMS ((struct df *, + basic_block, rtx)); + +extern int df_insn_dominates_uses_p PARAMS ((struct df *, basic_block, + rtx, bitmap)); + +extern int df_bb_reg_live_start_p PARAMS ((struct df *, basic_block, rtx)); + +extern int df_bb_reg_live_end_p PARAMS ((struct df *, basic_block, rtx)); + +extern int df_bb_regs_lives_compare PARAMS ((struct df *, basic_block, + rtx, rtx)); + +extern rtx df_bb_single_def_use_insn_find PARAMS((struct df *, basic_block, + rtx, rtx)); + + +/* Functions for debugging from GDB. */ + +extern void debug_df_insn PARAMS ((rtx)); + +extern void debug_df_regno PARAMS ((unsigned int)); + +extern void debug_df_reg PARAMS ((rtx)); + +extern void debug_df_defno PARAMS ((unsigned int)); + +extern void debug_df_useno PARAMS ((unsigned int)); + +extern void debug_df_ref PARAMS ((struct ref *)); + +extern void debug_df_chain PARAMS ((struct df_link *)); +extern void df_insn_debug PARAMS ((struct df *, rtx, FILE *)); +extern void df_insn_debug_regno PARAMS ((struct df *, rtx, FILE *)); |