diff options
| author | jeffhao <jeffhao@google.com> | 2011-04-08 12:14:27 -0700 |
|---|---|---|
| committer | jeffhao <jeffhao@google.com> | 2011-04-08 12:14:27 -0700 |
| commit | 1800713d172abd729e4eea04b1bf2110d4e5fd1a (patch) | |
| tree | 42b4349b0c5151a2a8bf0ef437cb13eaa68293c7 /dx | |
| parent | a72475036290f55cd578dd15f65922dd01fbd3ce (diff) | |
| download | android_dalvik-1800713d172abd729e4eea04b1bf2110d4e5fd1a.tar.gz android_dalvik-1800713d172abd729e4eea04b1bf2110d4e5fd1a.tar.bz2 android_dalvik-1800713d172abd729e4eea04b1bf2110d4e5fd1a.zip | |
Bug fix for rsubs being improperly generated.
This will miss some opportunities to generate rsubs, and has been marked
by a TODO note where code needs to be added.
Change-Id: I6dd2c7a5bb82294ee5f88ba41191e473133ed847
Diffstat (limited to 'dx')
| -rw-r--r-- | dx/src/com/android/dx/rop/code/Insn.java | 10 | ||||
| -rw-r--r-- | dx/src/com/android/dx/rop/code/PlainInsn.java | 13 | ||||
| -rw-r--r-- | dx/src/com/android/dx/ssa/NormalSsaInsn.java | 10 |
3 files changed, 21 insertions, 12 deletions
diff --git a/dx/src/com/android/dx/rop/code/Insn.java b/dx/src/com/android/dx/rop/code/Insn.java index dad2852b8..7b79422f4 100644 --- a/dx/src/com/android/dx/rop/code/Insn.java +++ b/dx/src/com/android/dx/rop/code/Insn.java @@ -237,14 +237,14 @@ public abstract class Insn implements ToHuman { /** * Returns an instance that is just like this one, except that, if - * possible, the insn is converted into a version in which the last - * source (if it is a constant) is represented directly rather than - * as a register reference. {@code this} is returned in cases where - * the translation is not possible. + * possible, the insn is converted into a version in which a source + * (if it is a constant) is represented directly rather than as a + * register reference. {@code this} is returned in cases where the + * translation is not possible. * * @return {@code non-null;} an appropriately-constructed instance */ - public Insn withLastSourceLiteral() { + public Insn withSourceLiteral() { return this; } diff --git a/dx/src/com/android/dx/rop/code/PlainInsn.java b/dx/src/com/android/dx/rop/code/PlainInsn.java index 3fd2ba58d..027249f5c 100644 --- a/dx/src/com/android/dx/rop/code/PlainInsn.java +++ b/dx/src/com/android/dx/rop/code/PlainInsn.java @@ -21,6 +21,7 @@ import com.android.dx.rop.type.Type; import com.android.dx.rop.type.TypeList; import com.android.dx.rop.type.TypeBearer; import com.android.dx.rop.cst.Constant; +import com.android.dx.rop.cst.CstInteger; /** * Plain instruction, which has no embedded data and which cannot possibly @@ -95,7 +96,7 @@ public final class PlainInsn /** {@inheritDoc} */ @Override - public Insn withLastSourceLiteral() { + public Insn withSourceLiteral() { RegisterSpecList sources = getSources(); int szSources = sources.size(); @@ -105,6 +106,7 @@ public final class PlainInsn TypeBearer lastType = sources.get(szSources - 1).getTypeBearer(); + // TODO: Check for reverse subtraction, where first source is constant if (!lastType.isConstant()) { return this; } @@ -115,8 +117,13 @@ public final class PlainInsn Rop newRop; try { - newRop = Rops.ropFor(getOpcode().getOpcode(), - getResult(), newSources, (Constant)lastType); + // Check for constant subtraction and flip them to be addition + int opcode = getOpcode().getOpcode(); + if (opcode == RegOps.SUB && cst instanceof CstInteger) { + opcode = RegOps.ADD; + cst = CstInteger.make(-((CstInteger)cst).getValue()); + } + newRop = Rops.ropFor(opcode, getResult(), newSources, cst); } catch (IllegalArgumentException ex) { // There's no rop for this case return this; diff --git a/dx/src/com/android/dx/ssa/NormalSsaInsn.java b/dx/src/com/android/dx/ssa/NormalSsaInsn.java index 93d36471b..cfef40083 100644 --- a/dx/src/com/android/dx/ssa/NormalSsaInsn.java +++ b/dx/src/com/android/dx/ssa/NormalSsaInsn.java @@ -105,6 +105,7 @@ public final class NormalSsaInsn extends SsaInsn implements Cloneable { * * @return {@code null-ok;} sources list */ + @Override public RegisterSpecList getSources() { return insn.getSources(); } @@ -135,6 +136,7 @@ public final class NormalSsaInsn extends SsaInsn implements Cloneable { } /** {@inheritDoc} */ + @Override public RegisterSpec getLocalAssignment() { RegisterSpec assignment; @@ -158,15 +160,15 @@ public final class NormalSsaInsn extends SsaInsn implements Cloneable { } /** - * Upgrades this insn to a version that represents the constant last - * source literally. If the upgrade is not possible, this does nothing. + * Upgrades this insn to a version that represents the constant source + * literally. If the upgrade is not possible, this does nothing. * - * @see Insn#withLastSourceLiteral + * @see Insn#withSourceLiteral */ public void upgradeToLiteral() { RegisterSpecList oldSources = insn.getSources(); - insn = insn.withLastSourceLiteral(); + insn = insn.withSourceLiteral(); getBlock().getParent().onSourcesChanged(this, oldSources); } |
