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

📄 ppc-opc.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 5 页
字号:
/* The BO field in a B form instruction when the + or - modifier is   used.  This is like the BO field, but it must be even.  When   extracting it, we force it to be even.  */static unsigned longinsert_boe (unsigned long insn,	    long value,	    int dialect,	    const char **errmsg){  if (!valid_bo (value, dialect))    *errmsg = _("invalid conditional option");  else if ((value & 1) != 0)    *errmsg = _("attempt to set y bit when using + or - modifier");  return insn | ((value & 0x1f) << 21);}static longextract_boe (unsigned long insn,	     int dialect,	     int *invalid){  long value;  value = (insn >> 21) & 0x1f;  if (!valid_bo (value, dialect))    *invalid = 1;  return value & 0x1e;}/* The DQ field in a DQ form instruction.  This is like D, but the   lower four bits are forced to zero. *//*ARGSUSED*/static unsigned longinsert_dq (unsigned long insn,	   long value,	   int dialect ATTRIBUTE_UNUSED,	   const char **errmsg){  if ((value & 0xf) != 0)    *errmsg = _("offset not a multiple of 16");  return insn | (value & 0xfff0);}/*ARGSUSED*/static longextract_dq (unsigned long insn,	    int dialect ATTRIBUTE_UNUSED,	    int *invalid ATTRIBUTE_UNUSED){  return ((insn & 0xfff0) ^ 0x8000) - 0x8000;}static unsigned longinsert_ev2 (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if ((value & 1) != 0)    *errmsg = _("offset not a multiple of 2");  if ((value > 62) != 0)    *errmsg = _("offset greater than 62");  return insn | ((value & 0x3e) << 10);}static longextract_ev2 (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  return (insn >> 10) & 0x3e;}static unsigned longinsert_ev4 (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if ((value & 3) != 0)    *errmsg = _("offset not a multiple of 4");  if ((value > 124) != 0)    *errmsg = _("offset greater than 124");  return insn | ((value & 0x7c) << 9);}static longextract_ev4 (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  return (insn >> 9) & 0x7c;}static unsigned longinsert_ev8 (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if ((value & 7) != 0)    *errmsg = _("offset not a multiple of 8");  if ((value > 248) != 0)    *errmsg = _("offset greater than 248");  return insn | ((value & 0xf8) << 8);}static longextract_ev8 (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  return (insn >> 8) & 0xf8;}/* The DS field in a DS form instruction.  This is like D, but the   lower two bits are forced to zero.  *//*ARGSUSED*/static unsigned longinsert_ds (unsigned long insn,	   long value,	   int dialect ATTRIBUTE_UNUSED,	   const char **errmsg){  if ((value & 3) != 0)    *errmsg = _("offset not a multiple of 4");  return insn | (value & 0xfffc);}/*ARGSUSED*/static longextract_ds (unsigned long insn,	    int dialect ATTRIBUTE_UNUSED,	    int *invalid ATTRIBUTE_UNUSED){  return ((insn & 0xfffc) ^ 0x8000) - 0x8000;}/* The DE field in a DE form instruction.  *//*ARGSUSED*/static unsigned longinsert_de (unsigned long insn,	   long value,	   int dialect ATTRIBUTE_UNUSED,	   const char **errmsg){  if (value > 2047 || value < -2048)    *errmsg = _("offset not between -2048 and 2047");  return insn | ((value << 4) & 0xfff0);}/*ARGSUSED*/static longextract_de (unsigned long insn,	    int dialect ATTRIBUTE_UNUSED,	    int *invalid ATTRIBUTE_UNUSED){  return (insn & 0xfff0) >> 4;}/* The DES field in a DES form instruction.  *//*ARGSUSED*/static unsigned longinsert_des (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if (value > 8191 || value < -8192)    *errmsg = _("offset not between -8192 and 8191");  else if ((value & 3) != 0)    *errmsg = _("offset not a multiple of 4");  return insn | ((value << 2) & 0xfff0);}/*ARGSUSED*/static longextract_des (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  return (((insn >> 2) & 0x3ffc) ^ 0x2000) - 0x2000;}/* FXM mask in mfcr and mtcrf instructions.  */static unsigned longinsert_fxm (unsigned long insn,	    long value,	    int dialect,	    const char **errmsg){  /* If the optional field on mfcr is missing that means we want to use     the old form of the instruction that moves the whole cr.  In that     case we'll have VALUE zero.  There doesn't seem to be a way to     distinguish this from the case where someone writes mfcr %r3,0.  */  if (value == 0)    ;  /* If only one bit of the FXM field is set, we can use the new form     of the instruction, which is faster.  Unlike the Power4 branch hint     encoding, this is not backward compatible.  */  else if ((dialect & PPC_OPCODE_POWER4) != 0 && (value & -value) == value)    insn |= 1 << 20;  /* Any other value on mfcr is an error.  */  else if ((insn & (0x3ff << 1)) == 19 << 1)    {      *errmsg = _("ignoring invalid mfcr mask");      value = 0;    }  return insn | ((value & 0xff) << 12);}static longextract_fxm (unsigned long insn,	     int dialect,	     int *invalid){  long mask = (insn >> 12) & 0xff;  /* Is this a Power4 insn?  */  if ((insn & (1 << 20)) != 0)    {      if ((dialect & PPC_OPCODE_POWER4) == 0)	*invalid = 1;      else	{	  /* Exactly one bit of MASK should be set.  */	  if (mask == 0 || (mask & -mask) != mask)	    *invalid = 1;	}    }  /* Check that non-power4 form of mfcr has a zero MASK.  */  else if ((insn & (0x3ff << 1)) == 19 << 1)    {      if (mask != 0)	*invalid = 1;    }  return mask;}/* The LI field in an I form instruction.  The lower two bits are   forced to zero.  *//*ARGSUSED*/static unsigned longinsert_li (unsigned long insn,	   long value,	   int dialect ATTRIBUTE_UNUSED,	   const char **errmsg){  if ((value & 3) != 0)    *errmsg = _("ignoring least significant bits in branch offset");  return insn | (value & 0x3fffffc);}/*ARGSUSED*/static longextract_li (unsigned long insn,	    int dialect ATTRIBUTE_UNUSED,	    int *invalid ATTRIBUTE_UNUSED){  return ((insn & 0x3fffffc) ^ 0x2000000) - 0x2000000;}/* The MB and ME fields in an M form instruction expressed as a single   operand which is itself a bitmask.  The extraction function always   marks it as invalid, since we never want to recognize an   instruction which uses a field of this type.  */static unsigned longinsert_mbe (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  unsigned long uval, mask;  int mb, me, mx, count, last;  uval = value;  if (uval == 0)    {      *errmsg = _("illegal bitmask");      return insn;    }  mb = 0;  me = 32;  if ((uval & 1) != 0)    last = 1;  else    last = 0;  count = 0;  /* mb: location of last 0->1 transition */  /* me: location of last 1->0 transition */  /* count: # transitions */  for (mx = 0, mask = 1L << 31; mx < 32; ++mx, mask >>= 1)    {      if ((uval & mask) && !last)	{	  ++count;	  mb = mx;	  last = 1;	}      else if (!(uval & mask) && last)	{	  ++count;	  me = mx;	  last = 0;	}    }  if (me == 0)    me = 32;  if (count != 2 && (count != 0 || ! last))    *errmsg = _("illegal bitmask");  return insn | (mb << 6) | ((me - 1) << 1);}static longextract_mbe (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid){  long ret;  int mb, me;  int i;  *invalid = 1;  mb = (insn >> 6) & 0x1f;  me = (insn >> 1) & 0x1f;  if (mb < me + 1)    {      ret = 0;      for (i = mb; i <= me; i++)	ret |= 1L << (31 - i);    }  else if (mb == me + 1)    ret = ~0;  else /* (mb > me + 1) */    {      ret = ~0;      for (i = me + 1; i < mb; i++)	ret &= ~(1L << (31 - i));    }  return ret;}/* The MB or ME field in an MD or MDS form instruction.  The high bit   is wrapped to the low end.  *//*ARGSUSED*/static unsigned longinsert_mb6 (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  return insn | ((value & 0x1f) << 6) | (value & 0x20);}/*ARGSUSED*/static longextract_mb6 (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  return ((insn >> 6) & 0x1f) | (insn & 0x20);}/* The NB field in an X form instruction.  The value 32 is stored as   0.  */static unsigned longinsert_nb (unsigned long insn,	   long value,	   int dialect ATTRIBUTE_UNUSED,	   const char **errmsg){  if (value < 0 || value > 32)    *errmsg = _("value out of range");  if (value == 32)    value = 0;

⌨️ 快捷键说明

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