Class InductionVarAnalyzer


  • public class InductionVarAnalyzer
    extends java.lang.Object
    InductionVarAnalyzer traverses a control flow graph and looks for array element swizzle operations inside loops. If possible, these swizzle operations are hoisted out of the loop and are replaced with range swizzle operations. The technique used is Demand-driven Induction Variable Analysis (DIVA).

    To accomplish its tasks, InductionVarAnalyzer keeps track of a number of induction variables (represented by Swizzler objects) and local variables.

    See Also:
    Swizzler, LocalExpr
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DEBUG  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void Display_store()
      Displays (to System.out) all of the Swizzlers stored in the induction variable store.
      void displaySwizzler​(Swizzler indswz)
      Displays the contents of a Swizzler object to System.out.
      MemExpr get_local​(int vn)
      Searchs the stored list of local variables for a local variable with a given value number.
      java.lang.Object get_swizzler​(int vn)
      Searches the list of induction variables for an induction variable with a given value number.
      void insert_aswrange​(Swizzler indswz)
      Adds a swizzle range statement (SRStmt) to the end of each predacessor block of the block containing the phi statement that defines an induction variable provided that the phi block does not dominate its predacessor.
      Block isMu​(PhiJoinStmt phi, FlowGraph cfg)
      Determines whether or not a phi statement is a mu function.
      void transform​(FlowGraph cfg)
      Performs DIVA on a CFG.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEBUG

        public static boolean DEBUG
    • Constructor Detail

      • InductionVarAnalyzer

        public InductionVarAnalyzer()
    • Method Detail

      • get_swizzler

        public java.lang.Object get_swizzler​(int vn)
        Searches the list of induction variables for an induction variable with a given value number.
        Parameters:
        vn - Value number to search for.
        Returns:
        Swizzler object whose target has the desired value number or null, if value number is not found.
      • get_local

        public MemExpr get_local​(int vn)
        Searchs the stored list of local variables for a local variable with a given value number.
        Parameters:
        vn - The value number to search for.
        Returns:
        The local variable with the given value number, or null, if not found.
      • Display_store

        public void Display_store()
        Displays (to System.out) all of the Swizzlers stored in the induction variable store.
        See Also:
        Swizzler
      • displaySwizzler

        public void displaySwizzler​(Swizzler indswz)
        Displays the contents of a Swizzler object to System.out.
        Parameters:
        indswz - The Swizzler to display.
      • insert_aswrange

        public void insert_aswrange​(Swizzler indswz)
        Adds a swizzle range statement (SRStmt) to the end of each predacessor block of the block containing the phi statement that defines an induction variable provided that the phi block does not dominate its predacessor. Phew.
        Parameters:
        indswz - Swizzler representing the induction variable on which the range swizzle statement is added.
      • isMu

        public Block isMu​(PhiJoinStmt phi,
                          FlowGraph cfg)
        Determines whether or not a phi statement is a mu function. A mu function is a phi function that merges values at loop headers, as opposed to those that occur as a result of forward branching. Mu functions always have two arguments.
        Parameters:
        phi - phi statement that may be a mu function
        cfg - CFG to look through Get rid of this parameter
        Returns:
        The block containing the mu functions external (that is, outside the loop) argument, also known as the external ssalink. If the phi statement is not a mu function, null is returned.
      • transform

        public void transform​(FlowGraph cfg)
        Performs DIVA on a CFG.