NewSymbolHolder

public final class NewSymbolHolder

Class that holds all info about a new symbol that we are going to add into a subroutine. For each new variable name that we wish to add, we create one such object. Then each time we want to insert a new reference to this new variable, we ask this object to build this new reference. Finally, when all references are built, we ask this object to choose the definitive name of the new variable, and insert its SymbolDecl into the correct symbolTable.

Fields

declare

public boolean declare

If false, do not declare this new symbol (e.g. the end-user will do it).

definitionModule

public Unit definitionModule

When this new symbol is declared by a module (of the target CallGraph), keeps this module.

derivationFrom

public SymbolDecl derivationFrom

The SymbolDecl of the symbol that gives its base name for this new symbol.

hintArrayTreeForCallSize

public Tree hintArrayTreeForCallSize

The Tree that must be used each time a variable must be created to with size(hintArrayTreeForCallSize).

hintRootTree

public Tree hintRootTree

When non-null, this tree is used to build the ISIZEnOF… variables that represent unknown dimension sizes, and the messages that come with them.

newSolvedVariableDecl

public VariableDecl newSolvedVariableDecl

newVariableDecl

public VariableDecl newVariableDecl

If needed, the VariableDecl for this future symbol.

probableName

public String probableName

The probable future name of this new symbol.

zone

public int zone

a temporary zone number for this new symbol.

Constructors

NewSymbolHolder

public NewSymbolHolder(String probableName, int diffSymbolSort)

Builds a NewSymbolHolder for a future symbol of probable name “probableName” “diffSymbolSort” is the sort (e.g. _FWD, _B, …) of derivative that this new symbol stands for.

NewSymbolHolder

public NewSymbolHolder(String probableName)

Builds a NewSymbolHolder for a future symbol of probable name “probableName”.

NewSymbolHolder

public NewSymbolHolder(String probableName, Unit hostUnit, WrapperTypeSpec type, int sizeModifier)

Builds a NewSymbolHolder that will be placed inside hostUnit, of probable name “probableName”, of the given type, possibly with a size modifier.

Methods

absorb

public void absorb(NewSymbolHolder absorbedSymbolHolder)

Add available info from absorbedSymbolHolder into this.

accumulateSymbolDecl

public void accumulateSymbolDecl(SymbolDecl newSymbolDecl, SymbolTable targetSymbolTable)

accumulateTargetForSymbolDecl

public void accumulateTargetForSymbolDecl(SymbolDecl modelSymbolDecl, SymbolTable targetSymbolTable)

addTypeDeclSymbolTable

public void addTypeDeclSymbolTable(SymbolTable symbolTable)

buildCptrTree

public static TapPair<NewSymbolHolder, Tree> buildCptrTree(Tree expr, SymbolTable usageSymbolTable, boolean isNullPTR, String cptrName, Unit targetUnit, WrapperTypeSpec type, boolean initCptr)

checkVariableDimension

public static WrapperTypeSpec checkVariableDimension(WrapperTypeSpec typeSpec, String arrayNameInIdent, String arrayNameInText, Tree treeInCallSize, Unit diffUnit, Unit origUnit, SymbolTable symbolTable)

Checks that the array dimensions in typeSpec use only numerical constants.

Parameters
  • treeInCallSize

  • symbolTable

copySymbolHolderAnnotation

public static void copySymbolHolderAnnotation(Tree fromTree, Tree toTree, SymbolTable newUsageSymbolTable)

If there is a “NewSymbolHolder” annotation on “fromTree”, put a similar annotation on “toTree”, and register “toTree” as a new occurrence of this NewSymbolHolder. As a consequence, the given “newUsageSymbolTable”, which is the SymbolTable on toTree, must see the future declaration of this NewSymbolHolder, This is to permit creation of a new symbol based on another new symbol, with the SymbolHolder mechanism (cf adj10.f)

declarationLevelMustInclude

public void declarationLevelMustInclude(SymbolTable symbolTable)

Says that the main SymbolDecl of this NewSymbolHolder must be declared in a SymbolTable which must be seen by (i.e. must be a root symbol table of) the given “symbolTable”.

declareUsageInstruction

public void declareUsageInstruction(Instruction instruction)

dependsOn

public TapList<SymbolDecl> dependsOn()

extraInfo

public TapList<String> extraInfo()

finalName

public String finalName()

getAttachedVariableDecl

public static VariableDecl getAttachedVariableDecl(Tree tree)

getNewSymbolHolder

public static NewSymbolHolder getNewSymbolHolder(Tree refTree)

Assuming that the given “refTree” is a reference to a NewSymbolHolder.

Returns

this NewSymbolHolder.

hasNewFunctionDecl

public boolean hasNewFunctionDecl()

instruction

public Instruction instruction()

instruction

public Instruction instruction(SymbolTable symbolTable)

isANewSymbolRef

public static boolean isANewSymbolRef(Tree refTree)
Returns

true if the given “refTree” is a reference to a NewSymbolHolder.

isDerivationFrom

public void isDerivationFrom(SymbolDecl baseDecl, String suffix)

isUsed

public boolean isUsed()
Returns

true if this NewSymbolHolder is actually used and therefore must be declared.

makeNewRef

public Tree makeNewRef(SymbolTable symbolTable)

Builds a new Tree referencing the future symbol. Register it so that it will receive the final name when chosen. If symbolTable is not null, add it into the usage SymbolTable’s.

migrateToCopySymbolTable

public void migrateToCopySymbolTable(SymbolTable copyST)

newFunctionDecl

public FunctionDecl newFunctionDecl()

newTypeDecl

public TypeDecl newTypeDecl()

newVariableDecl

public VariableDecl newVariableDecl()

prepareDeclarationInstr

public void prepareDeclarationInstr(Unit targetUnit)

Prepares the Instruction that will contain the declaration of this NewSymbolHolder in targetUnit.

preparePrivateClause

public void preparePrivateClause(Block srcOfUsageBlock, SymbolTable srcDeclST, boolean inFwd, boolean diff)

If this future new symbol is used in a block whose source correspondent is “srcOfUsageBlock” and if the opening clause ($OMP PARALLEL) of the enclosing OpenMP region is between usageBlock and its corresponding (future) declaration scope “srcDeclST”, then this opening clause must be extended to specify that this new symbol is “omp private”.

Parameters
  • srcOfUsageBlock – (the source block of) the block where this NewSymbolHolder will be used.

  • srcDeclST – source correspondent of the SymbolTable where the new symbol will be declared.

  • inFwd – when true, the private clause goes to the fwd differentiated pragma

  • diff – when true, the private clause must be about the variable’s derivative

prepareSharedClause

public void prepareSharedClause(Block srcOfUsageBlock, SymbolTable srcDeclST, boolean inFwd, boolean diff)

Same as preparePrivateClause, but will create a “omp shared” clause

prepareSumReductionClause

public void prepareSumReductionClause(Block usageBlock)

Same as preparePrivateClause, but will cause a REDUCTION(+:…), always in the BWD sweep, and on the diff

probableName

public String probableName()

sameNSH

public static boolean sameNSH(Tree tree1, Tree tree2)

setAsConstantVariable

public void setAsConstantVariable(WrapperTypeSpec typeSpec, TapList<SymbolDecl> dependsOn, Tree value)

Declares that this NewSymbolHolder represents a CONSTANT name, of the given “typeSpec”, and this “typeSpec” depends on the previous declarations “dependsOn”.

setAsType

public void setAsType(WrapperTypeSpec typeSpec, TapList<SymbolDecl> dependsOn)

Declares that this NewSymbolHolder represents a TYPE name.

setAsVariable

public void setAsVariable(WrapperTypeSpec typeSpec, TapList<SymbolDecl> dependsOn)

Declares that this NewSymbolHolder represents a VARIABLE name, of the given “typeSpec”, and this “typeSpec” depends on the previous declarations “dependsOn”.

setDependsOn

public void setDependsOn(TapList<SymbolDecl> dependsOn)

setExtraInfo

public void setExtraInfo(TapList<String> info)

setHintArrayTreeForCallSize

public void setHintArrayTreeForCallSize(Tree hintSize)

setHintRootTree

public void setHintRootTree(Tree hintRootTree)

setInstruction

public void setInstruction(Instruction instr)

setNewTypeDecl

public void setNewTypeDecl(TypeDecl typeDecl)

setOtherDefSymbolTable

public void setOtherDefSymbolTable(SymbolTable symbolTable)

setTypeDeclTreeAlreadyPlacedFor

public void setTypeDeclTreeAlreadyPlacedFor(SymbolTable symbolTable)

setUsesRefTo

public void setUsesRefTo()

Say that references to this variable X must emulate PASS-BY-REFERENCE by using *X and &X.

setVarDeclTreeAlreadyPlacedFor

public void setVarDeclTreeAlreadyPlacedFor(SymbolTable symbolTable)

setVarDeclTreeNotAlreadyPlaced

public void setVarDeclTreeNotAlreadyPlaced()

solve

public void solve(SymbolTable symbolTable, boolean noCopySuffix)

SOLVE a NewSymbolHolder. When we reach the rootmost SymbolTable, solve this NewSymbolHolder i.e. choose its final name and insert the new symbol SymbolDecl(s).

solvingLevelMustInclude

public void solvingLevelMustInclude(SymbolTable symbolTable)

solvingRootIsOutsideFile

public boolean solvingRootIsOutsideFile(SymbolTable symbolTable)
Returns

true when the symbolSolvingRootSymbolTable resulting from merging with “symbolTable” would be outside a C compilation unit, i.e. would be th C language root symboltable, therefore causing conflicts when solving for the new name.

toString

public String toString()

typeSpec

public WrapperTypeSpec typeSpec()

usesRefTo

public boolean usesRefTo()