# HG changeset patch # User Tom Rodriguez # Date 1395166067 25200 # Node ID 3eda945af90a5c0a6b397ae3d4e1624eccce7707 # Parent 9e05e9770c1e64cf64ac8d1a6cb183c86d4f908e dump final HIR schedule to c1visualizer diff -r 9e05e9770c1e -r 3eda945af90a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Mar 18 09:48:59 2014 -0700 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Mar 18 11:07:47 2014 -0700 @@ -205,7 +205,7 @@ SchedulePhase schedule = new SchedulePhase(); schedule.apply(graph); - Debug.dump(schedule, "final schedule"); + Debug.dump(schedule, "Final HIR schedule"); return schedule; } diff -r 9e05e9770c1e -r 3eda945af90a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Tue Mar 18 09:48:59 2014 -0700 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Tue Mar 18 11:07:47 2014 -0700 @@ -41,6 +41,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.cfg.*; +import com.oracle.graal.phases.schedule.*; /** * Utility for printing Graal IR at various compilation phases. @@ -51,6 +52,7 @@ protected LIR lir; protected LIRGenerator lirGenerator; protected ControlFlowGraph cfg; + protected SchedulePhase schedule; /** * Creates a control flow graph printer. @@ -118,7 +120,7 @@ private NodeBitMap printedNodes; private boolean inFixedSchedule(Node node) { - return lir != null || node.isDeleted() || cfg.getNodeToBlock().get(node) != null; + return lir != null || schedule != null || node.isDeleted() || cfg.getNodeToBlock().get(node) != null; } /** @@ -186,6 +188,19 @@ } private void printBlock(Block block, boolean printNodes) { + printBlockProlog(block); + if (printNodes) { + printNodes(block); + } + printBlockEpilog(block); + } + + private void printBlockEpilog(Block block) { + printLIR(block); + end("block"); + } + + private void printBlockProlog(Block block) { begin("block"); out.print("name \"").print(blockToString(block)).println('"'); @@ -230,12 +245,6 @@ out.print("loop_index ").println(block.getLoop().index); out.print("loop_depth ").println(block.getLoop().depth); } - - if (printNodes) { - printNodes(block); - } - printLIR(block); - end("block"); } private void printNodes(Block block) { @@ -287,7 +296,7 @@ } if (unscheduled) { - assert lir == null : "unscheduled nodes can only be present before LIR generation"; + assert lir == null && schedule == null : "unscheduled nodes can only be present before LIR generation"; out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END); } else if (node instanceof FixedWithNextNode) { out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END); @@ -464,7 +473,7 @@ return "-"; } String prefix; - if (node instanceof AbstractBeginNode && lir == null) { + if (node instanceof AbstractBeginNode && (lir == null && schedule == null)) { prefix = "B"; } else if (node instanceof ValueNode) { ValueNode value = (ValueNode) node; @@ -480,7 +489,7 @@ } private String blockToString(Block block) { - if (lir == null) { + if (lir == null && schedule == null) { // During all the front-end phases, the block schedule is built only for the debug // output. // Therefore, the block numbers would be different for every CFG printed -> use the id @@ -539,4 +548,46 @@ out.printf(" \"%s\"", interval.spillState()); out.println(); } + + public void printSchedule(String message, SchedulePhase theSchedule) { + schedule = theSchedule; + cfg = schedule.getCFG(); + printedNodes = new NodeBitMap(cfg.graph); + + begin("cfg"); + out.print("name \"").print(message).println('"'); + for (Block b : schedule.getCFG().getBlocks()) { + if (schedule.nodesFor(b) != null) { + printScheduledBlock(b, schedule.nodesFor(b)); + } + } + end("cfg"); + + schedule = null; + cfg = null; + printedNodes = null; + } + + private void printScheduledBlock(Block block, List nodesFor) { + printBlockProlog(block); + begin("IR"); + out.println("HIR"); + out.disableIndentation(); + + if (block.getBeginNode() instanceof MergeNode) { + // Currently phi functions are not in the schedule, so print them separately here. + for (ValueNode phi : ((MergeNode) block.getBeginNode()).phis()) { + printNode(phi, false); + } + } + + for (Node n : nodesFor) { + printNode(n, false); + } + + out.enableIndentation(); + end("IR"); + + printBlockEpilog(block); + } } diff -r 9e05e9770c1e -r 3eda945af90a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Tue Mar 18 09:48:59 2014 -0700 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Tue Mar 18 11:07:47 2014 -0700 @@ -36,6 +36,7 @@ import com.oracle.graal.lir.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; +import com.oracle.graal.phases.schedule.*; /** * Observes compilation events and uses {@link CFGPrinter} to produce a control flow graph for the @@ -162,6 +163,8 @@ boolean printNodes = previousObject != object; cfgPrinter.printCFG(message, cfgPrinter.lir.codeEmittingOrder(), printNodes); + } else if (object instanceof SchedulePhase) { + cfgPrinter.printSchedule(message, (SchedulePhase) object); } else if (object instanceof StructuredGraph) { if (cfgPrinter.cfg == null) { StructuredGraph graph = (StructuredGraph) object;