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

📄 ppc-opc.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 5 页
字号:
  /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form     instruction or the RT field in a D, DS, X, XFX or XO form     instruction.  */#define RS RBS + 1#define RT RS#define RT_MASK (0x1f << 21)  { 5, 21, NULL, NULL, PPC_OPERAND_GPR },  /* The RS field of the DS form stq instruction, which has special     value restrictions.  */#define RSQ RS + 1  { 5, 21, insert_rsq, NULL, PPC_OPERAND_GPR },  /* The RT field of the DQ form lq instruction, which has special     value restrictions.  */#define RTQ RSQ + 1  { 5, 21, insert_rtq, NULL, PPC_OPERAND_GPR },  /* The SH field in an X or M form instruction.  */#define SH RTQ + 1#define SH_MASK (0x1f << 11)  { 5, 11, NULL, NULL, 0 },  /* The SH field in an MD form instruction.  This is split.  */#define SH6 SH + 1#define SH6_MASK ((0x1f << 11) | (1 << 1))  { 6, 1, insert_sh6, extract_sh6, 0 },  /* The SI field in a D form instruction.  */#define SI SH6 + 1  { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED },  /* The SI field in a D form instruction when we accept a wide range     of positive values.  */#define SISIGNOPT SI + 1  { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },  /* The SPR field in an XFX form instruction.  This is flipped--the     lower 5 bits are stored in the upper 5 and vice- versa.  */#define SPR SISIGNOPT + 1#define PMR SPR#define SPR_MASK (0x3ff << 11)  { 10, 11, insert_spr, extract_spr, 0 },  /* The BAT index number in an XFX form m[ft]ibat[lu] instruction.  */#define SPRBAT SPR + 1#define SPRBAT_MASK (0x3 << 17)  { 2, 17, NULL, NULL, 0 },  /* The SPRG register number in an XFX form m[ft]sprg instruction.  */#define SPRG SPRBAT + 1#define SPRG_MASK (0x3 << 16)  { 2, 16, NULL, NULL, 0 },  /* The SR field in an X form instruction.  */#define SR SPRG + 1  { 4, 16, NULL, NULL, 0 },  /* The STRM field in an X AltiVec form instruction.  */#define STRM SR + 1#define STRM_MASK (0x3 << 21)  { 2, 21, NULL, NULL, 0 },  /* The SV field in a POWER SC form instruction.  */#define SV STRM + 1  { 14, 2, NULL, NULL, 0 },  /* The TBR field in an XFX form instruction.  This is like the SPR     field, but it is optional.  */#define TBR SV + 1  { 10, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL },  /* The TO field in a D or X form instruction.  */#define TO TBR + 1#define TO_MASK (0x1f << 21)  { 5, 21, NULL, NULL, 0 },  /* The U field in an X form instruction.  */#define U TO + 1  { 4, 12, NULL, NULL, 0 },  /* The UI field in a D form instruction.  */#define UI U + 1  { 16, 0, NULL, NULL, 0 },  /* The VA field in a VA, VX or VXR form instruction.  */#define VA UI + 1#define VA_MASK	(0x1f << 16)  { 5, 16, NULL, NULL, PPC_OPERAND_VR },  /* The VB field in a VA, VX or VXR form instruction.  */#define VB VA + 1#define VB_MASK (0x1f << 11)  { 5, 11, NULL, NULL, PPC_OPERAND_VR },  /* The VC field in a VA form instruction.  */#define VC VB + 1#define VC_MASK (0x1f << 6)  { 5, 6, NULL, NULL, PPC_OPERAND_VR },  /* The VD or VS field in a VA, VX, VXR or X form instruction.  */#define VD VC + 1#define VS VD#define VD_MASK (0x1f << 21)  { 5, 21, NULL, NULL, PPC_OPERAND_VR },  /* The SIMM field in a VX form instruction.  */#define SIMM VD + 1  { 5, 16, NULL, NULL, PPC_OPERAND_SIGNED},  /* The UIMM field in a VX form instruction.  */#define UIMM SIMM + 1  { 5, 16, NULL, NULL, 0 },  /* The SHB field in a VA form instruction.  */#define SHB UIMM + 1  { 4, 6, NULL, NULL, 0 },  /* The other UIMM field in a EVX form instruction.  */#define EVUIMM SHB + 1  { 5, 11, NULL, NULL, 0 },  /* The other UIMM field in a half word EVX form instruction.  */#define EVUIMM_2 EVUIMM + 1  { 32, 11, insert_ev2, extract_ev2, PPC_OPERAND_PARENS },  /* The other UIMM field in a word EVX form instruction.  */#define EVUIMM_4 EVUIMM_2 + 1  { 32, 11, insert_ev4, extract_ev4, PPC_OPERAND_PARENS },  /* The other UIMM field in a double EVX form instruction.  */#define EVUIMM_8 EVUIMM_4 + 1  { 32, 11, insert_ev8, extract_ev8, PPC_OPERAND_PARENS },  /* The WS field.  */#define WS EVUIMM_8 + 1#define WS_MASK (0x7 << 11)  { 3, 11, NULL, NULL, 0 },  /* The L field in an mtmsrd instruction */#define MTMSRD_L WS + 1  { 1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL },};/* The functions used to insert and extract complicated operands.  *//* The BA field in an XL form instruction when it must be the same as   the BT field in the same instruction.  This operand is marked FAKE.   The insertion function just copies the BT field into the BA field,   and the extraction function just checks that the fields are the   same.  *//*ARGSUSED*/static unsigned longinsert_bat (unsigned long insn,	    long value ATTRIBUTE_UNUSED,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  return insn | (((insn >> 21) & 0x1f) << 16);}static longextract_bat (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid){  if (((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))    *invalid = 1;  return 0;}/* The BB field in an XL form instruction when it must be the same as   the BA field in the same instruction.  This operand is marked FAKE.   The insertion function just copies the BA field into the BB field,   and the extraction function just checks that the fields are the   same.  *//*ARGSUSED*/static unsigned longinsert_bba (unsigned long insn,	    long value ATTRIBUTE_UNUSED,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  return insn | (((insn >> 16) & 0x1f) << 11);}static longextract_bba (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid){  if (((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))    *invalid = 1;  return 0;}/* The BD field in a B form instruction.  The lower two bits are   forced to zero.  *//*ARGSUSED*/static unsigned longinsert_bd (unsigned long insn,	   long value,	   int dialect ATTRIBUTE_UNUSED,	   const char **errmsg ATTRIBUTE_UNUSED){  return insn | (value & 0xfffc);}/*ARGSUSED*/static longextract_bd (unsigned long insn,	    int dialect ATTRIBUTE_UNUSED,	    int *invalid ATTRIBUTE_UNUSED){  return ((insn & 0xfffc) ^ 0x8000) - 0x8000;}/* The BD field in a B form instruction when the - modifier is used.   This modifier means that the branch is not expected to be taken.   For chips built to versions of the architecture prior to version 2   (ie. not Power4 compatible), we set the y bit of the BO field to 1   if the offset is negative.  When extracting, we require that the y   bit be 1 and that the offset be positive, since if the y bit is 0   we just want to print the normal form of the instruction.   Power4 compatible targets use two bits, "a", and "t", instead of   the "y" bit.  "at" == 00 => no hint, "at" == 01 => unpredictable,   "at" == 10 => not taken, "at" == 11 => taken.  The "t" bit is 00001   in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000   for branch on CTR.  We only handle the taken/not-taken hint here.  *//*ARGSUSED*/static unsigned longinsert_bdm (unsigned long insn,	    long value,	    int dialect,	    const char **errmsg ATTRIBUTE_UNUSED){  if ((dialect & PPC_OPCODE_POWER4) == 0)    {      if ((value & 0x8000) != 0)	insn |= 1 << 21;    }  else    {      if ((insn & (0x14 << 21)) == (0x04 << 21))	insn |= 0x02 << 21;      else if ((insn & (0x14 << 21)) == (0x10 << 21))	insn |= 0x08 << 21;    }  return insn | (value & 0xfffc);}static longextract_bdm (unsigned long insn,	     int dialect,	     int *invalid){  if ((dialect & PPC_OPCODE_POWER4) == 0)    {      if (((insn & (1 << 21)) == 0) != ((insn & (1 << 15)) == 0))	*invalid = 1;    }  else    {      if ((insn & (0x17 << 21)) != (0x06 << 21)	  && (insn & (0x1d << 21)) != (0x18 << 21))	*invalid = 1;    }  return ((insn & 0xfffc) ^ 0x8000) - 0x8000;}/* The BD field in a B form instruction when the + modifier is used.   This is like BDM, above, except that the branch is expected to be   taken.  *//*ARGSUSED*/static unsigned longinsert_bdp (unsigned long insn,	    long value,	    int dialect,	    const char **errmsg ATTRIBUTE_UNUSED){  if ((dialect & PPC_OPCODE_POWER4) == 0)    {      if ((value & 0x8000) == 0)	insn |= 1 << 21;    }  else    {      if ((insn & (0x14 << 21)) == (0x04 << 21))	insn |= 0x03 << 21;      else if ((insn & (0x14 << 21)) == (0x10 << 21))	insn |= 0x09 << 21;    }  return insn | (value & 0xfffc);}static longextract_bdp (unsigned long insn,	     int dialect,	     int *invalid){  if ((dialect & PPC_OPCODE_POWER4) == 0)    {      if (((insn & (1 << 21)) == 0) == ((insn & (1 << 15)) == 0))	*invalid = 1;    }  else    {      if ((insn & (0x17 << 21)) != (0x07 << 21)	  && (insn & (0x1d << 21)) != (0x19 << 21))	*invalid = 1;    }  return ((insn & 0xfffc) ^ 0x8000) - 0x8000;}/* Check for legal values of a BO field.  */static intvalid_bo (long value, int dialect){  if ((dialect & PPC_OPCODE_POWER4) == 0)    {      /* Certain encodings have bits that are required to be zero.	 These are (z must be zero, y may be anything):	     001zy	     011zy	     1z00y	     1z01y	     1z1zz      */      switch (value & 0x14)	{	default:	case 0:	  return 1;	case 0x4:	  return (value & 0x2) == 0;	case 0x10:	  return (value & 0x8) == 0;	case 0x14:	  return value == 0x14;	}    }  else    {      /* Certain encodings have bits that are required to be zero.	 These are (z must be zero, a & t may be anything):	     0000z	     0001z	     0100z	     0101z	     001at	     011at	     1a00t	     1a01t	     1z1zz      */      if ((value & 0x14) == 0)	return (value & 0x1) == 0;      else if ((value & 0x14) == 0x14)	return value == 0x14;      else	return 1;    }}/* The BO field in a B form instruction.  Warn about attempts to set   the field to an illegal value.  */static unsigned longinsert_bo (unsigned long insn,	   long value,	   int dialect,	   const char **errmsg){  if (!valid_bo (value, dialect))    *errmsg = _("invalid conditional option");  return insn | ((value & 0x1f) << 21);}static longextract_bo (unsigned long insn,	    int dialect,	    int *invalid){  long value;  value = (insn >> 21) & 0x1f;  if (!valid_bo (value, dialect))    *invalid = 1;  return value;}

⌨️ 快捷键说明

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