1*e4b17023SJohn Marino /* This file contains definitions for the register renamer. 2*e4b17023SJohn Marino Copyright (C) 2011 3*e4b17023SJohn Marino Free Software Foundation, Inc. 4*e4b17023SJohn Marino 5*e4b17023SJohn Marino This file is part of GCC. 6*e4b17023SJohn Marino 7*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under 8*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free 9*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later 10*e4b17023SJohn Marino version. 11*e4b17023SJohn Marino 12*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or 14*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15*e4b17023SJohn Marino for more details. 16*e4b17023SJohn Marino 17*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 18*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see 19*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 20*e4b17023SJohn Marino 21*e4b17023SJohn Marino #ifndef GCC_REGRENAME_H 22*e4b17023SJohn Marino #define GCC_REGRENAME_H 23*e4b17023SJohn Marino 24*e4b17023SJohn Marino /* We keep linked lists of DU_HEAD structures, each of which describes 25*e4b17023SJohn Marino a chain of occurrences of a reg. */ 26*e4b17023SJohn Marino struct du_head 27*e4b17023SJohn Marino { 28*e4b17023SJohn Marino /* The next chain. */ 29*e4b17023SJohn Marino struct du_head *next_chain; 30*e4b17023SJohn Marino /* The first and last elements of this chain. */ 31*e4b17023SJohn Marino struct du_chain *first, *last; 32*e4b17023SJohn Marino /* Describes the register being tracked. */ 33*e4b17023SJohn Marino unsigned regno; 34*e4b17023SJohn Marino int nregs; 35*e4b17023SJohn Marino 36*e4b17023SJohn Marino /* A unique id to be used as an index into the conflicts bitmaps. */ 37*e4b17023SJohn Marino unsigned id; 38*e4b17023SJohn Marino /* A bitmap to record conflicts with other chains. */ 39*e4b17023SJohn Marino bitmap_head conflicts; 40*e4b17023SJohn Marino /* Conflicts with untracked hard registers. */ 41*e4b17023SJohn Marino HARD_REG_SET hard_conflicts; 42*e4b17023SJohn Marino 43*e4b17023SJohn Marino /* Nonzero if the chain crosses a call. */ 44*e4b17023SJohn Marino unsigned int need_caller_save_reg:1; 45*e4b17023SJohn Marino /* Nonzero if the register is used in a way that prevents renaming, 46*e4b17023SJohn Marino such as the SET_DEST of a CALL_INSN or an asm operand that used 47*e4b17023SJohn Marino to be a hard register. */ 48*e4b17023SJohn Marino unsigned int cannot_rename:1; 49*e4b17023SJohn Marino }; 50*e4b17023SJohn Marino 51*e4b17023SJohn Marino typedef struct du_head *du_head_p; 52*e4b17023SJohn Marino DEF_VEC_P (du_head_p); 53*e4b17023SJohn Marino DEF_VEC_ALLOC_P (du_head_p, heap); 54*e4b17023SJohn Marino 55*e4b17023SJohn Marino /* This struct describes a single occurrence of a register. */ 56*e4b17023SJohn Marino struct du_chain 57*e4b17023SJohn Marino { 58*e4b17023SJohn Marino /* Links to the next occurrence of the register. */ 59*e4b17023SJohn Marino struct du_chain *next_use; 60*e4b17023SJohn Marino 61*e4b17023SJohn Marino /* The insn where the register appears. */ 62*e4b17023SJohn Marino rtx insn; 63*e4b17023SJohn Marino /* The location inside the insn. */ 64*e4b17023SJohn Marino rtx *loc; 65*e4b17023SJohn Marino /* The register class required by the insn at this location. */ 66*e4b17023SJohn Marino ENUM_BITFIELD(reg_class) cl : 16; 67*e4b17023SJohn Marino }; 68*e4b17023SJohn Marino 69*e4b17023SJohn Marino /* This struct describes data gathered during regrename_analyze about 70*e4b17023SJohn Marino a single operand of an insn. */ 71*e4b17023SJohn Marino typedef struct 72*e4b17023SJohn Marino { 73*e4b17023SJohn Marino /* The number of chains recorded for this operand. */ 74*e4b17023SJohn Marino int n_chains; 75*e4b17023SJohn Marino /* Holds either the chain for the operand itself, or for the registers in 76*e4b17023SJohn Marino a memory operand. */ 77*e4b17023SJohn Marino struct du_chain *chains[MAX_REGS_PER_ADDRESS]; 78*e4b17023SJohn Marino struct du_head *heads[MAX_REGS_PER_ADDRESS]; 79*e4b17023SJohn Marino } operand_rr_info; 80*e4b17023SJohn Marino 81*e4b17023SJohn Marino /* A struct to hold a vector of operand_rr_info structures describing the 82*e4b17023SJohn Marino operands of an insn. */ 83*e4b17023SJohn Marino typedef struct 84*e4b17023SJohn Marino { 85*e4b17023SJohn Marino operand_rr_info *op_info; 86*e4b17023SJohn Marino } insn_rr_info; 87*e4b17023SJohn Marino 88*e4b17023SJohn Marino DEF_VEC_O (insn_rr_info); 89*e4b17023SJohn Marino DEF_VEC_ALLOC_O (insn_rr_info, heap); 90*e4b17023SJohn Marino 91*e4b17023SJohn Marino extern VEC(insn_rr_info, heap) *insn_rr; 92*e4b17023SJohn Marino 93*e4b17023SJohn Marino extern void regrename_init (bool); 94*e4b17023SJohn Marino extern void regrename_finish (void); 95*e4b17023SJohn Marino extern void regrename_analyze (bitmap); 96*e4b17023SJohn Marino extern du_head_p regrename_chain_from_id (unsigned int); 97*e4b17023SJohn Marino extern int find_best_rename_reg (du_head_p, enum reg_class, HARD_REG_SET *, 98*e4b17023SJohn Marino int); 99*e4b17023SJohn Marino extern void regrename_do_replace (du_head_p, int); 100*e4b17023SJohn Marino 101*e4b17023SJohn Marino #endif 102