Block¶
-
public class
Block
¶ One Block of a Flow Graph. Blocks contain sequences of elementary instructions that are executed always in sequence from the first to the last. The last instruction may be a test which decides which Flow Arrow (FGArrow) is taken after the end of the Block’s execution. If the last instruction is not a test, then there may be only one flow arrow leaving from the Block.
Fields¶
analysisIsOutOfDate¶
-
public boolean
analysisIsOutOfDate
¶ Mark useful in any Data Flow analysis to write whether this Block must be analyzed again at next analysis sweep.
constantZones¶
-
public BoolVector
constantZones
¶ The zones that are constant from the beginning of this Block till the exit of the containing Unit. This info is filled by InOutAnalyzer.
controllers¶
controllersZone¶
-
public TapIntList
controllersZone
¶ The list of the control zones controlling this block.
dominator¶
-
public BoolVector
dominator
¶ Vector of the ranks of the Blocks that are certainly executed before this one.
immediateDominator¶
immediatePostDominator¶
instructions¶
-
public TapList<Instruction>
instructions
¶ The ordered list of all instructions in this Block.
isFGCycleHead¶
-
public boolean
isFGCycleHead
¶ True if this Block has an incoming backFlow FGArrow that comes from a Block later or equal (i.e. with a greater or equal rank) in the DFST order.
isFGCycleTail¶
-
public boolean
isFGCycleTail
¶ True if this Block has an exiting flow FGArrow that goes to a Block earlier or equal (i.e. with a lower or equal rank) in the DFST order.
parallelControls¶
-
public TapList<Instruction>
parallelControls
¶ The controlling parallel instructions for this Block.
pointerInfosIn¶
-
public BoolMatrix
pointerInfosIn
¶ The matrix of pointer destinations at the begining of the block.
postDominator¶
-
public BoolVector
postDominator
¶ Vector of the ranks of the Blocks that are certainly executed after this one.
predecessor¶
-
public BoolVector
predecessor
¶ Vector of the ranks of the Blocks that are possibly executed before this one.
rank¶
-
public int
rank
¶ A unique rank of this Block. -1 is for the EntryBlock. Other Blocks are numbered from 0 up, in DFST order.
reachable¶
-
protected boolean
reachable
¶ True if this Block is reachable from the Unit’s entry. [llh 9Nov2023]: this info is apparently not used and is different from the info stored in “reachUp” and “reachDown”. Maybe we could use the methods from Unit.computeReachability() to refine our “reachUp” and “reachDown”, then remove computeReachability().
successor¶
-
public BoolVector
successor
¶ Vector of the ranks of the Blocks that are possibly executed after this one.
symbolTable¶
-
public SymbolTable
symbolTable
¶ The SymbolTable of symbols visible from this Block.
symbolicRk¶
unusedZones¶
-
public BoolVector
unusedZones
¶ The zones that are unused from the beginning of this Block till the exit of the containing Unit. This info is filled by InOutAnalyzer.
Constructors¶
Block¶
-
public
Block
(SymbolTable symbolTable, TapList<Instruction> parallelControls, TapList<Block> allBlocks)¶ Create an empty Block, set its SymbolTable, and register it into the list of created Blocks “allBlocks” (if nonempty).
Methods¶
addBackFlow¶
addInstrDeclTl¶
-
public void
addInstrDeclTl
(TapList<Instruction> decls)¶ Adds instructions “decls” after the declarations in this Block.
addInstrDeclTlBeforeUse¶
-
public int
addInstrDeclTlBeforeUse
(Instruction instr, TapList<SymbolDecl> symbolDecls, TapList<Instruction> usageInstructions, SymbolTable declST, boolean strict)¶ Adds instruction “instr” after the declarations in this Block BUT before the declarations that depend on this declaration.
- Parameters
symbolDecls – the symbols that the given “instr” declares or defines.
declST – The SymbolTable where the new “symbolDecls” will be.
strict – when true, vars in a COMMON must be declared before the COMMON.
- Returns
when the instruction was moved some lines before its original location, to be before using declarations or computation instructions, returns the number of locations moved up. Otherwise returns 0.
addInstrHd¶
addInstrHd¶
-
public void
addInstrHd
(Instruction instr)¶ Adds instruction “instr” at the head of this Block.
addInstrHdAfterDecls¶
-
public Instruction
addInstrHdAfterDecls
(Tree tree)¶ Adds a new Instruction with “tree” at the head of this Block BUT after the declarations.
- Returns
the new Instruction created.
addInstrHdAfterDecls¶
-
public void
addInstrHdAfterDecls
(Instruction instr)¶ Adds instruction “instr” at the head of this Block BUT after the declarations.
addInstrHdIfNotPresent¶
-
public void
addInstrHdIfNotPresent
(Instruction instr)¶ Adds a new use statement Instruction at the head of this Block.
- Parameters
instr – fortran use statement.
addInstrTl¶
addInstrTl¶
-
public void
addInstrTl
(Instruction instr)¶ Adds instruction “instr” at the end of this Block.
addInstructionAt¶
-
public void
addInstructionAt
(Tree tree, int place)¶ Add inside this Block a new Instruction containing the given tree, at a location given by “place”. If place is positive or 0, location is counted from the head down, and 0 means before the 1st instruction. Too large place inserts at the tail. If place is negative, location is counted from the tail up, and -1 means after the last instruction. Too large (-)place inserts at head.
addTreeDeclTl¶
alreadyPresent¶
-
public boolean
alreadyPresent
(Instruction instr)¶ - Returns
true if instr is already in this Block and is not in an include.
backFlow¶
buildTemporaryVariable¶
-
public Tree
buildTemporaryVariable
(String name, Tree expr, SymbolTable targetSymbolTable, ToObject<NewSymbolHolder> toNSH, boolean reuse, TapList<NewSymbolHolder> excludedReuse, boolean declare, FunctionTypeSpec functionTypeSpec, int argRank, Tree refForHint)¶ Returns a temporary variable usable to split expression “expr” from this Instruction. This variable should be named after the given “name” (possibly extended as usual if conflicts with some existing variable). It is meant to contain the result of “expr”. This either reuses an existing temporary variable if available, or creates a new one and takes care of its declaration.
- Parameters
name – The suggested name for the returned temporary variable.
expr – The expression that should be precomputed and assigned to the temporary variable.
targetSymbolTable – The SymbolTable where the future temporary variable will live.
toNSH – When passed non-null, a container that will contain upon return the NewSymbolHolder of the temporary variable.
reuse – If passed true, may return an already created temporary variable of same name and type.
excludedReuse – when reuse==true, a list of NewSymbolHolder’s that must not be reused here.
declare – If passed false, assume the variable is not yet used and needs no declaration. In doubt, pass true.
functionTypeSpec – In the case where “expr” is the actual argument or result of some procedure call, the type of this procedure. Else null.
argRank – When “expr” is the actual argument or result of some procedure call, the rank of this argument (from 1 up) or 0 when result. Else -1.
refForHint – When given non-null, some ref-expression whose dimensions are the same as “expr”, that can be useful to get better hints about the values of ISIZEnOF… dimension sizes.
- Returns
The ref-expression Tree of the temporary variable.
checkUnusedDeclaration¶
cite¶
-
public void
cite
()¶ Prints a short reference to this Block onto TapEnv.curOutputStream().
- Throws
java.io.IOException – if an output error is detected.
containsInstructionTree¶
containsNoCode¶
-
public boolean
containsNoCode
()¶ Returns true if this block contains no meaningful code, and therefore can be skipped See for instance in FlowGraphDifferentiator.allExitsTurn()
copyInstructions¶
-
public void
copyInstructions
(Block modelBlock, TapList<TapPair<Instruction, Instruction>> copiedIncludes)¶ Fills this Block with a copy of the modelBlock instructions. Instruction’s are copied too. Tree’s are copied.
copyIntoWithoutArrows¶
-
protected void
copyIntoWithoutArrows
(Block newBlock, TapList<TapPair<Instruction, Instruction>> alreadyCopiedMasks)¶ Places most elements of this Block into “newBlock”. Copies instructions, labels, rank, and where masks Doesn’t copy Flow Graph arrows. Uses “alreadyCopiedMasks” to make sure that copied whereMask’s keep equal (==) tests.
dump¶
-
public void
dump
(int indent)¶ Prints in detail the contents of this Block, onto TapEnv.curOutputStream().
- Parameters
indent – the amount of indentation to be used for this printing.
- Throws
java.io.IOException – if an output error is detected.
dumpInstructions¶
-
protected final void
dumpInstructions
(int indent)¶ Dumps instructions of this Block.
- Parameters
indent – indentation.
- Throws
java.io.IOException – if an output error is detected.
enclosingBlock¶
enclosingLoop¶
enclosingLoops¶
exchangeFlowArrowsTo¶
findRankToInsert¶
firstInstrAfterDecls¶
-
public Instruction
firstInstrAfterDecls
()¶ - Returns
the first instruction of this Block which is not a declaration.
flow¶
flowsOutOfScope¶
-
public boolean
flowsOutOfScope
(SymbolTable symbolTable)¶ - Returns
true when this block flows to a Block that cannot see scope SymbolTable
flowsTo¶
getAssGotoInfoDone¶
getControlStruct¶
-
public ControlStruct
getControlStruct
()¶ Gets this Block’s Tree regeneration ControlStruct (using field “tmp1”).
getDominatorArrows¶
-
public BoolVector
getDominatorArrows
()¶ Gets this Block’s BoolVector of dominating FGArrow’s (using field “tmp3”).
getFGArrowTestCase¶
getFGArrowTo¶
getFinalGotoRank¶
-
public int
getFinalGotoRank
()¶ Gets the rank of the variable in the computed GOTO that terminates this block (using field “tmp2”). Must be -1 if no GOTO.
getLabelVariablesEffect¶
getOperatorDeclarationInstruction¶
-
public Instruction
getOperatorDeclarationInstruction
(SymbolDecl symbolDecl, int operator, SymbolTable symbolTable)¶ - Parameters
operator – == op_varDeclaration or op_typeDeclaration or op_interfaceDecl.
- Returns
the varDeclaration or typeDeclaration or interfaceDecl Instruction that declares this symbolDecl in this Block.
getStaticIterationIndices¶
getStaticIterationSpace¶
hasCommentWith¶
hasDeclarationCommentStartingWith¶
hasStaticIterationSpace¶
-
public boolean
hasStaticIterationSpace
()¶ For future use.
- Returns
true if the control context of this block allows for a static saving of the tape, i.e. this block is either in the main stream, of inside a nest of loops that all have a static iteration space.
headInstr¶
-
public Instruction
headInstr
()¶ - Returns
the first instruction in this Block.
insertBlockBefore¶
isACleanDoLoop¶
-
public boolean
isACleanDoLoop
()¶ - Returns
true if this Block “isALoop” and is the HeaderBlock of a normal DO-loop, which has no dirty jumps in or out of the loop.
isADoLoop¶
-
public boolean
isADoLoop
()¶ - Returns
true if this block “isALoop” and is the Header of a DO-loop.
isALoop¶
-
public boolean
isALoop
()¶ - Returns
true if this Block has a unique instruction which is an op_loop, used to control other Blocks. In particular returns false if it is an op_loop that already contains a body, which means it is a closed instruction that is equivalent in this Flow Graph to an atomic, simple instruction.
isANameSpace¶
-
public boolean
isANameSpace
()¶ - Returns
true if the block terminates with a nameSpace, which is a “true” analyzed nameSpace, meaning that its contents are in the next Block(s).
isATimesLoop¶
-
public boolean
isATimesLoop
()¶ - Returns
true if this block “isALoop” and is the Header of a TIMES-loop.
isAnIf¶
-
public boolean
isAnIf
()¶ - Returns
true if the block terminates with an if test, which is a real “if” that controls the next choice in the control flow.
isControl¶
-
public boolean
isControl
()¶ - Returns
true if this is a control block, i.e a block terminated by a control flow instruction. When this Block is a header, it is a control even if it has no LOOP:exit arrow.
isDoWithIndexUnusedAfterLoop¶
-
public boolean
isDoWithIndexUnusedAfterLoop
()¶ - Returns
true if this is a standard DO loop HeaderBlock, marked as loopIndexUnusedAfterLoop. Do not test on the “enclosing” field, as this method is called on differentiated Blocks, for which the “enclosing” field has not been conputed
isOutsideFlow¶
-
public boolean
isOutsideFlow
()¶ - Returns
true if this block that contains sub-units definitions is outside of the notion of control flow.
isParallelController¶
-
public boolean
isParallelController
()¶ - Returns
true if this Block is the controller of a parallel region or loop e.g. $OMP PARALLEL.
isVarDeclaredInBlock¶
-
public boolean
isVarDeclaredInBlock
(SymbolDecl symbolDecl)¶
lastInstr¶
-
public Instruction
lastInstr
()¶ - Returns
the last instruction in this Block.
lastTest¶
-
public int
lastTest
()¶ - Returns
the op_code of the tail test of this Block If the last instruction of this block is a test, returns its op_code, otherwise returns -1.
listOfStatements¶
mergeWithSuccessor¶
newDeclarationsBlock¶
-
protected void
newDeclarationsBlock
(Block modelBlock)¶ When necessary, makes this current Block the new declarationsBlock of its SymbolTable. When “modelBlock” was the declarationsBlock of its own symbolTable, and assuming that “this” new Block is in fact a copy of “modelBlock”, then fills the “declarationsBlock” field of their symbolTable so that it points to “this” new block instead of to the old “modelBlock”.
origLabel¶
removeAndShunt¶
-
public void
removeAndShunt
()¶ Removes this Block from its containing Flow Graph, redirecting all arrows flowing to it towards its unique flow destination. This requires that this Block has only one exiting flow arrow.
removeExternalInstr¶
-
protected void
removeExternalInstr
(SymbolDecl symbolDecl)¶ Removes external symbolDecl’s declaration-instruction from this Block.
removeInstr¶
-
public void
removeInstr
(Instruction instr)¶ Removes “instr” from this Block.
replaceInFlowGraph¶
setAssGotoInfoDone¶
setBackFlow¶
setControlStruct¶
-
public void
setControlStruct
(ControlStruct controlStruct)¶ Sets this Block’s Tree regeneration ControlStruct (using field “tmp1”).
setDominatorArrows¶
-
protected void
setDominatorArrows
(BoolVector dominators)¶ Sets this Block’s BoolVector of dominating FGArrow’s (using field “tmp3”).
setEnclosingBlock¶
setEnclosingBlockProtected¶
-
protected void
setEnclosingBlockProtected
(Block enclosingBlock)¶ Sets “enclosingBlock” as the header of the loop directly enclosing this Block. “enclosingBlock” may be a HeaderBlock or a BasicBlock. Protection: this setting is not done if the Block already has an enclosing loop and the new enclosing is not contained in the old enclosing.
setEnclosingLoop¶
setFinalGotoRank¶
-
public void
setFinalGotoRank
(int rank)¶ Sets the rank of the variable in the computed GOTO that terminates this block (using field “tmp2”). Must be -1 if no GOTO.
setFlow¶
setLabelVariablesEffect¶
setOrigLabel¶
skipEmpty¶
-
protected void
skipEmpty
()¶ Removes current Block, because we assume it is empty. All flow arrows jump over it.
splitInstructions¶
-
protected void
splitInstructions
(TapList<Instruction> beforeEntry, TapList<Instruction> beforeCycle)¶ Split instructions of this Block, e.g. to isolate subroutine and function calls.
symbolDeclDeclared¶
-
public TapList<SymbolDecl>
symbolDeclDeclared
(Instruction instruction)¶ - Returns
the list of all SymbolDecl’s defined in Instruction.
symbolDeclDeclared¶
-
public TapList<SymbolDecl>
symbolDeclDeclared
(Tree tree, SymbolTable inSymbolTable)¶ - Returns
the list of all SymbolDecl’s defined in Tree.
typeCheck¶
-
protected void
typeCheck
(SymbolTable definitionSymbolTable)¶ TypeChecks this Block.
- Parameters
definitionSymbolTable – SymbolTable used to typecheck this Block.