scale.frontend.fortran
Class EquivSet

java.lang.Object
  extended by scale.frontend.fortran.EquivSet

public final class EquivSet
extends java.lang.Object

This class tracks equivalence sets.

$Id: EquivSet.java,v 1.4 2007-03-21 13:32:06 burrill Exp $

Copyright 2006 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

An equivalence set specifies that all variables in the set share the same memory location at some offset in each variable when the variables are mapped to memory.


Constructor Summary
EquivSet(EquivSet prev)
          Create a new equivalence set and link it to the previous sets to form a linked list of sets.
 
Method Summary
 void addEntry(VariableDecl decl, long offset)
          Add the variable to this equivalence set.
 VariableDecl getBaseVariable()
          If any of the variables in the equivalence set are in COMMON, return the COMON variable or null if none.
 VariableDecl getDecl(int i)
          Return the specified variable in the set.
 int getIndexLargestOffset()
          Return the index of the equivalenced variable to use as the base.
 long getOffset(int i)
          Return the offset of the specified variable in the set.
 EquivSet getPrevious()
          Return the next set in the linked list.
 int numInSet()
          Return the number of variables in the set.
 java.lang.String toString()
           
 void update(VariableDecl decl, EquivalenceDecl ev)
          Replace a variable instance with an equivalence variable instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EquivSet

public EquivSet(EquivSet prev)
Create a new equivalence set and link it to the previous sets to form a linked list of sets.

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getPrevious

public EquivSet getPrevious()
Return the next set in the linked list.


getBaseVariable

public VariableDecl getBaseVariable()
If any of the variables in the equivalence set are in COMMON, return the COMON variable or null if none.


numInSet

public int numInSet()
Return the number of variables in the set.


getDecl

public VariableDecl getDecl(int i)
Return the specified variable in the set.


getOffset

public long getOffset(int i)
Return the offset of the specified variable in the set.


getIndexLargestOffset

public int getIndexLargestOffset()
Return the index of the equivalenced variable to use as the base.


update

public void update(VariableDecl decl,
                   EquivalenceDecl ev)
            throws InvalidException
Replace a variable instance with an equivalence variable instance.

Throws:
InvalidException

addEntry

public void addEntry(VariableDecl decl,
                     long offset)
              throws InvalidException
Add the variable to this equivalence set. If the variable appears in another equivalence set, attempt to merge that set into this one. A set cannot be merged if it would result in two locations in a variable mapping to the same place. A set cannot be merged if it contains a variable that is in another COMMON area.

Parameters:
decl - is the variable
offset - is the offset in the variable of the equivalence point
Throws:
InvalidException - if two sets can not be merged