|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.clef.Node scale.clef.decl.Declaration scale.clef.decl.RoutineDecl
public abstract class RoutineDecl
This is the base class representing all routine declarations.
$Id: RoutineDecl.java,v 1.86 2007-10-04 19:58:04 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Field Summary | |
---|---|
static int |
NOTPURE
The function may have side effects, may reference any global variables of this program, and may modify any locations referenced by an argument. |
static int |
PURE
The function is completely "pure". |
static int |
PUREARGS
The function does not modify any locations referenced by an argument. |
static int |
PUREGV
The function does not reference any global variables of this program. |
static int |
PUREGVA
The function does not reference any global variables of this program or modify any locations referenced by an argument. |
static int |
PURESE
The function does not have side effects. |
static int |
PURESGV
The function does not have side effects or use global variables. |
Constructor Summary | |
---|---|
protected |
RoutineDecl(java.lang.String name,
ProcedureType type)
|
protected |
RoutineDecl(java.lang.String name,
ProcedureType type,
Statement body)
Create a routine with the specified name and type. |
Method Summary | |
---|---|
void |
addCallee(RoutineDecl callee)
Add a link in the call graph to the callee. |
void |
addCaller(RoutineDecl caller)
Specify a caller of this call node. |
void |
addCandidate(Type type)
Add a potential (indirect) call. |
void |
addCost(int cost)
Add to the cost associated with this call node. |
VariableDecl |
addProfiling(int profileOptions)
Add the profiling information to this call node. |
void |
attachScribbleCFG(Scribble scribble)
Attach the Scribble CFG to the call node. |
boolean |
calls(RoutineDecl target,
HashSet<RoutineDecl> done)
Returns true if this call node routine calls the specified routine or calls a subroutine that results in a call to the specified routine. |
boolean |
cantInline()
Return true if this routine cannot be inlined for whatever reason. |
void |
clearAST()
Remove all Clef AST stuff. |
int |
getAddressRegister()
Return the register the code generator assigned to the address of this variable. |
Statement |
getBody()
Return the Clef AST for this routine or null . |
int |
getBuiltIn()
Return builtin function index. |
RoutineDecl |
getCallee(int i)
Return the specified callee. |
Type |
getCalleeCandidate(int i)
Return the return type of the specified caller. |
RoutineDecl |
getCaller(int i)
Return the specified caller. |
CallGraph |
getCallGraph()
Return the CallGraph that contains this RoutineDecl. |
Node |
getChild(int i)
Return the specified AST child of this node. |
int |
getCost()
Return the cost associated with this call node. |
Displacement |
getDisplacement()
Return the code generator displacement associated with this call node. |
DColor |
getDisplayColorHint()
Return a String specifying the color to use for coloring this node in a graphical display. |
VariableDecl |
getFtnResultVar()
Return the declared function result variable (if any). |
int |
getProfCallCnt()
Return the number of times this call occurred during execution. |
int |
getPurityLevel()
Return the level of purity of the routine. |
java.lang.String |
getRoutineName()
Return the name of the routine that the call node represents. |
Scribble |
getScribbleCFG()
Return the Scribble graph associated with this node. |
ProcedureType |
getSignature()
Return this routine's type |
int |
getSourceLineNumber()
Return the source line number associated with this node or -1 if not known. |
boolean |
inlineSpecified()
Return true if the programmer specified to inline this routine. |
boolean |
isBuiltIn()
Return true if calls to this function are a candidates for being converted to in-line code. |
boolean |
isMain()
Return true if the declaration is the main procedure. |
boolean |
isPure()
Return true if this declaration has a purity level of PUREGV. |
boolean |
isRecursive()
Returns true if this call node routine calls itself or calls a subroutine that results in a call to itself. |
boolean |
isReferenced()
Return true if the declaration is referenced somewhere in the Clef AST or has a body. |
boolean |
isRoutineDecl()
Return true if RoutineDecl instance. |
boolean |
isSpecification()
Return true if this is a specification of the routine and not the actual routine. |
int |
numCalleeCandidates()
Return the number of routines that call this routine. |
int |
numCallees()
Return the number of routines called by this routine. |
int |
numCallers()
Return the number of routines that call this routine. |
int |
numChildren()
Return the number of AST children of this node. |
void |
printCallees()
|
RoutineDecl |
returnRoutineDecl()
Return a RoutineDecl instance or
null . |
void |
setAddressRegister(int reg)
Specify the register the code generator assigned to the address of this variable. |
void |
setBody(Statement body)
Specify the Clef AST for this routine or null if none. |
void |
setBuiltIn(int index)
Specify the builtin function index. |
void |
setCantInline()
Specifiy that this routine cannot be inlined. |
void |
setCost(int cost)
Specify the cost associated with this call node. |
void |
setDisplacement(Displacement disp)
Specify the code generator displacement associated with this call node. |
void |
setFtnResultVar(VariableDecl ftnResultVar)
Declare the function result variable. |
void |
setInlineSpecified()
Specifiy that the programmer wants this routine inlined. |
void |
setMain()
Indicates that this procedure is the main procedure. |
void |
setNoinlineSpecified()
Specifiy that the programmer wants this routine to not be inlined. |
void |
setProfCallCnt(int count)
Specify the number of times this call occurred during execution. |
void |
setPurityLevel(int level)
|
void |
setReferenced()
Specify that the routine is referenced somewhere in the Clef AST. |
void |
setSignature(ProcedureType s)
Specify this routine's type |
void |
setSourceLineNumber(int lineNumber)
Set the source line number associated with this node or -1 if not known. |
void |
setUsesAlloca()
Specify that the routine uses __builtin_alloca() . |
void |
setUsesSetjmp()
Specify that the routine uses va_start . |
void |
setUsesVaStart()
Specify that the routine uses va_start . |
void |
specifyCallGraph(CallGraph cg)
Specify the call graph that contains this routine. |
java.lang.String |
toStringSpecial()
This method allows sub-classes to provide class specific stuff to the string. |
boolean |
usesAlloca()
Return true if the routine uses __builtin_alloca() . |
boolean |
usesSetjmp()
Return true if the routine uses va_start() . |
boolean |
usesVaStart()
Return true if the routine uses va_start() . |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.clef.Node |
---|
setAnnotationLevel, setReportLevel, 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 final int PURE
public static final int PURESGV
public static final int PURESE
public static final int PUREGVA
public static final int PUREGV
public static final int PUREARGS
public static final int NOTPURE
Constructor Detail |
---|
protected RoutineDecl(java.lang.String name, ProcedureType type, Statement body)
name
- is the method nametype
- is the method typebody
- is the method bodyprotected RoutineDecl(java.lang.String name, ProcedureType type)
Method Detail |
---|
public final void specifyCallGraph(CallGraph cg)
public final boolean isReferenced()
isReferenced
in class Declaration
VariableDecl
,
RoutineDecl
public final void setReferenced()
setReferenced
in class Declaration
VariableDecl
,
RoutineDecl
public final boolean usesVaStart()
va_start()
.
public final void setUsesVaStart()
va_start
.
public final boolean usesSetjmp()
va_start()
.
public final void setUsesSetjmp()
va_start
.
public final boolean usesAlloca()
__builtin_alloca()
.
public final void setUsesAlloca()
__builtin_alloca()
.
public final boolean isMain()
main
procedure.
public final void setMain()
main
procedure in the C sense.
public final boolean inlineSpecified()
public final void setInlineSpecified()
public final void setNoinlineSpecified()
public final boolean cantInline()
public final void setCantInline()
public int getPurityLevel()
bit | meaning |
---|---|
4 | does not have any side effects |
2 | does not reference any global variables of the program (it may modify file buffers and other OS things) |
1 | the routine does not modify any of its arguments or what they point to |
public void setPurityLevel(int level)
public boolean isPure()
isPure
in class Declaration
public VariableDecl getFtnResultVar()
public final void setProfCallCnt(int count)
public final int getProfCallCnt()
public final void setBuiltIn(int index)
-gcc
.
public final int getBuiltIn()
-gcc
.
public final boolean isBuiltIn()
-gcc
.
public void setFtnResultVar(VariableDecl ftnResultVar)
public java.lang.String toStringSpecial()
Node
toStringSpecial
in class Declaration
public CallGraph getCallGraph()
public VariableDecl addProfiling(int profileOptions)
profileOptions
- specifies which profiling instrumentation
to insert
public int numCallees()
public RoutineDecl getCallee(int i)
public int numCallers()
public RoutineDecl getCaller(int i)
public int numCalleeCandidates()
public Type getCalleeCandidate(int i)
public final java.lang.String getRoutineName()
public void addCallee(RoutineDecl callee)
callee
- the call node that represents the routine we're
callingpublic void addCaller(RoutineDecl caller)
public void addCandidate(Type type)
type
- is the return type of the routine called.public void printCallees()
public void attachScribbleCFG(Scribble scribble)
scribble
- is the Scribble CFGpublic void clearAST()
public Scribble getScribbleCFG()
public Displacement getDisplacement()
getDisplacement
in class Declaration
public void setDisplacement(Displacement disp)
setDisplacement
in class Declaration
public int getAddressRegister()
getAddressRegister
in class Declaration
public void setAddressRegister(int reg)
setAddressRegister
in class Declaration
public int getCost()
public void setCost(int cost)
public void addCost(int cost)
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 Declaration
Predicate
public ProcedureType getSignature()
public void setSignature(ProcedureType s)
public final boolean isSpecification()
public final void setBody(Statement body)
null
if none.
public final Statement getBody()
null
.
public Node getChild(int i)
getChild
in class Node
public int numChildren()
numChildren
in class Node
public DColor getDisplayColorHint()
getDisplayColorHint
in interface DisplayNode
getDisplayColorHint
in class Declaration
DColor
public boolean calls(RoutineDecl target, HashSet<RoutineDecl> done)
target
- is the specified routinedone
- is used to avoid infinite recursion and conbinatorial
explosionpublic boolean isRecursive()
public final int getSourceLineNumber()
getSourceLineNumber
in class Node
public final void setSourceLineNumber(int lineNumber)
setSourceLineNumber
in class Node
public final boolean isRoutineDecl()
Declaration
isRoutineDecl
in class Declaration
public final RoutineDecl returnRoutineDecl()
Declaration
RoutineDecl
instance or
null
.
returnRoutineDecl
in class Declaration
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |