Search in sources :

Example 1 with LoopBoundExpr

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);
    }
}
Also used : LoopBoundExpr(com.jopdesign.wcet.annotations.LoopBoundExpr) ExecutionContext(com.jopdesign.common.code.ExecutionContext) CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) LinearConstraint(com.jopdesign.wcet.ipet.LinearConstraint) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) SymbolicMarker(com.jopdesign.common.code.SymbolicMarker)

Example 2 with LoopBoundExpr

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;
}
Also used : LoopBoundExpr(com.jopdesign.wcet.annotations.LoopBoundExpr) CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) ArrayList(java.util.ArrayList) ExecutionContext(com.jopdesign.common.code.ExecutionContext) CFGEdge(com.jopdesign.common.code.ControlFlowGraph.CFGEdge) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) ExecutionEdge(com.jopdesign.wcet.ipet.IPETBuilder.ExecutionEdge) SymbolicMarker(com.jopdesign.common.code.SymbolicMarker)

Aggregations

CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)2 ExecutionContext (com.jopdesign.common.code.ExecutionContext)2 SymbolicMarker (com.jopdesign.common.code.SymbolicMarker)2 LoopBoundExpr (com.jopdesign.wcet.annotations.LoopBoundExpr)2 ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)1 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)1 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)1 ExecutionEdge (com.jopdesign.wcet.ipet.IPETBuilder.ExecutionEdge)1 LinearConstraint (com.jopdesign.wcet.ipet.LinearConstraint)1 ArrayList (java.util.ArrayList)1