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

📄 ppc-opc.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
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;  return insn | ((value & 0x1f) << 11);}static longextract_nb (unsigned long insn,	    int dialect ATTRIBUTE_UNUSED,	    int *invalid ATTRIBUTE_UNUSED){  long ret;  ret = (insn >> 11) & 0x1f;  if (ret == 0)    ret = 32;  return ret;}/* The NSI field in a D form instruction.  This is the same as the SI   field, only negated.  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_nsi (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  return insn | (-value & 0xffff);}static longextract_nsi (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid){  *invalid = 1;  return -(((insn & 0xffff) ^ 0x8000) - 0x8000);}/* The RA field in a D or X form instruction which is an updating   load, which means that the RA field may not be zero and may not   equal the RT field.  */static unsigned longinsert_ral (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if (value == 0      || (unsigned long) value == ((insn >> 21) & 0x1f))    *errmsg = "invalid register operand when updating";  return insn | ((value & 0x1f) << 16);}/* The RA field in an lmw instruction, which has special value   restrictions.  */static unsigned longinsert_ram (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if ((unsigned long) value >= ((insn >> 21) & 0x1f))    *errmsg = _("index register in load range");  return insn | ((value & 0x1f) << 16);}/* The RA field in the DQ form lq instruction, which has special   value restrictions.  */static unsigned longinsert_raq (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  long rtvalue = (insn & RT_MASK) >> 21;  if (value == rtvalue)    *errmsg = _("source and target register operands must be different");  return insn | ((value & 0x1f) << 16);}/* The RA field in a D or X form instruction which is an updating   store or an updating floating point load, which means that the RA   field may not be zero.  */static unsigned longinsert_ras (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if (value == 0)    *errmsg = _("invalid register operand when updating");  return insn | ((value & 0x1f) << 16);}/* The RB field in an X form instruction when it must be the same as   the RS field in the instruction.  This is used for extended   mnemonics like mr.  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.  */static unsigned longinsert_rbs (unsigned long insn,	    long value ATTRIBUTE_UNUSED,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  return insn | (((insn >> 21) & 0x1f) << 11);}static longextract_rbs (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid){  if (((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f))    *invalid = 1;  return 0;}/* The RT field of the DQ form lq instruction, which has special   value restrictions.  */static unsigned longinsert_rtq (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if ((value & 1) != 0)    *errmsg = _("target register operand must be even");  return insn | ((value & 0x1f) << 21);}/* The RS field of the DS form stq instruction, which has special   value restrictions.  */static unsigned longinsert_rsq (unsigned long insn,	    long value ATTRIBUTE_UNUSED,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg){  if ((value & 1) != 0)    *errmsg = _("source register operand must be even");  return insn | ((value & 0x1f) << 21);}/* The SH field in an MD form instruction.  This is split.  */static unsigned longinsert_sh6 (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4);}static longextract_sh6 (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  return ((insn >> 11) & 0x1f) | ((insn << 4) & 0x20);}/* The SPR field in an XFX form instruction.  This is flipped--the   lower 5 bits are stored in the upper 5 and vice- versa.  */static unsigned longinsert_spr (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);}static longextract_spr (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);}/* Some dialects have 8 SPRG registers instead of the standard 4.  */static unsigned longinsert_sprg (unsigned long insn,	     long value,	     int dialect,	     const char **errmsg){  /* This check uses PPC_OPCODE_403 because PPC405 is later defined     as a synonym.  If ever a 405 specific dialect is added this     check should use that instead.  */  if (value > 7      || (value > 3	  && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_403)) == 0))    *errmsg = _("invalid sprg number");  /* If this is mfsprg4..7 then use spr 260..263 which can be read in     user mode.  Anything else must use spr 272..279.  */  if (value <= 3 || (insn & 0x100) != 0)    value |= 0x10;  return insn | ((value & 0x17) << 16);}static longextract_sprg (unsigned long insn,	      int dialect,	      int *invalid){  unsigned long val = (insn >> 16) & 0x1f;  /* mfsprg can use 260..263 and 272..279.  mtsprg only uses spr 272..279     If not BOOKE or 405, then both use only 272..275.  */  if (val <= 3      || (val < 0x10 && (insn & 0x100) != 0)      || (val - 0x10 > 3	  && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_403)) == 0))    *invalid = 1;  return val & 7;}/* The TBR field in an XFX instruction.  This is just like SPR, but it   is optional.  When TBR is omitted, it must be inserted as 268 (the   magic number of the TB register).  These functions treat 0   (indicating an omitted optional operand) as 268.  This means that   ``mftb 4,0'' is not handled correctly.  This does not matter very   much, since the architecture manual does not define mftb as   accepting any values other than 268 or 269.  */#define TB (268)static unsigned longinsert_tbr (unsigned long insn,	    long value,	    int dialect ATTRIBUTE_UNUSED,	    const char **errmsg ATTRIBUTE_UNUSED){  if (value == 0)    value = TB;  return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);}static longextract_tbr (unsigned long insn,	     int dialect ATTRIBUTE_UNUSED,	     int *invalid ATTRIBUTE_UNUSED){  long ret;  ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);  if (ret == TB)    ret = 0;  return ret;}/* Macros used to form opcodes.  *//* The main opcode.  */#define OP(x) ((((unsigned long)(x)) & 0x3f) << 26)#define OP_MASK OP (0x3f)/* The main opcode combined with a trap code in the TO field of a D   form instruction.  Used for extended mnemonics for the trap   instructions.  */#define OPTO(x,to) (OP (x) | ((((unsigned long)(to)) & 0x1f) << 21))#define OPTO_MASK (OP_MASK | TO_MASK)/* The main opcode combined with a comparison size bit in the L field   of a D form or X form instruction.  Used for extended mnemonics for   the comparison instructions.  */#define OPL(x,l) (OP (x) | ((((unsigned long)(l)) & 1) << 21))#define OPL_MASK OPL (0x3f,1)/* An A form instruction.  */#define A(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1) | (((unsigned long)(rc)) & 1))#define A_MASK A (0x3f, 0x1f, 1)/* An A_MASK with the FRB field fixed.  */#define AFRB_MASK (A_MASK | FRB_MASK)/* An A_MASK with the FRC field fixed.  */#define AFRC_MASK (A_MASK | FRC_MASK)/* An A_MASK with the FRA and FRC fields fixed.  */#define AFRAFRC_MASK (A_MASK | FRA_MASK | FRC_MASK)/* An AFRAFRC_MASK, but with L bit clear.  */#define AFRALFRC_MASK (AFRAFRC_MASK & ~((unsigned long) 1 << 16))/* A B form instruction.  */#define B(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 1) | ((lk) & 1))#define B_MASK B (0x3f, 1, 1)/* A B form instruction setting the BO field.  */#define BBO(op, bo, aa, lk) (B ((op), (aa), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21))#define BBO_MASK BBO (0x3f, 0x1f, 1, 1)/* A BBO_MASK with the y bit of the BO field removed.  This permits   matching a conditional branch regardless of the setting of the y   bit.  Similarly for the 'at' bits used for power4 branch hints.  */#define Y_MASK   (((unsigned long) 1) << 21)#define AT1_MASK (((unsigned long) 3) << 21)#define AT2_MASK (((unsigned long) 9) << 21)#define BBOY_MASK  (BBO_MASK &~ Y_MASK)#define BBOAT_MASK (BBO_MASK &~ AT1_MASK)/* A B form instruction setting the BO field and the condition bits of   the BI field.  */#define BBOCB(op, bo, cb, aa, lk) \  (BBO ((op), (bo), (aa), (lk)) | ((((unsigned long)(cb)) & 0x3) << 16))#define BBOCB_MASK BBOCB (0x3f, 0x1f, 0x3, 1, 1)/* A BBOCB_MASK with the y bit of the BO field removed.  */#define BBOYCB_MASK (BBOCB_MASK &~ Y_MASK)#define BBOATCB_MASK (BBOCB_MASK &~ AT1_MASK)#define BBOAT2CB_MASK (BBOCB_MASK &~ AT2_MASK)/* A BBOYCB_MASK in which the BI field is fixed.  */#define BBOYBI_MASK (BBOYCB_MASK | BI_MASK)#define BBOATBI_MASK (BBOAT2CB_MASK | BI_MASK)/* An Context form instruction.  */#define CTX(op, xop)   (OP (op) | (((unsigned long)(xop)) & 0x7))#define CTX_MASK CTX(0x3f, 0x7)/* An User Context form instruction.  */#define UCTX(op, xop)  (OP (op) | (((unsigned long)(xop)) & 0x1f))#define UCTX_MASK UCTX(0x3f, 0x1f)/* The main opcode mask with the RA field clear.  */#define DRA_MASK (OP_MASK | RA_MASK)/* A DS form instruction.  */#define DSO(op, xop) (OP (op) | ((xop) & 0x3))#define DS_MASK DSO (0x3f, 3)/* A DE form instruction.  */#define DEO(op, xop) (OP (op) | ((xop) & 0xf))#define DE_MASK DEO (0x3e, 0xf)/* An EVSEL form instruction.  */#define EVSEL(op, xop) (OP (op) | (((unsigned long)(xop)) & 0xff) << 3)#define EVSEL_MASK EVSEL(0x3f, 0xff)/* An M form instruction.  */#define M(op, rc) (OP (op) | ((rc) & 1))#define M_MASK M (0x3f, 1)/* An M form instruction with the ME field specified.  */#define MME(op, me, rc) (M ((op), (rc)) | ((((unsigned long)(me)) & 0x1f) << 1))/* An M_MASK with the MB and ME fields fixed.  */#define MMBME_MASK (M_MASK | MB_MASK | ME_MASK)/* An M_MASK with the SH and ME fields fixed.  */#define MSHME_MASK (M_MASK | SH_MASK | ME_MASK)/* An MD form instruction.  */#define MD(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x7) << 2) | ((rc) & 1))#define MD_MASK MD (0x3f, 0x7, 1)/* An MD_MASK with the MB field fixed.  */#define MDMB_MASK (MD_MASK | MB6_MASK)/* An MD_MASK with the SH field fixed.  */#define MDSH_MASK (MD_MASK | SH6_MASK)/* An MDS form instruction.  */#define MDS(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0xf) << 1) | ((rc) & 1))#define MDS_MASK MDS (0x3f, 0xf, 1)/* An MDS_MASK with the MB field fixed.  */#define MDSMB_MASK (MDS_MASK | MB6_MASK)/* An SC form instruction.  */#define SC(op, sa, lk) (OP (op) | ((((unsigned long)(sa)) & 1) << 1) | ((lk) & 1))#define SC_MASK (OP_MASK | (((unsigned long)0x3ff) << 16) | (((unsigned long)1) << 1) | 1)

⌨️ 快捷键说明

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