ppc: support alias instructions. update Python & Java bindings accordingly

This commit is contained in:
Nguyen Anh Quynh 2014-09-04 12:03:31 +08:00
parent 25538b04bb
commit 721d07f6b2
7 changed files with 841 additions and 51 deletions

View File

@ -3683,73 +3683,73 @@ static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI)
break;
case 3:
// BCC
printPredicateOperand(MI, 0, O, "pm");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
SStream_concat0(O, ", ");
printBranchOperand(MI, 2, O);
return;
break;
case 4:
// BCCA
SStream_concat0(O, "a");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, "a");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
SStream_concat0(O, ", ");
printAbsBranchOperand(MI, 2, O);
return;
break;
case 5:
// BCCCTR, BCCCTR8
SStream_concat0(O, "ctr");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, "ctr");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
return;
break;
case 6:
// BCCCTRL, BCCCTRL8
SStream_concat0(O, "ctrl");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, "ctrl");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
return;
break;
case 7:
// BCCL
SStream_concat0(O, "l");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, "l");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
SStream_concat0(O, ", ");
printBranchOperand(MI, 2, O);
return;
break;
case 8:
// BCCLA
SStream_concat0(O, "la");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, "la");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
SStream_concat0(O, ", ");
printAbsBranchOperand(MI, 2, O);
return;
break;
case 9:
// BCCLR
SStream_concat0(O, "lr");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, "lr");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
return;
break;
case 10:
// BCCLRL
SStream_concat0(O, "lrl");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, "lrl");
printPredicateOperand(MI, 0, O, "pm");
SStream_concat0(O, " ");
printPredicateOperand(MI, 0, O, "reg");
printPredicateOperand(MI, 0, O, "reg");
return;
break;
case 11:
@ -3759,17 +3759,19 @@ static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI)
break;
case 12:
// BL8_NOP, BL8_NOP_TLS, BLA8_NOP
SStream_concat0(O, "\n\tnop");
// SStream_concat0(O, "\n\tnop"); // qq
return;
break;
case 13:
// MFTB8
SStream_concat0(O, ", 268");
SStream_concat0(O, ", 268");
op_addImm(MI, 268);
return;
break;
case 14:
// MFVRSAVE, MFVRSAVEv
SStream_concat0(O, ", 256");
SStream_concat0(O, ", 256");
op_addImm(MI, 256);
return;
break;
case 15:
@ -3780,7 +3782,8 @@ static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI)
break;
case 16:
// V_SETALLONES, V_SETALLONESB, V_SETALLONESH
SStream_concat0(O, ", -1");
SStream_concat0(O, ", -1");
op_addImm(MI, -1);
return;
break;
}

View File

@ -36,6 +36,7 @@ static char *getRegisterName(unsigned RegNo);
static void printOperand(MCInst *MI, unsigned OpNo, SStream *O);
static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI);
static void printAbsBranchOperand(MCInst *MI, unsigned OpNo, SStream *O);
static char *printAliasInstr(MCInst *MI, SStream *OS, void *info);
static void set_mem_access(MCInst *MI, bool status)
{
@ -60,7 +61,7 @@ void PPC_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
return;
// check if this insn has branch hint
if (strrchr(insn_asm, '+') != NULL) {
if (strrchr(insn_asm, '+') != NULL && !strstr(insn_asm, ".+")) {
insn->detail->ppc.bh = PPC_BH_PLUS;
} else if (strrchr(insn_asm, '-') != NULL) {
insn->detail->ppc.bh = PPC_BH_MINUS;
@ -72,6 +73,8 @@ void PPC_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
void PPC_printInst(MCInst *MI, SStream *O, void *Info)
{
char *mnem;
// Check for slwi/srwi mnemonics.
if (MCInst_getOpcode(MI) == PPC_RLWINM) {
unsigned char SH = (unsigned char)MCOperand_getImm(MCInst_getOperand(MI, 2));
@ -81,11 +84,13 @@ void PPC_printInst(MCInst *MI, SStream *O, void *Info)
if (SH <= 31 && MB == 0 && ME == (31-SH)) {
SStream_concat0(O, "slwi\t");
MCInst_setOpcodePub(MI, PPC_INS_SLWI);
useSubstituteMnemonic = true;
}
if (SH <= 31 && MB == (32-SH) && ME == 31) {
SStream_concat0(O, "srwi\t");
MCInst_setOpcodePub(MI, PPC_INS_SRWI);
useSubstituteMnemonic = true;
SH = 32-SH;
}
@ -106,6 +111,7 @@ void PPC_printInst(MCInst *MI, SStream *O, void *Info)
if ((MCInst_getOpcode(MI) == PPC_OR || MCInst_getOpcode(MI) == PPC_OR8) &&
MCOperand_getReg(MCInst_getOperand(MI, 1)) == MCOperand_getReg(MCInst_getOperand(MI, 1))) {
SStream_concat0(O, "mr\t");
MCInst_setOpcodePub(MI, PPC_INS_MR);
printOperand(MI, 0, O);
SStream_concat0(O, ", ");
printOperand(MI, 1, O);
@ -118,6 +124,7 @@ void PPC_printInst(MCInst *MI, SStream *O, void *Info)
// rldicr RA, RS, SH, 63-SH == sldi RA, RS, SH
if (63-SH == ME) {
SStream_concat0(O, "sldi\t");
MCInst_setOpcodePub(MI, PPC_INS_SLDI);
printOperand(MI, 0, O);
SStream_concat0(O, ", ");
printOperand(MI, 1, O);
@ -130,7 +137,16 @@ void PPC_printInst(MCInst *MI, SStream *O, void *Info)
}
}
printInstruction(MI, O, NULL);
mnem = printAliasInstr(MI, O, Info);
if (mnem) {
// check to remove the last letter of ('.', '-', '+')
if (mnem[strlen(mnem) - 1] == '-' || mnem[strlen(mnem) - 1] == '+' || mnem[strlen(mnem) - 1] == '.')
mnem[strlen(mnem) - 1] = '\0';
MCInst_setOpcodePub(MI, PPC_map_insn(mnem));
cs_mem_free(mnem);
} else
printInstruction(MI, O, NULL);
}
@ -420,23 +436,28 @@ static void printBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)
static void printAbsBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)
{
int tmp;
int imm;
if (!MCOperand_isImm(MCInst_getOperand(MI, OpNo))) {
printOperand(MI, OpNo, O);
return;
}
tmp = (int)MCOperand_getImm(MCInst_getOperand(MI, OpNo)) * 4;
if (tmp >= 0) {
if (tmp > HEX_THRESHOLD)
SStream_concat(O, "0x%x", tmp);
imm = (int)MCOperand_getImm(MCInst_getOperand(MI, OpNo)) * 4;
if (imm >= 0) {
if (imm > HEX_THRESHOLD)
SStream_concat(O, "0x%x", imm);
else
SStream_concat(O, "%u", tmp);
SStream_concat(O, "%u", imm);
} else {
if (tmp < -HEX_THRESHOLD)
SStream_concat(O, "-0x%x", -tmp);
if (imm < -HEX_THRESHOLD)
SStream_concat(O, "-0x%x", -imm);
else
SStream_concat(O, "-%u", -tmp);
SStream_concat(O, "-%u", -imm);
}
if (MI->csh->detail) {
MI->flat_insn->detail->ppc.operands[MI->flat_insn->detail->ppc.op_count].type = PPC_OP_IMM;
MI->flat_insn->detail->ppc.operands[MI->flat_insn->detail->ppc.op_count].imm = imm;
MI->flat_insn->detail->ppc.op_count++;
}
}
@ -597,7 +618,16 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
}
}
//#define PRINT_ALIAS_INSTR
static void op_addImm(MCInst *MI, int v)
{
if (MI->csh->detail) {
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].type = ARM_OP_IMM;
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].imm = v;
MI->flat_insn->detail->arm.op_count++;
}
}
#define PRINT_ALIAS_INSTR
#include "PPCGenAsmWriter.inc"
#endif

View File

@ -491,61 +491,61 @@ static insn_map insns[] = {
#endif
},
{
PPC_BCC, PPC_INS_B,
PPC_BCC, PPC_INS_B_CC,
#ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 1, 0
#endif
},
{
PPC_BCCA, PPC_INS_B,
PPC_BCCA, PPC_INS_BA_CC,
#ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 1, 0
#endif
},
{
PPC_BCCCTR, PPC_INS_B,
PPC_BCCCTR, PPC_INS_BCTR_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_CTR, 0 }, { 0 }, { 0 }, 1, 1
#endif
},
{
PPC_BCCCTR8, PPC_INS_B,
PPC_BCCCTR8, PPC_INS_BCTR_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_CTR8, 0 }, { 0 }, { PPC_GRP_MODE64, 0 }, 1, 1
#endif
},
{
PPC_BCCCTRL, PPC_INS_B,
PPC_BCCCTRL, PPC_INS_BCTRL_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_CTR, PPC_REG_RM, 0 }, { PPC_REG_LR, 0 }, { 0 }, 0, 0
#endif
},
{
PPC_BCCCTRL8, PPC_INS_B,
PPC_BCCCTRL8, PPC_INS_BCTRL_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_CTR8, PPC_REG_RM, 0 }, { PPC_REG_LR8, 0 }, { PPC_GRP_MODE64, 0 }, 0, 0
#endif
},
{
PPC_BCCL, PPC_INS_B,
PPC_BCCL, PPC_INS_BL_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_RM, 0 }, { PPC_REG_LR, 0 }, { 0 }, 0, 0
#endif
},
{
PPC_BCCLA, PPC_INS_B,
PPC_BCCLA, PPC_INS_BLA_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_RM, 0 }, { PPC_REG_LR, 0 }, { 0 }, 0, 0
#endif
},
{
PPC_BCCLR, PPC_INS_B,
PPC_BCCLR, PPC_INS_BLR_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_LR, PPC_REG_RM, 0 }, { 0 }, { 0 }, 1, 0
#endif
},
{
PPC_BCCLRL, PPC_INS_B,
PPC_BCCLRL, PPC_INS_BLRL_CC,
#ifndef CAPSTONE_DIET
{ PPC_REG_LR, PPC_REG_RM, 0 }, { PPC_REG_LR, 0 }, { 0 }, 0, 0
#endif
@ -7695,6 +7695,183 @@ static name_map insn_name_maps[] = {
{ PPC_INS_XXSPLTW, "xxspltw" },
{ PPC_INS_BCA, "bca" },
{ PPC_INS_BCLA, "bcla" },
// extra & alias instructions
{ PPC_INS_SLWI, "slwi" },
{ PPC_INS_SRWI, "srwi" },
{ PPC_INS_SLDI, "sldi" },
{ PPC_INS_BTA, "bta" },
{ PPC_INS_CRSET, "crset" },
{ PPC_INS_CRNOT, "crnot" },
{ PPC_INS_CRMOVE, "crmove" },
{ PPC_INS_CRCLR, "crclr" },
{ PPC_INS_MFBR0, "mfbr0" },
{ PPC_INS_MFBR1, "mfbr1" },
{ PPC_INS_MFBR2, "mfbr2" },
{ PPC_INS_MFBR3, "mfbr3" },
{ PPC_INS_MFBR4, "mfbr4" },
{ PPC_INS_MFBR5, "mfbr5" },
{ PPC_INS_MFBR6, "mfbr6" },
{ PPC_INS_MFBR7, "mfbr7" },
{ PPC_INS_MFXER, "mfxer" },
{ PPC_INS_MFRTCU, "mfrtcu" },
{ PPC_INS_MFRTCL, "mfrtcl" },
{ PPC_INS_MFDSCR, "mfdscr" },
{ PPC_INS_MFDSISR, "mfdsisr" },
{ PPC_INS_MFDAR, "mfdar" },
{ PPC_INS_MFSRR2, "mfsrr2" },
{ PPC_INS_MFSRR3, "mfsrr3" },
{ PPC_INS_MFCFAR, "mfcfar" },
{ PPC_INS_MFAMR, "mfamr" },
{ PPC_INS_MFPID, "mfpid" },
{ PPC_INS_MFTBLO, "mftblo" },
{ PPC_INS_MFTBHI, "mftbhi" },
{ PPC_INS_MFDBATU, "mfdbatu" },
{ PPC_INS_MFDBATL, "mfdbatl" },
{ PPC_INS_MFIBATU, "mfibatu" },
{ PPC_INS_MFIBATL, "mfibatl" },
{ PPC_INS_MFDCCR, "mfdccr" },
{ PPC_INS_MFICCR, "mficcr" },
{ PPC_INS_MFDEAR, "mfdear" },
{ PPC_INS_MFESR, "mfesr" },
{ PPC_INS_MFSPEFSCR, "mfspefscr" },
{ PPC_INS_MFTCR, "mftcr" },
{ PPC_INS_MFASR, "mfasr" },
{ PPC_INS_MFPVR, "mfpvr" },
{ PPC_INS_MFTBU, "mftbu" },
{ PPC_INS_MTCR, "mtcr" },
{ PPC_INS_MTBR0, "mtbr0" },
{ PPC_INS_MTBR1, "mtbr1" },
{ PPC_INS_MTBR2, "mtbr2" },
{ PPC_INS_MTBR3, "mtbr3" },
{ PPC_INS_MTBR4, "mtbr4" },
{ PPC_INS_MTBR5, "mtbr5" },
{ PPC_INS_MTBR6, "mtbr6" },
{ PPC_INS_MTBR7, "mtbr7" },
{ PPC_INS_MTXER, "mtxer" },
{ PPC_INS_MTDSCR, "mtdscr" },
{ PPC_INS_MTDSISR, "mtdsisr" },
{ PPC_INS_MTDAR, "mtdar" },
{ PPC_INS_MTSRR2, "mtsrr2" },
{ PPC_INS_MTSRR3, "mtsrr3" },
{ PPC_INS_MTCFAR, "mtcfar" },
{ PPC_INS_MTAMR, "mtamr" },
{ PPC_INS_MTPID, "mtpid" },
{ PPC_INS_MTTBL, "mttbl" },
{ PPC_INS_MTTBU, "mttbu" },
{ PPC_INS_MTTBLO, "mttblo" },
{ PPC_INS_MTTBHI, "mttbhi" },
{ PPC_INS_MTDBATU, "mtdbatu" },
{ PPC_INS_MTDBATL, "mtdbatl" },
{ PPC_INS_MTIBATU, "mtibatu" },
{ PPC_INS_MTIBATL, "mtibatl" },
{ PPC_INS_MTDCCR, "mtdccr" },
{ PPC_INS_MTICCR, "mticcr" },
{ PPC_INS_MTDEAR, "mtdear" },
{ PPC_INS_MTESR, "mtesr" },
{ PPC_INS_MTSPEFSCR, "mtspefscr" },
{ PPC_INS_MTTCR, "mttcr" },
{ PPC_INS_NOT, "not" },
{ PPC_INS_MR, "mr" },
{ PPC_INS_ROTLD, "rotld" },
{ PPC_INS_ROTLDI, "rotldi" },
{ PPC_INS_CLRLDI, "clrldi" },
{ PPC_INS_ROTLWI, "rotlwi" },
{ PPC_INS_CLRLWI, "clrlwi" },
{ PPC_INS_ROTLW, "rotlw" },
{ PPC_INS_SUB, "sub" },
{ PPC_INS_SUBC, "subc" },
{ PPC_INS_LWSYNC, "lwsync" },
{ PPC_INS_PTESYNC, "ptesync" },
{ PPC_INS_TDLT, "tdlt" },
{ PPC_INS_TDEQ, "tdeq" },
{ PPC_INS_TDGT, "tdgt" },
{ PPC_INS_TDNE, "tdne" },
{ PPC_INS_TDLLT, "tdllt" },
{ PPC_INS_TDLGT, "tdlgt" },
{ PPC_INS_TDU, "tdu" },
{ PPC_INS_TDLTI, "tdlti" },
{ PPC_INS_TDEQI, "tdeqi" },
{ PPC_INS_TDGTI, "tdgti" },
{ PPC_INS_TDNEI, "tdnei" },
{ PPC_INS_TDLLTI, "tdllti" },
{ PPC_INS_TDLGTI, "tdlgti" },
{ PPC_INS_TDUI, "tdui" },
{ PPC_INS_TLBREHI, "tlbrehi" },
{ PPC_INS_TLBRELO, "tlbrelo" },
{ PPC_INS_TLBWEHI, "tlbwehi" },
{ PPC_INS_TLBWELO, "tlbwelo" },
{ PPC_INS_TWLT, "twlt" },
{ PPC_INS_TWEQ, "tweq" },
{ PPC_INS_TWGT, "twgt" },
{ PPC_INS_TWNE, "twne" },
{ PPC_INS_TWLLT, "twllt" },
{ PPC_INS_TWLGT, "twlgt" },
{ PPC_INS_TWU, "twu" },
{ PPC_INS_TWLTI, "twlti" },
{ PPC_INS_TWEQI, "tweqi" },
{ PPC_INS_TWGTI, "twgti" },
{ PPC_INS_TWNEI, "twnei" },
{ PPC_INS_TWLLTI, "twllti" },
{ PPC_INS_TWLGTI, "twlgti" },
{ PPC_INS_TWUI, "twui" },
{ PPC_INS_WAITRSV, "waitrsv" },
{ PPC_INS_WAITIMPL, "waitimpl" },
{ PPC_INS_XNOP, "xnop" },
{ PPC_INS_XVMOVDP, "xvmovdp" },
{ PPC_INS_XVMOVSP, "xvmovsp" },
{ PPC_INS_XXSPLTD, "xxspltd" },
{ PPC_INS_XXMRGHD, "xxmrghd" },
{ PPC_INS_XXMRGLD, "xxmrgld" },
{ PPC_INS_XXSWAPD, "xxswapd" },
{ PPC_INS_BT, "bt" },
{ PPC_INS_BF, "bf" },
{ PPC_INS_BDNZT, "bdnzt" },
{ PPC_INS_BDNZF, "bdnzf" },
{ PPC_INS_BDZF, "bdzf" },
{ PPC_INS_BDZT, "bdzt" },
{ PPC_INS_BFA, "bfa" },
{ PPC_INS_BDNZTA, "bdnzta" },
{ PPC_INS_BDNZFA, "bdnzfa" },
{ PPC_INS_BDZTA, "bdzta" },
{ PPC_INS_BDZFA, "bdzfa" },
{ PPC_INS_BTCTR, "btctr" },
{ PPC_INS_BFCTR, "bfctr" },
{ PPC_INS_BTCTRL, "btctrl" },
{ PPC_INS_BFCTRL, "bfctrl" },
{ PPC_INS_BTL, "btl" },
{ PPC_INS_BFL, "bfl" },
{ PPC_INS_BDNZTL, "bdnztl" },
{ PPC_INS_BDNZFL, "bdnzfl" },
{ PPC_INS_BDZTL, "bdztl" },
{ PPC_INS_BDZFL, "bdzfl" },
{ PPC_INS_BTLA, "btla" },
{ PPC_INS_BFLA, "bfla" },
{ PPC_INS_BDNZTLA, "bdnztla" },
{ PPC_INS_BDNZFLA, "bdnzfla" },
{ PPC_INS_BDZTLA, "bdztla" },
{ PPC_INS_BDZFLA, "bdzfla" },
{ PPC_INS_BTLR, "btlr" },
{ PPC_INS_BFLR, "bflr" },
{ PPC_INS_BDNZTLR, "bdnztlr" },
{ PPC_INS_BDZTLR, "bdztlr" },
{ PPC_INS_BDZFLR, "bdzflr" },
{ PPC_INS_BTLRL, "btlrl" },
{ PPC_INS_BFLRL, "bflrl" },
{ PPC_INS_BDNZTLRL, "bdnztlrl" },
{ PPC_INS_BDNZFLRL, "bdnzflrl" },
{ PPC_INS_BDZTLRL, "bdztlrl" },
{ PPC_INS_BDZFLRL, "bdzflrl" },
// BccX
{ PPC_INS_B_CC, "b_cc" },
{ PPC_INS_BL_CC, "bl_cc" },
{ PPC_INS_BLA_CC, "bla_cc" },
{ PPC_INS_BLR_CC, "blr_cc" },
{ PPC_INS_BLRL_CC, "blrl_cc" },
{ PPC_INS_BA_CC, "ba_cc" },
{ PPC_INS_BCTR_CC, "bctr_cc" },
{ PPC_INS_BCTRL_CC, "bctrl_cc" },
};
// special alias insn
@ -7821,4 +7998,58 @@ ppc_reg PPC_map_register(unsigned int r)
return 0;
}
static name_map alias_insn_name_maps[] = {
{ PPC_INS_BTA, "bta" },
{ PPC_INS_B, "blt" },
{ PPC_INS_B, "bgt" },
{ PPC_INS_B, "beq" },
{ PPC_INS_B, "bne" },
{ PPC_INS_BA_CC, "blta" },
{ PPC_INS_BA_CC, "bgta" },
{ PPC_INS_BA_CC, "beqa" },
{ PPC_INS_BA_CC, "bnea" },
{ PPC_INS_BCTR_CC, "bltctr" },
{ PPC_INS_BCTR_CC, "bgtctr" },
{ PPC_INS_BCTR_CC, "beqctr" },
{ PPC_INS_BCTR_CC, "bnectr" },
{ PPC_INS_BCTRL_CC, "bltctrl" },
{ PPC_INS_BCTRL_CC, "bgtctrl" },
{ PPC_INS_BCTRL_CC, "beqctrl" },
{ PPC_INS_BCTRL_CC, "bnectrl" },
{ PPC_INS_BL_CC, "bltl" },
{ PPC_INS_BL_CC, "bgtl" },
{ PPC_INS_BL_CC, "beql" },
{ PPC_INS_BL_CC, "bnel" },
{ PPC_INS_BLA_CC, "bltla" },
{ PPC_INS_BLA_CC, "bgtla" },
{ PPC_INS_BLA_CC, "beqla" },
{ PPC_INS_BLA_CC, "bnela" },
{ PPC_INS_BLR_CC, "bltlr" },
{ PPC_INS_BLR_CC, "bgtlr" },
{ PPC_INS_BLR_CC, "beqlr" },
{ PPC_INS_BLR_CC, "bnelr" },
{ PPC_INS_BLRL_CC, "bltlrl" },
{ PPC_INS_BLRL_CC, "bgtlrl" },
{ PPC_INS_BLRL_CC, "beqlrl" },
{ PPC_INS_BLRL_CC, "bnelrl" },
};
// map instruction name to public instruction ID
ppc_reg PPC_map_insn(const char *name)
{
// NOTE: skip first NULL name in insn_name_maps
int i = name2id(&insn_name_maps[1], ARR_SIZE(insn_name_maps) - 1, name);
if (i == -1)
// try again with 'special' insn that is not available in insn_name_maps
i = name2id(alias_insn_name_maps, ARR_SIZE(alias_insn_name_maps), name);
return (i != -1)? i : PPC_REG_INVALID;
}
#endif

View File

@ -18,5 +18,7 @@ const char *PPC_group_name(csh handle, unsigned int id);
// map internal raw register to 'public' register
ppc_reg PPC_map_register(unsigned int r);
ppc_reg PPC_map_insn(const char *name);
#endif

View File

@ -997,7 +997,180 @@ public class Ppc_const {
public static final int PPC_INS_XXSPLTW = 766;
public static final int PPC_INS_BCA = 767;
public static final int PPC_INS_BCLA = 768;
public static final int PPC_INS_MAX = 769;
public static final int PPC_INS_SLWI = 769;
public static final int PPC_INS_SRWI = 770;
public static final int PPC_INS_SLDI = 771;
public static final int PPC_INS_BTA = 772;
public static final int PPC_INS_CRSET = 773;
public static final int PPC_INS_CRNOT = 774;
public static final int PPC_INS_CRMOVE = 775;
public static final int PPC_INS_CRCLR = 776;
public static final int PPC_INS_MFBR0 = 777;
public static final int PPC_INS_MFBR1 = 778;
public static final int PPC_INS_MFBR2 = 779;
public static final int PPC_INS_MFBR3 = 780;
public static final int PPC_INS_MFBR4 = 781;
public static final int PPC_INS_MFBR5 = 782;
public static final int PPC_INS_MFBR6 = 783;
public static final int PPC_INS_MFBR7 = 784;
public static final int PPC_INS_MFXER = 785;
public static final int PPC_INS_MFRTCU = 786;
public static final int PPC_INS_MFRTCL = 787;
public static final int PPC_INS_MFDSCR = 788;
public static final int PPC_INS_MFDSISR = 789;
public static final int PPC_INS_MFDAR = 790;
public static final int PPC_INS_MFSRR2 = 791;
public static final int PPC_INS_MFSRR3 = 792;
public static final int PPC_INS_MFCFAR = 793;
public static final int PPC_INS_MFAMR = 794;
public static final int PPC_INS_MFPID = 795;
public static final int PPC_INS_MFTBLO = 796;
public static final int PPC_INS_MFTBHI = 797;
public static final int PPC_INS_MFDBATU = 798;
public static final int PPC_INS_MFDBATL = 799;
public static final int PPC_INS_MFIBATU = 800;
public static final int PPC_INS_MFIBATL = 801;
public static final int PPC_INS_MFDCCR = 802;
public static final int PPC_INS_MFICCR = 803;
public static final int PPC_INS_MFDEAR = 804;
public static final int PPC_INS_MFESR = 805;
public static final int PPC_INS_MFSPEFSCR = 806;
public static final int PPC_INS_MFTCR = 807;
public static final int PPC_INS_MFASR = 808;
public static final int PPC_INS_MFPVR = 809;
public static final int PPC_INS_MFTBU = 810;
public static final int PPC_INS_MTCR = 811;
public static final int PPC_INS_MTBR0 = 812;
public static final int PPC_INS_MTBR1 = 813;
public static final int PPC_INS_MTBR2 = 814;
public static final int PPC_INS_MTBR3 = 815;
public static final int PPC_INS_MTBR4 = 816;
public static final int PPC_INS_MTBR5 = 817;
public static final int PPC_INS_MTBR6 = 818;
public static final int PPC_INS_MTBR7 = 819;
public static final int PPC_INS_MTXER = 820;
public static final int PPC_INS_MTDSCR = 821;
public static final int PPC_INS_MTDSISR = 822;
public static final int PPC_INS_MTDAR = 823;
public static final int PPC_INS_MTSRR2 = 824;
public static final int PPC_INS_MTSRR3 = 825;
public static final int PPC_INS_MTCFAR = 826;
public static final int PPC_INS_MTAMR = 827;
public static final int PPC_INS_MTPID = 828;
public static final int PPC_INS_MTTBL = 829;
public static final int PPC_INS_MTTBU = 830;
public static final int PPC_INS_MTTBLO = 831;
public static final int PPC_INS_MTTBHI = 832;
public static final int PPC_INS_MTDBATU = 833;
public static final int PPC_INS_MTDBATL = 834;
public static final int PPC_INS_MTIBATU = 835;
public static final int PPC_INS_MTIBATL = 836;
public static final int PPC_INS_MTDCCR = 837;
public static final int PPC_INS_MTICCR = 838;
public static final int PPC_INS_MTDEAR = 839;
public static final int PPC_INS_MTESR = 840;
public static final int PPC_INS_MTSPEFSCR = 841;
public static final int PPC_INS_MTTCR = 842;
public static final int PPC_INS_NOT = 843;
public static final int PPC_INS_MR = 844;
public static final int PPC_INS_ROTLD = 845;
public static final int PPC_INS_ROTLDI = 846;
public static final int PPC_INS_CLRLDI = 847;
public static final int PPC_INS_ROTLWI = 848;
public static final int PPC_INS_CLRLWI = 849;
public static final int PPC_INS_ROTLW = 850;
public static final int PPC_INS_SUB = 851;
public static final int PPC_INS_SUBC = 852;
public static final int PPC_INS_LWSYNC = 853;
public static final int PPC_INS_PTESYNC = 854;
public static final int PPC_INS_TDLT = 855;
public static final int PPC_INS_TDEQ = 856;
public static final int PPC_INS_TDGT = 857;
public static final int PPC_INS_TDNE = 858;
public static final int PPC_INS_TDLLT = 859;
public static final int PPC_INS_TDLGT = 860;
public static final int PPC_INS_TDU = 861;
public static final int PPC_INS_TDLTI = 862;
public static final int PPC_INS_TDEQI = 863;
public static final int PPC_INS_TDGTI = 864;
public static final int PPC_INS_TDNEI = 865;
public static final int PPC_INS_TDLLTI = 866;
public static final int PPC_INS_TDLGTI = 867;
public static final int PPC_INS_TDUI = 868;
public static final int PPC_INS_TLBREHI = 869;
public static final int PPC_INS_TLBRELO = 870;
public static final int PPC_INS_TLBWEHI = 871;
public static final int PPC_INS_TLBWELO = 872;
public static final int PPC_INS_TWLT = 873;
public static final int PPC_INS_TWEQ = 874;
public static final int PPC_INS_TWGT = 875;
public static final int PPC_INS_TWNE = 876;
public static final int PPC_INS_TWLLT = 877;
public static final int PPC_INS_TWLGT = 878;
public static final int PPC_INS_TWU = 879;
public static final int PPC_INS_TWLTI = 880;
public static final int PPC_INS_TWEQI = 881;
public static final int PPC_INS_TWGTI = 882;
public static final int PPC_INS_TWNEI = 883;
public static final int PPC_INS_TWLLTI = 884;
public static final int PPC_INS_TWLGTI = 885;
public static final int PPC_INS_TWUI = 886;
public static final int PPC_INS_WAITRSV = 887;
public static final int PPC_INS_WAITIMPL = 888;
public static final int PPC_INS_XNOP = 889;
public static final int PPC_INS_XVMOVDP = 890;
public static final int PPC_INS_XVMOVSP = 891;
public static final int PPC_INS_XXSPLTD = 892;
public static final int PPC_INS_XXMRGHD = 893;
public static final int PPC_INS_XXMRGLD = 894;
public static final int PPC_INS_XXSWAPD = 895;
public static final int PPC_INS_BT = 896;
public static final int PPC_INS_BF = 897;
public static final int PPC_INS_BDNZT = 898;
public static final int PPC_INS_BDNZF = 899;
public static final int PPC_INS_BDZF = 900;
public static final int PPC_INS_BDZT = 901;
public static final int PPC_INS_BFA = 902;
public static final int PPC_INS_BDNZTA = 903;
public static final int PPC_INS_BDNZFA = 904;
public static final int PPC_INS_BDZTA = 905;
public static final int PPC_INS_BDZFA = 906;
public static final int PPC_INS_BTCTR = 907;
public static final int PPC_INS_BFCTR = 908;
public static final int PPC_INS_BTCTRL = 909;
public static final int PPC_INS_BFCTRL = 910;
public static final int PPC_INS_BTL = 911;
public static final int PPC_INS_BFL = 912;
public static final int PPC_INS_BDNZTL = 913;
public static final int PPC_INS_BDNZFL = 914;
public static final int PPC_INS_BDZTL = 915;
public static final int PPC_INS_BDZFL = 916;
public static final int PPC_INS_BTLA = 917;
public static final int PPC_INS_BFLA = 918;
public static final int PPC_INS_BDNZTLA = 919;
public static final int PPC_INS_BDNZFLA = 920;
public static final int PPC_INS_BDZTLA = 921;
public static final int PPC_INS_BDZFLA = 922;
public static final int PPC_INS_BTLR = 923;
public static final int PPC_INS_BFLR = 924;
public static final int PPC_INS_BDNZTLR = 925;
public static final int PPC_INS_BDZTLR = 926;
public static final int PPC_INS_BDZFLR = 927;
public static final int PPC_INS_BTLRL = 928;
public static final int PPC_INS_BFLRL = 929;
public static final int PPC_INS_BDNZTLRL = 930;
public static final int PPC_INS_BDNZFLRL = 931;
public static final int PPC_INS_BDZTLRL = 932;
public static final int PPC_INS_BDZFLRL = 933;
public static final int PPC_INS_B_CC = 934;
public static final int PPC_INS_BL_CC = 935;
public static final int PPC_INS_BLA_CC = 936;
public static final int PPC_INS_BLR_CC = 937;
public static final int PPC_INS_BLRL_CC = 938;
public static final int PPC_INS_BA_CC = 939;
public static final int PPC_INS_BCTR_CC = 940;
public static final int PPC_INS_BCTRL_CC = 941;
public static final int PPC_INS_MAX = 942;
// Group of PPC instructions

View File

@ -994,7 +994,180 @@ PPC_INS_XXSLDWI = 765
PPC_INS_XXSPLTW = 766
PPC_INS_BCA = 767
PPC_INS_BCLA = 768
PPC_INS_MAX = 769
PPC_INS_SLWI = 769
PPC_INS_SRWI = 770
PPC_INS_SLDI = 771
PPC_INS_BTA = 772
PPC_INS_CRSET = 773
PPC_INS_CRNOT = 774
PPC_INS_CRMOVE = 775
PPC_INS_CRCLR = 776
PPC_INS_MFBR0 = 777
PPC_INS_MFBR1 = 778
PPC_INS_MFBR2 = 779
PPC_INS_MFBR3 = 780
PPC_INS_MFBR4 = 781
PPC_INS_MFBR5 = 782
PPC_INS_MFBR6 = 783
PPC_INS_MFBR7 = 784
PPC_INS_MFXER = 785
PPC_INS_MFRTCU = 786
PPC_INS_MFRTCL = 787
PPC_INS_MFDSCR = 788
PPC_INS_MFDSISR = 789
PPC_INS_MFDAR = 790
PPC_INS_MFSRR2 = 791
PPC_INS_MFSRR3 = 792
PPC_INS_MFCFAR = 793
PPC_INS_MFAMR = 794
PPC_INS_MFPID = 795
PPC_INS_MFTBLO = 796
PPC_INS_MFTBHI = 797
PPC_INS_MFDBATU = 798
PPC_INS_MFDBATL = 799
PPC_INS_MFIBATU = 800
PPC_INS_MFIBATL = 801
PPC_INS_MFDCCR = 802
PPC_INS_MFICCR = 803
PPC_INS_MFDEAR = 804
PPC_INS_MFESR = 805
PPC_INS_MFSPEFSCR = 806
PPC_INS_MFTCR = 807
PPC_INS_MFASR = 808
PPC_INS_MFPVR = 809
PPC_INS_MFTBU = 810
PPC_INS_MTCR = 811
PPC_INS_MTBR0 = 812
PPC_INS_MTBR1 = 813
PPC_INS_MTBR2 = 814
PPC_INS_MTBR3 = 815
PPC_INS_MTBR4 = 816
PPC_INS_MTBR5 = 817
PPC_INS_MTBR6 = 818
PPC_INS_MTBR7 = 819
PPC_INS_MTXER = 820
PPC_INS_MTDSCR = 821
PPC_INS_MTDSISR = 822
PPC_INS_MTDAR = 823
PPC_INS_MTSRR2 = 824
PPC_INS_MTSRR3 = 825
PPC_INS_MTCFAR = 826
PPC_INS_MTAMR = 827
PPC_INS_MTPID = 828
PPC_INS_MTTBL = 829
PPC_INS_MTTBU = 830
PPC_INS_MTTBLO = 831
PPC_INS_MTTBHI = 832
PPC_INS_MTDBATU = 833
PPC_INS_MTDBATL = 834
PPC_INS_MTIBATU = 835
PPC_INS_MTIBATL = 836
PPC_INS_MTDCCR = 837
PPC_INS_MTICCR = 838
PPC_INS_MTDEAR = 839
PPC_INS_MTESR = 840
PPC_INS_MTSPEFSCR = 841
PPC_INS_MTTCR = 842
PPC_INS_NOT = 843
PPC_INS_MR = 844
PPC_INS_ROTLD = 845
PPC_INS_ROTLDI = 846
PPC_INS_CLRLDI = 847
PPC_INS_ROTLWI = 848
PPC_INS_CLRLWI = 849
PPC_INS_ROTLW = 850
PPC_INS_SUB = 851
PPC_INS_SUBC = 852
PPC_INS_LWSYNC = 853
PPC_INS_PTESYNC = 854
PPC_INS_TDLT = 855
PPC_INS_TDEQ = 856
PPC_INS_TDGT = 857
PPC_INS_TDNE = 858
PPC_INS_TDLLT = 859
PPC_INS_TDLGT = 860
PPC_INS_TDU = 861
PPC_INS_TDLTI = 862
PPC_INS_TDEQI = 863
PPC_INS_TDGTI = 864
PPC_INS_TDNEI = 865
PPC_INS_TDLLTI = 866
PPC_INS_TDLGTI = 867
PPC_INS_TDUI = 868
PPC_INS_TLBREHI = 869
PPC_INS_TLBRELO = 870
PPC_INS_TLBWEHI = 871
PPC_INS_TLBWELO = 872
PPC_INS_TWLT = 873
PPC_INS_TWEQ = 874
PPC_INS_TWGT = 875
PPC_INS_TWNE = 876
PPC_INS_TWLLT = 877
PPC_INS_TWLGT = 878
PPC_INS_TWU = 879
PPC_INS_TWLTI = 880
PPC_INS_TWEQI = 881
PPC_INS_TWGTI = 882
PPC_INS_TWNEI = 883
PPC_INS_TWLLTI = 884
PPC_INS_TWLGTI = 885
PPC_INS_TWUI = 886
PPC_INS_WAITRSV = 887
PPC_INS_WAITIMPL = 888
PPC_INS_XNOP = 889
PPC_INS_XVMOVDP = 890
PPC_INS_XVMOVSP = 891
PPC_INS_XXSPLTD = 892
PPC_INS_XXMRGHD = 893
PPC_INS_XXMRGLD = 894
PPC_INS_XXSWAPD = 895
PPC_INS_BT = 896
PPC_INS_BF = 897
PPC_INS_BDNZT = 898
PPC_INS_BDNZF = 899
PPC_INS_BDZF = 900
PPC_INS_BDZT = 901
PPC_INS_BFA = 902
PPC_INS_BDNZTA = 903
PPC_INS_BDNZFA = 904
PPC_INS_BDZTA = 905
PPC_INS_BDZFA = 906
PPC_INS_BTCTR = 907
PPC_INS_BFCTR = 908
PPC_INS_BTCTRL = 909
PPC_INS_BFCTRL = 910
PPC_INS_BTL = 911
PPC_INS_BFL = 912
PPC_INS_BDNZTL = 913
PPC_INS_BDNZFL = 914
PPC_INS_BDZTL = 915
PPC_INS_BDZFL = 916
PPC_INS_BTLA = 917
PPC_INS_BFLA = 918
PPC_INS_BDNZTLA = 919
PPC_INS_BDNZFLA = 920
PPC_INS_BDZTLA = 921
PPC_INS_BDZFLA = 922
PPC_INS_BTLR = 923
PPC_INS_BFLR = 924
PPC_INS_BDNZTLR = 925
PPC_INS_BDZTLR = 926
PPC_INS_BDZFLR = 927
PPC_INS_BTLRL = 928
PPC_INS_BFLRL = 929
PPC_INS_BDNZTLRL = 930
PPC_INS_BDNZFLRL = 931
PPC_INS_BDZTLRL = 932
PPC_INS_BDZFLRL = 933
PPC_INS_B_CC = 934
PPC_INS_BL_CC = 935
PPC_INS_BLA_CC = 936
PPC_INS_BLR_CC = 937
PPC_INS_BLRL_CC = 938
PPC_INS_BA_CC = 939
PPC_INS_BCTR_CC = 940
PPC_INS_BCTRL_CC = 941
PPC_INS_MAX = 942
# Group of PPC instructions

View File

@ -1053,6 +1053,184 @@ typedef enum ppc_insn {
PPC_INS_BCA,
PPC_INS_BCLA,
// extra & alias instructions
PPC_INS_SLWI,
PPC_INS_SRWI,
PPC_INS_SLDI,
PPC_INS_BTA,
PPC_INS_CRSET,
PPC_INS_CRNOT,
PPC_INS_CRMOVE,
PPC_INS_CRCLR,
PPC_INS_MFBR0,
PPC_INS_MFBR1,
PPC_INS_MFBR2,
PPC_INS_MFBR3,
PPC_INS_MFBR4,
PPC_INS_MFBR5,
PPC_INS_MFBR6,
PPC_INS_MFBR7,
PPC_INS_MFXER,
PPC_INS_MFRTCU,
PPC_INS_MFRTCL,
PPC_INS_MFDSCR,
PPC_INS_MFDSISR,
PPC_INS_MFDAR,
PPC_INS_MFSRR2,
PPC_INS_MFSRR3,
PPC_INS_MFCFAR,
PPC_INS_MFAMR,
PPC_INS_MFPID,
PPC_INS_MFTBLO,
PPC_INS_MFTBHI,
PPC_INS_MFDBATU,
PPC_INS_MFDBATL,
PPC_INS_MFIBATU,
PPC_INS_MFIBATL,
PPC_INS_MFDCCR,
PPC_INS_MFICCR,
PPC_INS_MFDEAR,
PPC_INS_MFESR,
PPC_INS_MFSPEFSCR,
PPC_INS_MFTCR,
PPC_INS_MFASR,
PPC_INS_MFPVR,
PPC_INS_MFTBU,
PPC_INS_MTCR,
PPC_INS_MTBR0,
PPC_INS_MTBR1,
PPC_INS_MTBR2,
PPC_INS_MTBR3,
PPC_INS_MTBR4,
PPC_INS_MTBR5,
PPC_INS_MTBR6,
PPC_INS_MTBR7,
PPC_INS_MTXER,
PPC_INS_MTDSCR,
PPC_INS_MTDSISR,
PPC_INS_MTDAR,
PPC_INS_MTSRR2,
PPC_INS_MTSRR3,
PPC_INS_MTCFAR,
PPC_INS_MTAMR,
PPC_INS_MTPID,
PPC_INS_MTTBL,
PPC_INS_MTTBU,
PPC_INS_MTTBLO,
PPC_INS_MTTBHI,
PPC_INS_MTDBATU,
PPC_INS_MTDBATL,
PPC_INS_MTIBATU,
PPC_INS_MTIBATL,
PPC_INS_MTDCCR,
PPC_INS_MTICCR,
PPC_INS_MTDEAR,
PPC_INS_MTESR,
PPC_INS_MTSPEFSCR,
PPC_INS_MTTCR,
PPC_INS_NOT,
PPC_INS_MR,
PPC_INS_ROTLD,
PPC_INS_ROTLDI,
PPC_INS_CLRLDI,
PPC_INS_ROTLWI,
PPC_INS_CLRLWI,
PPC_INS_ROTLW,
PPC_INS_SUB,
PPC_INS_SUBC,
PPC_INS_LWSYNC,
PPC_INS_PTESYNC,
PPC_INS_TDLT,
PPC_INS_TDEQ,
PPC_INS_TDGT,
PPC_INS_TDNE,
PPC_INS_TDLLT,
PPC_INS_TDLGT,
PPC_INS_TDU,
PPC_INS_TDLTI,
PPC_INS_TDEQI,
PPC_INS_TDGTI,
PPC_INS_TDNEI,
PPC_INS_TDLLTI,
PPC_INS_TDLGTI,
PPC_INS_TDUI,
PPC_INS_TLBREHI,
PPC_INS_TLBRELO,
PPC_INS_TLBWEHI,
PPC_INS_TLBWELO,
PPC_INS_TWLT,
PPC_INS_TWEQ,
PPC_INS_TWGT,
PPC_INS_TWNE,
PPC_INS_TWLLT,
PPC_INS_TWLGT,
PPC_INS_TWU,
PPC_INS_TWLTI,
PPC_INS_TWEQI,
PPC_INS_TWGTI,
PPC_INS_TWNEI,
PPC_INS_TWLLTI,
PPC_INS_TWLGTI,
PPC_INS_TWUI,
PPC_INS_WAITRSV,
PPC_INS_WAITIMPL,
PPC_INS_XNOP,
PPC_INS_XVMOVDP,
PPC_INS_XVMOVSP,
PPC_INS_XXSPLTD,
PPC_INS_XXMRGHD,
PPC_INS_XXMRGLD,
PPC_INS_XXSWAPD,
PPC_INS_BT,
PPC_INS_BF,
PPC_INS_BDNZT,
PPC_INS_BDNZF,
PPC_INS_BDZF,
PPC_INS_BDZT,
PPC_INS_BFA,
PPC_INS_BDNZTA,
PPC_INS_BDNZFA,
PPC_INS_BDZTA,
PPC_INS_BDZFA,
PPC_INS_BTCTR,
PPC_INS_BFCTR,
PPC_INS_BTCTRL,
PPC_INS_BFCTRL,
PPC_INS_BTL,
PPC_INS_BFL,
PPC_INS_BDNZTL,
PPC_INS_BDNZFL,
PPC_INS_BDZTL,
PPC_INS_BDZFL,
PPC_INS_BTLA,
PPC_INS_BFLA,
PPC_INS_BDNZTLA,
PPC_INS_BDNZFLA,
PPC_INS_BDZTLA,
PPC_INS_BDZFLA,
PPC_INS_BTLR,
PPC_INS_BFLR,
PPC_INS_BDNZTLR,
PPC_INS_BDZTLR,
PPC_INS_BDZFLR,
PPC_INS_BTLRL,
PPC_INS_BFLRL,
PPC_INS_BDNZTLRL,
PPC_INS_BDNZFLRL,
PPC_INS_BDZTLRL,
PPC_INS_BDZFLRL,
// branch CC instruction
PPC_INS_B_CC, // Bcc
PPC_INS_BL_CC, // BccL
PPC_INS_BLA_CC, // BccLA
PPC_INS_BLR_CC, // BccLR
PPC_INS_BLRL_CC, // BccLRL
PPC_INS_BA_CC, // BccA
PPC_INS_BCTR_CC, // BccCTR
PPC_INS_BCTRL_CC, // BccCTRL
PPC_INS_MAX, // <-- mark the end of the list of instructions
} ppc_insn;