Search in sources :

Example 1 with CstInsn

use of com.android.dx.dex.code.CstInsn in project buck by facebook.

the class Form11n method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) && (regs.size() == 1) && unsignedFitsInNibble(regs.get(0).getReg()))) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();
    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }
    CstLiteralBits cb = (CstLiteralBits) cst;
    return cb.fitsInInt() && signedFitsInNibble(cb.getIntBits());
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) CstLiteralBits(com.android.dx.rop.cst.CstLiteralBits) Constant(com.android.dx.rop.cst.Constant) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 2 with CstInsn

use of com.android.dx.dex.code.CstInsn in project buck by facebook.

the class Form35c method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    if (!unsignedFitsInShort(cpi)) {
        return false;
    }
    Constant cst = ci.getConstant();
    if (!((cst instanceof CstMethodRef) || (cst instanceof CstType))) {
        return false;
    }
    RegisterSpecList regs = ci.getRegisters();
    return (wordCount(regs) >= 0);
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) Constant(com.android.dx.rop.cst.Constant) CstType(com.android.dx.rop.cst.CstType) CstMethodRef(com.android.dx.rop.cst.CstMethodRef) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 3 with CstInsn

use of com.android.dx.dex.code.CstInsn in project buck by facebook.

the class Form35c method writeTo.

/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    int cpi = ((CstInsn) insn).getIndex();
    RegisterSpecList regs = explicitize(insn.getRegisters());
    int sz = regs.size();
    int r0 = (sz > 0) ? regs.get(0).getReg() : 0;
    int r1 = (sz > 1) ? regs.get(1).getReg() : 0;
    int r2 = (sz > 2) ? regs.get(2).getReg() : 0;
    int r3 = (sz > 3) ? regs.get(3).getReg() : 0;
    int r4 = (sz > 4) ? regs.get(4).getReg() : 0;
    write(out, opcodeUnit(insn, // encode the fifth operand here
    makeByte(r4, sz)), (short) cpi, codeUnit(r0, r1, r2, r3));
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 4 with CstInsn

use of com.android.dx.dex.code.CstInsn in project buck by facebook.

the class Form3rc method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    Constant cst = ci.getConstant();
    if (!unsignedFitsInShort(cpi)) {
        return false;
    }
    if (!((cst instanceof CstMethodRef) || (cst instanceof CstType))) {
        return false;
    }
    RegisterSpecList regs = ci.getRegisters();
    int sz = regs.size();
    return (regs.size() == 0) || (isRegListSequential(regs) && unsignedFitsInShort(regs.get(0).getReg()) && unsignedFitsInByte(regs.getWordCount()));
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) Constant(com.android.dx.rop.cst.Constant) CstType(com.android.dx.rop.cst.CstType) CstMethodRef(com.android.dx.rop.cst.CstMethodRef) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 5 with CstInsn

use of com.android.dx.dex.code.CstInsn in project buck by facebook.

the class Form21c method isCompatible.

/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }
    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec reg;
    switch(regs.size()) {
        case 1:
            {
                reg = regs.get(0);
                break;
            }
        case 2:
            {
                /*
                 * This format is allowed for ops that are effectively
                 * 2-arg but where the two args are identical.
                 */
                reg = regs.get(0);
                if (reg.getReg() != regs.get(1).getReg()) {
                    return false;
                }
                break;
            }
        default:
            {
                return false;
            }
    }
    if (!unsignedFitsInByte(reg.getReg())) {
        return false;
    }
    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    Constant cst = ci.getConstant();
    if (!unsignedFitsInShort(cpi)) {
        return false;
    }
    return (cst instanceof CstType) || (cst instanceof CstFieldRef) || (cst instanceof CstString);
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) Constant(com.android.dx.rop.cst.Constant) CstType(com.android.dx.rop.cst.CstType) CstFieldRef(com.android.dx.rop.cst.CstFieldRef) CstString(com.android.dx.rop.cst.CstString) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Aggregations

CstInsn (com.android.dx.dex.code.CstInsn)34 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)34 Constant (com.android.dx.rop.cst.Constant)24 CstLiteralBits (com.android.dx.rop.cst.CstLiteralBits)12 CstType (com.android.dx.rop.cst.CstType)10 CstFieldRef (com.android.dx.rop.cst.CstFieldRef)6 RegisterSpec (com.android.dx.rop.code.RegisterSpec)4 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)4 CstString (com.android.dx.rop.cst.CstString)4 CstLiteral64 (com.android.dx.rop.cst.CstLiteral64)2