FileDocCategorySizeDatePackage
NormalSsaInsn.javaAPI DocAndroid 1.5 API6352Wed May 06 22:41:02 BST 2009com.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 Insn
insn
ROP insn that we're wrapping
Constructors Summary
NormalSsaInsn(Insn insn, SsaBasicBlock block)
Creates an instance.

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

        super(block);
        this.insn = insn;
        this.result = insn.getResult();
    
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, RegisterSpec newSpec)
Changes one of the insn's sources. New source should be of same type and category.

param
index >=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
             */
            block.getParent().onSourceChanged(this, origSpec, newSpec);
        }

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

        return (NormalSsaInsn)super.clone();
    
public RegisterSpecgetLocalAssignment()
{@inheritDoc}

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

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

        LocalItem local = assignment.getLocalItem();

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

        return assignment;
    
public RopgetOpcode()

return
the Rop opcode for this insn

        return insn.getOpcode();
    
public InsngetOriginalRopInsn()
{@inheritDoc}

        return insn;
    
public RegisterSpecListgetSources()
Like rop.Insn.getSources()

return
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(result, newSources);
            block.getParent().onSourcesChanged(this, oldSources);
        }
    
public final voidsetNewSources(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(result, newSources);
    
public java.lang.StringtoHuman()
{@inheritDoc}

        return toRopInsn().toHuman();
    
public InsntoRopInsn()
{@inheritDoc}

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

see
Insn#withLastSourceLiteral

        RegisterSpecList oldSources = insn.getSources();
        insn = insn.withLastSourceLiteral();
        block.getParent().onSourcesChanged(this, oldSources);