Search in sources :

Example 1 with RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList 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 RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList 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 RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList 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 RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList in project buck by facebook.

the class Form35c method explicitize.

/**
     * Returns a register list which is equivalent to the given one,
     * except that it splits category-2 registers into two explicit
     * entries. This returns the original list if no modification is
     * required
     *
     * @param orig {@code non-null;} the original list
     * @return {@code non-null;} the list with the described transformation
     */
private static RegisterSpecList explicitize(RegisterSpecList orig) {
    int wordCount = wordCount(orig);
    int sz = orig.size();
    if (wordCount == sz) {
        return orig;
    }
    RegisterSpecList result = new RegisterSpecList(wordCount);
    int wordAt = 0;
    for (int i = 0; i < sz; i++) {
        RegisterSpec one = orig.get(i);
        result.set(wordAt, one);
        if (one.getCategory() == 2) {
            result.set(wordAt + 1, RegisterSpec.make(one.getReg() + 1, Type.VOID));
            wordAt += 2;
        } else {
            wordAt++;
        }
    }
    result.setImmutable();
    return result;
}
Also used : RegisterSpecList(com.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Example 5 with RegisterSpecList

use of com.android.dx.rop.code.RegisterSpecList 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)

Aggregations

RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)204 RegisterSpec (com.android.dx.rop.code.RegisterSpec)50 BitSet (java.util.BitSet)45 CstLiteralBits (com.android.dx.rop.cst.CstLiteralBits)42 Constant (com.android.dx.rop.cst.Constant)36 CstInsn (com.android.dx.dex.code.CstInsn)34 PlainInsn (com.android.dx.rop.code.PlainInsn)19 CstType (com.android.dx.rop.cst.CstType)12 TargetInsn (com.android.dx.dex.code.TargetInsn)10 Insn (com.android.dx.rop.code.Insn)10 TypedConstant (com.android.dx.rop.cst.TypedConstant)10 Rop (com.android.dx.rop.code.Rop)9 PlainCstInsn (com.android.dx.rop.code.PlainCstInsn)8 CstFieldRef (com.android.dx.rop.cst.CstFieldRef)8 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)8 TypeBearer (com.android.dx.rop.type.TypeBearer)8 ThrowingInsn (com.android.dx.rop.code.ThrowingInsn)7 ThrowingCstInsn (com.android.dx.rop.code.ThrowingCstInsn)6 CstInteger (com.android.dx.rop.cst.CstInteger)6 MultiCstInsn (com.android.dx.dex.code.MultiCstInsn)4