FileDocCategorySizeDatePackage
HighRegisterPrefix.javaAPI DocAndroid 5.1 API4333Thu Mar 12 22:18:30 GMT 2015com.android.dx.dex.code

HighRegisterPrefix

public final class HighRegisterPrefix extends VariableSizeInsn
Combination instruction which turns into a variable number of {@code move*} instructions to move a set of registers into registers starting at {@code 0} sequentially. This is used in translating an instruction whose register requirements cannot be met using a straightforward choice of a single opcode.

Fields Summary
private SimpleInsn[]
insns
{@code null-ok;} cached instructions, if constructed
Constructors Summary
public HighRegisterPrefix(com.android.dx.rop.code.SourcePosition position, com.android.dx.rop.code.RegisterSpecList registers)
Constructs an instance. The output address of this instance is initially unknown ({@code -1}).

param
position {@code non-null;} source position
param
registers {@code non-null;} source registers

        super(position, registers);

        if (registers.size() == 0) {
            throw new IllegalArgumentException("registers.size() == 0");
        }

        insns = null;
    
Methods Summary
protected java.lang.StringargString()
{@inheritDoc}

        return null;
    
private voidcalculateInsnsIfNecessary()
Helper for {@link #codeSize} and {@link #writeTo} which sets up {@link #insns} if not already done.

        if (insns != null) {
            return;
        }

        RegisterSpecList registers = getRegisters();
        int sz = registers.size();

        insns = new SimpleInsn[sz];

        for (int i = 0, outAt = 0; i < sz; i++) {
          RegisterSpec src = registers.get(i);
          insns[i] = moveInsnFor(src, outAt);
          outAt += src.getCategory();
        }
    
public intcodeSize()
{@inheritDoc}

        int result = 0;

        calculateInsnsIfNecessary();

        for (SimpleInsn insn : insns) {
            result += insn.codeSize();
        }

        return result;
    
protected java.lang.StringlistingString0(boolean noteIndices)
{@inheritDoc}

        RegisterSpecList registers = getRegisters();
        int sz = registers.size();
        StringBuffer sb = new StringBuffer(100);

        for (int i = 0, outAt = 0; i < sz; i++) {
            RegisterSpec src = registers.get(i);
            SimpleInsn insn = moveInsnFor(src, outAt);

            if (i != 0) {
                sb.append('\n");
            }

            sb.append(insn.listingString0(noteIndices));

            outAt += src.getCategory();
        }

        return sb.toString();
    
private static SimpleInsnmoveInsnFor(com.android.dx.rop.code.RegisterSpec src, int destIndex)
Returns the proper move instruction for the given source spec and destination index.

param
src {@code non-null;} the source register spec
param
destIndex {@code >= 0;} the destination register index
return
{@code non-null;} the appropriate move instruction

        return DalvInsn.makeMove(SourcePosition.NO_INFO,
                RegisterSpec.make(destIndex, src.getType()),
                src);
    
public DalvInsnwithRegisters(com.android.dx.rop.code.RegisterSpecList registers)
{@inheritDoc}

        return new HighRegisterPrefix(getPosition(), registers);
    
public voidwriteTo(com.android.dx.util.AnnotatedOutput out)
{@inheritDoc}

        calculateInsnsIfNecessary();

        for (SimpleInsn insn : insns) {
            insn.writeTo(out);
        }