split DIV to Idiv/Ldiv/Fdiv/Ddiv

Fixes issue 230

--HG--
branch : 2.x
This commit is contained in:
Bob Pan 2014-10-08 21:31:25 +08:00
parent ac831e3f8f
commit e742563077
5 changed files with 44 additions and 4 deletions

View File

@ -106,7 +106,18 @@ public final class Exprs {
}
public static BinopExpr nDiv(Value a, Value b, String type) {
return new BinopExpr(VT.DIV, a, b, type);
switch (type){
case "I":
return new BinopExpr(VT.IDIV, a, b, type);
case "J":
return new BinopExpr(VT.LDIV, a, b, type);
case "F":
return new BinopExpr(VT.FDIV, a, b, type);
case "D":
return new BinopExpr(VT.DDIV, a, b, type);
default:
throw new RuntimeException("type must set to one of I/J/F/D");
}
}
public static BinopExpr nEq(Value a, Value b, String type) {

View File

@ -176,7 +176,7 @@ public abstract class Value implements Cloneable {
public static enum VT {
ADD("+", MAY_THROW), AND("&", MAY_THROW), ARRAY(MAY_THROW), CAST(MAY_THROW), CHECK_CAST(CAN_THROW), CONSTANT(0), DCMPG(
MAY_THROW), DCMPL(MAY_THROW), DIV("/", CAN_THROW), EQ("==", MAY_THROW), EXCEPTION_REF(0), FCMPG(
MAY_THROW), DCMPL(MAY_THROW), IDIV("/", CAN_THROW), LDIV("/", CAN_THROW), FDIV("/", MAY_THROW), DDIV("/", MAY_THROW), EQ("==", MAY_THROW), EXCEPTION_REF(0), FCMPG(
MAY_THROW), FCMPL(MAY_THROW), FIELD(CAN_THROW), FILLED_ARRAY(CAN_THROW), GE(">=", MAY_THROW), GT(">",
MAY_THROW), INSTANCE_OF(CAN_THROW), INVOKE_INTERFACE(CAN_THROW), //
INVOKE_NEW(CAN_THROW), INVOKE_SPECIAL(CAN_THROW), INVOKE_STATIC(CAN_THROW), INVOKE_VIRTUAL(CAN_THROW), LCMP(

View File

@ -590,7 +590,10 @@ public class TypeTransformer implements Transformer {
break;
case ADD:
case SUB:
case DIV:
case IDIV:
case LDIV:
case FDIV:
case DDIV:
case MUL:
case REM: {
BinopExpr be = (BinopExpr) e2;

View File

@ -814,7 +814,10 @@ public class IR2JConverter implements Opcodes {
case SUB:
asm.visitInsn(getOpcode(type, ISUB));
break;
case DIV:
case IDIV:
case LDIV:
case FDIV:
case DDIV:
asm.visitInsn(getOpcode(type, IDIV));
break;
case MUL:

View File

@ -0,0 +1,23 @@
.class Li230;
.super Li230;
.method public i230(II)F
.catchall { :L5 .. :L10 } :L9
.registers 10
move-object v0, p0
monitor-enter v0
:L5
int-to-float v0, p1
int-to-float v1, p2
div-float/2addr v1, v0
move-object v0, p0
monitor-exit v0
return v1
:L9
move-exception v1
monitor-exit v0
:L10
const v1, 0
return v1
.end method