scale.score.trans
Class ExprMap

java.lang.Object
  extended by scale.score.trans.ExprMap

public final class ExprMap
extends java.lang.Object

Map from an expression to another expression.

$Id: ExprMap.java,v 1.33 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.

This class is used solely by the value numbering optimization.

See Also:
ValNum

Constructor Summary
ExprMap(int capacity)
           
 
Method Summary
 Expr get(Expr key)
          Return the mapped value for the specified key.
 Expr getKey()
          Return the actual expression used as the key.
 ExprChord getUseDef()
          Return the ExprChord to use for the use-def link.
 boolean hasMultipleOccurrences()
          Return true if the expression has more than one occurrence.
 boolean insertCopyRequired()
          Return true if a copy into a temporary is required.
 Expr put(Expr key, Expr value, ExprChord ud, boolean insertCopy, Stack<java.lang.Object> hashedExprs)
          Place an entry in the map unless it is already there.
 void remove(Stack<java.lang.Object> hashedExprs)
          Remove the specified mapping.
 void setUseDef(ExprChord se)
          Set the ExprChord to use for the use-def link.
 void specifyMultipleOccurrences()
          Specify that the current entry has multiple occurrences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExprMap

public ExprMap(int capacity)
Parameters:
capacity - initial capacity - should be prime
Method Detail

put

public final Expr put(Expr key,
                      Expr value,
                      ExprChord ud,
                      boolean insertCopy,
                      Stack<java.lang.Object> hashedExprs)
Place an entry in the map unless it is already there. There can be only one tuple with this value. If the entry is created, push the key on the stack.

Parameters:
key - map from this expression
value - map to this expression
ud - use-def link
insertCopy - is true if a copy into a new temporary variable is needed
hashedExprs - is the set of expressions that are mapped
Returns:
the equivalent expression

specifyMultipleOccurrences

public void specifyMultipleOccurrences()
Specify that the current entry has multiple occurrences.


hasMultipleOccurrences

public boolean hasMultipleOccurrences()
Return true if the expression has more than one occurrence.


get

public final Expr get(Expr key)
Return the mapped value for the specified key. Return null if it is not found. Remember this entry so that it may be accessed directly.

See Also:
getUseDef(), setUseDef(scale.score.chords.ExprChord)

insertCopyRequired

public final boolean insertCopyRequired()
Return true if a copy into a temporary is required. Reset the switch so that false is returned the next time making this a one-time switch.


getUseDef

public final ExprChord getUseDef()
Return the ExprChord to use for the use-def link.


getKey

public final Expr getKey()
Return the actual expression used as the key.


setUseDef

public final void setUseDef(ExprChord se)
Set the ExprChord to use for the use-def link.


remove

public final void remove(Stack<java.lang.Object> hashedExprs)
Remove the specified mapping.