protected void checkGraph(String fileName, String dirName) throws IOException, SyntaxFormatException { Parser parser = new Parser(fileName); parser.parse(); Block blk = parser.getRootBlock(); PrintWriter writer = new PrintWriter(fileName.replaceAll("testprogs", dirName) + ".vcg", "UTF-8"); writer.print(GraphPrinter.printCFGBody(blk, "main", true)); // for (Function func : Function.getAllFunction()) { // writer.print(GraphPrinter.printCFGBody(func.getBody().getFirstBlock(), // func.getName(), // false)); // } // writer.print(GraphPrinter.printCFGTailer()); writer.close(); }
protected void checkGraph(String fileName, String dirName) throws IOException, SyntaxFormatException { Parser parser = new Parser(fileName); parser.parse(); Optimizer optimizer = new Optimizer(Optimizer.LEVEL.ALL); // optimizer.copyPropagate(parser.getRootBlock()); // optimizer.commonExpressionChangeToMove(parser.getRootBlock()); optimizer.optimize(parser.getRootBlock()); for (Function func : Function.getAllFunction()) { // optimizer.copyPropagate(func.getBody().getFirstBlock()); // optimizer.commonExpressionChangeToMove(func.getBody().getFirstBlock()); optimizer.optimize(func.getBody().getFirstBlock()); } Block blk = parser.getRootBlock(); PrintWriter writer = new PrintWriter(fileName.replaceAll("testprogs", dirName) + ".vcg", "UTF-8"); writer.print(GraphPrinter.printCFGBody(blk, "main", true)); writer.close(); }