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

📄 stupid.c

📁 GCC编译器源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Comparison function for qsort.   Returns -1 (1) if register *R1P is higher priority than *R2P.  */static intstupid_reg_compare (r1p, r2p)     const GENERIC_PTR r1p;     const GENERIC_PTR r2p;{  register int r1 = *(int *)r1p, r2 = *(int *)r2p;  register int len1 = reg_where_dead[r1] - reg_where_born[r1];  register int len2 = reg_where_dead[r2] - reg_where_born[r2];  int tem;  tem = len2 - len1;  if (tem != 0)    return tem;  tem = REG_N_REFS (r1) - REG_N_REFS (r2);  if (tem != 0)    return tem;  /* If regs are equally good, sort by regno,     so that the results of qsort leave nothing to chance.  */  return r1 - r2;}/* Find a block of SIZE words of hard registers in reg_class CLASS   that can hold a value of machine-mode MODE     (but actually we test only the first of the block for holding MODE)   currently free from after insn whose suid is BORN_INSN   through the insn whose suid is DEAD_INSN,   and return the number of the first of them.   Return -1 if such a block cannot be found.   If CALL_PRESERVED is nonzero, insist on registers preserved   over subroutine calls, and return -1 if cannot find such.   If CHANGES_SIZE is nonzero, it means this register was used as the   operand of a SUBREG that changes its size.  */static intstupid_find_reg (call_preserved, class, mode,		 born_insn, dead_insn, changes_size)     int call_preserved;     enum reg_class class;     enum machine_mode mode;     int born_insn, dead_insn;     int changes_size;{  register int i, ins;#ifdef HARD_REG_SET  register		/* Declare them register if they are scalars.  */#endif    HARD_REG_SET used, this_reg;#ifdef ELIMINABLE_REGS  static struct {int from, to; } eliminables[] = ELIMINABLE_REGS;#endif  /* If this register's life is more than 5,000 insns, we probably     can't allocate it, so don't waste the time trying.  This avoids     quadratic behavior on programs that have regularly-occurring     SAVE_EXPRs.  */  if (dead_insn > born_insn + 5000)    return -1;  COPY_HARD_REG_SET (used,		     call_preserved ? call_used_reg_set : fixed_reg_set);#ifdef ELIMINABLE_REGS  for (i = 0; i < sizeof eliminables / sizeof eliminables[0]; i++)    SET_HARD_REG_BIT (used, eliminables[i].from);#if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM  SET_HARD_REG_BIT (used, HARD_FRAME_POINTER_REGNUM);#endif#else  SET_HARD_REG_BIT (used, FRAME_POINTER_REGNUM);#endif  for (ins = born_insn; ins < dead_insn; ins++)    IOR_HARD_REG_SET (used, after_insn_hard_regs[ins]);  IOR_COMPL_HARD_REG_SET (used, reg_class_contents[(int) class]);#ifdef CLASS_CANNOT_CHANGE_SIZE  if (changes_size)    IOR_HARD_REG_SET (used,		      reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE]);#endif  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)    {#ifdef REG_ALLOC_ORDER      int regno = reg_alloc_order[i];#else      int regno = i;#endif      /* If a register has screwy overlap problems,	 don't use it at all if not optimizing.	 Actually this is only for the 387 stack register,	 and it's because subsequent code won't work.  */#ifdef OVERLAPPING_REGNO_P      if (OVERLAPPING_REGNO_P (regno))	continue;#endif      if (! TEST_HARD_REG_BIT (used, regno)	  && HARD_REGNO_MODE_OK (regno, mode))	{	  register int j;	  register int size1 = HARD_REGNO_NREGS (regno, mode);	  for (j = 1; j < size1 && ! TEST_HARD_REG_BIT (used, regno + j); j++);	  if (j == size1)	    {	      CLEAR_HARD_REG_SET (this_reg);	      while (--j >= 0)		SET_HARD_REG_BIT (this_reg, regno + j);	      for (ins = born_insn; ins < dead_insn; ins++)		{		  IOR_HARD_REG_SET (after_insn_hard_regs[ins], this_reg);		}	      return regno;	    }#ifndef REG_ALLOC_ORDER	  i += j;		/* Skip starting points we know will lose */#endif	}    }  return -1;}/* Walk X, noting all assignments and references to registers   and recording what they imply about life spans.   INSN is the current insn, supplied so we can find its suid.  */static voidstupid_mark_refs (x, insn)     rtx x, insn;{  register RTX_CODE code;  register char *fmt;  register int regno, i;  if (x == 0)    return;  code = GET_CODE (x);  if (code == SET || code == CLOBBER)    {      if (SET_DEST (x) != 0	  && (GET_CODE (SET_DEST (x)) == REG	      || (GET_CODE (SET_DEST (x)) == SUBREG		  && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG		  && (REGNO (SUBREG_REG (SET_DEST (x)))		      >= FIRST_PSEUDO_REGISTER))))	{	  /* Register is being assigned.  */	  /* If setting a SUBREG, we treat the entire reg as being set.  */	  if (GET_CODE (SET_DEST (x)) == SUBREG)	    regno = REGNO (SUBREG_REG (SET_DEST (x)));	  else	    regno = REGNO (SET_DEST (x));	  /* For hard regs, update the where-live info.  */	  if (regno < FIRST_PSEUDO_REGISTER)	    {	      register int j		= HARD_REGNO_NREGS (regno, GET_MODE (SET_DEST (x)));	      while (--j >= 0)		{		  regs_ever_live[regno+j] = 1;		  regs_live[regno+j] = 0;		  /* The following line is for unused outputs;		     they do get stored even though never used again.  */		  MARK_LIVE_AFTER (insn, regno+j);		  /* When a hard reg is clobbered, mark it in use		     just before this insn, so it is live all through.  */		  if (code == CLOBBER && INSN_SUID (insn) > 0)		    SET_HARD_REG_BIT (after_insn_hard_regs[INSN_SUID (insn) - 1],				      regno+j);		}	    }	  /* For pseudo regs, record where born, where dead, number of	     times used, and whether live across a call.  */	  else	    {	      /* Update the life-interval bounds of this pseudo reg.  */	      /* When a pseudo-reg is CLOBBERed, it is born just before		 the clobbering insn.  When setting, just after.  */	      int where_born = INSN_SUID (insn) - (code == CLOBBER);	      reg_where_born[regno] = where_born;	      /* The reg must live at least one insn even		 in it is never again used--because it has to go		 in SOME hard reg.  Mark it as dying after the current		 insn so that it will conflict with any other outputs of		 this insn.  */	      if (reg_where_dead[regno] < where_born + 2)		{		  reg_where_dead[regno] = where_born + 2;		  regs_live[regno] = 1;		}	      /* Count the refs of this reg.  */	      REG_N_REFS (regno)++;	      if (last_call_suid < reg_where_dead[regno])		REG_N_CALLS_CROSSED (regno) += 1;	      if (last_setjmp_suid < reg_where_dead[regno])		regs_crosses_setjmp[regno] = 1;	      /* If this register is only used in this insn and is only		 set, mark it unused.  We have to do this even when not 		 optimizing so that MD patterns which count on this		 behavior (e.g., it not causing an output reload on		 an insn setting CC) will operate correctly.  */	      if (GET_CODE (SET_DEST (x)) == REG		  && REGNO_FIRST_UID (regno) == INSN_UID (insn)		  && REGNO_LAST_UID (regno) == INSN_UID (insn)		  && (code == CLOBBER || ! reg_mentioned_p (SET_DEST (x),							    SET_SRC (x))))		REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_UNUSED,					    SET_DEST (x), REG_NOTES (insn));	    }	}      /* Record references from the value being set,	 or from addresses in the place being set if that's not a reg.	 If setting a SUBREG, we treat the entire reg as *used*.  */      if (code == SET)	{	  stupid_mark_refs (SET_SRC (x), insn);	  if (GET_CODE (SET_DEST (x)) != REG)	    stupid_mark_refs (SET_DEST (x), insn);	}      return;    }  else if (code == SUBREG	   && GET_CODE (SUBREG_REG (x)) == REG	   && REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER	   && (GET_MODE_SIZE (GET_MODE (x))	       != GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))	   && (INTEGRAL_MODE_P (GET_MODE (x))	       || INTEGRAL_MODE_P (GET_MODE (SUBREG_REG (x)))))    regs_change_size[REGNO (SUBREG_REG (x))] = 1;  /* Register value being used, not set.  */  else if (code == REG)    {      regno = REGNO (x);      if (regno < FIRST_PSEUDO_REGISTER)	{	  /* Hard reg: mark it live for continuing scan of previous insns.  */	  register int j = HARD_REGNO_NREGS (regno, GET_MODE (x));	  while (--j >= 0)	    {	      regs_ever_live[regno+j] = 1;	      regs_live[regno+j] = 1;	    }	}      else	{	  /* Pseudo reg: record first use, last use and number of uses.  */	  reg_where_born[regno] = INSN_SUID (insn);	  REG_N_REFS (regno)++;	  if (regs_live[regno] == 0)	    {	      regs_live[regno] = 1;	      reg_where_dead[regno] = INSN_SUID (insn);	    }	}      return;    }  /* Recursive scan of all other rtx's.  */  fmt = GET_RTX_FORMAT (code);  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)    {      if (fmt[i] == 'e')	stupid_mark_refs (XEXP (x, i), insn);      if (fmt[i] == 'E')	{	  register int j;	  for (j = XVECLEN (x, i) - 1; j >= 0; j--)	    stupid_mark_refs (XVECEXP (x, i, j), insn);	}    }}

⌨️ 快捷键说明

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