Annotation of gcc/loop.h, revision 1.1.1.1

1.1       root        1: /* Loop optimization definitions for GNU C-Compiler
                      2:    Copyright (C) 1991 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: GNU CC is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: /* Get the luid of an insn.  Catch the error of trying to reference the LUID
                     21:    of an insn added during loop, since these don't have LUIDs.  */
                     22: 
                     23: #define INSN_LUID(INSN)                        \
                     24:   (INSN_UID (INSN) < max_uid_for_loop ? uid_luid[INSN_UID (INSN)] \
                     25:    : (abort (), -1))
                     26: 
                     27: /* A "basic induction variable" or biv is a pseudo reg that is set
                     28:    (within this loop) only by incrementing or decrementing it.  */
                     29: /* A "general induction variable" or giv is a pseudo reg whose
                     30:    value is a linear function of a biv.  */
                     31: 
                     32: /* Bivs are recognized by `basic_induction_var';
                     33:    Givs by `general_induct_var'.  */
                     34: 
                     35: /* An enum for the two different types of givs, those that are used
                     36:    as memory addresses and those that are calculated into registers.  */
                     37: enum g_types { DEST_ADDR, DEST_REG };
                     38: 
                     39: /* A `struct induction' is created for every instruction that sets
                     40:    an induction variable (either a biv or a giv).  */
                     41: 
                     42: struct induction
                     43: {
                     44:   rtx insn;                    /* The insn that sets a biv or giv */
                     45:   rtx new_reg;                 /* New register, containing strength reduced
                     46:                                   version of this giv.  */
                     47:   rtx src_reg;                 /* Biv from which this giv is computed.
                     48:                                   (If this is a biv, then this is the biv.) */
                     49:   enum g_types giv_type;       /* Indicate whether DEST_ADDR or DEST_REG */
                     50:   rtx dest_reg;                        /* Destination register for insn: this is the
                     51:                                   register which was the biv or giv.
                     52:                                   For a biv, this equals src_reg.
                     53:                                   For a DEST_ADDR type giv, this is 0.  */
                     54:   rtx *location;               /* Place in the insn where this giv occurs.
                     55:                                   If GIV_TYPE is DEST_REG, this is 0.  */
                     56:   enum machine_mode mode;      /* The mode of this biv or giv */
                     57:   enum machine_mode mem_mode;  /* For DEST_ADDR, mode of the memory object. */
                     58:   rtx mult_val;                        /* Multiplicative factor for src_reg.  */
                     59:   rtx add_val;                 /* Additive constant for that product.  */
                     60:   int benefit;                 /* Gain from eliminating this insn.  */
                     61:   rtx final_value;             /* If the giv is used outside the loop, and its
                     62:                                   final value could be calculated, it is put
                     63:                                   here, and the giv is made replaceable.  Set
                     64:                                   the giv to this value before the loop.  */
                     65:   unsigned replaceable : 1;    /* 1 if we can substitute the strength-reduced
                     66:                                   variable for the original variable.
                     67:                                   0 means they must be kept separate and the
                     68:                                   new one must be copied into the old pseudo
                     69:                                   reg each time the old one is set.  */
                     70:   unsigned not_replaceable : 1;        /* Used to prevent duplicating work.  This is
                     71:                                   1 if we know that the giv definitely can
                     72:                                   not be made replaceable, in which case we
                     73:                                   don't bother checking the variable again
                     74:                                   even if further info is available.
                     75:                                   Both this and the above can be zero.  */
                     76:   unsigned ignore : 1;         /* 1 prohibits further processing of giv */
                     77:   unsigned always_computable : 1;/* 1 if this set occurs each iteration */
                     78:   unsigned cant_derive : 1;    /* For giv's, 1 if this giv cannot derive
                     79:                                   another giv.  This occurs in many cases
                     80:                                   where a giv's lifetime spans an update to
                     81:                                   a biv. */
                     82:   unsigned combined_with : 1;  /* 1 if this giv has been combined with.  It
                     83:                                   then cannot combine with any other giv.  */
                     84:   unsigned maybe_dead : 1;     /* 1 if this giv might be dead.  In that case,
                     85:                                   we won't use it to elminate a biv, it
                     86:                                   would probably lose. */
                     87:   int lifetime;                        /* Length of life of this giv */
                     88:   int times_used;              /* # times this giv is used. */
                     89:   rtx derive_adjustment;       /* If nonzero, is an adjustment to be
                     90:                                   subtracted from add_val when this giv
                     91:                                   derives another.  This occurs when the
                     92:                                   giv spans a biv update by incrementation. */
                     93:   struct induction *next_iv;   /* For givs, links together all givs that are
                     94:                                   based on the same biv.  For bivs, links
                     95:                                   together all biv entries that refer to the
                     96:                                   same biv register.  */
                     97:   struct induction *same;      /* If this giv has been combined with another
                     98:                                   giv, this points to the base giv.  The base
                     99:                                   giv will have COMBINED_WITH non-zero.  */
                    100:   int const_adjust;            /* Used by loop unrolling, when an address giv
                    101:                                   is split, and a constant is eliminated from
                    102:                                   the address, the -constant is stored here
                    103:                                   for later use. */
                    104: };
                    105: 
                    106: /* A `struct iv_class' is created for each biv.  */
                    107: 
                    108: struct iv_class {
                    109:   int regno;                   /* Pseudo reg which is the biv.  */
                    110:   int biv_count;               /* Number of insns setting this reg.  */
                    111:   struct induction *biv;       /* List of all insns that set this reg.  */
                    112:   int giv_count;               /* Number of DEST_REG givs computed from this
                    113:                                   biv.  The resulting count is only used in
                    114:                                   check_dbra_loop.  */
                    115:   struct induction *giv;       /* List of all insns that compute a giv
                    116:                                   from this reg.  */
                    117:   int total_benefit;           /* Sum of BENEFITs of all those givs */
                    118:   rtx initial_value;           /* Value of reg at loop start */
                    119:   rtx initial_test;            /* Test performed on BIV before loop */
                    120:   struct iv_class *next;       /* Links all class structures together */
                    121:   rtx init_insn;               /* insn which intializes biv, 0 if none. */
                    122:   rtx init_set;                        /* SET of INIT_INSN, if any. */
                    123:   unsigned incremented : 1;    /* 1 if somewhere incremented/decremented */
                    124:   unsigned eliminable : 1;     /* 1 if plausible candidate for elimination. */
                    125:   unsigned nonneg : 1;         /* 1 if we added a REG_NONNEG note for this. */
                    126:   unsigned reversed : 1;       /* 1 if we reversed the loop that this
                    127:                                   biv controls. */
                    128: };
                    129: 
                    130: /* Definitions used by the basic induction variable discovery code.  */
                    131: enum iv_mode { UNKNOWN_INDUCT, BASIC_INDUCT, NOT_BASIC_INDUCT,
                    132:                 GENERAL_INDUCT };
                    133: 
                    134: /* Variables declared in loop.c, but also needed in unroll.c.  */
                    135: 
                    136: extern int *uid_luid;
                    137: extern int max_uid_for_loop;
                    138: extern int *uid_loop_num;
                    139: extern int *loop_outer_loop;
                    140: extern rtx *loop_number_exit_labels;
                    141: extern unsigned long loop_n_iterations;
                    142: extern int max_reg_before_loop;
                    143: 
                    144: extern FILE *loop_dump_stream;
                    145: 
                    146: extern enum iv_mode *reg_iv_type;
                    147: extern struct induction **reg_iv_info;
                    148: extern struct iv_class **reg_biv_class;
                    149: extern struct iv_class *loop_iv_list;
                    150: 
                    151: /* Forward declarations for non-static functions declared in loop.c and
                    152:    unroll.c.  */
                    153: int invariant_p ();
                    154: rtx get_condition_for_loop ();
                    155: void emit_iv_add_mult ();
                    156: 
                    157: /* Variables declared in stmt.c but also needed in loop.c.  */
                    158: 
                    159: extern union tree_node **loop_number_first_block;
                    160: extern union tree_node **loop_number_last_block;
                    161: extern int *loop_number_block_level;
                    162: 
                    163: /* Forward declarations for non-static functions declared in stmt.c.  */
                    164: void find_loop_tree_blocks ();
                    165: void unroll_block_trees ();
                    166: 
                    167: void unroll_loop ();
                    168: rtx biv_total_increment ();
                    169: unsigned long loop_iterations ();
                    170: rtx final_biv_value ();
                    171: rtx final_giv_value ();
                    172: void emit_unrolled_add ();

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.