baksmali: added DIFFPRE reg info

This commit is contained in:
Connor Tumbleson 2013-06-20 08:42:43 -05:00
parent a417cba9e1
commit 2ca53880b1
2 changed files with 20 additions and 0 deletions

View File

@ -40,6 +40,8 @@ import java.io.IOException;
import java.util.BitSet;
public class PreInstructionRegisterInfoMethodItem extends MethodItem {
private static AnalyzedInstruction lastInstruction;
private final int registerInfo;
@Nonnull private final MethodAnalyzer methodAnalyzer;
@Nonnull private final RegisterFormatter registerFormatter;
@ -77,6 +79,9 @@ public class PreInstructionRegisterInfoMethodItem extends MethodItem {
if ((registerInfo & baksmaliOptions.ARGS) != 0) {
addArgsRegs(registers);
}
if ((registerInfo & baksmaliOptions.DIFFPRE) != 0) {
addDiffRegs(registers);
}
if ((registerInfo & baksmaliOptions.MERGE) != 0) {
if (analyzedInstruction.isBeginningInstruction()) {
addParamRegs(registers, registerCount);
@ -144,6 +149,19 @@ public class PreInstructionRegisterInfoMethodItem extends MethodItem {
}
}
private void addDiffRegs(BitSet registers) {
if (! analyzedInstruction.isBeginningInstruction()) {
for (int i = 0; i < analyzedInstruction.getRegisterCount(); i++) {
if (lastInstruction.getPreInstructionRegisterType(i).category !=
analyzedInstruction.getPreInstructionRegisterType(i).category) {
registers.set(i);
}
}
}
lastInstruction = analyzedInstruction;
}
private void addMergeRegs(BitSet registers, int registerCount) {
if (analyzedInstruction.getPredecessorCount() <= 1) {
//in the common case of an instruction that only has a single predecessor which is the previous

View File

@ -49,6 +49,8 @@ public class baksmaliOptions {
public static final int MERGE = 32;
public static final int FULLMERGE = 64;
public static final int DIFFPRE = 128;
public int apiLevel = 15;
public String outputDirectory = "out";
public List<String> bootClassPathDirs = Lists.newArrayList();