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

📄 1750a.c

📁 gcc3.2.1源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
static int addr_inc;/* A C compound statement to output to stdio stream STREAM the   assembler syntax for an instruction operand X.  X is an RTL   expression.   CODE is a value that can be used to specify one of several ways   of printing the operand.  It is used when identical operands   must be printed differently depending on the context.  CODE   comes from the `%' specification that was used to request   printing of the operand.  If the specification was just `%DIGIT'   then CODE is 0; if the specification was `%LTR DIGIT' then CODE   is the ASCII code for LTR.   If X is a register, this macro should print the register's name.   The names can be found in an array `reg_names' whose type is   `char *[]'.  `reg_names' is initialized from `REGISTER_NAMES'.   When the machine description has a specification `%PUNCT' (a `%'   followed by a punctuation character), this macro is called with   a null pointer for X and the punctuation character for CODE.   The 1750 specific codes are:   'J' for the negative of a constant   'Q' for printing addresses in B mode syntax   'd' for the second register in a pair   't' for the third register in a triple    'b' for the bit number (using 1750 test bit convention)   'B' for the bit number of the 1's complement (for bit clear)   'w' for int - 16*/voidprint_operand (file, x, letter)     FILE *file;     rtx x;     int letter;{  switch (GET_CODE (x))    {    case REG:      if (letter == 'd')	fprintf (file, "%d", REGNO (x) + 1);      else if (letter == 't')	fprintf (file, "%d", REGNO (x) + 2);      else	fprintf (file, "%d", REGNO (x));      break;    case SYMBOL_REF:      fprintf (file, "%s", XSTR (x, 0));      if (letter == 'A')	fprintf (file, "+1");      break;    case LABEL_REF:    case CONST:    case MEM:      if (letter == 'Q')	{	  rtx inner = XEXP (x, 0);	  switch (GET_CODE (inner))	    {	    case REG:	      fprintf (file, "r%d,0", REGNO (inner));	      break;	    case PLUS:	      fprintf (file, "r%d,%d", REGNO (XEXP (inner, 0)),		       INTVAL (XEXP (inner, 1)));	      break;	    default:	      fprintf (file, "[ill Q code=%d]", GET_CODE (inner));	    }	}      else	{	  addr_inc = (letter == 'A' ? 1 : 0);	  output_address (XEXP (x, 0));	}      break;    case CONST_DOUBLE:/*    {	double value = get_double (x);	char fltstr[32];	sprintf (fltstr, "%f", value);	if (letter == 'D' || letter == 'E')	  {	    int i, found = 0;	    for (i = 0; i <= datalbl_ndx; i++)	      if (strcmp (fltstr, datalbl[i].value) == 0)		{		  found = 1;		  break;		}	    if (!found)	      {		strcpy (datalbl[i = ++datalbl_ndx].value, fltstr);		datalbl[i].name = float_label (letter, value);		datalbl[i].size = (letter == 'E') ? 3 : 2;		check_section (Konst);		fprintf (file, "K%s \tdata%s %s ;p_o\n", datalbl[i].name,			(letter == 'E' ? "ef" : "f"), fltstr);		check_section (Normal);	      }	  }	else if (letter == 'F' || letter == 'G')	  {	    int i, found = 0;	    for (i = 0; i <= datalbl_ndx; i++)	      if (strcmp (fltstr, datalbl[i].value) == 0)		{		  found = 1;		  break;		}	    if (!found)	      {		fprintf (stderr,		   "float value %f not found upon label reference\n", value);		strcpy (datalbl[i = ++datalbl_ndx].value, fltstr);		datalbl[i].name = float_label (letter, value);		datalbl[i].size = (letter == 'G') ? 3 : 2;		check_section (Konst);		fprintf (file, "K%s \tdata%s %s ;p_o\n", datalbl[i].name,			(letter == 'G' ? "ef" : "f"), fltstr);		check_section (Normal);	      }	    fprintf (file, "%s ;P_O 'F'", datalbl[i].name);	  }	else	  fprintf (file, " %s  ;P_O cst_dbl ", fltstr);      } */      fprintf (file, "%f", get_double (x));      break;    case CONST_INT:      if (letter == 'J')	fprintf (file, HOST_WIDE_INT_PRINT_DEC, -INTVAL (x));      else if (letter == 'b')        fprintf (file, "%d", which_bit (INTVAL (x)));      else if (letter == 'B')        fprintf (file, "%d", which_bit (~INTVAL (x)));      else if (letter == 'w')	fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) - 16);      else	fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x));      break;    case CODE_LABEL:      fprintf (file, "L%d", XINT (x, 3));      break;    case CALL:      fprintf (file, "CALL nargs=");      fprintf (file, HOST_PTR_PRINTF, (PTR) XEXP (x, 1));      fprintf (file, ", func is either '%s' or '%s'",	       XSTR (XEXP (XEXP (x, 0), 1), 0), XSTR (XEXP (x, 0), 1));      break;    case PLUS:      {	rtx op0 = XEXP (x, 0), op1 = XEXP (x, 1);	int op0code = GET_CODE (op0), op1code = GET_CODE (op1);	if (op1code == CONST_INT)	  switch (op0code)	    {	    case REG:	      fprintf (file, "%d,r%d  ; p_o_PLUS for REG and CONST_INT",		       INTVAL (op1), REGNO (op0));	      break;	    case SYMBOL_REF:	      fprintf (file, "%d+%s", INTVAL (op1), XSTR (op0, 0));	      break;	    case MEM:	      fprintf (file, "%d,[mem:", INTVAL (op1));	      output_address (XEXP (op0, 0));	      fprintf (file, "] ;P_O plus");	      break;	    default:	      fprintf (file, "p_o_PLUS UFO, code=%d, with CONST=%d",		       (int) op0code, INTVAL (op1));	    }	else if (op1code == SYMBOL_REF && op0code == REG)	  fprintf (file, "%s,r%d  ; P_O: (plus reg sym)",		   XSTR (op1, 0), REGNO (op0));	else	  fprintf (file, "p_o_+: op0code=%d, op1code=%d", op0code, op1code);      }      break;    default:      fprintf (file, "p_o_UFO code=%d", GET_CODE (x));    }  addr_inc = 0;}voidprint_operand_address (file, addr)     FILE *file;     rtx addr;{  switch (GET_CODE (addr))    {    case REG:      fprintf (file, "%d,r%d ; P_O_A", addr_inc, REGNO (addr));      break;    case PLUS:      {	register rtx x = XEXP (addr, 0), y = XEXP (addr, 1);	switch (GET_CODE (x))	  {	  case REG:	    switch (GET_CODE (y))	      {	      case CONST:		output_address (XEXP (y, 0));		fprintf (file, ",r%d ;P_O_A reg + const expr", REGNO (x));		break;	      case CONST_INT:		fprintf (file, "%d,r%d", INTVAL (y) + addr_inc, REGNO (x));		break;	      case SYMBOL_REF:		fprintf (file, "%s", XSTR (y, 0));		if (addr_inc)		  fprintf (file, "+%d", addr_inc);		fprintf (file, ",r%d  ; P_O_A reg + sym", REGNO (x));		break;	      case LABEL_REF:		output_address (XEXP (y, 0));		fprintf (file, ",r%d  ; P_O_A reg + label", REGNO (x));		break;	      default:		fprintf (file, "[P_O_A reg%d+UFO code=%d]",			 REGNO (x), GET_CODE (y));	      }	    break;	  case LABEL_REF:	    output_address (XEXP (x, 0));	    break;	  case SYMBOL_REF:	    switch (GET_CODE (y))	      {	      case CONST_INT:		fprintf (file, "%d+%s", INTVAL (y) + addr_inc, XSTR (x, 0));		break;	      case REG:		fprintf (file, "%s,r%d ;P_O_A sym + reg",			 XSTR (x, 0), REGNO (y));		break;	      default:		fprintf (file, "P_O_A sym/lab+UFO[sym=%s,code(y)=%d]",			 XSTR (x, 0), GET_CODE (y));	      }	    break;	  case CONST:	    output_address (XEXP (x, 0));	    if (GET_CODE (y) == REG)	      fprintf (file, ",r%d ;P_O_A const + reg", REGNO (x));	    else	      fprintf (file, "P_O_A const+UFO code(y)=%d]", GET_CODE (y));	    break;	  case MEM:	    output_address (y);	    fprintf (file, ",[mem:");	    output_address (XEXP (x, 0));	    fprintf (file, "] ;P_O_A plus");	    break;	  default:	    fprintf (file, "P_O_A plus op1_UFO[code1=%d,code2=%d]",		     GET_CODE (x), GET_CODE (y));	  }      }      break;    case CONST_INT:      if (INTVAL (addr) < 0x10000 && INTVAL (addr) >= -0x10000)	fprintf (file, "%d ; p_o_a const addr?!", INTVAL (addr));      else	{	  fprintf (file, "[p_o_a=ILLEGAL_CONST]");	  output_addr_const (file, addr);	}      break;    case LABEL_REF:    case SYMBOL_REF:      fprintf (file, "%s", XSTR (addr, 0));      if (addr_inc)	fprintf (file, "+%d", addr_inc);      break;    case MEM:      fprintf (file, "[memUFO:");      output_address (XEXP (addr, 0));      fprintf (file, "]");      break;    case CONST:      output_address (XEXP (addr, 0));      fprintf (file, " ;P_O_A const");      break;    case CODE_LABEL:      fprintf (file, "L%d", XINT (addr, 3));      break;    default:      fprintf (file, " p_o_a UFO, code=%d val=0x%x",	       (int) GET_CODE (addr), INTVAL (addr));      break;    }  addr_inc = 0;}/* Target hook for assembling integer objects.  The 1750a version needs to   keep track of how many bytes have been written.  */static boolassemble_integer_1750a (x, size, aligned_p)     rtx x;     unsigned int size;     int aligned_p;{  if (default_assemble_integer (x, size, aligned_p))    {      if (label_pending)	label_pending = 0;      datalbl[datalbl_ndx].size += size;      return true;    }  return false;}/* *  Return non zero if the LS 16 bits of the given value has just one bit set, *  otherwise return zero. Note this function may be used to detect one *  bit clear by inverting the param. */intone_bit_set_p (x)     int x;{  x &= 0xffff;   return x && (x & (x - 1)) == 0;}/* * Return the number of the least significant bit set, using the  same * convention for bit numbering as in the MIL-STD-1750 sb instruction. */static intwhich_bit (x)     int x;{  int b = 15;  while (b > 0 && (x & 1) == 0)    {      b--;      x >>= 1;    }  return b;}/* Convert a REAL_VALUE_TYPE to the target float format:        MSB                             LSB MSB            LSB        ------------------------------------------------------        |S|                 Mantissa       |  Exponent       |        ------------------------------------------------------         0 1                             23 24             31*/longreal_value_to_target_single(in)     REAL_VALUE_TYPE in;{  union {    double d;    struct {#if HOST_WORDS_BIG_ENDIAN        unsigned int negative:1;        unsigned int exponent:11;        unsigned int mantissa0:20;        unsigned int mantissa1:32;#else        unsigned int mantissa1:32;        unsigned int mantissa0:20;        unsigned int exponent:11;        unsigned int negative:1;#endif    } s;  } ieee;  unsigned int mant;  int exp;  if (HOST_FLOAT_FORMAT != IEEE_FLOAT_FORMAT)    abort ();  ieee.d = in;  /* Don't bother with NaN, Inf, 0 special cases, since they'll be handled     by the over/underflow code below.  */  exp = ieee.s.exponent - 0x3ff;  mant = 1 << 23 | ieee.s.mantissa0 << 3 | ieee.s.mantissa1 >> 29;  /* The sign is actually part of the mantessa.  Since we're comming from     IEEE we know that either bit 23 is set or we have a zero.  */  if (! ieee.s.negative)    {      mant >>= 1;      exp += 1;    }  /* Check for overflow.  Crop to FLT_MAX.  */  if (exp > 127)    {      exp = 127;      mant = (ieee.s.negative ? 0xffffff : 0x7fffff);    }  /* Underflow to zero.  */  else if (exp < -128)    {      exp = 0;      mant = 0;    }  return mant << 8 | (exp & 0xff);}/* Convert a REAL_VALUE_TYPE to the target 1750a extended float format:        ----------------------------------------------------        | |      Mantissa       |        |   Mantissa      |        |S|         MS          |Exponent|      LS         |        ----------------------------------------------------         0 1                  23 24    31 32             47*/voidreal_value_to_target_double(in, out)     REAL_VALUE_TYPE in;     long out[];{  union {    double d;    struct {#if HOST_WORDS_BIG_ENDIAN        unsigned int negative:1;        unsigned int exponent:11;        unsigned int mantissa0:20;        unsigned int mantissa1:32;#else        unsigned int mantissa1:32;        unsigned int mantissa0:20;        unsigned int exponent:11;        unsigned int negative:1;#endif    } s;  } ieee;  unsigned int mant_h24, mant_l16;  int exp;  if (HOST_FLOAT_FORMAT != IEEE_FLOAT_FORMAT)    abort ();  ieee.d = in;  /* Don't bother with NaN, Inf, 0 special cases, since they'll be handled     by the over/underflow code below.  */  exp = ieee.s.exponent - 0x3ff;  mant_h24 = 1 << 23 | ieee.s.mantissa0 << 3 | ieee.s.mantissa1 >> 29;  mant_l16 = (ieee.s.mantissa1 >> 13) & 0xffff;  /* The sign is actually part of the mantessa.  Since we're comming from     IEEE we know that either bit 23 is set or we have a zero.  */  if (! ieee.s.negative)    {      mant_l16 = mant_l16 >> 1 | (mant_h24 & 1) << 15;      mant_h24 >>= 1;      exp += 1;    }  /* Check for overflow.  Crop to DBL_MAX.  */  if (exp > 127)    {      exp = 127;      mant_h24 = (ieee.s.negative ? 0xffffff : 0x7fffff);      mant_l16 = 0xffff;    }  /* Underflow to zero.  */  else if (exp < -128)    {      exp = 0;      mant_h24 = 0;      mant_l16 = 0;    }  out[0] = mant_h24 << 8 | (exp & 0xff);  out[1] = mant_l16;}

⌨️ 快捷键说明

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