harpoon.Analysis.Instr
Class EqTempSets

java.lang.Object
  extended by harpoon.Analysis.Instr.EqTempSets
All Implemented Interfaces:
TempMap

public abstract class EqTempSets
extends Object
implements TempMap

EqTempSets tracks a set of disjoint set of temps, and potentially associates each set with a favored register temp (which itself is not part of the set)

Overview: an EqTempSets is a pair <S,M>, where

Each element of S is represented by one of its members, called the Representative (or Rep for short).

Version:
$Id: EqTempSets.java,v 1.6 2004/02/08 01:52:07 cananian Exp $
Author:
Felix S. Klock II <pnkfelix@mit.edu>

Field Summary
protected  RegAlloc ra
           
protected  HashMap repToReg
           
 
Constructor Summary
EqTempSets()
           
 
Method Summary
 void add(Temp t1, Temp t2)
          Adds an equivalency between t1 and t2 to this.
 void associate(Temp t, Temp reg)
          Associates t with reg.
 Temp getReg(Temp t)
          Returns the register temp associated with t.
abstract  Temp getRep(Temp t)
          Returns the rep for t.
static EqTempSets make(RegAlloc ra, boolean printable)
          Constructs and returns a new EqTempSets.
 Temp tempMap(Temp t)
          Rename a single Temp.
protected abstract  void union(Temp t1, Temp t2)
          Unifies t1 and t2.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ra

protected RegAlloc ra

repToReg

protected HashMap repToReg
Constructor Detail

EqTempSets

public EqTempSets()
Method Detail

make

public static EqTempSets make(RegAlloc ra,
                              boolean printable)
Constructs and returns a new EqTempSets. The returned EqTempSets will have a usable toString() method (but have less efficent operation) if the printable argument is true.


associate

public void associate(Temp t,
                      Temp reg)
Associates t with reg. effects: M_post = { getRep( `t' ) -> `reg' } + M


getReg

public Temp getReg(Temp t)
Returns the register temp associated with t. effects: if `t' is a register temp, returns `t'. else if the set for `t' has an register `r', returns `r' else returns null


tempMap

public Temp tempMap(Temp t)
Description copied from interface: TempMap
Rename a single Temp.

Specified by:
tempMap in interface TempMap

add

public void add(Temp t1,
                Temp t2)
Adds an equivalency between t1 and t2 to this. requires: t1 or t2 is not a register modifies: this effects: puts t1 and t2 in the same equivalence class, unifying all the temps in the two equivalence classes for t1 and t2 unless: - one of the temps is a register and the equivalence set for the other temp already has a register => no modification to this


getRep

public abstract Temp getRep(Temp t)
Returns the rep for t. effects: if `t' is not a register, returns the set-rep for the set containing `t'. If `t' is a register, returns `t'.


union

protected abstract void union(Temp t1,
                              Temp t2)
Unifies t1 and t2. requires: t1 and t2 are not registers modifies: this effects: unifies the equivalence classes for t1 and t2, removing the old equivalence sets and creating a new one whose rep is either t1 or t2.