Class PhiInsn

java.lang.Object
com.android.dx.ssa.SsaInsn
com.android.dx.ssa.PhiInsn
All Implemented Interfaces:
ToHuman, Cloneable

public final class PhiInsn extends SsaInsn
A Phi instruction (magical post-control-flow-merge) instruction in SSA form. Will be converted to moves in predecessor blocks before conversion back to ROP form.
  • Constructor Details

    • PhiInsn

      public PhiInsn(RegisterSpec resultReg, SsaBasicBlock block)
      Constructs a new phi insn with no operands.
      Parameters:
      resultReg - the result reg for this phi insn
      block - block containing this insn.
    • PhiInsn

      public PhiInsn(int resultReg, SsaBasicBlock block)
      Makes a phi insn with a void result type.
      Parameters:
      resultReg - the result register for this phi insn.
      block - block containing this insn.
  • Method Details

    • clone

      public PhiInsn clone()
      Overrides:
      clone in class SsaInsn
    • updateSourcesToDefinitions

      public void updateSourcesToDefinitions(SsaMethod ssaMeth)
      Updates the TypeBearers of all the sources (phi operands) to be the current TypeBearer of the register-defining instruction's result. This is used during phi-type resolution.

      Note that local association of operands are preserved in this step.

      Parameters:
      ssaMeth - method that contains this insn
    • changeResultType

      public void changeResultType(TypeBearer type, LocalItem local)
      Changes the result type. Used during phi type resolution
      Parameters:
      type - non-null; new TypeBearer
      local - null-ok; new local info, if available
    • getRopResultReg

      public int getRopResultReg()
      Gets the original rop-form result reg. This is useful during renaming.
      Returns:
      the original rop-form result reg
    • addPhiOperand

      public void addPhiOperand(RegisterSpec registerSpec, SsaBasicBlock predBlock)
      Adds an operand to this phi instruction.
      Parameters:
      registerSpec - register spec, including type and reg of operand
      predBlock - predecessor block to be associated with this operand
    • removePhiRegister

      public void removePhiRegister(RegisterSpec registerSpec)
      Removes all operand uses of a register from this phi instruction.
      Parameters:
      registerSpec - register spec, including type and reg of operand
    • predBlockIndexForSourcesIndex

      public int predBlockIndexForSourcesIndex(int sourcesIndex)
      Gets the index of the pred block associated with the RegisterSpec at the particular getSources() index.
      Parameters:
      sourcesIndex - index of source in getSources()
      Returns:
      block index
    • getOpcode

      public Rop getOpcode()
      Returns the Rop opcode for this insn, or null if this is a phi insn. TODO: Move this up into NormalSsaInsn. Always returns null for PhiInsns.
      Specified by:
      getOpcode in class SsaInsn
      Returns:
      null-ok; Rop opcode if there is one.
    • getOriginalRopInsn

      public Insn getOriginalRopInsn()
      Returns the original Rop insn for this insn, or null if this is a phi insn. TODO: Move this up into NormalSsaInsn. Always returns null for PhiInsns.
      Specified by:
      getOriginalRopInsn in class SsaInsn
      Returns:
      null-ok; Rop insn if there is one.
    • canThrow

      public boolean canThrow()
      Always returns false for PhiInsns.
      Specified by:
      canThrow in class SsaInsn
      Returns:
      true if this instruction can throw.
    • getSources

      public RegisterSpecList getSources()
      Gets sources. Constructed lazily from phi operand data structures and then cached.
      Specified by:
      getSources in class SsaInsn
      Returns:
      non-null; sources list
    • isRegASource

      public boolean isRegASource(int reg)
      Indicates whether the specified register is amongst the registers used as sources for this instruction.
      Overrides:
      isRegASource in class SsaInsn
      Parameters:
      reg - the register in question
      Returns:
      true if the reg is a source
    • areAllOperandsEqual

      public boolean areAllOperandsEqual()
      Returns:
      true if all operands use the same register
    • mapSourceRegisters

      public final void mapSourceRegisters(RegisterMapper mapper)
      Maps only source registers.
      Specified by:
      mapSourceRegisters in class SsaInsn
      Parameters:
      mapper - new mapping
    • toRopInsn

      public Insn toRopInsn()
      Always throws an exeption, since a phi insn may not be converted back to rop form.
      Specified by:
      toRopInsn in class SsaInsn
      Returns:
      always throws exception
    • predBlocksForReg

      public List<SsaBasicBlock> predBlocksForReg(int reg, SsaMethod ssaMeth)
      Returns the list of predecessor blocks associated with all operands that have reg as an operand register.
      Parameters:
      reg - register to look up
      ssaMeth - method we're operating on
      Returns:
      list of predecessor blocks, empty if none
    • isPhiOrMove

      public boolean isPhiOrMove()
      Specified by:
      isPhiOrMove in class SsaInsn
      Returns:
      true if this is a PhiInsn or a normal move insn
    • hasSideEffect

      public boolean hasSideEffect()
      Returns true if this insn is considered to have a side effect beyond that of assigning to the result reg.
      Specified by:
      hasSideEffect in class SsaInsn
      Returns:
      true if this insn is considered to have a side effect beyond that of assigning to the result reg.
    • accept

      public void accept(SsaInsn.Visitor v)
      Accepts a visitor.
      Specified by:
      accept in class SsaInsn
      Parameters:
      v - non-null the visitor
    • toHuman

      public String toHuman()
      Return the "human" string form of this instance. This is generally less "debuggy" than toString().
      Returns:
      non-null; the human string form
    • toHumanWithInline

      protected final String toHumanWithInline(String extra)
      Returns human-readable string for listing dumps. This method allows sub-classes to specify extra text.
      Parameters:
      extra - null-ok; the argument to print after the opcode
      Returns:
      human-readable string for listing dumps