public final class LoadElimination extends OptimizationPlanCompositeElement
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
LoadElimination.GVNPreparation
This class sets up the IR state prior to entering SSA for GVN. 
 | 
static class  | 
LoadElimination.LoadEliminationPreparation
This class sets up the IR state prior to entering SSA for load
 elimination 
 | 
(package private) static class  | 
LoadElimination.LoadEliminator  | 
(package private) static class  | 
LoadElimination.UseRecord  | 
(package private) static class  | 
LoadElimination.UseRecordSet  | 
| Modifier and Type | Field and Description | 
|---|---|
(package private) static boolean | 
DEBUG  | 
private int | 
round
which round of load elimination is this? 
 | 
| Constructor and Description | 
|---|
LoadElimination(int round)  | 
| Modifier and Type | Method and Description | 
|---|---|
(package private) static void | 
appendMove(Register r,
          Operand src,
          Instruction store)
Append a move instruction after a store instruction that caches
 value in register r. 
 | 
(package private) static boolean | 
eliminateLoads(IR ir,
              DF_Solution available)
Eliminates redundant loads with respect to prior defs and prior
 uses. 
 | 
private static <T> HashSet<T> | 
findOrCreateIndexSet(HashMap<Object,HashSet<T>> map,
                    Object key)  | 
(package private) static Register | 
findOrCreateRegister(Object heapType,
                    int valueNumber,
                    HashMap<LoadElimination.UseRecord,Register> registers,
                    GenericRegisterPool pool,
                    TypeReference type)
Given a value number, return the temporary register allocated
 for that value number. 
 | 
(package private) static Register | 
findOrCreateRegister(Object heapType,
                    int v1,
                    int v2,
                    HashMap<LoadElimination.UseRecord,Register> registers,
                    GenericRegisterPool pool,
                    TypeReference type)
Given a pair of value numbers, return the temporary register
 allocated for that pair. 
 | 
static HashSet<Object> | 
getCandidates(IR ir)
Do a quick pass over the IR, and return types that are candidates
 for redundant load elimination. 
 | 
String | 
getName()  | 
(package private) static void | 
replaceDefs(IR ir,
           LoadElimination.UseRecordSet UseRepSet,
           HashMap<LoadElimination.UseRecord,Register> registers)
Perform scalar replacement actions for a Def of a heap variable. 
 | 
(package private) static LoadElimination.UseRecordSet | 
replaceLoads(IR ir,
            DF_Solution available,
            HashMap<LoadElimination.UseRecord,Register> registers)
Walk over each instruction. 
 | 
(package private) static void | 
replaceLoadWithMove(Register r,
                   Instruction load)
Replace a Load instruction s with a load from a scalar register r
 
 TODO: factor this functionality out elsewhere 
 | 
boolean | 
shouldPerform(OptOptions options)
Determine, possibly by consulting the passed options object,
 if this optimization plan element should be performed. 
 | 
compose, elapsedTime, initializeForMeasureCompilation, perform, printingEnabled, reportStatsprettyPrintTimestatic final boolean DEBUG
private final int round
public LoadElimination(int round)
round - which round of load elimination is this?public boolean shouldPerform(OptOptions options)
OptimizationPlanElementshouldPerform in class OptimizationPlanCompositeElementoptions - The Options object for the current compilation.true if the plan element should be performed.public String getName()
getName in class OptimizationPlanCompositeElementstatic boolean eliminateLoads(IR ir, DF_Solution available)
ir - the governing IRavailable - results of index propagation analysistrue if any load is eliminated.static LoadElimination.UseRecordSet replaceLoads(IR ir, DF_Solution available, HashMap<LoadElimination.UseRecord,Register> registers)
POSTCONDITION: sets up the mapping 'registers' from value number to temporary register
ir - the IRavailable - information on which values are availableregisters - a place to store information about temp registersstatic void replaceLoadWithMove(Register r, Instruction load)
TODO: factor this functionality out elsewhere
r - the register to load fromload - the load instructionstatic void replaceDefs(IR ir, LoadElimination.UseRecordSet UseRepSet, HashMap<LoadElimination.UseRecord,Register> registers)
NOTE: Even loads can def a heap variable.
ir - the governing IRUseRepSet - stores the uses(loads) that have been eliminatedregisters - mapping from valueNumber -> temporary registerstatic void appendMove(Register r, Operand src, Instruction store)
r - move targetsrc - move sourcestore - the instruction after which the move will be insertedstatic Register findOrCreateRegister(Object heapType, int valueNumber, HashMap<LoadElimination.UseRecord,Register> registers, GenericRegisterPool pool, TypeReference type)
heapType - a TypeReference or RVMField identifying the array SSA
                    heap typevalueNumber - the value numberregisters - a mapping from value number to temporary registerpool - register pool to allocate new temporaries fromtype - the type to store in the new registerstatic Register findOrCreateRegister(Object heapType, int v1, int v2, HashMap<LoadElimination.UseRecord,Register> registers, GenericRegisterPool pool, TypeReference type)
heapType - a TypeReference identifying the array SSA
                    heap typev1 - first value numberv2 - second value numberregisters - a mapping from value number to temporary registerpool - register pool to allocate new temporaries fromtype - the type to store in the new registerprivate static <T> HashSet<T> findOrCreateIndexSet(HashMap<Object,HashSet<T>> map, Object key)
T - the type for the collection returned as value in the mappingmap - a mapping from key to HashSetkey - a key into the mappublic static HashSet<Object> getCandidates(IR ir)
Algorithm: return those types T where
The result contains objects of type RVMField and TypeReference, whose narrowest common ancestor is Object.
ir - the governing IR