FileDocCategorySizeDatePackage
Form12x.javaAPI DocAndroid 5.1 API4697Thu Mar 12 22:18:30 GMT 2015com.android.dx.dex.code.form

Form12x

public final class Form12x extends com.android.dx.dex.code.InsnFormat
Instruction format {@code 12x}. See the instruction format spec for details.

Fields Summary
public static final com.android.dx.dex.code.InsnFormat
THE_ONE
{@code non-null;} unique instance of this class
Constructors Summary
private Form12x()
Constructs an instance. This class is not publicly instantiable. Use {@link #THE_ONE}.


                     
      
        // This space intentionally left blank.
    
Methods Summary
public intcodeSize()
{@inheritDoc}

        return 1;
    
public java.util.BitSetcompatibleRegs(com.android.dx.dex.code.DalvInsn insn)
{@inheritDoc}

        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;
    
public java.lang.StringinsnArgString(com.android.dx.dex.code.DalvInsn insn)
{@inheritDoc}

        RegisterSpecList regs = insn.getRegisters();
        int sz = regs.size();

        /*
         * The (sz - 2) and (sz - 1) below makes this code work for
         * both the two- and three-register ops. (See "case 3" in
         * isCompatible(), below.)
         */

        return regs.get(sz - 2).regString() + ", " +
            regs.get(sz - 1).regString();
    
public java.lang.StringinsnCommentString(com.android.dx.dex.code.DalvInsn insn, boolean noteIndices)
{@inheritDoc}

        // This format has no comment.
        return "";
    
public booleanisCompatible(com.android.dx.dex.code.DalvInsn insn)
{@inheritDoc}

        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());
    
public voidwriteTo(com.android.dx.util.AnnotatedOutput out, com.android.dx.dex.code.DalvInsn insn)
{@inheritDoc}

        RegisterSpecList regs = insn.getRegisters();
        int sz = regs.size();

        /*
         * The (sz - 2) and (sz - 1) below makes this code work for
         * both the two- and three-register ops. (See "case 3" in
         * isCompatible(), above.)
         */

        write(out, opcodeUnit(insn,
                              makeByte(regs.get(sz - 2).getReg(),
                                       regs.get(sz - 1).getReg())));