|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectscale.common.Root
scale.clef.Node
scale.clef.decl.Declaration
scale.clef.decl.ValueDecl
scale.clef.decl.VariableDecl
public class VariableDecl
This class declares a variable.
$Id: VariableDecl.java,v 1.103 2007-08-28 13:34:32 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
If you want to name your generated variables _inxxx
where xxx is a number you would do
UniqueName un = new UniqueName("_in");
...
VariableDecl vd = new VariableDecl(un.genName(), type);
vd.setTemporary();
...
If you don't care about the name just do
VariableDecl vd = new VariableDecl(type);The naming scheme is basically
_oonnn where
oo identifies the optimization that created the
variable. Compiler created variables should be temporary variables
unless they must reside in memory. Some values in use for
oo are
oo | creater | use |
|---|---|---|
A |
parser | Function prototype argument names |
V |
parser | Compiler created variables |
_t |
FindAliases | Compiler created temporary alias variables |
vv |
Aliases | Compiler created temporary alias virtual variables |
rv_ |
Aliases | Compiler created temporary alias variables |
addrtaken_ |
Aliases | Compiler created temporary alias variables |
s |
Scribble |
Compiler created temporary variables |
vn |
ValNum | Compiler created temporary variables |
li |
LICM | Compiler created temporary variables |
sr |
ScalarReplacement |
Compiler created temporary variables |
np |
frontend | Compiler created temporary variables |
cs |
Clef2Scribble | Compiler created temporary variables |
UniqueName| Field Summary | |
|---|---|
static boolean |
ignoreAddressTaken
Set this flag true to study the effect of the address-taken attribute. |
| Constructor Summary | |
|---|---|
VariableDecl(java.lang.String name,
Type type)
Create a variable declaration which doesn't have a default value. |
|
VariableDecl(java.lang.String name,
Type type,
Expression initialValue)
|
|
| Method Summary | |
|---|---|
boolean |
addressTaken()
Return true if the address of this Declaration has been taken. |
protected void |
computeAttributes()
Determine how the variable must be handled. |
Declaration |
copy(java.lang.String name)
Return a copy of this Declaration but with a different name. |
void |
declareFtnResultVar()
Specify that the variable is declared as the result variable of a function. |
int |
getAddressRegister()
Return the register the code generator assigned to the address of this variable. |
Literal |
getConstantValue()
Return the constant value of the expression. |
Displacement |
getDisplacement()
Return the displacement the code generator assigned to this variable. |
Expression |
getInitialValue()
Return the initializer for this variable or null. |
VariableDecl |
getOriginal()
Return the variable that this variable was renamed from. |
Assigned |
getStorageLoc()
Return the location type used for this declaration. |
int |
getValueRegister()
Return the register the code generator assigned to this variable. |
boolean |
hasHiddenAliases()
Return true if the variable may be modified in an unknown way. |
boolean |
hasHiddenPtrAliases()
Return true if the memory, to which this pointer variable refers, may be modified in an unknown way. |
boolean |
hasInvalidArrayReferences()
Return true if the array specified by this variable has invalid array references. |
boolean |
inMemory()
Return true if this declaration is to be allocated to memory. |
boolean |
isCommonBaseVar()
Return true if the variable is the base variable for Fortran COMMON. |
boolean |
isCommonBaseVariable()
Return true if this is the base variable of a Fortran COMMON area. |
boolean |
isConst()
Return true if the variable is a const variable. |
boolean |
isFtnResultVar()
Return true if the declaration is declared as the result variable of a function. |
boolean |
isNotAliasCandidate()
Return true if no aliases should be created for this variable. |
boolean |
isNotSSACandidate()
Return true if this variable can not be in SSA form. |
boolean |
isReferenced()
Return true if the declaration is referenced somewhere in the Clef AST. |
boolean |
isRestricted()
Return true if the type specifies restricted. |
boolean |
isStatic()
Return true if this declaration is static. |
protected boolean |
isStorageLocSet()
Return true if the location type used for this declaration is known. |
boolean |
isTemporary()
Return true if the declaration is a temporary variable. |
boolean |
isVariableDecl()
Return true if VariableDecl instance. |
boolean |
isVolatile()
Return true if the type specifies volatile. |
boolean |
optimizationCandidate()
Return true if this variable is not a global variable, is not an atomic type, is not volatile,
is not const,
has no hidden alias,
does not have its address taken, and
does not have an initial value. |
Residency |
residency()
Return the declaration residency. |
VariableDecl |
returnVariableDecl()
Return a VariableDecl instance or
null. |
void |
setAddressRegister(int reg)
Specify the register the code generator assigned to the address of this variable. |
void |
setAddressTaken()
Record that the address is used. |
void |
setDisplacement(Displacement disp)
Specify the displacement the code generator assigned to this variable. |
void |
setHiddenAliases()
Specify that the variable may be modified in an unknown way. |
void |
setHiddenPtrAliases()
Specify that the memory, to which this pointer variable refers, may be modified in an unknown way. |
void |
setInitialValue(Expression value)
Specify the initial value for a variable. |
void |
setInvalidArrayReferences()
Record that the array specified by this variable has invalid array references. |
void |
setReferenced()
Specify that the variable is referenced somewhere in the Clef AST. |
void |
setResidency(Residency residency)
Specify the residency of the declaration. |
void |
setStorageLoc(Assigned loc)
Set the location type used for this declaration. |
void |
setTemporary()
Specify that the variable is a temporary variable. |
void |
setType(Type type)
Specify the type of this declaration. |
void |
setValue(Expression value)
Specify the initial value for a variable. |
void |
setValueRegister(int reg,
ResultMode mode)
Specify the register the code generator temporarily assigned to this variable. |
void |
setVisibility(Visibility visibility)
Specify the visibility of the declaration. |
boolean |
shouldBeInRegister()
Return true if this variable should be allocated to a register. |
void |
specifyCommonBaseVariable()
Specify that this variable is the base variable for a Fortram COMMON. |
java.lang.String |
toStringSpecial()
This method allows sub-classes to provide class specific stuff to the string. |
ResultMode |
valueRegMode()
Return the register mode that the code generator temporarily assigned to this variable. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
| Methods inherited from class scale.clef.decl.ValueDecl |
|---|
getChild, getValue, isValueDecl, numChildren, returnValueDecl |
| 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 |
| Field Detail |
|---|
public static boolean ignoreAddressTaken
| Constructor Detail |
|---|
public VariableDecl(java.lang.String name,
Type type,
Expression initialValue)
public VariableDecl(java.lang.String name,
Type type)
| Method Detail |
|---|
public void setType(Type type)
Declaration
setType in class Declarationpublic void setVisibility(Visibility visibility)
setVisibility in class Declarationvisibility - is the visibility of the declarationVisibilitypublic void setResidency(Residency residency)
setResidency in class Declarationresidency - is the residency of the declarationResidencypublic Residency residency()
residency in class DeclarationResidencyprotected final boolean isStorageLocSet()
public Assigned getStorageLoc()
getStorageLoc in class DeclarationsetStorageLoc(scale.clef.decl.Assigned),
Machine.keepTypeInRegister(scale.clef.type.Type, boolean)public final void setStorageLoc(Assigned loc)
setStorageLoc in class Declarationpublic boolean inMemory()
inMemory in class Declarationpublic final Displacement getDisplacement()
getDisplacement in class Declarationpublic final void setDisplacement(Displacement disp)
setDisplacement in class Declarationpublic final int getValueRegister()
getValueRegister in class Declarationpublic final ResultMode valueRegMode()
valueRegMode in class DeclarationGenerator
public final void setValueRegister(int reg,
ResultMode mode)
setValueRegister in class DeclarationGeneratorpublic final int getAddressRegister()
getAddressRegister in class Declarationpublic final void setAddressRegister(int reg)
setAddressRegister in class Declarationpublic boolean isReferenced()
isReferenced in class DeclarationVariableDecl,
RoutineDeclpublic final void setReferenced()
setReferenced in class DeclarationVariableDecl,
RoutineDeclpublic boolean isConst()
isConst in class ValueDeclpublic final boolean isTemporary()
isTemporary in class Declarationpublic final void setTemporary()
public boolean hasHiddenAliases()
hasHiddenAliases in class Declarationpublic final void setHiddenAliases()
public boolean hasHiddenPtrAliases()
public final void setHiddenPtrAliases()
public final boolean isFtnResultVar()
isFtnResultVar in class Declarationpublic final void declareFtnResultVar()
public final void setAddressTaken()
setAddressTaken in class Declarationpublic boolean addressTaken()
addressTaken in class Declarationpublic final void specifyCommonBaseVariable()
public final boolean isCommonBaseVariable()
isCommonBaseVariable in class Declarationpublic final void setInvalidArrayReferences()
((int) ((char *) a + 14))[5]
public final boolean hasInvalidArrayReferences()
((int) ((char *) a + 14))[5]
protected final void computeAttributes()
public final boolean isNotSSACandidate()
struct),
volatile,
const variables in
SSA form.
public final boolean isNotAliasCandidate()
struct).
public final boolean shouldBeInRegister()
volatile,
public final boolean optimizationCandidate()
volatile,
const,
public final boolean isVolatile()
public final boolean isRestricted()
public void visit(Predicate p)
Node
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.
visit in class ValueDeclPredicatepublic final Expression getInitialValue()
public final void setInitialValue(Expression value)
public final void setValue(Expression value)
setValue in class ValueDeclpublic Literal getConstantValue()
getConstantValue in class ValueDeclLatticepublic final boolean isStatic()
public VariableDecl getOriginal()
public java.lang.String toStringSpecial()
Node
toStringSpecial in class Declarationpublic Declaration copy(java.lang.String name)
copy in class Declarationpublic final boolean isCommonBaseVar()
public final boolean isVariableDecl()
Declaration
isVariableDecl in class Declarationpublic final VariableDecl returnVariableDecl()
DeclarationVariableDecl instance or
null.
returnVariableDecl in class Declaration
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||