Java Code Examples for com.android.dx.dex.code.DalvInsn#getRegisters()

The following examples show how to use com.android.dx.dex.code.DalvInsn#getRegisters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Form31i.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    return ((CstLiteralBits) cst).fitsInInt();
}
 
Example 2
Source File: Form4rcc.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    MultiCstInsn mci = (MultiCstInsn) insn;
    short regB = (short) mci.getIndex(0);  // B is the method index
    short regH = (short) mci.getIndex(1);  // H is the call site proto index

    RegisterSpecList regs = insn.getRegisters();
    short regC = 0;
    if (regs.size() > 0) {
        regC = (short) regs.get(0).getReg();
    }
    int regA = regs.getWordCount();

    // The output format is: AA|op BBBB CCCC HHHH
    write(out, opcodeUnit(insn,regA), regB, regC, regH);
}
 
Example 3
Source File: Form21c.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int sz = regs.size();
    BitSet bits = new BitSet(sz);
    boolean compat = unsignedFitsInByte(regs.get(0).getReg());

    if (sz == 1) {
        bits.set(0, compat);
    } else {
        if (regs.get(0).getReg() == regs.get(1).getReg()) {
            bits.set(0, compat);
            bits.set(1, compat);
        }
    }

    return bits;
}
 
Example 4
Source File: Form21c.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int sz = regs.size();
    BitSet bits = new BitSet(sz);
    boolean compat = unsignedFitsInByte(regs.get(0).getReg());

    if (sz == 1) {
        bits.set(0, compat);
    } else {
        if (regs.get(0).getReg() == regs.get(1).getReg()) {
            bits.set(0, compat);
            bits.set(1, compat);
        }
    }

    return bits;
}
 
Example 5
Source File: Form22s.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    BitSet bits = new BitSet(2);

    bits.set(0, unsignedFitsInNibble(regs.get(0).getReg()));
    bits.set(1, unsignedFitsInNibble(regs.get(1).getReg()));
    return bits;
}
 
Example 6
Source File: Form11x.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    BitSet bits = new BitSet(1);

    bits.set(0, unsignedFitsInByte(regs.get(0).getReg()));
    return bits;
}
 
Example 7
Source File: Form22t.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    if (!((insn instanceof TargetInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    TargetInsn ti = (TargetInsn) insn;
    return ti.hasTargetOffset() ? branchFits(ti) : true;
}
 
Example 8
Source File: Form23x.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    return (insn instanceof SimpleInsn) &&
        (regs.size() == 3) &&
        unsignedFitsInByte(regs.get(0).getReg()) &&
        unsignedFitsInByte(regs.get(1).getReg()) &&
        unsignedFitsInByte(regs.get(2).getReg());
}
 
Example 9
Source File: Form12x.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof SimpleInsn)) {
        return false;
    }

    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec rs1;
    RegisterSpec rs2;

    switch (regs.size()) {
        case 2: {
            rs1 = regs.get(0);
            rs2 = regs.get(1);
            break;
        }
        case 3: {
            /*
             * This format is allowed for ops that are effectively
             * 3-arg but where the first two args are identical.
             */
            rs1 = regs.get(1);
            rs2 = regs.get(2);
            if (rs1.getReg() != regs.get(0).getReg()) {
                return false;
            }
            break;
        }
        default: {
            return false;
        }
    }

    return unsignedFitsInNibble(rs1.getReg()) &&
        unsignedFitsInNibble(rs2.getReg());
}
 
Example 10
Source File: Form22x.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    return (insn instanceof SimpleInsn) &&
        (regs.size() == 2) &&
        unsignedFitsInByte(regs.get(0).getReg()) &&
        unsignedFitsInShort(regs.get(1).getReg());
}
 
Example 11
Source File: Form22c.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    return regs.get(0).regString() + ", " + regs.get(1).regString() +
        ", " + insn.cstString();
}
 
Example 12
Source File: Form22b.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int value =
        ((CstLiteralBits) ((CstInsn) insn).getConstant()).getIntBits();

    write(out,
          opcodeUnit(insn, regs.get(0).getReg()),
          codeUnit(regs.get(1).getReg(), value & 0xff));
}
 
Example 13
Source File: Form22b.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();

    return regs.get(0).regString() + ", " + regs.get(1).regString() +
        ", " + literalBitsString(value);
}
 
Example 14
Source File: Form12x.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof SimpleInsn)) {
        return false;
    }

    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec rs1;
    RegisterSpec rs2;

    switch (regs.size()) {
        case 2: {
            rs1 = regs.get(0);
            rs2 = regs.get(1);
            break;
        }
        case 3: {
            /*
             * This format is allowed for ops that are effectively
             * 3-arg but where the first two args are identical.
             */
            rs1 = regs.get(1);
            rs2 = regs.get(2);
            if (rs1.getReg() != regs.get(0).getReg()) {
                return false;
            }
            break;
        }
        default: {
            return false;
        }
    }

    return unsignedFitsInNibble(rs1.getReg()) &&
        unsignedFitsInNibble(rs2.getReg());
}
 
Example 15
Source File: Form3rc.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int cpi = ((CstInsn) insn).getIndex();
    int firstReg = (regs.size() == 0) ? 0 : regs.get(0).getReg();
    int count = regs.getWordCount();

    write(out, opcodeUnit(insn, count), (short) cpi, (short) firstReg);
}
 
Example 16
Source File: Form12x.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    BitSet bits = new BitSet(2);
    int r0 = regs.get(0).getReg();
    int r1 = regs.get(1).getReg();

    switch (regs.size()) {
      case 2: {
        bits.set(0, unsignedFitsInNibble(r0));
        bits.set(1, unsignedFitsInNibble(r1));
        break;
      }
      case 3: {
        if (r0 != r1) {
            bits.set(0, false);
            bits.set(1, false);
        } else {
            boolean dstRegComp = unsignedFitsInNibble(r1);
            bits.set(0, dstRegComp);
            bits.set(1, dstRegComp);
        }

        bits.set(2, unsignedFitsInNibble(regs.get(2).getReg()));
        break;
      }
      default: {
        throw new AssertionError();
      }
    }

    return bits;
}
 
Example 17
Source File: Form31t.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    if (!((insn instanceof TargetInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    return true;
}
 
Example 18
Source File: Form32x.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    return (insn instanceof SimpleInsn) &&
        (regs.size() == 2) &&
        unsignedFitsInShort(regs.get(0).getReg()) &&
        unsignedFitsInShort(regs.get(1).getReg());
}
 
Example 19
Source File: Form32x.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    return regs.get(0).regString() + ", " + regs.get(1).regString();
}
 
Example 20
Source File: Form31t.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    return regs.get(0).regString() + ", " + branchString(insn);
}