Search in sources :

Example 11 with LoopBound

use of com.jopdesign.common.code.LoopBound in project jop by jop-devel.

the class JavaOneProcessPerSupergraphTranslator method recordLoops.

// Global maximal nesting depth is given by the equation
//   node.gmnd = node.method.gmnd + (node.loop ? node.loop.nestingDepth : 0)
//   method.gmnd = max { cs.method.gmnd + cs.gmnd | cs <- method.callsites }
// Example:
//  main() { for() for() X: f(); }
//  f() { for() for(HOL) }
//  nesting depth of HOL is 2
//  gmnd of f is gmnd of X = 2 + gmnd of main = 2
//  gmnd of HOL is 4
private void recordLoops(TemplateBuilder tBuilder) {
    try {
        computeMethodNestingDepths();
    } catch (BadGraphException e) {
        throw new BadGraphError(e);
    }
    for (MethodInfo m : methodInfos) {
        ControlFlowGraph cfg = project.getFlowGraph(m);
        for (Entry<CFGNode, LoopBound> entry : cfg.buildLoopBoundMap().entrySet()) {
            CFGNode hol = entry.getKey();
            LoopBound lb = entry.getValue();
            int nesting = cfg.getLoopColoring().getLoopColor(hol).size();
            int gmnd = nesting + methodMNDs.get(m);
            tBuilder.addLoop(hol, gmnd, lb);
        }
    }
    if (config.debug)
        tBuilder.dumpLoops();
}
Also used : BadGraphException(com.jopdesign.common.misc.BadGraphException) CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) BadGraphError(com.jopdesign.common.misc.BadGraphError) LoopBound(com.jopdesign.common.code.LoopBound) ControlFlowGraph(com.jopdesign.common.code.ControlFlowGraph) MethodInfo(com.jopdesign.common.MethodInfo)

Example 12 with LoopBound

use of com.jopdesign.common.code.LoopBound in project jop by jop-devel.

the class ParserTest method parseTest.

private static void parseTest(String string) {
    System.out.println("Parsing: '" + string + "'");
    InputStream is = new ByteArrayInputStream(string.getBytes());
    Scanner scanner = new Scanner(is);
    Parser parser = new Parser(scanner);
    try {
        parser.Parse();
        LoopBound loopBound = parser.getResult();
        System.out.println(loopBound);
    } catch (Error e) {
        e.printStackTrace();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) LoopBound(com.jopdesign.common.code.LoopBound)

Aggregations

LoopBound (com.jopdesign.common.code.LoopBound)12 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)7 MethodInfo (com.jopdesign.common.MethodInfo)5 ControlFlowGraph (com.jopdesign.common.code.ControlFlowGraph)4 CFGEdge (com.jopdesign.common.code.ControlFlowGraph.CFGEdge)3 ExecutionContext (com.jopdesign.common.code.ExecutionContext)3 BasicBlockNode (com.jopdesign.common.code.ControlFlowGraph.BasicBlockNode)2 AppInfoError (com.jopdesign.common.misc.AppInfoError)2 SourceAnnotations (com.jopdesign.wcet.annotations.SourceAnnotations)2 ArrayList (java.util.ArrayList)2 ClassInfo (com.jopdesign.common.ClassInfo)1 MethodCode (com.jopdesign.common.MethodCode)1 BasicBlock (com.jopdesign.common.code.BasicBlock)1 ContextCFG (com.jopdesign.common.code.SuperGraph.ContextCFG)1 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)1 BadGraphError (com.jopdesign.common.misc.BadGraphError)1 BadGraphException (com.jopdesign.common.misc.BadGraphException)1 Interval (com.jopdesign.dfa.analyses.Interval)1 LoopBounds (com.jopdesign.dfa.analyses.LoopBounds)1 BadAnnotationException (com.jopdesign.wcet.annotations.BadAnnotationException)1