InOutAnalyzer

public final class InOutAnalyzer extends DataFlowAnalyzer

In-out analysis (aka read-write).

Fields

CONSTANT

public static final int CONSTANT

Constant that codes for the CONSTANT sub phase.

INOUT

public static final int INOUT

Constant that codes for the INOUT phase.

OTHER

public static final int OTHER

Constant for the three other phases.

UNUSED

public static final int UNUSED

Constant that codes for the UNUSED sub phase.

USED_UNDEF

public static final int USED_UNDEF

Constant that codes for the USED_UNDEF sub phase.

Methods

analyze

protected boolean analyze()

Runs in-out analysis on “curUnit”, plus related analyses.

Returns

true if the analysis result for this curUnit has changed since the previous time.

compareChannelZoneDataDownstream

protected boolean compareChannelZoneDataDownstream(int mpZone, Block refBlock)

compareChannelZoneDataUpstream

protected boolean compareChannelZoneDataUpstream(int mpZone, Block refBlock)

compareDownstreamValues

protected boolean compareDownstreamValues()

Compares the downstream info with the result of previous sweep. Sometimes (e.g. for INOUT) we think comparison might take too long, so we don’t compare and we return the default “true”.

compareUpstreamValues

protected boolean compareUpstreamValues()

Compares the in-out data flow information with the same info of the previous sweep. Overwrites the previous info if different. @return true when the new result is different from the previous one, thus asking for a new FG sweep.

cumulCycleValueWithAdditional

protected void cumulCycleValueWithAdditional(SymbolTable commonSymbolTable)

First initialize the cumul cycle-values if they are null, then accumulate the additional value into the cumul cycle-value.

cumulValueWithAdditional

protected void cumulValueWithAdditional(SymbolTable commonSymbolTable)

First initialize the cumul values if they are null, then accumulate the additional value into the cumul value.

getFrontierModifiedZones

public BoolVector getFrontierModifiedZones(TapList<FGArrow> frontier)

When “frontier” is a list of converging flow arrows that define the entry into a fragment of the current Unit.

Returns

the vector of the zones that are modified by this fragment.

getFrontierPossiblyReadZones

public BoolVector getFrontierPossiblyReadZones(TapList<FGArrow> frontier)

When “frontier” is a list of converging flow arrows that define the entry into a fragment of the current Unit.

Returns

the vector of the zones that are read/used by this fragment.

getFrontierPossiblyWrittenZones

public BoolVector getFrontierPossiblyWrittenZones(TapList<FGArrow> frontier)

When “frontier” is a list of converging flow arrows that define the entry into a fragment of the current Unit.

Returns

the vector of the zones that are possibly overwritten by this fragment.

getFrontierUnusedZones

public BoolVector getFrontierUnusedZones(TapList<FGArrow> frontier)

When “frontier” is a list of converging flow arrows that define the entry into a fragment of the current Unit.

Returns

the vector of the zones that are unused by this fragment.

getIOeffectOfIOspec

public static Tree getIOeffectOfIOspec(Tree ioSpec, int i, String ioOper, ToBool written, ToBool totally, SymbolTable symbolTable)

For the IO specification element “ioSpec”, which is at rank “i” in the list of IO specificators of an IO call to IO operation “ioOper”.

Returns

the Tree of expressions that are affected for this ioSpec, and whether they are read or written, totally or not. VERY specific to FORTRAN (77?) IO syntax. cf VAX-Fortran manual.

getInOutOfRegion

public TapPair<BoolVector, BoolVector> getInOutOfRegion(TapTriplet<TapList<FGArrow>, TapList<Block>, TapList<FGArrow>> region, Unit unit)

Run in-out analyzer locally on the piece of code defined by “region”, and return the pair of the possibly read and oberwritten BoolVectors TODO: try use possiblyW info of the INOUT phase instead of MODIFIED of the CONSTANT phase.

getValueFlowingBack

protected boolean getValueFlowingBack()

getValueFlowingThrough

protected boolean getValueFlowingThrough()

initializeCGForUnit

protected Object initializeCGForUnit()

During initialization on the whole CallGraph, do whatever initialization is needed for “unit”, i.e. set the results to null for normal units and to the default values for intrinsics, externals, etc…

initializeCumulValue

protected void initializeCumulValue()

initializeFGForBlock

protected void initializeFGForBlock()

Initializes the in-out information through “curBlock”.

initializeInitBlock

protected void initializeInitBlock()

Set an identity information on the given initial block.

initializeUnit

protected void initializeUnit()

Initialize before one sweep on the curUnit.

isCheapDuplicableConstant

public static boolean isCheapDuplicableConstant(Tree expression, Block block, Instruction instruction)
Returns

true when the “expression” is cheap and is not modified from the beginning of “block” till the end of the enclosing Unit.

propagateValuesBackwardThroughBlock

protected boolean propagateValuesBackwardThroughBlock()

propagateValuesForwardThroughBlock

protected boolean propagateValuesForwardThroughBlock()

Only during USED_UNDEF phase, combine the “Initialized zones” info before “curBlock” with in-out infos through “curBlock”, to obtain and store the “Initialized zones” after “curBlock”.

run

protected void run(TapList<Unit> rootUnits)

Runs in-out analysis, upwards from the leaves of the CallGraph. As a result, this function fills the inOut fields of each Unit.

runAnalysis

public static void runAnalysis(CallGraph callGraph, TapList<Unit> rootUnits)

Main trigger method. Runs In-Out analysis under the rootUnits. If the context for calling the differentiated root must be created, then pass rootUnits==null and the analysis will run on the complete CallGraph, including the parts that are not under the root differentiation Units.

setCurBlockEtc

protected void setCurBlockEtc(Block block)

Set curBlock, curSymbolTable, nDZ, nDRZ, vectorMap’s.

Parameters
  • block – The new current Block.

setCurUnitEtc

public void setCurUnitEtc(Unit unit)

Set the current unit “curUnit”, and various other globals specific to curUnit.

Parameters
  • unit – The new current Unit.

setEmptyCumulAndCycleValues

protected void setEmptyCumulAndCycleValues()

setExternalOrIntrinsicDefaultInOutInfo

public static void setExternalOrIntrinsicDefaultInOutInfo(Unit unit)

Computes the default in-out signature for an intrinsic, an external or a varFunction: All vars possibly read and possibly written, except for the function result, which is never read and completely written, and for the I-O streams and all system-predefined symbols, which are never read nor written. [llh: the following is arbitrary and may be discussed:] We also assume that variables in COMMON are not read nor writen, i.e. that the external routine does not touch the COMMON, even if it might see it.

setFgPhase

public void setFgPhase(int fgPhase)

Set the current phase of the analysis at the flow graph level.

setFgSubPhase

public void setFgSubPhase(int fgSubPhase)

Set the current subphase of the analysis at the flow graph level, when fgPhase==OTHER.

terminateCGForUnit

protected void terminateCGForUnit()

terminateUnit

protected boolean terminateUnit()

Gets and stores the final InOut result on the “curUnit”. The result is computed from the InOut value propagated back till the Entry Block. @return true when the result has changed since previous time.