org.jikesrvm.compilers.opt
Class DefUse

java.lang.Object
  extended by org.jikesrvm.compilers.opt.DefUse

public final class DefUse
extends Object

This class computes du-lists and associated information.

Note: DU operands are stored on the USE lists, but not the DEF lists.


Nested Class Summary
private static class DefUse.RegOpListWalker
          Utility class to encapsulate walking a use/def list.
 
Field Summary
(package private) static boolean DEBUG
           
(package private) static boolean SUPRESS_DU_FOR_PHYSICALS
           
(package private) static boolean TRACE_DU_ACTIONS
           
 
Constructor Summary
DefUse()
           
 
Method Summary
static void clearDU(IR ir)
          Clear defList, useList for an IR.
static void computeDU(IR ir)
          Compute the register list and def-use lists for a method.
static Enumeration<RegisterOperand> defs(Register reg)
          Enumerate all operands that def a given register.
(package private) static boolean exactlyOneUse(Register reg)
          Does a given register have exactly one use?
private static void logAppearance(Register reg, int bbNum)
          Mark that we have seen a register in a particular basic block, and whether we saw a use
static void mergeRegisters(IR ir, Register reg1, Register reg2)
          Merge register reg2 into register reg1.
(package private) static void printDefs(Register reg)
          Print all the instructions that def a register.
(package private) static void printUses(Register reg)
          Print all the instructions that usea register.
static void recomputeSpansBasicBlock(IR ir)
          Recompute spansBasicBlock flags for all registers.
static void recomputeSSA(IR ir)
          Recompute isSSA for all registers by traversing register list.
static void recordDef(RegisterOperand regOp)
          Record a def of a register
static void recordDefUse(RegisterOperand regOp)
          Record a def/use of a register TODO: For now we just pretend this is a use!!!!
static void recordUse(RegisterOperand regOp)
          Record a use of a register
static void removeDef(RegisterOperand regOp)
          Record that a def of a register no longer applies
static void removeInstructionAndUpdateDU(Instruction s)
          Remove an instruction and update register lists.
static void removeUse(RegisterOperand regOp)
          Record that a use of a register no longer applies
static void replaceInstructionAndUpdateDU(Instruction oldI, Instruction newI)
          Replace an instruction and update register lists.
private static boolean seenInDifferentBlock(Register reg, int bbNum)
          Have we seen this register in a different basic block?
static void transferUse(RegisterOperand origRegOp, RegisterOperand newRegOp)
          This code changes the use in origRegOp to use the use in newRegOp.
static void updateDUForNewInstruction(Instruction s)
          Update register lists to account for the effect of a new instruction s
static Enumeration<RegisterOperand> uses(Register reg)
          Enumerate all operands that use a given register.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

static final boolean DEBUG
See Also:
Constant Field Values

TRACE_DU_ACTIONS

static final boolean TRACE_DU_ACTIONS
See Also:
Constant Field Values

SUPRESS_DU_FOR_PHYSICALS

static final boolean SUPRESS_DU_FOR_PHYSICALS
See Also:
Constant Field Values
Constructor Detail

DefUse

public DefUse()
Method Detail

clearDU

public static void clearDU(IR ir)
Clear defList, useList for an IR.

Parameters:
ir - the IR in question

computeDU

public static void computeDU(IR ir)
Compute the register list and def-use lists for a method.

Parameters:
ir - the IR in question

recordUse

public static void recordUse(RegisterOperand regOp)
Record a use of a register

Parameters:
regOp - the operand that uses the register

recordDefUse

public static void recordDefUse(RegisterOperand regOp)
Record a def/use of a register TODO: For now we just pretend this is a use!!!!

Parameters:
regOp - the operand that uses the register

recordDef

public static void recordDef(RegisterOperand regOp)
Record a def of a register

Parameters:
regOp - the operand that uses the register

removeUse

public static void removeUse(RegisterOperand regOp)
Record that a use of a register no longer applies

Parameters:
regOp - the operand that uses the register

removeDef

public static void removeDef(RegisterOperand regOp)
Record that a def of a register no longer applies

Parameters:
regOp - the operand that uses the register

transferUse

public static void transferUse(RegisterOperand origRegOp,
                               RegisterOperand newRegOp)
This code changes the use in origRegOp to use the use in newRegOp.

If the type of origRegOp is not a reference, but the type of newRegOp is a reference, we need to update origRegOp to be a reference. Otherwise, the GC map code will be incorrect. -- Mike Hind

Parameters:
origRegOp - the register operand to change
newRegOp - the register operand to use for the change

removeInstructionAndUpdateDU

public static void removeInstructionAndUpdateDU(Instruction s)
Remove an instruction and update register lists.


updateDUForNewInstruction

public static void updateDUForNewInstruction(Instruction s)
Update register lists to account for the effect of a new instruction s


replaceInstructionAndUpdateDU

public static void replaceInstructionAndUpdateDU(Instruction oldI,
                                                 Instruction newI)
Replace an instruction and update register lists.


uses

public static Enumeration<RegisterOperand> uses(Register reg)
Enumerate all operands that use a given register.


defs

public static Enumeration<RegisterOperand> defs(Register reg)
Enumerate all operands that def a given register.


exactlyOneUse

static boolean exactlyOneUse(Register reg)
Does a given register have exactly one use?


printDefs

static void printDefs(Register reg)
Print all the instructions that def a register.

Parameters:
reg -

printUses

static void printUses(Register reg)
Print all the instructions that usea register.

Parameters:
reg -

recomputeSSA

public static void recomputeSSA(IR ir)
Recompute isSSA for all registers by traversing register list. NOTE: the DU MUST be computed BEFORE calling this function

Parameters:
ir - the IR in question

mergeRegisters

public static void mergeRegisters(IR ir,
                                  Register reg1,
                                  Register reg2)
Merge register reg2 into register reg1. Remove reg2 from the DU information


recomputeSpansBasicBlock

public static void recomputeSpansBasicBlock(IR ir)
Recompute spansBasicBlock flags for all registers.

Parameters:
ir - the IR in question

logAppearance

private static void logAppearance(Register reg,
                                  int bbNum)
Mark that we have seen a register in a particular basic block, and whether we saw a use

Parameters:
reg - the register
bbNum - the number of the basic block

seenInDifferentBlock

private static boolean seenInDifferentBlock(Register reg,
                                            int bbNum)
Have we seen this register in a different basic block?

Parameters:
reg - the register
bbNum - the number of the basic block