From: <mic...@us...> - 2007-08-20 21:08:44
|
Revision: 169 http://pearcolator.svn.sourceforge.net/pearcolator/?rev=169&view=rev Author: michael_baer Date: 2007-08-20 14:08:34 -0700 (Mon, 20 Aug 2007) Log Message: ----------- - Introduce option to use optimized flag handling instructions - otherwise resorting to traditional flag evaluation Modified Paths: -------------- src/org/binarytranslator/arch/arm/decoder/ARM2IR.java src/org/binarytranslator/arch/arm/decoder/ARM_Options.java src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java Modified: src/org/binarytranslator/arch/arm/decoder/ARM2IR.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM2IR.java 2007-08-20 14:12:59 UTC (rev 168) +++ src/org/binarytranslator/arch/arm/decoder/ARM2IR.java 2007-08-20 21:08:34 UTC (rev 169) @@ -198,6 +198,7 @@ /** Called when the ARM flags shall be set by a SUB operation. This sets all ARM flags. */ public abstract void appendSubFlags(ARM_Laziness lazy, OPT_Operand result, OPT_Operand op1, OPT_Operand op2); + public abstract void appendReverseSubFlags(ARM_Laziness lazy, OPT_RegisterOperand result, OPT_Operand lhs, OPT_Operand rhs); } /** Implements a flag behavior that will immediately evaluate all flag values. */ @@ -209,7 +210,23 @@ appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Zero), result.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.EQUAL(), new OPT_BranchProfileOperand())); appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Carry), result.copy(), op1.copy(), OPT_ConditionOperand.LOWER(), new OPT_BranchProfileOperand())); appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Negative), result.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.LESS(), new OPT_BranchProfileOperand())); - appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Overflow), op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_ADD(), OPT_BranchProfileOperand.unlikely())); + + if (ARM_Options.useOptimizedFlags) { + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Overflow), op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_ADD(), OPT_BranchProfileOperand.unlikely())); + } + else { + //resolve overflow + OPT_RegisterOperand overflow = getFlag(Flag.Overflow); + OPT_RegisterOperand tmp1 = getTempInt(5); + OPT_RegisterOperand tmp2 = getTempInt(6); + OPT_RegisterOperand tmp_bool = gc.temps.makeTempBoolean(); + + appendInstruction(Binary.create(INT_SUB, tmp1.copyRO(), new OPT_IntConstantOperand(Integer.MAX_VALUE), op2.copy())); + appendInstruction(Binary.create(INT_SUB, tmp2.copyRO(), new OPT_IntConstantOperand(Integer.MIN_VALUE), op2.copy())); + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, tmp_bool.copyRO(), op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.GREATER_EQUAL(), new OPT_BranchProfileOperand(), op1.copy(), tmp1.copy(), OPT_ConditionOperand.GREATER(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, overflow.copyRO(), op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.LESS() , new OPT_BranchProfileOperand(), op1.copy(), tmp2.copy(), OPT_ConditionOperand.LESS(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(Binary.create(INT_OR, overflow.copyRO(), overflow.copy(), tmp_bool.copy())); + } } @Override @@ -223,9 +240,29 @@ @Override public void appendSubFlags(ARM_Laziness lazy, OPT_Operand result, OPT_Operand op1, OPT_Operand op2) { appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Zero), result.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.EQUAL(), new OPT_BranchProfileOperand())); - appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Negative), result.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.LESS(), new OPT_BranchProfileOperand())); - appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Carry), op1.copy(), op2.copy(), OPT_ConditionOperand.BORROW_FROM_SUB().flipCode(), new OPT_BranchProfileOperand())); - appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Overflow), op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_SUB(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Negative), result.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.LESS(), new OPT_BranchProfileOperand())); + + if (ARM_Options.useOptimizedFlags) { + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Carry), op1.copy(), op2.copy(), OPT_ConditionOperand.BORROW_FROM_SUB().flipCode(), new OPT_BranchProfileOperand())); + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Overflow), op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_SUB(), OPT_BranchProfileOperand.unlikely())); + } + else { + //resolve carry + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Carry), op1.copy(), op2.copy(), OPT_ConditionOperand.LOWER().flipCode(), new OPT_BranchProfileOperand())); + + //resolve overflow + OPT_RegisterOperand overflow = getFlag(Flag.Overflow); + OPT_RegisterOperand tmp1 = getTempInt(5); + OPT_RegisterOperand tmp2 = getTempInt(6); + OPT_RegisterOperand tmp_bool = gc.temps.makeTempBoolean(); + + appendInstruction(Binary.create(INT_ADD, tmp1.copyRO(), new OPT_IntConstantOperand(Integer.MIN_VALUE), op2.copy())); + appendInstruction(Binary.create(INT_ADD, tmp2.copyRO(), new OPT_IntConstantOperand(Integer.MAX_VALUE), op2.copy())); + + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, tmp_bool.copyRO(), op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.GREATER_EQUAL(), new OPT_BranchProfileOperand(), op1.copy(), tmp1.copy(), OPT_ConditionOperand.LESS(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, overflow.copyRO(), op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.LESS() , new OPT_BranchProfileOperand(), op1.copy(), tmp2.copy(), OPT_ConditionOperand.GREATER(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(Binary.create(INT_OR, overflow.copyRO(), overflow.copy(), tmp_bool.copy())); + } } @Override @@ -237,6 +274,11 @@ public void onFlagWrite(Flag flag, ARM_Laziness lazy) { //nothing to do here, because the flags are already resolved } + + @Override + public void appendReverseSubFlags(ARM_Laziness lazy, OPT_RegisterOperand result, OPT_Operand op1, OPT_Operand op2) { + appendSubFlags(lazy, result, op2, op1); + } } /** Implements a flag behavior that will use lazy evaluation to only determine a flag value @@ -366,7 +408,13 @@ case LogicalOpAfterSub: case Sub: - appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, flagRegister, op1.copy(), op2.copy(), OPT_ConditionOperand.BORROW_FROM_SUB().flipCode(), new OPT_BranchProfileOperand())); + + if (ARM_Options.useOptimizedFlags) { + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, flagRegister, op1.copy(), op2.copy(), OPT_ConditionOperand.BORROW_FROM_SUB().flipCode(), new OPT_BranchProfileOperand())); + } + else { + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Carry), op1.copy(), op2.copy(), OPT_ConditionOperand.LOWER().flipCode(), new OPT_BranchProfileOperand())); + } break; default: @@ -382,12 +430,40 @@ switch (lazy.getOperation()) { case Add: case LogicalOpAfterAdd: - appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, flagRegister, op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_ADD(), OPT_BranchProfileOperand.unlikely())); + if (ARM_Options.useOptimizedFlags) { + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, getFlag(Flag.Overflow), op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_ADD(), OPT_BranchProfileOperand.unlikely())); + } + else { + OPT_RegisterOperand tmp1 = getTempInt(5); + OPT_RegisterOperand tmp2 = getTempInt(6); + OPT_RegisterOperand tmp_bool = gc.temps.makeTempBoolean(); + + appendInstruction(Binary.create(INT_SUB, tmp1.copyRO(), new OPT_IntConstantOperand(Integer.MAX_VALUE), op2.copy())); + appendInstruction(Binary.create(INT_SUB, tmp2.copyRO(), new OPT_IntConstantOperand(Integer.MIN_VALUE), op2.copy())); + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, tmp_bool.copyRO(), op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.GREATER_EQUAL(), new OPT_BranchProfileOperand(), op1.copy(), tmp1.copy(), OPT_ConditionOperand.GREATER(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, getFlag(Flag.Overflow), op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.LESS() , new OPT_BranchProfileOperand(), op1.copy(), tmp2.copy(), OPT_ConditionOperand.LESS(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(Binary.create(INT_OR, getFlag(Flag.Overflow), getFlag(Flag.Overflow), tmp_bool.copy())); + } break; case Sub: case LogicalOpAfterSub: - appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, flagRegister, op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_SUB(), OPT_BranchProfileOperand.unlikely())); + if (ARM_Options.useOptimizedFlags) { + appendInstruction(BooleanCmp.create(BOOLEAN_CMP_INT, flagRegister, op1.copy(), op2.copy(), OPT_ConditionOperand.OVERFLOW_FROM_SUB(), OPT_BranchProfileOperand.unlikely())); + } + else { + //resolve overflow + OPT_RegisterOperand tmp1 = getTempInt(5); + OPT_RegisterOperand tmp2 = getTempInt(6); + OPT_RegisterOperand tmp_bool = gc.temps.makeTempBoolean(); + + appendInstruction(Binary.create(INT_ADD, tmp1.copyRO(), new OPT_IntConstantOperand(Integer.MIN_VALUE), op2.copy())); + appendInstruction(Binary.create(INT_ADD, tmp2.copyRO(), new OPT_IntConstantOperand(Integer.MAX_VALUE), op2.copy())); + + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, tmp_bool.copyRO(), op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.GREATER_EQUAL(), new OPT_BranchProfileOperand(), op1.copy(), tmp1.copy(), OPT_ConditionOperand.LESS(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(BooleanCmp2.create(BOOLEAN_CMP2_INT_AND, flagRegister, op2.copy(), new OPT_IntConstantOperand(0), OPT_ConditionOperand.LESS() , new OPT_BranchProfileOperand(), op1.copy(), tmp2.copy(), OPT_ConditionOperand.GREATER(), OPT_BranchProfileOperand.unlikely())); + appendInstruction(Binary.create(INT_OR, flagRegister.copyRO(), flagRegister.copy(), tmp_bool.copy())); + } break; default: @@ -416,6 +492,11 @@ public void onFlagWrite(Flag flag, ARM_Laziness lazy) { lazy.setValid(flag, true); } + + @Override + public void appendReverseSubFlags(ARM_Laziness lazy, OPT_RegisterOperand result, OPT_Operand op1, OPT_Operand op2) { + appendSubFlags(lazy, result, op2, op1); + } } @Override @@ -701,6 +782,12 @@ flagBehavior.appendSubFlags(lazy, result, op1, op2); } + + public void appendReverseSubFlags(ARM_Laziness lazy, OPT_RegisterOperand result, OPT_Operand lhs, OPT_Operand rhs) { + zeroUsed = negativeUsed = carryUsed = overflowUsed = true; + flagBehavior.appendReverseSubFlags(lazy, result, lhs, rhs); + } + public void appendAddFlags(ARM_Laziness lazy, OPT_Operand result, OPT_Operand op1, OPT_Operand op2) { zeroUsed = negativeUsed = carryUsed = overflowUsed = true; flagBehavior.appendAddFlags(lazy, result, op1, op2); @@ -846,4 +933,5 @@ appendInstruction(BooleanCmp.create(OPT_Operators.BOOLEAN_CMP_INT, target, target, new OPT_IntConstantOperand(0), OPT_ConditionOperand.NOT_EQUAL(), new OPT_BranchProfileOperand())); } + } Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Options.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Options.java 2007-08-20 14:12:59 UTC (rev 168) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Options.java 2007-08-20 21:08:34 UTC (rev 169) @@ -24,12 +24,15 @@ /** Set to true to enable a fastpath for the decoding of data processing instructions.. */ public final static boolean DATAPROCESSING_DECODER_FASTPATH = false; + + /** Shall ARM use the optimized BORROW_FROM_SUB() etc. operations? */ + public static boolean useOptimizedFlags = false; /** This variable describes, if the translated program shall be optimized using profiling information. */ public static boolean optimizeTranslationByProfiling = false; /** This variable describes, if the translated program shall be optimized using lazy evaluation.*/ - public static FlagBehaviour flagEvaluation = FlagBehaviour.Lazy; + public static FlagBehaviour flagEvaluation = FlagBehaviour.Immediate; /** Describes the default behaviour for dealing with ARM function calls and indirect jumps. */ public static InliningBehaviour inlining = InliningBehaviour.Default; @@ -47,7 +50,9 @@ inlining = ARM_Options.InliningBehaviour.valueOf(value); } else if (key.equalsIgnoreCase("memory")) { memoryModel = ARM_Options.MemoryModel.valueOf(value); - } + } else if (key.equalsIgnoreCase("optimizedFlags")) { + useOptimizedFlags = Boolean.parseBoolean(value); + } else { throw new Error("Unknown ARM option: " + key); } Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java 2007-08-20 14:12:59 UTC (rev 168) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java 2007-08-20 21:08:34 UTC (rev 169) @@ -843,22 +843,35 @@ case CC: //return !regs.isCarrySet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readCarryFlag(lazy), OPT_ConditionOperand.NOT_EQUAL()); + { + OPT_Operand carry = arm2ir.readCarryFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, carry, OPT_ConditionOperand.NOT_EQUAL()); + } break; case CS: //return regs.isCarrySet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readCarryFlag(lazy), OPT_ConditionOperand.EQUAL()); + { + OPT_Operand carry = arm2ir.readCarryFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, carry, OPT_ConditionOperand.EQUAL()); + } break; case EQ: //return regs.isZeroSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readZeroFlag(lazy), OPT_ConditionOperand.EQUAL()); + { + OPT_Operand zero = arm2ir.readZeroFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, zero, OPT_ConditionOperand.EQUAL()); + } break; case GE: //return regs.isNegativeSet() == regs.isOverflowSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readNegativeFlag(lazy), OPT_ConditionOperand.EQUAL(), arm2ir.readOverflowFlag(lazy)); + { + OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); + OPT_Operand negative = arm2ir.readNegativeFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, negative, OPT_ConditionOperand.EQUAL(), overflow); + } break; case GT: @@ -879,17 +892,27 @@ case LT: //return regs.isNegativeSet() != regs.isOverflowSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readNegativeFlag(lazy), OPT_ConditionOperand.NOT_EQUAL(), arm2ir.readOverflowFlag(lazy)); + { + OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); + OPT_Operand negative = arm2ir.readNegativeFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, negative, OPT_ConditionOperand.NOT_EQUAL(), overflow); + } break; case MI: //return regs.isNegativeSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readNegativeFlag(lazy), OPT_ConditionOperand.EQUAL()); + { + OPT_Operand negative = arm2ir.readNegativeFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, negative, OPT_ConditionOperand.EQUAL()); + } break; case NE: //return !regs.isZeroSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readZeroFlag(lazy), OPT_ConditionOperand.NOT_EQUAL()); + { + OPT_Operand zero = arm2ir.readZeroFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, zero, OPT_ConditionOperand.NOT_EQUAL()); + } break; case NV: @@ -899,17 +922,26 @@ case PL: //return !regs.isNegativeSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readNegativeFlag(lazy), OPT_ConditionOperand.NOT_EQUAL()); + { + OPT_Operand negative = arm2ir.readNegativeFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, negative, OPT_ConditionOperand.NOT_EQUAL()); + } break; case VC: //return !regs.isOverflowSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readOverflowFlag(lazy), OPT_ConditionOperand.NOT_EQUAL()); + { + OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, overflow, OPT_ConditionOperand.NOT_EQUAL()); + } break; case VS: //return regs.isOverflowSet(); - translateCondition(nextInstruction_InstructionSkipped, profileOperand, arm2ir.readOverflowFlag(lazy), OPT_ConditionOperand.EQUAL()); + { + OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); + translateCondition(nextInstruction_InstructionSkipped, profileOperand, overflow, OPT_ConditionOperand.EQUAL()); + } break; default: @@ -997,8 +1029,8 @@ private void translateCondition_GT(OPT_BasicBlock nextInstruction, OPT_BranchProfileOperand skipProbability) { //return (regs.isNegativeSet() == regs.isOverflowSet()) && !regs.isZeroSet(); + OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); OPT_Operand negative = arm2ir.readNegativeFlag(lazy); - OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); OPT_Operand zero = arm2ir.readZeroFlag(lazy); OPT_RegisterOperand result = arm2ir.getGenerationContext().temps.makeTempBoolean(); @@ -1010,8 +1042,8 @@ private void translateCondition_LE(OPT_BasicBlock nextInstruction, OPT_BranchProfileOperand skipProbability) { //return regs.isZeroSet() || (regs.isNegativeSet() != regs.isOverflowSet()); + OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); OPT_Operand negative = arm2ir.readNegativeFlag(lazy); - OPT_Operand overflow = arm2ir.readOverflowFlag(lazy); OPT_Operand zero = arm2ir.readZeroFlag(lazy); OPT_RegisterOperand result = arm2ir.getGenerationContext().temps.makeTempBoolean(); @@ -1109,11 +1141,14 @@ } /** Sets the processor flags according to the result of subtracting <code>rhs</code> from <code>lhs</code>.*/ - protected final void setSubResult(OPT_RegisterOperand result, OPT_Operand lhs, OPT_Operand rhs) { + protected final void setSubResult(OPT_RegisterOperand result, OPT_Operand lhs, OPT_Operand rhs, boolean wasReverseSub) { if (i.updateConditionCodes) { if (i.Rd != ARM_Registers.PC) { - setSubFlags(result, lhs, rhs); + if (wasReverseSub) + setReverseSubFlags(result, lhs, rhs); + else + setSubFlags(result, lhs, rhs); } else { OPT_Instruction s = createCallToRegisters("restoreSPSR2CPSR", "()V", 0); @@ -1136,7 +1171,12 @@ arm2ir.appendInstruction(Move.create(INT_MOVE, arm2ir.getRegister(i.Rd), result.copy()) ); } } + + private void setReverseSubFlags(OPT_RegisterOperand result, OPT_Operand lhs, OPT_Operand rhs) { + arm2ir.appendReverseSubFlags(lazy, result, lhs, rhs); + } + /** * Sets the processor flags according to the result of a sub operation. * @param result @@ -1147,7 +1187,6 @@ * The sub's right-hand-side operator. */ protected final void setSubFlags(OPT_Operand result, OPT_Operand lhs, OPT_Operand rhs) { - arm2ir.appendSubFlags(lazy, result, lhs, rhs); } @@ -1294,7 +1333,7 @@ arm2ir.appendInstruction(Binary.create(INT_SUB, result, operand1, operand2)); - setSubResult(result, operand1, operand2); + setSubResult(result, operand1, operand2, false); } } @@ -1313,7 +1352,7 @@ arm2ir.appendInstruction(Binary.create(INT_SUB, result, operand2, operand1)); - setSubResult(result, operand2, operand1); + setSubResult(result, operand1, operand2, true); } } @@ -1385,7 +1424,7 @@ //Finally, subtract the second operands from the result arm2ir.setCurrentBlock(subWithoutCarry); arm2ir.appendInstruction(Binary.create(INT_SUB, result, operand1, operand2.copy())); - setSubResult(result, operand1, operand2); + setSubResult(result, operand1, operand2, false); } } @@ -2188,8 +2227,9 @@ return base; //add the offset to the base register + OPT_Operand offset = resolveOffset(); OPT_RegisterOperand tmp = arm2ir.getTempInt(0); - arm2ir.appendInstruction(Binary.create(INT_ADD, tmp, base, resolveOffset())); + arm2ir.appendInstruction(Binary.create(INT_ADD, tmp, base, offset)); if (i.isThumb && i.isLoad && i.Rn == ARM_Registers.PC) { //with thumb, bit 1 of the address is always ignored - address = address & 0xFFFFFFFC; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |