Search in sources :

Example 11 with RegisterSpec

use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.

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.taobao.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Example 12 with RegisterSpec

use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.

the class Form35c method wordCount.

/**
     * Gets the number of words required for the given register list, where
     * category-2 values count as two words. Return {@code -1} if the
     * list requires more than five words or contains registers that need
     * more than a nibble to identify them.
     *
     * @param regs {@code non-null;} the register list in question
     * @return {@code >= -1;} the number of words required, or {@code -1}
     * if the list couldn't possibly fit in this format
     */
private static int wordCount(RegisterSpecList regs) {
    int sz = regs.size();
    if (sz > MAX_NUM_OPS) {
        // It can't possibly fit.
        return -1;
    }
    int result = 0;
    for (int i = 0; i < sz; i++) {
        RegisterSpec one = regs.get(i);
        result += one.getCategory();
        /*
             * The check below adds (category - 1) to the register, to
             * account for the fact that the second half of a
             * category-2 register has to be represented explicitly in
             * the result.
             */
        if (!unsignedFitsInNibble(one.getReg() + one.getCategory() - 1)) {
            return -1;
        }
    }
    return (result <= MAX_NUM_OPS) ? result : -1;
}
Also used : RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Example 13 with RegisterSpec

use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.

the class Form35c method compatibleRegs.

/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int sz = regs.size();
    BitSet bits = new BitSet(sz);
    for (int i = 0; i < sz; i++) {
        RegisterSpec reg = regs.get(i);
        /*
             * The check below adds (category - 1) to the register, to
             * account for the fact that the second half of a
             * category-2 register has to be represented explicitly in
             * the result.
             */
        bits.set(i, unsignedFitsInNibble(reg.getReg() + reg.getCategory() - 1));
    }
    return bits;
}
Also used : BitSet(java.util.BitSet) RegisterSpecList(com.taobao.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Example 14 with RegisterSpec

use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.

the class SsaMethod method updateOneDefinition.

/**
     * Updates a single definition.
     *
     * @param insn {@code non-null;} insn who's result should be recorded as
     * a definition
     * @param oldResult {@code null-ok;} a previous result that should
     * be no longer considered a definition by this insn
     */
/*package*/
void updateOneDefinition(SsaInsn insn, RegisterSpec oldResult) {
    if (definitionList == null)
        return;
    if (oldResult != null) {
        int reg = oldResult.getReg();
        definitionList[reg] = null;
    }
    RegisterSpec resultReg = insn.getResult();
    if (resultReg != null) {
        int reg = resultReg.getReg();
        if (definitionList[reg] != null) {
            throw new RuntimeException("Duplicate add of insn");
        } else {
            definitionList[resultReg.getReg()] = insn;
        }
    }
}
Also used : RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Example 15 with RegisterSpec

use of com.taobao.android.dx.rop.code.RegisterSpec in project atlas by alibaba.

the class FirstFitLocalCombiningAllocator method handleUnassociatedParameters.

/**
     * Maps any parameter that isn't local-associated, which can happen
     * in the case where there is no java debug info.
     */
private void handleUnassociatedParameters() {
    int szSsaRegs = ssaMeth.getRegCount();
    for (int ssaReg = 0; ssaReg < szSsaRegs; ssaReg++) {
        if (ssaRegsMapped.get(ssaReg)) {
            // We already did this one above
            continue;
        }
        int paramIndex = getParameterIndexForReg(ssaReg);
        RegisterSpec ssaSpec = getDefinitionSpecForSsaReg(ssaReg);
        if (paramIndex >= 0) {
            addMapping(ssaSpec, paramIndex);
        }
    }
}
Also used : RegisterSpec(com.taobao.android.dx.rop.code.RegisterSpec)

Aggregations

RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)66 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)24 PlainInsn (com.taobao.android.dx.rop.code.PlainInsn)12 Constant (com.taobao.android.dx.rop.cst.Constant)10 TypedConstant (com.taobao.android.dx.rop.cst.TypedConstant)8 ArrayList (java.util.ArrayList)8 Insn (com.taobao.android.dx.rop.code.Insn)7 PlainCstInsn (com.taobao.android.dx.rop.code.PlainCstInsn)7 Rop (com.taobao.android.dx.rop.code.Rop)7 ThrowingCstInsn (com.taobao.android.dx.rop.code.ThrowingCstInsn)7 CstType (com.taobao.android.dx.rop.cst.CstType)7 TypeBearer (com.taobao.android.dx.rop.type.TypeBearer)7 LocalItem (com.taobao.android.dx.rop.code.LocalItem)5 RegisterSpecSet (com.taobao.android.dx.rop.code.RegisterSpecSet)5 ThrowingInsn (com.taobao.android.dx.rop.code.ThrowingInsn)5 CstString (com.taobao.android.dx.rop.cst.CstString)5 BitSet (java.util.BitSet)5 HashSet (java.util.HashSet)5 SourcePosition (com.taobao.android.dx.rop.code.SourcePosition)4 CstFieldRef (com.taobao.android.dx.rop.cst.CstFieldRef)4