|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.score.trans.Optimization scale.score.trans.GlobalVarReplacement
public class GlobalVarReplacement
This class replaces references to global variables with references to local variables.
$Id: GlobalVarReplacement.java,v 1.62 2007-10-04 19:58:35 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
An attempt is made to put the first load of the global variable outside of the loop. This optimization must be performed outside of SSA form because
In the following algorithm the relation "dominated by" means those nodes in the iterative dominance domain. The iterative dominance domain terminates at calls to subroutines.
For each global variable g Obtain set uses of the uses of g Pushd CFG start node on stack wl While set uses is not empty firstNode = null insertNode = null while stack wl is not empty sNode = pop(wl) push children of sNode on wl if sNode is a loop header and all exits of the loop are dominated by sNode insert = sNode if sNode is in set uses firstNode = sNode end while stack wl if firstNode == null exit while set uses if insertNode == null insertNode = firstNode else if firstNode is not dominated by the loop header insertNode insert = first Insert a load of the global variable into a temporary variable before insertNode Replace references to g in firstNode with references to the temporary Change all references to g in the nodes specified by uses that are dominated by firstNode remove firstNode from set uses Change all defs of g in the nodes specified by defs that are dominated by firstNode to def both the temporary and the global variable End while set uses End for each global variable g
Register pressure is always increased because a new variable is introduced that has a live range that is always greater than the live range of the reference to the gloabl variable it represents.
A transformation is legal
if:
volatile
,
beneficial
if:
Field Summary | |
---|---|
static boolean |
classTrace
True if traces are to be performed. |
static boolean |
useHeuristics
If true, use heuristics that prune the cases where the optimization is applied. |
Fields inherited from class scale.score.trans.Optimization |
---|
dChanged, fpReorder, hasDummyAliases, IN_SSA, minimumExecutionCost, NA_SSA, NO_SSA, rChanged, scribble, signedIntsWrapOnOverflow, trace, un, unsafe, unsignedIntsWrapOnOverflow, VALID_SSA |
Constructor Summary | |
---|---|
GlobalVarReplacement(Scribble scribble)
|
Method Summary | |
---|---|
static int |
newCFGNodes()
Return the number of new nodes created. |
static int |
outOfLoops()
Return the current number of loads placed outside of loops. |
void |
perform()
Perform the optimization. |
static int |
replacedLoads()
Return the current number of array loads replaced. |
int |
requiresSSA()
Specify that this optimization requires that the CFG NOT be in SSA form. |
Methods inherited from class scale.score.trans.Optimization |
---|
assertTrace, assertTrace, assertTrace, assertTrace, assertTrace, genTemp, insertStores, setTrace, sort |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean classTrace
public static boolean useHeuristics
Constructor Detail |
---|
public GlobalVarReplacement(Scribble scribble)
Method Detail |
---|
public static int replacedLoads()
public static int outOfLoops()
public static int newCFGNodes()
public void perform()
Optimization
Scribble
class provides methods that may be used to sepcify this
information.
perform
in class Optimization
public int requiresSSA()
requiresSSA
in class Optimization
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |