scale.clef.decl
Class EquivalenceDecl

java.lang.Object
  extended by scale.common.Root
      extended by scale.clef.Node
          extended by scale.clef.decl.Declaration
              extended by scale.clef.decl.ValueDecl
                  extended by scale.clef.decl.VariableDecl
                      extended by scale.clef.decl.EquivalenceDecl
All Implemented Interfaces:
java.lang.Comparable, AnnotationInterface, DisplayNode

public final class EquivalenceDecl
extends VariableDecl

This class declares a variable that is equivalenced to an offset in another variable.

$Id: EquivalenceDecl.java,v 1.39 2007-10-04 19:58:04 burrill Exp $

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

This class declares a variable that is equivalenced to an offset in another variable. An equivalence relationship is generated for Fortran EQUIVALENCE statements and COMMON statements. For the statement

 EQUIVALENCE A, B
 
the base variable would be A with a offset of zero. For the statement
 EQUIVALENCE A(20), B
 
the base variable would be A with a offset of 20*sizeof(double).

Note - an EquivalenceDecl specifies an implied equivalence for COMMON variables.


Field Summary
 
Fields inherited from class scale.clef.decl.VariableDecl
ignoreAddressTaken
 
Constructor Summary
EquivalenceDecl(java.lang.String name, Type type, VariableDecl base, long offset)
           
 
Method Summary
 Declaration copy(java.lang.String name)
          Make a copy of this VariableDecl using a new name.
 long getBaseOffset()
          Return the offset from the base (i.e.
 VariableDecl getBaseVariable()
          Return the base variable (i.e.
 Node getChild(int i)
          Return the specified AST child of this node.
 Literal getConstantValue()
          Return the constant value of the expression.
 Assigned getStorageLoc()
          Return the location type used for this declaration.
 boolean hasHiddenAliases()
          Return true if the declaration may be modified in an unknown way.
 boolean inMemory()
          Return true if this declaration is to be allocated to memory.
 boolean isEquivalenceDecl()
          Return true if the declaration is a variable in Fortran COMMON.
 boolean isGlobal()
          Return true if this declaration is globally visible.
 int numChildren()
          Return the number of AST children of this node.
 Residency residency()
          Return the declaration residency.
 EquivalenceDecl returnEquivalenceDecl()
          Return a EquivalenceDecl instance or null.
 void setBaseOffset(long offset)
          Specify the offset from the base variable that this variable is equivalenced to.
 void setBaseVariable(VariableDecl base)
          Specify the base variable that this variable is equivalenced to.
 void setResidency(Residency residency)
          Generate an error - residency is specified only for the base VariableDecl.
 void setVisibility(int visibility)
          Generate an error - visibility is specified only for the base variable.
 Visibility visibility()
          Return the declaration visibility.
 void visit(Predicate p)
          Process a node by calling its associated routine.
 
Methods inherited from class scale.clef.decl.VariableDecl
addressTaken, computeAttributes, declareFtnResultVar, getAddressRegister, getDisplacement, getInitialValue, getOriginal, getValueRegister, hasHiddenPtrAliases, hasInvalidArrayReferences, isCommonBaseVar, isCommonBaseVariable, isConst, isFtnResultVar, isNotAliasCandidate, isNotSSACandidate, isReferenced, isRestricted, isStatic, isStorageLocSet, isTemporary, isVariableDecl, isVolatile, optimizationCandidate, returnVariableDecl, setAddressRegister, setAddressTaken, setDisplacement, setHiddenAliases, setHiddenPtrAliases, setInitialValue, setInvalidArrayReferences, setReferenced, setStorageLoc, setTemporary, setType, setValue, setValueRegister, setVisibility, shouldBeInRegister, specifyCommonBaseVariable, toStringSpecial, valueRegMode
 
Methods inherited from class scale.clef.decl.ValueDecl
getValue, isValueDecl, returnValueDecl
 
Methods inherited from class scale.clef.decl.Declaration
accessibility, compareTo, getActualType, getAlias, getCoreType, getDecl, getDisplayColorHint, getDisplayLabel, getDisplayShapeHint, getMode, getName, getPointedToCore, getTag, getType, hashCode, isCaseLabelDecl, isEnumElementDecl, isExceptionDecl, isFieldDecl, isFileDecl, isFormalDecl, isForwardProcedureDecl, isLabelDecl, isProcedureDecl, isPure, isRenamed, isRenamedVariableDecl, isRoutineDecl, isStmtFtnDecl, isTypeDecl, isTypeName, isUnknownFormals, isVirtual, isWeak, returnCaseLabelDecl, returnEnumElementDecl, returnExceptionDecl, returnFieldDecl, returnFileDecl, returnFormalDecl, returnForwardProcedureDecl, returnLabelDecl, returnProcedureDecl, returnRenamedVariableDecl, returnRoutineDecl, returnStmtFtnDecl, returnTypeDecl, returnTypeName, returnUnknownFormals, setAccessibility, setAlias, setName, setTag, setWeak
 
Methods inherited from class scale.clef.Node
getSourceLineNumber, setAnnotationLevel, setReportLevel, setSourceLineNumber, toString, toString, toStringChildren
 
Methods inherited from class scale.common.Root
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EquivalenceDecl

public EquivalenceDecl(java.lang.String name,
                       Type type,
                       VariableDecl base,
                       long offset)
Parameters:
name - - name of the variable
type - - type of the variable
base - - VariableDecl representing the base variable (COMMONM area) in the equivalence relationship
offset - - offset of this variable in bytes into the base variable
Method Detail

copy

public Declaration copy(java.lang.String name)
Make a copy of this VariableDecl using a new name.

Overrides:
copy in class VariableDecl

visit

public void visit(Predicate p)
Description copied from class: Node
Process a node by calling its associated routine. See the "visitor" design pattern in Design Patterns: Elements of Reusable Object-Oriented Software by E. Gamma, et al, Addison Wesley, ISBN 0-201-63361-2.

Each class has a visit(Predicate p) method. For example, in class ABC:

   public void visit(Predicate p)
   {
     p.visitABC(this);
   }
 
and the class that implements Predicate has a method
   public void visitABC(Node n)
   {
     ABC a = (ABC) n;
     ...
   }
 
Thus, the class that implements Predicate can call
   n.visit(this);
 
where n is a Node sub-class without determining which specific sub-class n is. The visit pattern basically avoids implementing a large switch statement or defining different methods in each class for some purpose.

Overrides:
visit in class VariableDecl
See Also:
Predicate

getBaseVariable

public VariableDecl getBaseVariable()
Return the base variable (i.e. COMMON area).


setBaseVariable

public void setBaseVariable(VariableDecl base)
Specify the base variable that this variable is equivalenced to.


getBaseOffset

public long getBaseOffset()
Return the offset from the base (i.e. COMMON area).


setBaseOffset

public void setBaseOffset(long offset)
Specify the offset from the base variable that this variable is equivalenced to.


setResidency

public void setResidency(Residency residency)
Generate an error - residency is specified only for the base VariableDecl.

Overrides:
setResidency in class VariableDecl
Parameters:
residency - is the residency of the declaration
See Also:
Residency

residency

public Residency residency()
Return the declaration residency. The residency of an EquivalenceDecl is the residency of the base VariableDecl.

Overrides:
residency in class VariableDecl
See Also:
Residency

inMemory

public boolean inMemory()
Return true if this declaration is to be allocated to memory.

Overrides:
inMemory in class VariableDecl

setVisibility

public void setVisibility(int visibility)
Generate an error - visibility is specified only for the base variable.

Parameters:
visibility - is the visibility of the declaration
See Also:
Visibility

visibility

public Visibility visibility()
Return the declaration visibility. The visibility of an EquivalenceDecl is the visibility of the base variable.

Overrides:
visibility in class Declaration
See Also:
Visibility

isGlobal

public boolean isGlobal()
Return true if this declaration is globally visible.

Overrides:
isGlobal in class Declaration

hasHiddenAliases

public boolean hasHiddenAliases()
Return true if the declaration may be modified in an unknown way.

Overrides:
hasHiddenAliases in class VariableDecl

getStorageLoc

public Assigned getStorageLoc()
Return the location type used for this declaration.

Overrides:
getStorageLoc in class VariableDecl
See Also:
VariableDecl.setStorageLoc(scale.clef.decl.Assigned), Machine.keepTypeInRegister(scale.clef.type.Type, boolean)

getConstantValue

public Literal getConstantValue()
Return the constant value of the expression.

Overrides:
getConstantValue in class VariableDecl
See Also:
Lattice

getChild

public Node getChild(int i)
Return the specified AST child of this node.

Overrides:
getChild in class ValueDecl

numChildren

public int numChildren()
Return the number of AST children of this node.

Overrides:
numChildren in class ValueDecl

isEquivalenceDecl

public final boolean isEquivalenceDecl()
Description copied from class: Declaration
Return true if the declaration is a variable in Fortran COMMON.

Overrides:
isEquivalenceDecl in class Declaration

returnEquivalenceDecl

public final EquivalenceDecl returnEquivalenceDecl()
Description copied from class: Declaration
Return a EquivalenceDecl instance or null.

Overrides:
returnEquivalenceDecl in class Declaration