use of com.jopdesign.common.code.SymbolicMarker in project jop by jop-devel.
the class FatalError method Context.
SymbolicMarker Context() {
SymbolicMarker marker;
marker = null;
if (la.kind == 16) {
Get();
int outerLoop = 1;
if (la.kind == 12) {
Get();
Expect(3);
outerLoop = Integer.parseInt(t.val);
Expect(13);
}
marker = SymbolicMarker.outerLoopMarker(outerLoop);
} else if (la.kind == 17) {
Get();
String markerMethod = null;
if (la.kind == 12) {
Get();
Expect(4);
markerMethod = t.val;
Expect(13);
}
marker = SymbolicMarker.methodMarker(markerMethod);
} else if (la.kind == 0) {
} else
SynErr(19);
return marker;
}
use of com.jopdesign.common.code.SymbolicMarker 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.common.code.SymbolicMarker 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;
}
use of com.jopdesign.common.code.SymbolicMarker in project jop by jop-devel.
the class FatalError method Annotation.
void Annotation() {
String cmpop;
LoopBoundExpr expr;
SymbolicMarker marker;
Expect(7);
Expect(6);
cmpop = t.val;
expr = Expression();
marker = Context();
result = buildLoopBound(cmpop, expr, marker);
}
Aggregations