⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.c

📁 GCC编译器源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
  register int ialloc_prod;  while (--len >= 0)    {      allocno = allocno_vec[len];      ialloc_prod = allocno * allocno_row_words;      IOR_HARD_REG_SET (hard_reg_conflicts[allocno], hard_regs_live);      for (j = allocno_row_words - 1; j >= 0; j--)	conflicts[ialloc_prod + j] |= allocnos_live[j];    }}/* Handle the case where REG is set by the insn being scanned,   during the forward scan to accumulate conflicts.   Store a 1 in regs_live or allocnos_live for this register, record how many   consecutive hardware registers it actually needs,   and record a conflict with all other registers already live.   Note that even if REG does not remain alive after this insn,   we must mark it here as live, to ensure a conflict between   REG and any other regs set in this insn that really do live.   This is because those other regs could be considered after this.   REG might actually be something other than a register;   if so, we do nothing.   SETTER is 0 if this register was modified by an auto-increment (i.e.,   a REG_INC note was found for it).   CLOBBERs are processed here by calling mark_reg_clobber.  */ static voidmark_reg_store (orig_reg, setter)     rtx orig_reg, setter;{  register int regno;  register rtx reg = orig_reg;  /* WORD is which word of a multi-register group is being stored.     For the case where the store is actually into a SUBREG of REG.     Except we don't use it; I believe the entire REG needs to be     made live.  */  int word = 0;  if (GET_CODE (reg) == SUBREG)    {      word = SUBREG_WORD (reg);      reg = SUBREG_REG (reg);    }  if (GET_CODE (reg) != REG)    return;  if (setter && GET_CODE (setter) == CLOBBER)    {      /* A clobber of a register should be processed here too.  */      mark_reg_clobber (orig_reg, setter);      return;    }  regs_set[n_regs_set++] = reg;  if (setter)    set_preference (reg, SET_SRC (setter));  regno = REGNO (reg);  if (reg_renumber[regno] >= 0)    regno = reg_renumber[regno] /* + word */;  /* Either this is one of the max_allocno pseudo regs not allocated,     or it is or has a hardware reg.  First handle the pseudo-regs.  */  if (regno >= FIRST_PSEUDO_REGISTER)    {      if (reg_allocno[regno] >= 0)	{	  SET_ALLOCNO_LIVE (reg_allocno[regno]);	  record_one_conflict (regno);	}    }  /* Handle hardware regs (and pseudos allocated to hard regs).  */  else if (! fixed_regs[regno])    {      register int last = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));      while (regno < last)	{	  record_one_conflict (regno);	  SET_HARD_REG_BIT (hard_regs_live, regno);	  regno++;	}    }}/* Like mark_reg_set except notice just CLOBBERs; ignore SETs.  */static voidmark_reg_clobber (reg, setter)     rtx reg, setter;{  register int regno;  /* WORD is which word of a multi-register group is being stored.     For the case where the store is actually into a SUBREG of REG.     Except we don't use it; I believe the entire REG needs to be     made live.  */  int word = 0;  if (GET_CODE (setter) != CLOBBER)    return;  if (GET_CODE (reg) == SUBREG)    {      word = SUBREG_WORD (reg);      reg = SUBREG_REG (reg);    }  if (GET_CODE (reg) != REG)    return;  regs_set[n_regs_set++] = reg;  regno = REGNO (reg);  if (reg_renumber[regno] >= 0)    regno = reg_renumber[regno] /* + word */;  /* Either this is one of the max_allocno pseudo regs not allocated,     or it is or has a hardware reg.  First handle the pseudo-regs.  */  if (regno >= FIRST_PSEUDO_REGISTER)    {      if (reg_allocno[regno] >= 0)	{	  SET_ALLOCNO_LIVE (reg_allocno[regno]);	  record_one_conflict (regno);	}    }  /* Handle hardware regs (and pseudos allocated to hard regs).  */  else if (! fixed_regs[regno])    {      register int last = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));      while (regno < last)	{	  record_one_conflict (regno);	  SET_HARD_REG_BIT (hard_regs_live, regno);	  regno++;	}    }}/* Record that REG has conflicts with all the regs currently live.   Do not mark REG itself as live.  */static voidmark_reg_conflicts (reg)     rtx reg;{  register int regno;  if (GET_CODE (reg) == SUBREG)    reg = SUBREG_REG (reg);  if (GET_CODE (reg) != REG)    return;  regno = REGNO (reg);  if (reg_renumber[regno] >= 0)    regno = reg_renumber[regno];  /* Either this is one of the max_allocno pseudo regs not allocated,     or it is or has a hardware reg.  First handle the pseudo-regs.  */  if (regno >= FIRST_PSEUDO_REGISTER)    {      if (reg_allocno[regno] >= 0)	record_one_conflict (regno);    }  /* Handle hardware regs (and pseudos allocated to hard regs).  */  else if (! fixed_regs[regno])    {      register int last = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));      while (regno < last)	{	  record_one_conflict (regno);	  regno++;	}    }}/* Mark REG as being dead (following the insn being scanned now).   Store a 0 in regs_live or allocnos_live for this register.  */static voidmark_reg_death (reg)     rtx reg;{  register int regno = REGNO (reg);  /* For pseudo reg, see if it has been assigned a hardware reg.  */  if (reg_renumber[regno] >= 0)    regno = reg_renumber[regno];  /* Either this is one of the max_allocno pseudo regs not allocated,     or it is a hardware reg.  First handle the pseudo-regs.  */  if (regno >= FIRST_PSEUDO_REGISTER)    {      if (reg_allocno[regno] >= 0)	CLEAR_ALLOCNO_LIVE (reg_allocno[regno]);    }  /* Handle hardware regs (and pseudos allocated to hard regs).  */  else if (! fixed_regs[regno])    {      /* Pseudo regs already assigned hardware regs are treated	 almost the same as explicit hardware regs.  */      register int last = regno + HARD_REGNO_NREGS (regno, GET_MODE (reg));      while (regno < last)	{	  CLEAR_HARD_REG_BIT (hard_regs_live, regno);	  regno++;	}    }}/* Mark hard reg REGNO as currently live, assuming machine mode MODE   for the value stored in it.  MODE determines how many consecutive   registers are actually in use.  Do not record conflicts;   it is assumed that the caller will do that.  */static voidmark_reg_live_nc (regno, mode)     register int regno;     enum machine_mode mode;{  register int last = regno + HARD_REGNO_NREGS (regno, mode);  while (regno < last)    {      SET_HARD_REG_BIT (hard_regs_live, regno);      regno++;    }}/* Try to set a preference for an allocno to a hard register.   We are passed DEST and SRC which are the operands of a SET.  It is known   that SRC is a register.  If SRC or the first operand of SRC is a register,   try to set a preference.  If one of the two is a hard register and the other   is a pseudo-register, mark the preference.      Note that we are not as aggressive as local-alloc in trying to tie a   pseudo-register to a hard register.  */static voidset_preference (dest, src)     rtx dest, src;{  int src_regno, dest_regno;  /* Amount to add to the hard regno for SRC, or subtract from that for DEST,     to compensate for subregs in SRC or DEST.  */  int offset = 0;  int i;  int copy = 1;  if (GET_RTX_FORMAT (GET_CODE (src))[0] == 'e')    src = XEXP (src, 0), copy = 0;  /* Get the reg number for both SRC and DEST.     If neither is a reg, give up.  */  if (GET_CODE (src) == REG)    src_regno = REGNO (src);  else if (GET_CODE (src) == SUBREG && GET_CODE (SUBREG_REG (src)) == REG)    {      src_regno = REGNO (SUBREG_REG (src));      offset += SUBREG_WORD (src);    }  else    return;  if (GET_CODE (dest) == REG)    dest_regno = REGNO (dest);  else if (GET_CODE (dest) == SUBREG && GET_CODE (SUBREG_REG (dest)) == REG)    {      dest_regno = REGNO (SUBREG_REG (dest));      offset -= SUBREG_WORD (dest);    }  else    return;  /* Convert either or both to hard reg numbers.  */  if (reg_renumber[src_regno] >= 0)    src_regno = reg_renumber[src_regno];  if (reg_renumber[dest_regno] >= 0)    dest_regno = reg_renumber[dest_regno];  /* Now if one is a hard reg and the other is a global pseudo     then give the other a preference.  */  if (dest_regno < FIRST_PSEUDO_REGISTER && src_regno >= FIRST_PSEUDO_REGISTER      && reg_allocno[src_regno] >= 0)    {      dest_regno -= offset;      if (dest_regno >= 0 && dest_regno < FIRST_PSEUDO_REGISTER)	{	  if (copy)	    SET_REGBIT (hard_reg_copy_preferences,			reg_allocno[src_regno], dest_regno);	  SET_REGBIT (hard_reg_preferences,		      reg_allocno[src_regno], dest_regno);	  for (i = dest_regno;	       i < dest_regno + HARD_REGNO_NREGS (dest_regno, GET_MODE (dest));	       i++)	    SET_REGBIT (hard_reg_full_preferences, reg_allocno[src_regno], i);	}    }  if (src_regno < FIRST_PSEUDO_REGISTER && dest_regno >= FIRST_PSEUDO_REGISTER      && reg_allocno[dest_regno] >= 0)    {      src_regno += offset;      if (src_regno >= 0 && src_regno < FIRST_PSEUDO_REGISTER)	{	  if (copy)	    SET_REGBIT (hard_reg_copy_preferences,			reg_allocno[dest_regno], src_regno);	  SET_REGBIT (hard_reg_preferences,		      reg_allocno[dest_regno], src_regno);	  for (i = src_regno;	       i < src_regno + HARD_REGNO_NREGS (src_regno, GET_MODE (src));	       i++)	    SET_REGBIT (hard_reg_full_preferences, reg_allocno[dest_regno], i);	}    }}/* Indicate that hard register number FROM was eliminated and replaced with   an offset from hard register number TO.  The status of hard registers live   at the start of a basic block is updated by replacing a use of FROM with   a use of TO.  */voidmark_elimination (from, to)     int from, to;{  int i;  for (i = 0; i < n_basic_blocks; i++)    if (REGNO_REG_SET_P (basic_block_live_at_start[i], from))      {	CLEAR_REGNO_REG_SET (basic_block_live_at_start[i], from);	SET_REGNO_REG_SET (basic_block_live_at_start[i], to);      }}/* Print debugging trace information if -greg switch is given,   showing the information on which the allocation decisions are based.  */static voiddump_conflicts (file)     FILE *file;{  register int i;  register int has_preferences;  fprintf (file, ";; %d regs to allocate:", max_allocno);  for (i = 0; i < max_allocno; i++)    {      int j;      fprintf (file, " %d", allocno_reg[allocno_order[i]]);      for (j = 0; j < max_regno; j++)	if (reg_allocno[j] == allocno_order[i]	    && j != allocno_reg[allocno_order[i]])	  fprintf (file, "+%d", j);      if (allocno_size[allocno_order[i]] != 1)	fprintf (file, " (%d)", allocno_size[allocno_order[i]]);    }  fprintf (file, "\n");  for (i = 0; i < max_allocno; i++)    {      register int j;      fprintf (file, ";; %d conflicts:", allocno_reg[i]);      for (j = 0; j < max_allocno; j++)	if (CONFLICTP (i, j) || CONFLICTP (j, i))	  fprintf (file, " %d", allocno_reg[j]);      for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)	if (TEST_HARD_REG_BIT (hard_reg_conflicts[i], j))	  fprintf (file, " %d", j);      fprintf (file, "\n");      has_preferences = 0;      for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)	if (TEST_HARD_REG_BIT (hard_reg_preferences[i], j))	  has_preferences = 1;      if (! has_preferences)	continue;      fprintf (file, ";; %d preferences:", allocno_reg[i]);      for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)	if (TEST_HARD_REG_BIT (hard_reg_preferences[i], j))	  fprintf (file, " %d", j);      fprintf (file, "\n");    }  fprintf (file, "\n");}voiddump_global_regs (file)     FILE *file;{  register int i, j;    fprintf (file, ";; Register dispositions:\n");  for (i = FIRST_PSEUDO_REGISTER, j = 0; i < max_regno; i++)    if (reg_renumber[i] >= 0)      {	fprintf (file, "%d in %d  ", i, reg_renumber[i]);        if (++j % 6 == 0)	  fprintf (file, "\n");      }  fprintf (file, "\n\n;; Hard regs used: ");  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)    if (regs_ever_live[i])      fprintf (file, " %d", i);  fprintf (file, "\n\n");}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -