arm: convert MCOperand_CreateReg() to MCOperand_CreateReg0() to avoid malloc/free

v2
Nguyen Anh Quynh 11 years ago
parent 748687df46
commit 9678705d57
  1. 33
      arch/ARM/ARMInstPrinter.c

@ -536,23 +536,22 @@ void ARM_printInst(MCInst *MI, SStream *O, void *Info)
unsigned Reg = MCOperand_getReg(MCInst_getOperand(MI, isStore ? 1 : 0));
if (MCRegisterClass_contains(MRC, Reg)) {
MCInst NewMI;
MCOperand *NewReg;
MCInst_Init(MI->csh, &NewMI);
MCInst_setOpcode(&NewMI, Opcode);
if (isStore)
MCInst_addOperand2(&NewMI, MCInst_getOperand(MI, 0));
NewReg = MCOperand_CreateReg(MCRegisterInfo_getMatchingSuperReg(MRI, Reg, ARM_gsub_0,
MCRegisterInfo_getRegClass(MRI, ARM_GPRPairRegClassID)));
MCInst_addOperand2(&NewMI, NewReg);
cs_mem_free(NewReg);
// Copy the rest operands into NewMI.
for(i= isStore ? 3 : 2; i < MCInst_getNumOperands(MI); ++i)
MCInst_addOperand2(&NewMI, MCInst_getOperand(MI, i));
printInstruction(&NewMI, O, MRI);
MCInst NewMI;
MCInst_Init(MI->csh, &NewMI);
MCInst_setOpcode(&NewMI, Opcode);
if (isStore)
MCInst_addOperand2(&NewMI, MCInst_getOperand(MI, 0));
MCOperand_CreateReg0(&NewMI, MCRegisterInfo_getMatchingSuperReg(MRI, Reg, ARM_gsub_0,
MCRegisterInfo_getRegClass(MRI, ARM_GPRPairRegClassID)));
// Copy the rest operands into NewMI.
for(i = isStore ? 3 : 2; i < MCInst_getNumOperands(MI); ++i)
MCInst_addOperand2(&NewMI, MCInst_getOperand(MI, i));
printInstruction(&NewMI, O, MRI);
return;
}
}

Loading…
Cancel
Save