Examples of ControlFlowGraph


Examples of org.renjin.compiler.cfg.ControlFlowGraph

public class ControlFlowGraphTest extends CompilerTestCase {

  @Test
  public void singleBlock() {
    IRBody block = buildScope("y<-x+1;z<-3; 4");
    ControlFlowGraph cfg = new ControlFlowGraph(block);
   
    System.out.println(cfg);
   
    List<BasicBlock> basicBlocks = cfg.getBasicBlocks();
    assertThat(basicBlocks.size(), equalTo(3))// 1 + exit + entry = 3
    assertThat(basicBlocks.get(0).getStatements().size(), equalTo(block.getStatements().size()));
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

  public void forLoop() {
    IRBody block = buildScope("y <- 0; for(i in 1:10) y <- y + i; sqrt(y + 3 * x)");
    System.out.println(block);

   
    ControlFlowGraph cfg = new ControlFlowGraph(block);
    System.out.println(cfg.getGraph());
    System.out.println(cfg);

    List<BasicBlock> basicBlocks = cfg.getBasicBlocks();
    assertThat(basicBlocks.size(), equalTo(7));
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

//         true,    //L5   14: _t2 := NULL
//        
//         true    //L1   15: return _t2
//      }));
//   
    ControlFlowGraph cfg = new ControlFlowGraph(block);
   
    System.out.println(cfg);
   
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

  }
 
  @Test
  public void cytron() throws IOException {
    IRBody block = parseCytron();
    ControlFlowGraph cfg = new ControlFlowGraph(block);
    List<BasicBlock> bb = cfg.getLiveBasicBlocks();
   
    // see Figure 5 in
    // http://www.cs.utexas.edu/~pingali/CS380C/2010/papers/ssaCytron.pdf
   
    assertThat(cfg.getGraph().getSuccessors(bb.get(0)), itemsEqualTo(bb.get(1)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(1)), itemsEqualTo(bb.get(2), bb.get(6)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(2)), itemsEqualTo(bb.get(3), bb.get(4)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(3)), itemsEqualTo(bb.get(5)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(4)), itemsEqualTo(bb.get(5)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(5)), itemsEqualTo(bb.get(7)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(6)), itemsEqualTo(bb.get(7)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(7)), itemsEqualTo(bb.get(8)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(8)), itemsEqualTo(bb.get(9), bb.get(10)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(9)), itemsEqualTo(bb.get(10)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(10)), itemsEqualTo(bb.get(8),bb.get(11)));
    assertThat(cfg.getGraph().getSuccessors(bb.get(11)), itemsEqualTo(bb.get(12),bb.get(1)));
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

  @Test
  public void dataframe() throws IOException {
   IRBody body = buildScope(Resources.toString(
       getClass().getResource("dataframe.test.R"), Charsets.UTF_8));
   ControlFlowGraph cfg = new ControlFlowGraph(body);
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph


  @Test
  public void immediateDominators() {
    IRBody block = buildScope("y<-1; if(q) y<-y+1 else y<-4; y");
    ControlFlowGraph cfg = new ControlFlowGraph(block);
   
    System.out.println(cfg);
   
    BasicBlock bb0 = cfg.getBasicBlocks().get(0); // y <- 1; if q goto BB1 else BB2
    BasicBlock bb1 = cfg.getBasicBlocks().get(1); // y <- y + 1
    BasicBlock bb2 = cfg.getBasicBlocks().get(2); // y <- 4
    BasicBlock bb3 = cfg.getBasicBlocks().get(3); // return y;
   
    DominanceTree domTree = new DominanceTree(cfg);
    assertThat(domTree.getImmediateDominator(bb1), equalTo(bb0));
    assertThat(domTree.getImmediateDominator(bb2), equalTo(bb0));
    assertThat(domTree.getImmediateDominator(bb3), equalTo(bb0));
    assertThat(domTree.getImmediateDominator(cfg.getExit()), equalTo(cfg.getEntry()));
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

  }
 
  @Test
  public void dominanceFrontier() throws IOException {
    IRBody block = parseCytron();
    ControlFlowGraph cfg = new ControlFlowGraph(block);
    List<BasicBlock> bb = cfg.getLiveBasicBlocks();
    DominanceTree dtree = new DominanceTree(cfg);

    // See Figure 9 in
    // http://www.cs.utexas.edu/~pingali/CS380C/2010/papers/ssaCytron.pdf
   
    assertThat(dtree.getFrontier(bb.get(1)), itemsEqualTo(bb.get(1), cfg.getExit()));
    assertThat(dtree.getFrontier(bb.get(2)), itemsEqualTo(bb.get(7)));
    assertThat(dtree.getFrontier(bb.get(3)), itemsEqualTo(bb.get(5)));
    assertThat(dtree.getFrontier(bb.get(4)), itemsEqualTo(bb.get(5)));
    assertThat(dtree.getFrontier(bb.get(5)), itemsEqualTo(bb.get(7)));
    assertThat(dtree.getFrontier(bb.get(6)), itemsEqualTo(bb.get(7)));
    assertThat(dtree.getFrontier(bb.get(7)), itemsEqualTo(bb.get(1), cfg.getExit()));
    assertThat(dtree.getFrontier(bb.get(8)), itemsEqualTo(bb.get(1), bb.get(8), cfg.getExit()));
    assertThat(dtree.getFrontier(bb.get(9)), itemsEqualTo(bb.get(10)));
    assertThat(dtree.getFrontier(bb.get(10)), itemsEqualTo(bb.get(1), bb.get(8), cfg.getExit()));
    assertThat(dtree.getFrontier(bb.get(11)), itemsEqualTo(bb.get(1), cfg.getExit()));
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

    IRBodyBuilder builder = new IRBodyBuilder(functionTable);
    IRBody body = builder.build(exp);
   
    ByteCodeVisitor visitor = new ByteCodeVisitor(generationContext, mv);
   
    ControlFlowGraph cfg = new ControlFlowGraph(body);
    for(BasicBlock bb : cfg.getBasicBlocks()) {
     
      System.out.println(bb.statementsToString());
     
      visitor.startBasicBlock(bb);
     
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

   
  }
 
  private void compileBody(IRBody body) {
   
    ControlFlowGraph cfg = new ControlFlowGraph(body);
    TreeBuilder builder = new TreeBuilder();
  
  }
View Full Code Here

Examples of org.renjin.compiler.cfg.ControlFlowGraph

    generationContext.setContextLdc(0);
    generationContext.setEnvironmentLdc(1);
    ByteCodeVisitor visitor = new ByteCodeVisitor(generationContext, mv);
   
   
    ControlFlowGraph cfg = new ControlFlowGraph(body);
    for(BasicBlock bb : cfg.getBasicBlocks()) {
     
      System.out.println(bb.statementsToString());
     
      visitor.startBasicBlock(bb);
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.