FileDocCategorySizeDatePackage
NormalSsaInsn.javaAPI DocAndroid 5.1 API6617Thu Mar 12 22:18:30 GMT 2015com.android.dx.ssa

NormalSsaInsn

public final class NormalSsaInsn extends SsaInsn implements Cloneable
A "normal" (non-phi) instruction in SSA form. Always wraps a rop insn.

Fields Summary
private com.android.dx.rop.code.Insn
insn
{@code non-null;} rop insn that we're wrapping
Constructors Summary
NormalSsaInsn(com.android.dx.rop.code.Insn insn, SsaBasicBlock block)
Creates an instance.

param
insn Rop insn to wrap
param
block block that contains this insn

        super(insn.getResult(), block);
        this.insn = insn;
    
Methods Summary
public voidaccept(Visitor v)
{@inheritDoc}

        if (isNormalMoveInsn()) {
            v.visitMoveInsn(this);
        } else {
            v.visitNonMoveInsn(this);
        }
    
public booleancanThrow()
{@inheritDoc}

        return insn.canThrow();
    
public final voidchangeOneSource(int index, com.android.dx.rop.code.RegisterSpec newSpec)
Changes one of the insn's sources. New source should be of same type and category.

param
index {@code >=0;} index of source to change
param
newSpec spec for new source

        RegisterSpecList origSources = insn.getSources();
        int sz = origSources.size();
        RegisterSpecList newSources = new RegisterSpecList(sz);

        for (int i = 0; i < sz; i++) {
            newSources.set(i, i == index ? newSpec : origSources.get(i));
        }

        newSources.setImmutable();

        RegisterSpec origSpec = origSources.get(index);
        if (origSpec.getReg() != newSpec.getReg()) {
            /*
             * If the register remains unchanged, we're only changing
             * the type or local var name so don't update use list
             */
            getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
        }

        insn = insn.withNewRegisters(getResult(), newSources);
    
public com.android.dx.ssa.NormalSsaInsnclone()
{@inheritDoc}

        return (NormalSsaInsn) super.clone();
    
public com.android.dx.rop.code.RegisterSpecgetLocalAssignment()
{@inheritDoc}

        RegisterSpec assignment;

        if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) {
            assignment = insn.getSources().get(0);
        } else {
            assignment = getResult();
        }

        if (assignment == null) {
            return null;
        }

        LocalItem local = assignment.getLocalItem();

        if (local == null) {
            return null;
        }

        return assignment;
    
public com.android.dx.rop.code.RopgetOpcode()

return
the Rop opcode for this insn

        return insn.getOpcode();
    
public com.android.dx.rop.code.InsngetOriginalRopInsn()
{@inheritDoc}

        return insn;
    
public com.android.dx.rop.code.RegisterSpecListgetSources()
Like rop.Insn.getSources().

return
{@code null-ok;} sources list

        return insn.getSources();
    
public booleanhasSideEffect()
{@inheritDoc} TODO: Increase the scope of this.

        Rop opcode = getOpcode();

        if (opcode.getBranchingness() != Rop.BRANCH_NONE) {
            return true;
        }

        boolean hasLocalSideEffect
            = Optimizer.getPreserveLocals() && getLocalAssignment() != null;

        switch (opcode.getOpcode()) {
            case RegOps.MOVE_RESULT:
            case RegOps.MOVE:
            case RegOps.CONST:
                return hasLocalSideEffect;
            default:
                return true;
        }
    
public booleanisMoveException()
{@inheritDoc}

        return insn.getOpcode().getOpcode() == RegOps.MOVE_EXCEPTION;
    
public booleanisNormalMoveInsn()

return
true if this is a move (but not a move-operand) instruction

        return insn.getOpcode().getOpcode() == RegOps.MOVE;
    
public booleanisPhiOrMove()
{@inheritDoc}

        return isNormalMoveInsn();
    
public final voidmapSourceRegisters(RegisterMapper mapper)
{@inheritDoc}

        RegisterSpecList oldSources = insn.getSources();
        RegisterSpecList newSources = mapper.map(oldSources);

        if (newSources != oldSources) {
            insn = insn.withNewRegisters(getResult(), newSources);
            getBlock().getParent().onSourcesChanged(this, oldSources);
        }
    
public final voidsetNewSources(com.android.dx.rop.code.RegisterSpecList newSources)
Changes the source list of the insn. New source list should be the same size and consist of sources of identical types.

param
newSources non-null new sources list.

        RegisterSpecList origSources = insn.getSources();

        if (origSources.size() != newSources.size()) {
            throw new RuntimeException("Sources counts don't match");
        }

        insn = insn.withNewRegisters(getResult(), newSources);
    
public java.lang.StringtoHuman()
{@inheritDoc}

        return toRopInsn().toHuman();
    
public com.android.dx.rop.code.InsntoRopInsn()
{@inheritDoc}

        return insn.withNewRegisters(getResult(), insn.getSources());
    
public voidupgradeToLiteral()
Upgrades this insn to a version that represents the constant source literally. If the upgrade is not possible, this does nothing.

see
Insn#withSourceLiteral

        RegisterSpecList oldSources = insn.getSources();

        insn = insn.withSourceLiteral();
        getBlock().getParent().onSourcesChanged(this, oldSources);