Class SsaRenamer

java.lang.Object
com.android.dx.ssa.SsaRenamer
All Implemented Interfaces:
Runnable

public class SsaRenamer extends Object implements Runnable
Complete transformation to SSA form by renaming all registers accessed.

See Appel algorithm 19.7

Unlike the original algorithm presented in Appel, this renamer converts to a new flat (versionless) register space. The "version 0" registers, which represent the initial state of the Rop registers and should never actually be meaningfully accessed in a legal program, are represented as the first N registers in the SSA namespace. Subsequent assignments are assigned new unique names. Note that the incoming Rop representation has a concept of register widths, where 64-bit values are stored into two adjoining Rop registers. This adjoining register representation is ignored in SSA form conversion and while in SSA form, each register can be e either 32 or 64 bits wide depending on use. The adjoining-register represention is re-created later when converting back to Rop form.

But, please note, the SSA Renamer's ignoring of the adjoining-register ROP representation means that unaligned accesses to 64-bit registers are not supported. For example, you cannot do a 32-bit operation on a portion of a 64-bit register. This will never be observed to happen when coming from Java code, of course.

The implementation here, rather than keeping a single register version stack for the entire method as the dom tree is walked, instead keeps a mapping table for the current block being processed. Once the current block has been processed, this mapping table is then copied and used as the initial state for child blocks.

  • Constructor Details

    • SsaRenamer

      public SsaRenamer(SsaMethod ssaMeth)
      Constructs an instance of the renamer
      Parameters:
      ssaMeth - non-null; un-renamed SSA method that will be renamed.
    • SsaRenamer

      public SsaRenamer(SsaMethod ssaMeth, int thresh)
      Constructs an instance of the renamer with threshold set
      Parameters:
      ssaMeth - non-null; un-renamed SSA method that will be renamed.
      thresh - registers below this number are unchanged
  • Method Details

    • run

      public void run()
      Performs renaming transformation, modifying the method's instructions in-place.
      Specified by:
      run in interface Runnable