use of com.jopdesign.wcet.annotations.LoopBoundExpr in project jop by jop-devel.
the class GlobalAnalysis method addLoopConstraints.
/**
* Add loop contraints
* @param constraints the new constraints are added to this collection
* @param segment
* @param ccfg
* @param headOfLoop
* @param loops
* @param loopBound
* @throws InvalidFlowFactException
*/
private static void addLoopConstraints(List<LinearConstraint<SuperGraphEdge>> constraints, Segment segment, ContextCFG ccfg, CFGNode headOfLoop, LoopColoring<CFGNode, CFGEdge> loops, LoopBound loopBound) throws InvalidFlowFactException {
/* marker loop constraints */
for (Entry<SymbolicMarker, LoopBoundExpr> markerBound : loopBound.getLoopBounds()) {
/* loop constraint */
LinearConstraint<SuperGraphEdge> loopConstraint = new LinearConstraint<SuperGraphEdge>(ConstraintType.GreaterEqual);
/* rhs = sum(continue-edges(loop)) */
Iterable<SuperGraphEdge> continueEdges = segment.liftCFGEdges(ccfg, loops.getBackEdgesTo(headOfLoop));
loopConstraint.addRHS(continueEdges);
/* Multiplicities */
ExecutionContext executionContext = new ExecutionContext(ccfg.getCfg().getMethodInfo(), ccfg.getCallString());
long lhsMultiplicity = markerBound.getValue().upperBound(executionContext);
SymbolicMarker marker = markerBound.getKey();
if (marker.getMarkerType() == SymbolicMarkerType.OUTER_LOOP_MARKER) {
CFGNode outerLoopHol;
outerLoopHol = loops.getLoopAncestor(headOfLoop, marker.getOuterLoopDistance());
if (outerLoopHol == null) {
throw new InvalidFlowFactException("Bad outer loop annotation");
}
Iterable<SuperGraphEdge> exitEdges = segment.liftCFGEdges(ccfg, loops.getExitEdgesOf(outerLoopHol));
for (SuperGraphEdge exitEdge : exitEdges) {
loopConstraint.addLHS(exitEdge, lhsMultiplicity);
}
} else {
assert (marker.getMarkerType() == SymbolicMarkerType.METHOD_MARKER);
throw new AssertionError("ILPModelBuilder: method markers not yet supported, sorry");
}
constraints.add(loopConstraint);
}
}
use of com.jopdesign.wcet.annotations.LoopBoundExpr in project jop by jop-devel.
the class IPETUtils method constraintsForLoop.
/**
* Generate Loop Constraints
*/
public static <C extends CallStringProvider> List<LinearConstraint<IPETBuilder.ExecutionEdge>> constraintsForLoop(LoopColoring<CFGNode, ControlFlowGraph.CFGEdge> loops, CFGNode hol, LoopBound loopBound, IPETBuilder<C> ctx) {
ExecutionContext eCtx = new ExecutionContext(hol.getControlFlowGraph().getMethodInfo(), ctx.getCallString());
List<LinearConstraint<IPETBuilder.ExecutionEdge>> loopConstraints = new ArrayList<LinearConstraint<IPETBuilder.ExecutionEdge>>();
/* marker loop constraints */
for (Entry<SymbolicMarker, LoopBoundExpr> markerBound : loopBound.getLoopBounds()) {
/* loop constraint */
LinearConstraint<IPETBuilder.ExecutionEdge> loopConstraint = new LinearConstraint<IPETBuilder.ExecutionEdge>(ConstraintType.GreaterEqual);
for (ControlFlowGraph.CFGEdge continueEdge : loops.getBackEdgesTo(hol)) {
loopConstraint.addRHS(ctx.newEdge(continueEdge));
}
/* Multiplicities */
long lhsMultiplicity = markerBound.getValue().upperBound(eCtx);
SymbolicMarker marker = markerBound.getKey();
if (marker.getMarkerType() == SymbolicMarkerType.OUTER_LOOP_MARKER) {
CFGNode outerLoopHol;
outerLoopHol = loops.getLoopAncestor(hol, marker.getOuterLoopDistance());
if (outerLoopHol == null) {
// FIXME: [annotations] This is a user error, not an assertion error
throw new AssertionError("Invalid Loop Nest Level");
}
for (ControlFlowGraph.CFGEdge exitEdge : loops.getExitEdgesOf(outerLoopHol)) {
loopConstraint.addLHS(ctx.newEdge(exitEdge), lhsMultiplicity);
}
} else {
assert (marker.getMarkerType() == SymbolicMarkerType.METHOD_MARKER);
throw new AssertionError("ILPModelBuilder: method markers not yet supported, sorry");
}
loopConstraints.add(loopConstraint);
}
return loopConstraints;
}
Aggregations