ILUtils¶
-
public final class
ILUtils
¶ IL Trees basic utility methods.
Methods¶
acceptsMultiDirDimension¶
addAddressOf¶
addAddressOfAtBase¶
addExpressionsNumConstants¶
addListTreeInList¶
addNumericalStrings¶
addPointerAccess¶
addPointerAccessAtBase¶
addProtectedExprs¶
addSchedule¶
addVarIntoFuturePrivates¶
-
public static void
addVarIntoFuturePrivates
(NewSymbolHolder privateNSH, Tree pragma, boolean inFwd, boolean diff)¶ Assumes pragma is an OpenMP pragma. Adds privateNSH into the list of variables that must be added as “private”.
- Parameters
privateNSH – the symbol holder of the future variable to declare private.
pragma – the OpenMP pragma source tree.
inFwd – when true, the private clause goes to the fwd differentiated pragma
diff – when true, the private clause will be about the variable’s derivative
addVarIntoFutureSumReductions¶
-
public static void
addVarIntoFutureSumReductions
(NewSymbolHolder sumReductionNSH, Tree pragma)¶ Same as addVarIntoFuturePrivates, but will cause a REDUCTION(+:…)
adoptOrAppendComments¶
appendComments¶
arrayTypeToArrayDeclarator¶
assignedLabel¶
assignedLabelVar¶
assignedName¶
baseName¶
baseTree¶
build¶
build¶
build¶
buildArrayDeclarator¶
buildArrayTripletAccess¶
buildDimColon¶
buildExpressionOpposite¶
buildInitAssign¶
buildIterativeLength¶
-
public static int
buildIterativeLength
(Tree tree, SymbolTable symbolTable)¶ - Returns
the number of successive individual atomic values in the list of expressions “tree”. If this length cannot be statically determined, return -1.
buildListIdents¶
buildNameInIdent¶
buildNameInText¶
buildNumericalOpposite¶
buildSingleStatement¶
buildSizeArgument1¶
-
public static Tree
buildSizeArgument1
(Tree tree, SymbolTable symbolTable)¶ used in size(…).
buildSizeTree¶
buildSmartAddSub¶
buildSmartMulDiv¶
checkFunctionName¶
-
public static void
checkFunctionName
(FunctionDecl functionDecl, SymbolTable symbolTable)¶
collectCommentStrings¶
collectCommentStrings¶
contains¶
containsArrayDeclarator¶
-
public static boolean
containsArrayDeclarator
(SymbolDecl varDecl, Tree tree)¶
containsFunctionDeclarator¶
containsModifier¶
containsUnknownDimension¶
copy¶
-
public static Tree
copy
(Tree tree)¶ - Returns
a copy of the given “tree”. The original Tree and the copied Tree share their set of annotations. Each subtree annotated with a “NewSymbolHolder”, (i.e. the subtree might change later) is copied into a new subtree with the same “NewSymbolHolder”, and registered by this “NewSymbolHolder”. This way, when the “NewSymbolHolder” eventually decides on the final form of the subtree, the copied subtree will receive the final form too.
copyWatchingEqualsSubtrees¶
copyWatchingSubtrees¶
-
public static TapPair<Tree, TapList<TapPair<Tree, Tree>>>
copyWatchingSubtrees
(Tree origTree, TapList<TapPair<Tree, Tree>> subTreeCopies)¶ Builds a recursive copy of origTree, observing separately copied sub-trees given by “subTreeCopies”. The TapList “subTreeCopies” is a key-list of TapPair’s (Tree . Tree). For each sub-tree of origTree that appears as a key in subTreeCopies, this sub-tree is not copied, and instead the corresponding “value” tree is inserted into the copied tree. In the special case where the “value” Tree is null, a copy of the key-tree is inserted into the copied tree. This function builds also a new key-list, where the keys are the copies of the original key Trees. These copies are those who appear in the copied Tree. The values in this new key-list are null.
- Returns
the TapPair of the copied Tree and the new key-list.
declaresVariable¶
disjointPath¶
divProtectedExprs¶
dump¶
-
public static void
dump
(Tree tree, int indent)¶ Prints in detail the contents of the given IL tree, onto TapEnv.curOutputStream(). This printing may go on several lines, with indentation. This printing calls toStringRec() for single-line pieces of the tree.
- Parameters
indent – the amount of indentation to be used for this printing.
eqOrDisjointRef¶
-
public static int
eqOrDisjointRef
(Tree tree1, Tree tree2, Instruction instr1, Instruction instr2)¶ - Returns
DIFFERENT = -1 if the two trees certainly always refer to different memory cells, SAME = 1 if the two trees certainly always refer to the same memory cell, DOUBT = 0 otherwise, i.e. in case of doubt.
equalValues¶
-
public static boolean
equalValues
(Tree tree1, Tree tree2, Instruction instr1, Instruction instr2)¶
evalsToGEZero¶
evalsToGTZero¶
evalsToLTZero¶
evalsToMinusOne¶
evalsToOne¶
evalsToZero¶
extractPrivateTrees¶
-
public static TapList<Tree>
extractPrivateTrees
(Tree pragma, SymbolTable usageST, boolean inFwd, boolean diff)¶ Assumes pragma is an OpenMP pragma.
- Parameters
pragma – the OpenMP pragma source tree.
usageST – the scope of the place where the pragma is.
inFwd – when true, returns the trees for the fwd differentiated pragma
diff – when true, returns the trees that are meant to be differentiated
- Returns
the list of Tree’s coming from the variables stored for private declaration. The stored list of variables stored to be private is then cleared. Since this list has been accumulated with the latest first, we can reverse it again upon rebuild.
extractSumReductionTrees¶
-
public static TapList<Tree>
extractSumReductionTrees
(Tree pragma, SymbolTable usageST)¶ Same as extractPrivateTrees, but extracts the future REDUCTION(+:…) diff variables
findArrayTriplet¶
findDimColons¶
findRankOfDeclarator¶
getArguments¶
getBindCValue¶
-
public static String
getBindCValue
(Tree tree, int rank)¶ - Parameters
tree – is an accessDecl Tree
rank – of declared variable
- Returns
FORTRAN_NAME if tree== accessDecl(accessDecl(ident:bind, expressions[ident:c]), expressions[ident:FORTRAN_NAME]) or return C_NAME if tree == accessDecl(accessDecl(ident:bind, expressions[ident:c, nameEq(ident:name, C_NAME)]), expressions[ident:FORTRAN_NAME]). [llh 12Dec2022] TODO: make this method cleaner and more general, or remove if not used any more.
getCall¶
getCallFunctionNameString¶
getCalledName¶
getCalledNameString¶
getFieldRank¶
getIdentString¶
getLineNumber¶
getListOfStatements¶
getModulesFromInterfaceDecl¶
getNamedElement¶
getObject¶
getOptionalDim¶
-
public static Tree
getOptionalDim
(Tree[] srcParamExprs, SymbolTable symbolTable)¶ - Returns
the optional “dim” argument of a F90 SUM. Returns null when no dim is present.
getOptionalMask¶
-
public static Tree
getOptionalMask
(Tree[] srcParamExprs, SymbolTable symbolTable)¶ - Returns
the optional “mask” argument of a F90 SUM. Returns null when no mask is present.
getRemoveSchedule¶
gotoLabelVar¶
hasDuplicableLastIndex¶
-
public static Tree
hasDuplicableLastIndex
(Tree doLoopControl, boolean exit)¶ - Returns
the expression tree that computes the last (if “exit” is false) or the exit value (if “exit” is true) of the index of a do-loop. @return null when this expression contains side-effets and therefore cannot be executed twice without risk.
hasTwoLevelIndex¶
-
public static boolean
hasTwoLevelIndex
(Tree indices, SymbolTable symbolTable)¶ Detects that some index in indices is itself an array of arbitrary indices
incorporateAnnotations¶
-
public static void
incorporateAnnotations
(Tree destTree, Tree origTree)¶ Reads the annotations at the root of origTree and tries to merge them with the annotations at the root of destTree. This depends on the “meaning” of the annotations created by Tapenade. You may develop this method further if other annotations get lost…
incrementByProtectedExpr¶
intConstantValue¶
isAConstModified¶
isAVarRef¶
-
public static boolean
isAVarRef
(Tree tree, SymbolTable symbolTable)¶ - Returns
true when “tree” is a reference to a variable writable at the present location. This means that “tree” can be overwritten, modified, passed as a “write” argument of a function or put on the left side of an assignment. WARNING: differs from isAWritableVarRef(): if this variable was declared as a “const” argument of a C procedure, this method considers this tree is not writeable.
isAVarRefOrConstant¶
isAWritableIdentVarRef¶
-
public static boolean
isAWritableIdentVarRef
(Tree tree, SymbolTable symbolTable)¶ Same as isAWritableVarRef() but rejects op_fieldAccess and op_substringAccess.
isAWritableVarRef¶
-
public static boolean
isAWritableVarRef
(Tree tree, SymbolTable symbolTable)¶ - Returns
true when “tree” is a reference to a variable intrinsically writable. This means that “tree” can be overwritten, modified, passed as a “write” argument of a function or put on the left side of an assignment. WARNING: this is not exactly the same as isAVarRef(): a FORTRAN CONSTANT is considered not writable whereas a C “const” argument is considered writable because “const” only means that this procedure promises it will not write in the variable (but it would be possible). This is important because the diff of tree will be writeable because we will not make it “const”.
isAccessedThroughPointer¶
isAccessibleDirectlyFromVariable¶
isCallingString¶
isCudaController¶
isExpressionConstant¶
isExpressionIntConstant¶
isExpressionNumConstant¶
isIORead¶
isIOWrite¶
isIdent¶
isIdentOf¶
isIntCst¶
isNegativeExpression¶
isOptPointersIdent¶
isOverloadedAssign¶
isParallelController¶
isStaticSchedule¶
isStringOf¶
listReversedToComments¶
matches¶
-
public static boolean
matches
(Tree tree, Tree patternTree, TapList<TapPair<Tree, Tree>> keyTreeList)¶ - Returns
true iff “tree” matches “patternTree”. As a side-effect, places inside “keyTreeList”, in front of each metavariable Tree from “patternTree”, the matched Tree from “tree”. However, even if finally there is no matching, tree traversal goes on and keeps associating trees when reasonably possible.
mayBeTransformed2Do¶
mergeUseDeclTrees¶
-
public static Tree
mergeUseDeclTrees
(Tree newRestrict, Tree oldRestrict)¶ Combines two successive use-restriction trees, that are of form either “onlyVisibles” or “renamesVisibles”. These restriction trees apply in order, i.e. this method returns the use-restriction tree that results from applying “newRestrict” over “oldRestrict”.
[any] + renamedVisibles[] → [any] onlyVisibles[ident1] + onlyVisibles[ident2] → onlyVisibles[ident1] renamedVisibles[r1] + renamedVisibles[r2] → renamedVisibles[r1 + r2] (TODO) onlyVisibles[ident1] + renamedVisibles[r2] → onlyVisibles[ident1, renamedVisibles[r2]] (TODO)
minusProtectedExpr¶
mulProtectedExprs¶
-
public static Tree
mulProtectedExprs
(Tree factor1, TypeSpec type1, Tree factor2, TypeSpec type2)¶ Multiplies two factors, taking care of the case where any of them is protected. In this case, builds a new protected factor, where the test is the OR of both tests and the factor is the mulTree of the two factors. In either branch “then” and “else”, a null or a none “()” means zero. Works only in the following cases (symmetric cases work just as well):
() * () → () Exp1 * Exp2 → Exp1*Exp2 Exp1 * (T2?SExp2:Exp2) → (T2?Exp1*SExp2:Exp1*Exp2) (T1?():Exp1) * (T2?():Exp2) → (T1orT2?():Exp1*Exp2)
normalizePath¶
operator¶
pathFromPointerAccess¶
position¶
pullProtectedArg¶
-
public static Tree
pullProtectedArg
(Tree callTree, int argRank)¶ Looks at argument argRank of the given callTree. If this argument is “protected”, i.e. it is an ifExpression, and we are targetting Fortran, then returns a new tree which has the protection outside and the call inside. Otherwise returns the unmodified callTree.
putBackNamedArguments¶
realIsInt¶
-
protected static boolean
realIsInt
(String str, TapIntList toIntVal)¶ Tests that the current String (found in a op_realCst) actually represents an integer. If so, returns true, and if “toIntVal” is non-null, also sets its head to the corresponding integer value if in [-maxint;+maxint].
removeUsedModuleFromInterfaceDecl¶
replaceAllCallName¶
replaceAllIdentsNamed¶
replaceIdentStringOccurences¶
replaceRootWithNewRoot¶
replaceUsedModule¶
resetAssignFromInitDecl¶
resetReturnFromAssign¶
reverseArrayComponentOrder¶
reversedExprAccess¶
reversedExprAccessFromPointerAccess¶
seemsInteger¶
setToProtectedExpr¶
skipAllocate¶
splitDeclInit¶
splitLongDeclaration¶
stripArrayAccesses¶
stripSpecialization¶
tapenadeUtilityFunctionName¶
toString¶
-
public static String
toString
(Tree tree, int language, ActivityPattern pattern)¶
toString¶
-
public static String
toString
(Tree tree, ActivityPattern pattern)¶
transformFor2Do¶
turnAssignFromInitDecl¶
-
public static void
turnAssignFromInitDecl
(Tree assignmentTree)¶ Modifies assigmentTree to represent the corresponding “true” assignment. For instance, given
(*x) = y+1
which is the 2nd child offloat *x = y+1
, turns it temporarily intox = y+1
. This damages the original assignment. WARNING: IMMEDIATELY after usage of the modified assignment tree, it MUST be repaired into its original form with resetAssignFromInitDecl(returnedTree).- Parameters
assignmentTree – Tree present in a declaration with initialization.
turnReturnIntoAssign¶
-
public static Tree
turnReturnIntoAssign
(Tree returnTree, String returnVarName)¶ Given “returnTree” (a C-style “return <expression>” tree), creates “assignTree” (a tree of shape “returnVarName := <expression>”) that shares the <expression> tree instead of copying it. This damages the original returnTree. WARNING: IMMEDIATELY after usage of the created assignTree, the returnTree MUST be repaired into its original form with resetReturnFromAssign(returnTree, assignTree).
usedVarsInDiffExp¶
-
public static TapList<Tree>
usedVarsInDiffExp
(Tree expression, TapList<Tree> refsR, TapList<Tree> toDiffRefsR, boolean keepTop)¶ Augment the list of Trees “refsR” with all the expressions whose primal is recursively needed to evaluate the diff of “expression”. Augment the (hatted) list of Trees “toDiffRefsR” with all the expressions whose diff is recursively needed to evaluate the diff of “expression”. New expressions are added only if they are not already present. Example: for *(p[i+j]), i , j go to refsR, and p, p[i], (and if keepTop *(p[i])) go to toDiffRefsR
- Parameters
toDiffRefsR – the hatted list that accumulates the expressions whose diff is used.
keepTop – if false, the top “expression” itself is not added.
- Returns
the augmented “refsR” list.
usedVarsInExp¶
-
public static TapList<Tree>
usedVarsInExp
(Tree expression, TapList<Tree> refsR, boolean keepTop)¶ Augment the list of Trees “refsR” with all the expressions recursively needed to evaluate “expression”. New expressions are added only if they are not already present.
- Parameters
keepTop – if false, the top “expression” itself is not added.
- Returns
the augmented “refsR” list.
usedVarsInTreeOfExps¶
-
public static TapList<Tree>
usedVarsInTreeOfExps
(TapList<Tree> treeOfExps, TapList<Tree> refsR, boolean keepTop)¶ - Returns
the list of Trees “refsR”, augmented with all the expressions recursively needed to evaluate expressions in “treeOfExps”. New expressions are added only if they are not already present. If “keepTop” is false, top-level expressions in “treeOfExps” are not returned.