CallGraph

public final class CallGraph

Top of internal representation, holding the call graph for a given program or library.

Fields

MPIRecvCalls

public TapList<Unit> MPIRecvCalls

allGlobalsForExternals

public TapList<ZoneInfo> allGlobalsForExternals

The ordered list of all global zones that an external routine may see

backAssociations

public TapList<TapPair<Unit, TapList<Unit>>> backAssociations

When this CallGraph was built by transformation from some origin CallGraph, this A-list may hold the link from each Unit of the origin CallGraph to the list of the related Units of this new CallGraph.

globalCMaps

public TapList<TapList<ZoneInfoAccessElements>> globalCMaps

The “maps” built for C global vars that are visible across files (Translation Units).

globalFortranMaps

public MemoryMaps globalFortranMaps

The memory maps built for all COMMON, SAVE, and BIND(C) variables (Fortran-specific)

globalZonesNumber4

public int[] globalZonesNumber4

The number of global zones in this CallGraph (together with the 3 kind-specific numbers)

globalsForExternalsNumber4

public int[] globalsForExternalsNumber4

The number of global zones in allGlobalsForExternals (together with the 3 kind-specific numbers)

hasCuda

public boolean hasCuda

True when the given code contains CUDA operations

numberOfDummyRootZones

public int numberOfDummyRootZones

The number of dummy zones of the root SymbolTable, i.e. the destinations of NULL, Undef, the IO stream(s), and the MPI channels.

toSharingTypes

public TapList<TapPair<String, TypeSpec>> toSharingTypes

The (hatted) list of all named types encountered, used to organize sharing of CompositeTypeSpec’s activities

topBlock

public Block topBlock

Block that will contain global declarations.

topPostComments

public Tree topPostComments

The tree of comments post-attached to this CallGraph.

topPostCommentsBlock

public Tree topPostCommentsBlock

The tree of block-comments post-attached to this CallGraph.

topPreComments

public Tree topPreComments

The tree of comments pre-attached to this CallGraph.

topPreCommentsBlock

public Tree topPreCommentsBlock

The tree of block-comments pre-attached to this CallGraph.

usedCommonNames

public TapList<String> usedCommonNames

zoneNbOfAllIOStreams

public int zoneNbOfAllIOStreams

index of the special memory zone that represents all I-O files.

zoneNbOfNullDest

public int zoneNbOfNullDest

index of the special memory zone that represents destination of NULL.

zoneNbOfUnknownDest

public int zoneNbOfUnknownDest

index of the special memory zone that represents destination of an uninitialized pointer.

Constructors

CallGraph

public CallGraph(String name)

Creates a new CallGraph called “name”.

Methods

absorbAndDeleteAfterCreateNewUnit

public void absorbAndDeleteAfterCreateNewUnit()

addAllocationPoint

protected void addAllocationPoint(Tree allocateTree, Tree recipientTree, TypeSpec allocatedType, SymbolTable symbolTable)

addBindFortranCDiffUnit

public void addBindFortranCDiffUnit(Unit diffUnit)

addBindFortranCFunction

public void addBindFortranCFunction(String unitFortranName, String unitCName, FunctionDecl funcDecl)

addBindFortranCType

public void addBindFortranCType(TypeDecl fortranTypeDecl, TypeDecl cTypeDecl)

addCallArrow

public static CallArrow addCallArrow(Unit origin, int kind, Unit destination)

Adds a new CallArrow into the CallGraph, from “origin” to “destination”. If such an arrow already exists, no arrow is created. “kind” is the kind of arrow, belongs to {CALLS, IMPORTS, CONTAINS, -1}. If this arrow CALLS, the number of calls is incremented.

addIntrinsicUnit

public void addIntrinsicUnit(Unit unit)

Adds the given unit into the list of all intrinsic Units used in this CallGraph.

addTranslationUnitSymbolTable

public void addTranslationUnitSymbolTable(SymbolTable symbolTable)

attachToUpperUnit

public void attachToUpperUnit(Unit unit, Unit upper)

bindFortranCFunctions

public TapList<TapTriplet<String, String, FunctionDecl>> bindFortranCFunctions()
Returns

the unordered list of all Fortran2003 Units with bind(c) in this CallGraph.

bindFortranCType

public TapList<TapPair<TypeDecl, TypeDecl>> bindFortranCType()

buildSortedUnitsList

public TapList<Unit> buildSortedUnitsList(int callsDir, int importsDir, int containsDir)
Returns

a sorted list of all the units found in the “units” field of this CallGraph, following the sorting criteria defined by “callsDir”, “importsDir”, and “containsDir”. When a CallArrow from A to B says that “A xxxx’es B”, then: if xxxxsDir is 1 then A will be before B; if xxxxsDir is -1 then B will be before A; if xxxxsDir is 0, this doensn’t constrain A B order. When order is free, places the Units by increasing original “positions”. Beware of code duplication with sortUnits() !!

cPlusPlusRootSymbolTable

public SymbolTable cPlusPlusRootSymbolTable()

cRootSymbolTable

public SymbolTable cRootSymbolTable()

checkBindFortranCType

public boolean checkBindFortranCType(WrapperTypeSpec fortranTypeSpec, WrapperTypeSpec cTypeSpec)

copyZone4Ranks

public static final int[] copyZone4Ranks(int[] rks)

createNewIntrinsicUnit

public Unit createNewIntrinsicUnit(String name, int language)

Create a new intrinsic Unit for this CallGraph.

createNewUnit

public Unit createNewUnit(Unit upperLevelUnit, int language)

Create a new Unit into this CallGraph, contained in upperLevelUnit.

createRootSymbolTables

public void createRootSymbolTables()

cudaRootSymbolTable

public SymbolTable cudaRootSymbolTable()

decideForwardDeclarations

public void decideForwardDeclarations()

deleteUnit

public void deleteUnit(Unit unit)

Delete the given unit, and all its lower-level Units, from this CallGraph.

deleteUnitFromSymbolTable

public void deleteUnitFromSymbolTable(Unit unit)

Delete the declaration of the given unit from the SymbolTable that contains these declarations.

detachFromUpperUnit

public void detachFromUpperUnit(Unit unit)

Re-attach the given Unit to the given new upper-level unit.

dump

public void dump(int indent)

Prints in detail the contents of this CallGraph, onto TapEnv.curOutputStream().

Parameters
  • indent – the amount of indentation to be used for this printing.

dumpAllDataFlows

public void dumpAllDataFlows(TapList<Unit> unitsToDump)

Dumps the data-flow info of the Units of this CallGraph, restricted to all Units in “unitsToDump”.

dumpAllFlowGraphs

public void dumpAllFlowGraphs(TapList<Unit> unitsToDump, int indent)

Dumps all the contents of “callGraph”, restricted to all Units in “unitsToDump”. Dumps SymbolTable hierarchy first, then all flow-graphs

dumpAllSymbolTables

public void dumpAllSymbolTables(TapList<Unit> unitsToDump, boolean dumpAll, int indent)

Dumps the hierarchy of SymbolTable’s.

dumpCompactCallGraph

public static void dumpCompactCallGraph(TapList<Unit> unitsToDump)

Dumps a compact textual form of the call graph, i.e. the nodes (the Units) and the CallArrows.

fixRemainingInterfaces

public void fixRemainingInterfaces()

fortranRootSymbolTable

public SymbolTable fortranRootSymbolTable()

getAllMessagePassingChannelZones

public TapIntList getAllMessagePassingChannelZones()
Returns

the list of all the zones representing a message-passing channel.

getAllMessagePassingChannels

public TapList<TapPair<MPIcallInfo, TapIntList>> getAllMessagePassingChannels()
Returns

the list of all Message-Passing channels.

getAnyIntrinsicUnit

public Unit getAnyIntrinsicUnit(String name)
Returns

the intrinsic Unit with name ‘name’, ‘null’ if not found. This method is dirty and should be used only for debugging, because it does not use the scoping mechanism and therefore several Unit’s can have the same name.

getAnyNonVarUnit

public Unit getAnyNonVarUnit(String name, Unit inUnit)
Returns

one Unit with name ‘name’ from the CallGraph, provided it is not a VarFunctionUnit. This method is dirty and should be used only for debugging, because it does not use the scoping mechanism and therefore several Unit’s can have the same name.

getAnyUnit

public Unit getAnyUnit(String name)
Returns

a standard Unit with name ‘name’ from this CallGraph, ‘null’ if not found. This method is dirty and should be used only for debugging, because it does not use the scoping mechanism and therefore several Unit’s can have the same name.

getCallArrow

public static CallArrow getCallArrow(Unit callerUnit, Unit calleeUnit)
Returns

the CallArrow from “callerUnit” to “calleeUnit”. In the special case where “calleeUnit” is an intrinsic, there is no CallArrow coming from each routine that uses it. Therefore, we return a “generic” arrow with its origin set to “callerUnit”.

getCglobalMap

public TapList<ZoneInfoAccessElements> getCglobalMap(SymbolDecl sharedDecl)

getFileUnit

public Unit getFileUnit(String fileName)
Returns

the “package” Unit (i.e. a file, i.e. a compilation unit) with the given fileName.

getMainUnit

public Unit getMainUnit()
Returns

main Unit if this CallGraph has a main Unit. Otherwise returns null.

getMixedLanguageFunctionName

public TapPair<String, FunctionDecl> getMixedLanguageFunctionName(String functionName, int callerLanguage, int calleeLanguage)
Parameters
  • functionName – name of function in a call

  • callerLanguage – TapEnv.C, TapEnv.FORTRAN, …

  • calleeLanguage – TapEnv.C, TapEnv.FORTRAN, …

Returns

the corresponding Unit.name, i.e.

if callerLanguage == TapEnv.C, the Fortran name FOO
if callerLanguage == TapEnv.FORTRAN, the C name BAR or bind's result
+ FunctionDecl

getOtherBindType

public TypeDecl getOtherBindType(WrapperTypeSpec typeSpec)

getOtherLangFunctionDeclFromBindC

public TapTriplet<String, String, FunctionDecl> getOtherLangFunctionDeclFromBindC(String funcName, int calleeLang)

getOtherLanguageName

public String getOtherLanguageName(String symbolName, int callerLanguage, int calleeLanguage)

getPreviousFunctionDeclAndNewUnit

public TapTriplet<FunctionDecl, Unit, TapPair<FunctionDecl, SymbolTable>> getPreviousFunctionDeclAndNewUnit(String name)

getRecursivityUnits

public TapList<Unit> getRecursivityUnits()

getTranslationUnitSymbolTables

public TapList<SymbolTable> getTranslationUnitSymbolTables()

getUnit

public Unit getUnit(String funcName)
Returns

the Unit corresponding to the given full name “funcName”. A full name (path) of a procedure is prefixed with the names of the containing modules or procedures as in “module.func”.

getUnit

public Unit getUnit(TapList<String> funcPath)
Returns

the Unit corresponding to the given path “funcPath”, starting from the namespace of the root SymbolTable of this CallGraph. If finds no Unit, complains and returns any unit with the same name. May return an external Unit or even null!

getUnit

public Unit getUnit(String name, FunctionTypeSpec functionTypeSpec)
Returns

‘null’ if not found or if it finds an interface.

getUnits

public TapList<Unit> getUnits(TapList<String> unitNames)

Returns the list of all Units that match one name or one unit rank in “unitNames”. Returns null if unitNames is null or no Unit is found. If the given list “unitNames” starts with special String “%all%, then this returns a one-element list containing null, which must be understood as “all Units”.

globalRootSymbolTable

public SymbolTable globalRootSymbolTable()

interfaceUnits

public TapList<Unit> interfaceUnits()
Returns

the unordered list of all interface Units in this CallGraph.

intrinsicUnits

public TapList<Unit> intrinsicUnits()
Returns

the unordered list of all intrinsic Units used in this CallGraph.

isAMessagePassingChannelZone

public boolean isAMessagePassingChannelZone(int zoneNb)
Returns

true if “zoneNb” represents a message-passing channel.

isCommonName

public boolean isCommonName(String name)

isMessagePassingChannelName

public static boolean isMessagePassingChannelName(String name)

languageRootSymbolTable

public SymbolTable languageRootSymbolTable(int language)

name

public String name()
Returns

Some given name for this CallGraph.

naturalBindFortranCType

public boolean naturalBindFortranCType(WrapperTypeSpec fType, WrapperTypeSpec cType)

Returns true if fType and cType are based on primitive types and naturally match, without any need for BIND declaration.

nbUnits

public int nbUnits()
Returns

Number of Units present in this CallGraph Includes procedures, classes, externals, interfaces, but not intrinsics.

numberSymbolTables

public void numberSymbolTables()

Assigns a unique number to each SymbolTable. This number is used mostly to identify SymbolTable’s in debug and trace

orderedFiles

public TapList<Unit> orderedFiles()
Returns

a reordered list of the Translation Units in “fileUnits”, ordered so that the USE’d and CALL’ed Units occur before their usage. This is useful if the user wants all code generated in a single file.

prepareAnalyses

public void prepareAnalyses(TapList<Unit> rootUnits)

Run all general-purpose analyses.

replaceInAllocationPoints

protected void replaceInAllocationPoints(Tree oldAllocate, Tree newAllocate)

resetPreviousFunctionDeclAndNewUnit

public void resetPreviousFunctionDeclAndNewUnit()

setAllMessagePassingChannels

public void setAllMessagePassingChannels(TapList<TapPair<MPIcallInfo, TapIntList>> allChannels)

Sets the list of all Message-Passing channels.

setBindCFortranCFunctions

public void setBindCFortranCFunctions(TapList<TapTriplet<String, String, FunctionDecl>> origBindC)

setBindFortranCType

public void setBindFortranCType(TapList<TapPair<TypeDecl, TypeDecl>> origBindCType)

setCPlusPlusRootSymbolTable

public void setCPlusPlusRootSymbolTable(SymbolTable cPlusPlusRootSymbolTable)

setCRootSymbolTable

public void setCRootSymbolTable(SymbolTable cRootSymbolTable)

setCudaRootSymbolTable

public void setCudaRootSymbolTable(SymbolTable cudaRootSymbolTable)

setFortranRootSymbolTable

public void setFortranRootSymbolTable(SymbolTable fortranRootSymbolTable)

setGlobalRootSymbolTable

public void setGlobalRootSymbolTable(SymbolTable globalRootSymbolTable)

setInputStream

public void setInputStream(TreeProtocol stream)

Sets the inputStream to “stream”.

setInterfaceUnits

public void setInterfaceUnits(TapList<Unit> units)

Sets the unordered list of all interface Units in this CallGraph.

setMainUnit

public void setMainUnit(Unit unit)

Sets “unit” as the main Unit of this CallGraph.

setPreviousFunctionDeclAndNewUnit

public void setPreviousFunctionDeclAndNewUnit(FunctionDecl oldFunctionDecl, Unit newUnit)

sortUnits

public void sortUnits(boolean keepAllUnits, int callsDir, int importsDir, int containsDir)

Sorts into field “sortedUnits” all Unit’s of this CallGraph, following the sorting criteria defined by “callsDir”, “importsDir”, and “containsDir”. When a CallArrow from A to B says that “A xxxx’es B”, then: if xxxxsDir is 1 then A will be before B; if xxxxsDir is -1 then B will be before A; if xxxxsDir is 0, this doesn’t constrain A B order. When order is free, places the Units by increasing original “positions”. Re-assigns the ranks of the Units according to this order.

sortedComputationalUnits

public TapList<Unit> sortedComputationalUnits()
Returns

a TapList of all computational units in this CallGraph in top-down call order, topmost first.

sortedUnit

public Unit sortedUnit(int rank)
Returns

the Unit at index “rank” (from 0 up) in the current sorted list of all Units of this CallGraph. Sorting is recomputed by each call to sortUnits().

sortedUnits

public TapList<Unit> sortedUnits()
Returns

the ordered list of all Units in this CallGraph.

terminateTypesAndZones

public void terminateTypesAndZones()

Final preparation of the CallGraph. Prepare the types. Set all the remaining CallArrows. Prepare the zones, zone numbering, zone translations. Must be done after all parsing and before all analyses.

topUnits

public TapList<Unit> topUnits()
Returns

the list of all top Units in this CallGraph. i.e. the Units of the topmost scope.

units

public TapList<Unit> units()
Returns

the unordered list of all Units present in this CallGraph.

zoneRksOfChannelOrIO

public TapIntList zoneRksOfChannelOrIO()

zoneRksOfIO

public TapIntList zoneRksOfIO()