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

📄 rs6000.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
	fprintf (file, "u");      return;    case 'I':      /* Print `i' is this is a constant, else nothing.  */      if (INT_P (x))	fprintf (file, "i");      return;    case 'N':      /* Write the number of elements in the vector times 4.  */      if (GET_CODE (x) != PARALLEL)	output_operand_lossage ("invalid %%N value");      fprintf (file, "%d", XVECLEN (x, 0) * 4);      return;    case 'O':      /* Similar, but subtract 1 first.  */      if (GET_CODE (x) != PARALLEL)	output_operand_lossage ("invalid %%N value");      fprintf (file, "%d", (XVECLEN (x, 0) - 1) * 4);      return;    case 'P':      /* The operand must be an indirect memory reference.  The result	 is the register number. */      if (GET_CODE (x) != MEM || GET_CODE (XEXP (x, 0)) != REG	  || REGNO (XEXP (x, 0)) >= 32)	output_operand_lossage ("invalid %%P value");      fprintf (file, "%d", REGNO (XEXP (x, 0)));      return;    case 'L':      /* Write second word of DImode or DFmode reference.  Works on register	 or non-indexed memory only.  */      if (GET_CODE (x) == REG)	fprintf (file, "%d", REGNO (x) + 1);      else if (GET_CODE (x) == MEM)	{	  /* Handle possible auto-increment.  Since it is pre-increment and	     we have already done it, we can just use an offset of four.  */	  if (GET_CODE (XEXP (x, 0)) == PRE_INC	      || GET_CODE (XEXP (x, 0)) == PRE_DEC)	    output_address (plus_constant (XEXP (XEXP (x, 0), 0), 4));	  else	    output_address (plus_constant (XEXP (x, 0), 4));	}      return;			        case 'Y':      /* Similar, for third word of TImode  */      if (GET_CODE (x) == REG)	fprintf (file, "%d", REGNO (x) + 2);      else if (GET_CODE (x) == MEM)	{	  if (GET_CODE (XEXP (x, 0)) == PRE_INC	      || GET_CODE (XEXP (x, 0)) == PRE_DEC)	    output_address (plus_constant (XEXP (XEXP (x, 0), 0), 8));	  else	    output_address (plus_constant (XEXP (x, 0), 8));	}      return;			        case 'Z':      /* Similar, for last word of TImode.  */      if (GET_CODE (x) == REG)	fprintf (file, "%d", REGNO (x) + 3);      else if (GET_CODE (x) == MEM)	{	  if (GET_CODE (XEXP (x, 0)) == PRE_INC	      || GET_CODE (XEXP (x, 0)) == PRE_DEC)	    output_address (plus_constant (XEXP (XEXP (x, 0), 0), 12));	  else	    output_address (plus_constant (XEXP (x, 0), 12));	}      return;			        case 't':      /* Write 12 if this jump operation will branch if true, 4 otherwise. 	 All floating-point operations except NE branch true and integer	 EQ, LT, GT, LTU and GTU also branch true.  */      if (GET_RTX_CLASS (GET_CODE (x)) != '<')	output_operand_lossage ("invalid %%t value");      else if ((GET_MODE (XEXP (x, 0)) == CCFPmode		&& GET_CODE (x) != NE)	       || GET_CODE (x) == EQ	       || GET_CODE (x) == LT || GET_CODE (x) == GT	       || GET_CODE (x) == LTU || GET_CODE (x) == GTU)	fprintf (file, "12");      else	fprintf (file, "4");      return;          case 'T':      /* Opposite of 't': write 4 if this jump operation will branch if true,	 12 otherwise.   */      if (GET_RTX_CLASS (GET_CODE (x)) != '<')	output_operand_lossage ("invalid %%t value");      else if ((GET_MODE (XEXP (x, 0)) == CCFPmode		&& GET_CODE (x) != NE)	       || GET_CODE (x) == EQ	       || GET_CODE (x) == LT || GET_CODE (x) == GT	       || GET_CODE (x) == LTU || GET_CODE (x) == GTU)	fprintf (file, "4");      else	fprintf (file, "12");      return;          case 'j':      /* Write the bit number in CCR for jump.  */      i = ccr_bit (x, 0);      if (i == -1)	output_operand_lossage ("invalid %%j code");      else	fprintf (file, "%d", i);      return;    case 'J':      /* Similar, but add one for shift count in rlinm for scc and pass	 scc flag to `ccr_bit'.  */      i = ccr_bit (x, 1);      if (i == -1)	output_operand_lossage ("invalid %%J code");      else	fprintf (file, "%d", i + 1);      return;    case 'C':      /* This is an optional cror needed for LE or GE floating-point	 comparisons.  Otherwise write nothing.  */      if ((GET_CODE (x) == LE || GET_CODE (x) == GE)	  && GET_MODE (XEXP (x, 0)) == CCFPmode)	{	  int base_bit = 4 * (REGNO (XEXP (x, 0)) - 68);	  fprintf (file, "cror %d,%d,%d\n\t", base_bit + 3,		   base_bit + 2, base_bit + (GET_CODE (x) == GE));	}      return;    case 'D':      /* Similar, except that this is for an scc, so we must be able to	 encode the test in a single bit that is one.  We do the above	 for any LE, GE, GEU, or LEU and invert the bit for NE.  */      if (GET_CODE (x) == LE || GET_CODE (x) == GE	  || GET_CODE (x) == LEU || GET_CODE (x) == GEU)	{	  int base_bit = 4 * (REGNO (XEXP (x, 0)) - 68);	  fprintf (file, "cror %d,%d,%d\n\t", base_bit + 3,		   base_bit + 2,		   base_bit + (GET_CODE (x) == GE || GET_CODE (x) == GEU));	}      else if (GET_CODE (x) == NE)	{	  int base_bit = 4 * (REGNO (XEXP (x, 0)) - 68);	  fprintf (file, "crnor %d,%d,%d\n\t", base_bit + 3,		   base_bit + 2, base_bit + 2);	}      return;    case 'z':      /* X is a SYMBOL_REF.  Write out the name preceded by a	 period and without any trailing data in brackets.  Used for function	 names.  */      if (GET_CODE (x) != SYMBOL_REF)	abort ();      fprintf (file, ".");      RS6000_OUTPUT_BASENAME (file, XSTR (x, 0));      return;    case 'A':      /* If X is a constant integer whose low-order 5 bits are zero,	 write 'l'.  Otherwise, write 'r'.  This is a kludge to fix a bug	 in the RS/6000 assembler where "sri" with a zero shift count	 write a trash instruction.  */      if (GET_CODE (x) == CONST_INT && (INTVAL (x) & 31) == 0)	fprintf (file, "l");      else	fprintf (file, "r");      return;    case 0:      if (GET_CODE (x) == REG)	fprintf (file, "%s", reg_names[REGNO (x)]);      else if (GET_CODE (x) == MEM)	{	  /* We need to handle PRE_INC and PRE_DEC here, since we need to	     know the width from the mode.  */	  if (GET_CODE (XEXP (x, 0)) == PRE_INC)	    fprintf (file, "%d(%d)", GET_MODE_SIZE (GET_MODE (x)),		     REGNO (XEXP (XEXP (x, 0), 0)));	  else if (GET_CODE (XEXP (x, 0)) == PRE_DEC)	    fprintf (file, "%d(%d)", - GET_MODE_SIZE (GET_MODE (x)),		     REGNO (XEXP (XEXP (x, 0), 0)));	  else	    output_address (XEXP (x, 0));	}      else	output_addr_const (file, x);      break;    default:      output_operand_lossage ("invalid %%xn code");    }}/* Print the address of an operand.  */voidprint_operand_address (file, x)     FILE *file;     register rtx x;{  if (GET_CODE (x) == REG)    fprintf (file, "0(%d)", REGNO (x));  else if (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST)    {      output_addr_const (file, x);      fprintf (file, "(2)");    }  else if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == REG)    {      if (REGNO (XEXP (x, 0)) == 0)	fprintf (file, "%d,%d", REGNO (XEXP (x, 1)), REGNO (XEXP (x, 0)));      else	fprintf (file, "%d,%d", REGNO (XEXP (x, 0)), REGNO (XEXP (x, 1)));    }  else if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == CONST_INT)    fprintf (file, "%d(%d)", INTVAL (XEXP (x, 1)), REGNO (XEXP (x, 0)));  else    abort ();}/* This page contains routines that are used to determine what the function   prologue and epilogue code will do and write them out.  *//*  Return the first fixed-point register that is required to be saved. 32 if    none.  */intfirst_reg_to_save (){  int first_reg;  /* Find lowest numbered live register.  */  for (first_reg = 13; first_reg <= 31; first_reg++)    if (regs_ever_live[first_reg])      break;  /* If profiling, then we must save/restore every register that contains     a parameter before/after the .mcount call.  Use registers from 30 down     to 23 to do this.  Don't use the frame pointer in reg 31.     For now, save enough room for all of the parameter registers.  */  if (profile_flag)    if (first_reg > 23)      first_reg = 23;  return first_reg;}/* Similar, for FP regs.  */intfirst_fp_reg_to_save (){  int first_reg;  /* Find lowest numbered live register.  */  for (first_reg = 14 + 32; first_reg <= 63; first_reg++)    if (regs_ever_live[first_reg])      break;  return first_reg;}/* Return 1 if we need to save CR.  */intmust_save_cr (){  return regs_ever_live[70] || regs_ever_live[71] || regs_ever_live[72];}/* Compute the size of the save area in the stack, including the space for   the fixed area.  */intrs6000_sa_size (){  int size;  int i;  /* We have the six fixed words, plus the size of the register save      areas, rounded to a double-word.  */  size = 6 + (32 - first_reg_to_save ()) + (64 - first_fp_reg_to_save ()) * 2;  if (size & 1)    size++;  return size * 4;}/* Return non-zero if this function makes calls.  */intrs6000_makes_calls (){  rtx insn;  for (insn = get_insns (); insn; insn = next_insn (insn))    if (GET_CODE (insn) == CALL_INSN)      return 1;  return 0;}/* Return non-zero if this function needs to push space on the stack.  */intrs6000_pushes_stack (){  int total_size = (rs6000_sa_size () + get_frame_size ()		    + current_function_outgoing_args_size);  /* We need to push the stack if a frame pointer is needed (because the     stack might be dynamically adjusted), if we are debugging, if the     total stack size is more than 220 bytes, or if we make calls.  */  return (frame_pointer_needed || write_symbols != NO_DEBUG	  || total_size > 220	  || rs6000_makes_calls ());}/* Write function prologue.  */voidoutput_prolog (file, size)     FILE *file;     int size;{  int first_reg = first_reg_to_save ();  int must_push = rs6000_pushes_stack ();  int first_fp_reg = first_fp_reg_to_save ();  int basic_size = rs6000_sa_size ();  int total_size = (basic_size + size + current_function_outgoing_args_size);  /* Round size to multiple of 8 bytes.  */  total_size = (total_size + 7) & ~7;  /* Write .extern for any function we will call to save and restore fp     values.  */  if (first_fp_reg < 62)    fprintf (file, "\t.extern ._savef%d\n\t.extern ._restf%d\n",	     first_fp_reg - 32, first_fp_reg - 32);  /* Write .extern for truncation routines, if needed.  */  if (rs6000_trunc_used && ! trunc_defined)    {      fprintf (file, "\t.extern .itrunc\n\t.extern .uitrunc\n");      trunc_defined = 1;    }  /* If we have to call a function to save fpr's, or if we are doing profiling,     then we will be using LR.  */  if (first_fp_reg < 62 || profile_flag)    regs_ever_live[65] = 1;  /* If we use the link register, get it into r0.  */  if (regs_ever_live[65])    fprintf (file, "\tmflr 0\n");  /* If we need to save CR, put it into r12.  */  if (must_save_cr ())    fprintf (file, "\tmfcr 12\n");  /* Do any required saving of fpr's.  If only one or two to save, do it     ourself.  Otherwise, call function.  */  if (first_fp_reg == 62)    fprintf (file, "\tstfd 30,-16(1)\n\tstfd 31,-8(1)\n");  else if (first_fp_reg == 63)    fprintf (file, "\tstfd 31,-8(1)\n");  else if (first_fp_reg != 64)    fprintf (file, "\tbl ._savef%d\n\tcror 15,15,15\n", first_fp_reg - 32);  /* Now save gpr's.  */  if (first_reg == 31)    fprintf (file, "\tst 31,%d(1)\n", -4 - (64 - first_fp_reg) * 8);  else if (first_reg != 32)    fprintf (file, "\tstm %d,%d(1)\n", first_reg,	     - (32 - first_reg) * 4 - (64 - first_fp_reg) * 8);  /* Save lr if we used it.  */  if (regs_ever_live[65])    fprintf (file, "\tst 0,8(1)\n");  /* Save CR if we use any that must be preserved.  */  if (must_save_cr ())    fprintf (file, "\tst 12,4(1)\n");  /* Update stack and set back pointer.  */  if (must_push)    {      if (total_size < 32767)	fprintf (file, "\tstu 1,%d(1)\n", - total_size);      else	{	  fprintf (file, "\tcau 0,0,%d\n\toril 0,0,%d\n",		   (total_size >> 16) & 0xffff, total_size & 0xffff);	  fprintf (file, "\tsf 12,0,1\n\tst 1,0(12)\n\toril 1,12,0\n");	}    }  /* Set frame pointer, if needed.  */  if (frame_pointer_needed)    fprintf (file, "\toril 31,1,0\n");}/* Write function epilogue.  */voidoutput_epilog (file, size)     FILE *file;     int size;{  int first_reg = first_reg_to_save ();  int must_push = rs6000_pushes_stack ();  int first_fp_reg = first_fp_reg_to_save ();  int basic_size = rs6000_sa_size ();  int total_size = (basic_size + size + current_function_outgoing_args_size);  rtx insn = get_last_insn ();  /* Round size to multiple of 8 bytes.  */  total_size = (total_size + 7) & ~7;  /* If the last insn was a BARRIER, we don't have to write anything except     the trace table.  */  if (GET_CODE (insn) == NOTE)    insn = prev_nonnote_insn (insn);  if (insn == 0 ||  GET_CODE (insn) != BARRIER)    {      /* If we have a frame pointer, a call to alloca,  or a large stack	 frame, restore the old stack pointer using the backchain.  Otherwise,	 we know what size to update it with.  */

⌨️ 快捷键说明

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