Search in sources :

Example 1 with SimpleInsn

use of com.taobao.android.dx.dex.code.SimpleInsn in project atlas by alibaba.

the class Form12x method isCompatible.

/** {@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());
}
Also used : SimpleInsn(com.taobao.android.dx.dex.code.SimpleInsn) RegisterSpecList(com.taobao.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Aggregations

SimpleInsn (com.taobao.android.dx.dex.code.SimpleInsn)1 RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)1 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)1