📄 hdefs.c
字号:
PPC32Instr* PPC32Instr_FpLdSt ( Bool isLoad, UChar sz, HReg reg, PPC32AMode* addr ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_FpLdSt; i->Pin.FpLdSt.isLoad = isLoad; i->Pin.FpLdSt.sz = sz; i->Pin.FpLdSt.reg = reg; i->Pin.FpLdSt.addr = addr; vassert(sz == 4 || sz == 8); return i;}PPC32Instr* PPC32Instr_FpF64toF32 ( HReg dst, HReg src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_FpF64toF32; i->Pin.FpF64toF32.dst = dst; i->Pin.FpF64toF32.src = src; return i;}PPC32Instr* PPC32Instr_FpF64toI32 ( HReg dst, HReg src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_FpF64toI32; i->Pin.FpF64toI32.dst = dst; i->Pin.FpF64toI32.src = src; return i;}PPC32Instr* PPC32Instr_FpCMov ( PPC32CondCode cond, HReg dst, HReg src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_FpCMov; i->Pin.FpCMov.cond = cond; i->Pin.FpCMov.dst = dst; i->Pin.FpCMov.src = src; vassert(cond.test != Pct_ALWAYS); return i;}PPC32Instr* PPC32Instr_FpLdFPSCR ( HReg src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_FpLdFPSCR; i->Pin.FpLdFPSCR.src = src; return i;}PPC32Instr* PPC32Instr_FpCmp ( HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_FpCmp; i->Pin.FpCmp.dst = dst; i->Pin.FpCmp.srcL = srcL; i->Pin.FpCmp.srcR = srcR; return i;}/* Read/Write Link Register */PPC32Instr* PPC32Instr_RdWrLR ( Bool wrLR, HReg gpr ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_RdWrLR; i->Pin.RdWrLR.wrLR = wrLR; i->Pin.RdWrLR.gpr = gpr; return i;}/* AltiVec */PPC32Instr* PPC32Instr_AvLdSt ( Bool isLoad, UChar sz, HReg reg, PPC32AMode* addr ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvLdSt; i->Pin.AvLdSt.isLoad = isLoad; i->Pin.AvLdSt.sz = sz; i->Pin.AvLdSt.reg = reg; i->Pin.AvLdSt.addr = addr; return i;}PPC32Instr* PPC32Instr_AvUnary ( PPC32AvOp op, HReg dst, HReg src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvUnary; i->Pin.AvUnary.op = op; i->Pin.AvUnary.dst = dst; i->Pin.AvUnary.src = src; return i;}PPC32Instr* PPC32Instr_AvBinary ( PPC32AvOp op, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvBinary; i->Pin.AvBinary.op = op; i->Pin.AvBinary.dst = dst; i->Pin.AvBinary.srcL = srcL; i->Pin.AvBinary.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvBin8x16 ( PPC32AvOp op, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvBin8x16; i->Pin.AvBin8x16.op = op; i->Pin.AvBin8x16.dst = dst; i->Pin.AvBin8x16.srcL = srcL; i->Pin.AvBin8x16.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvBin16x8 ( PPC32AvOp op, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvBin16x8; i->Pin.AvBin16x8.op = op; i->Pin.AvBin16x8.dst = dst; i->Pin.AvBin16x8.srcL = srcL; i->Pin.AvBin16x8.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvBin32x4 ( PPC32AvOp op, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvBin32x4; i->Pin.AvBin32x4.op = op; i->Pin.AvBin32x4.dst = dst; i->Pin.AvBin32x4.srcL = srcL; i->Pin.AvBin32x4.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvBin32Fx4 ( PPC32AvOp op, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvBin32Fx4; i->Pin.AvBin32Fx4.op = op; i->Pin.AvBin32Fx4.dst = dst; i->Pin.AvBin32Fx4.srcL = srcL; i->Pin.AvBin32Fx4.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvPerm ( HReg ctl, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvPerm; i->Pin.AvPerm.ctl = ctl; i->Pin.AvPerm.dst = dst; i->Pin.AvPerm.srcL = srcL; i->Pin.AvPerm.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvSel ( HReg ctl, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvSel; i->Pin.AvSel.ctl = ctl; i->Pin.AvSel.dst = dst; i->Pin.AvSel.srcL = srcL; i->Pin.AvSel.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvShlDbl ( UChar shift, HReg dst, HReg srcL, HReg srcR ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvShlDbl; i->Pin.AvShlDbl.shift = shift; i->Pin.AvShlDbl.dst = dst; i->Pin.AvShlDbl.srcL = srcL; i->Pin.AvShlDbl.srcR = srcR; return i;}PPC32Instr* PPC32Instr_AvSplat ( UChar sz, HReg dst, PPC32RI* src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvSplat; i->Pin.AvSplat.sz = sz; i->Pin.AvSplat.dst = dst; i->Pin.AvSplat.src = src; return i;}PPC32Instr* PPC32Instr_AvCMov ( PPC32CondCode cond, HReg dst, HReg src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvCMov; i->Pin.AvCMov.cond = cond; i->Pin.AvCMov.dst = dst; i->Pin.AvCMov.src = src; vassert(cond.test != Pct_ALWAYS); return i;}PPC32Instr* PPC32Instr_AvLdVSCR ( HReg src ) { PPC32Instr* i = LibVEX_Alloc(sizeof(PPC32Instr)); i->tag = Pin_AvLdVSCR; i->Pin.AvLdVSCR.src = src; return i;}/* Pretty Print instructions */static void ppLoadImm ( HReg dst, UInt imm ) { if (imm < 0x10000) { vex_printf("li "); ppHRegPPC32(dst); vex_printf(",0x%x", imm); } else { vex_printf("lis "); ppHRegPPC32(dst); vex_printf(",0x%x ; ", imm >> 16); vex_printf("ori "); ppHRegPPC32(dst); vex_printf(","); ppHRegPPC32(dst); vex_printf(",0x%x", imm & 0xFFFF); }}static void ppMovReg ( HReg dst, HReg src ) { if (hregNumber(dst) != hregNumber(src)) { vex_printf("mr "); ppHRegPPC32(dst); vex_printf(","); ppHRegPPC32(src); }}void ppPPC32Instr ( PPC32Instr* i ){ switch (i->tag) { case Pin_LI32: vex_printf("li32 "); ppHRegPPC32(i->Pin.LI32.dst); vex_printf(",0x%x", i->Pin.LI32.imm32); break; case Pin_Alu32: /* special-case "mr" */ if (i->Pin.Alu32.op == Palu_OR && // or Rd,Rs,Rs == mr Rd,Rs i->Pin.Alu32.srcR->tag == Prh_Reg && i->Pin.Alu32.srcR->Prh.Reg.reg == i->Pin.Alu32.srcL) { vex_printf("mr "); ppHRegPPC32(i->Pin.Alu32.dst); vex_printf(","); ppHRegPPC32(i->Pin.Alu32.srcL); } else { /* generic */ vex_printf("%s ", showPPC32AluOp(i->Pin.Alu32.op, i->Pin.Alu32.srcR->tag == Prh_Imm)); ppHRegPPC32(i->Pin.Alu32.dst); vex_printf(","); ppHRegPPC32(i->Pin.Alu32.srcL); vex_printf(","); ppPPC32RH(i->Pin.Alu32.srcR); } return; case Pin_Cmp32: vex_printf("%s%s %%cr%u,", i->Pin.Cmp32.syned ? "cmp" : "cmpl", i->Pin.Cmp32.srcR->tag == Prh_Imm ? "i" : "", i->Pin.Cmp32.crfD); ppHRegPPC32(i->Pin.Cmp32.srcL); vex_printf(","); ppPPC32RH(i->Pin.Cmp32.srcR); return; case Pin_Unary32: vex_printf("%s ", showPPC32UnaryOp(i->Pin.Unary32.op)); ppHRegPPC32(i->Pin.Unary32.dst); vex_printf(","); ppHRegPPC32(i->Pin.Unary32.src); return; case Pin_MulL: vex_printf("mul%s%s ", i->Pin.MulL.hi32 ? "hw" : "lw", i->Pin.MulL.hi32 ? (i->Pin.MulL.syned ? "s" : "u") : ""); ppHRegPPC32(i->Pin.MulL.dst); vex_printf(","); ppHRegPPC32(i->Pin.MulL.srcL); vex_printf(","); ppHRegPPC32(i->Pin.MulL.srcR); return; case Pin_Div: vex_printf("divw%s ", i->Pin.Div.syned ? "" : "u"); ppHRegPPC32(i->Pin.Div.dst); vex_printf(","); ppHRegPPC32(i->Pin.Div.srcL); vex_printf(","); ppHRegPPC32(i->Pin.Div.srcR); return; case Pin_Call: vex_printf("call: "); if (i->Pin.Call.cond.test != Pct_ALWAYS) { vex_printf("if (%s) ", showPPC32CondCode(i->Pin.Call.cond)); } vex_printf("{ "); ppLoadImm(hregPPC32_GPR12(), i->Pin.Call.target); vex_printf(" ; mtctr r12 ; bctrl [regparms=%d] }",i->Pin.Call.regparms); break; case Pin_Goto: vex_printf("goto: "); if (i->Pin.Goto.cond.test != Pct_ALWAYS) { vex_printf("if (%s) ", showPPC32CondCode(i->Pin.Goto.cond)); } vex_printf("{ "); if (i->Pin.Goto.jk != Ijk_Boring) { vex_printf("li %%r31,$"); ppIRJumpKind(i->Pin.Goto.jk); vex_printf(" ; "); } if (i->Pin.Goto.dst->tag == Pri_Imm) { ppLoadImm(hregPPC32_GPR3(), i->Pin.Goto.dst->Pri.Imm); } else { ppMovReg(hregPPC32_GPR3(), i->Pin.Goto.dst->Pri.Reg); } vex_printf(" ; blr }"); return; case Pin_CMov32: vex_printf("cmov32 (%s) ", showPPC32CondCode(i->Pin.CMov32.cond)); ppHRegPPC32(i->Pin.CMov32.dst); vex_printf(","); ppPPC32RI(i->Pin.CMov32.src); vex_printf(": "); if (i->Pin.CMov32.cond.test != Pct_ALWAYS) { vex_printf("if (%s) ", showPPC32CondCode(i->Pin.CMov32.cond)); } vex_printf("{ "); if (i->Pin.CMov32.src->tag == Pri_Imm) { ppLoadImm(i->Pin.CMov32.dst, i->Pin.CMov32.src->Pri.Imm); } else { ppMovReg(i->Pin.CMov32.dst, i->Pin.CMov32.src->Pri.Reg); } vex_printf(" }"); return; case Pin_Load: { UChar sz = i->Pin.Load.sz; Bool syned = i->Pin.Load.syned; Bool idxd = toBool(i->Pin.Load.src->tag == Pam_RR); vex_printf("l%c%c%s ", (sz==1) ? 'b' : (sz==2 ? 'h' : 'w'), syned ? 'a' : 'z', idxd ? "x" : "" ); ppHRegPPC32(i->Pin.Load.dst); vex_printf(","); ppPPC32AMode(i->Pin.Load.src); return; } case Pin_Store: { UChar sz = i->Pin.Store.sz; Bool idxd = toBool(i->Pin.Store.dst->tag == Pam_RR); vex_printf("st%c%s ", (sz==1) ? 'b' : (sz==2 ? 'h' : 'w'), idxd ? "x" : "" ); ppHRegPPC32(i->Pin.Store.src); vex_printf(","); ppPPC32AMode(i->Pin.Store.dst); return; } case Pin_Set32: { PPC32CondCode cc = i->Pin.Set32.cond; vex_printf("set32 (%s),", showPPC32CondCode(cc)); ppHRegPPC32(i->Pin.Set32.dst); if (cc.test == Pct_ALWAYS) { vex_printf(": { li "); ppHRegPPC32(i->Pin.Set32.dst); vex_printf(",1 }"); } else { vex_printf(": { mfcr r0 ; rlwinm "); ppHRegPPC32(i->Pin.Set32.dst); vex_printf(",r0,%u,31,31", cc.flag+1); if (cc.test == Pct_FALSE) { vex_printf("; xori "); ppHRegPPC32(i->Pin.Set32.dst); vex_printf(","); ppHRegPPC32(i->Pin.Set32.dst); vex_printf("1"); } vex_printf(" }"); } return; } case Pin_MfCR: vex_printf("mfcr "); ppHRegPPC32(i->Pin.MfCR.dst); break; case Pin_MFence: vex_printf("mfence (=sync)"); return; case Pin_FpUnary: vex_printf("%s ", showPPC32FpOp(i->Pin.FpUnary.op)); ppHRegPPC32(i->Pin.FpUnary.dst); vex_printf(","); ppHRegPPC32(i->Pin.FpUnary.src); return; case Pin_FpBinary: vex_printf("%s ", showPPC32FpOp(i->Pin.FpBinary.op)); ppHRegPPC32(i->Pin.FpBinary.dst); vex_printf(","); ppHRegPPC32(i->Pin.FpBinary.srcL); vex_printf(","); ppHRegPPC32(i->Pin.FpBinary.srcR); return; case Pin_FpLdSt: { UChar sz = i->Pin.FpLdSt.sz; Bool idxd = toBool(i->Pin.FpLdSt.addr->tag == Pam_RR); if (i->Pin.FpLdSt.isLoad) { vex_printf("lf%c%s ", (sz==4 ? 's' : 'd'), idxd ? "x" : "" ); ppHRegPPC32(i->Pin.FpLdSt.reg); vex_printf(","); ppPPC32AMode(i->Pin.FpLdSt.addr); } else { vex_printf("stf%c%s ", (sz==4 ? 's' : 'd'), idxd ? "x" : "" ); ppHRegPPC32(i->Pin.FpLdSt.reg); vex_printf(","); ppPPC32AMode(i->Pin.FpLdSt.addr); } return; } case Pin_FpF64toF32: vex_printf("frsp ");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -