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

📄 global-alloc.c

📁 这是完整的gcc源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
  register int j;  if (regno < FIRST_PSEUDO_REGISTER)    /* When a hard register becomes live,       record conflicts with live pseudo regs.  */    for (j = 0; j < max_allocno; j++)      {	if (ALLOCNO_LIVE_P (j))	  SET_HARD_REG_BIT (hard_reg_conflicts[j], regno);      }  else    /* When a pseudo-register becomes live,       record conflicts first with hard regs,       then with other pseudo regs.  */    {      register int ialloc = reg_allocno[regno];      register int ialloc_prod = ialloc * allocno_row_words;      IOR_HARD_REG_SET (hard_reg_conflicts[ialloc], hard_regs_live);      for (j = allocno_row_words - 1; j >= 0; j--)	conflicts[ialloc_prod + j] |= allocnos_live[j];    }}/* Record all allocnos currently live as conflicting   with each other and with all hard regs currently live.   ALLOCNO_VEC is a vector of LEN allocnos, all allocnos that   are currently live.  Their bits are also flagged in allocnos_live.  */static voidrecord_conflicts (allocno_vec, len)     register short *allocno_vec;     register int len;{  register int allocno;  register int j;  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.   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 (GET_CODE (setter) != SET)    {      /* A clobber of a register should be processed here too.  */      mark_reg_clobber (orig_reg, setter);      return;    }  regs_set[n_regs_set++] = reg;  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++;	}    }}/* 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 agressive 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;  if (GET_RTX_FORMAT (GET_CODE (src))[0] == 'e')    src = XEXP (src, 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)	{	  SET_REGBIT (hard_reg_preferences,		      reg_allocno[src_regno], dest_regno);	  SET_HARD_REG_BIT (regs_someone_prefers, dest_regno);	}    }  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)	{	  SET_REGBIT (hard_reg_preferences,		      reg_allocno[dest_regno], src_regno);	  SET_HARD_REG_BIT (regs_someone_prefers, src_regno);	}    }}/* 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;  fprintf (file, ";; %d regs to allocate:", max_allocno);  for (i = 0; i < max_allocno; i++)    {      fprintf (file, " %d", allocno_reg[allocno_order[i]]);      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");    }  fprintf (file, "\n");}voiddump_global_regs (file)     FILE *file;{  register int i;  fprintf (file, ";; Register dispositions:");  for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)    {      if (reg_renumber[i] >= 0)	fprintf (file, " %d in %d ", i, reg_renumber[i]);    }  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 + -