annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java @ 5061:e808627bd16f

Renamed projects.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 08 Mar 2012 19:24:17 +0100
parents graal/com.oracle.max.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java@4ed4295ce15f
children 438ab53efdd0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4169
diff changeset
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.printer;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
4199
aaac4894175c Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4183
diff changeset
25 import static com.oracle.max.cri.ci.CiValueUtil.*;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4169
diff changeset
26
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import java.io.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29
4199
aaac4894175c Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4183
diff changeset
30 import com.oracle.max.cri.ci.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import com.oracle.max.criutils.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
32 import com.oracle.graal.alloc.util.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
33 import com.oracle.graal.compiler.alloc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
34 import com.oracle.graal.compiler.alloc.Interval.UsePosList;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.compiler.gen.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
36 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
37 import com.oracle.graal.graph.Node.Verbosity;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.graph.NodeClass.NodeClassIterator;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.graph.NodeClass.Position;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
40 import com.oracle.graal.java.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 import com.oracle.graal.lir.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.lir.cfg.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.nodes.calc.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 * Utility for printing Graal IR at various compilation phases.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 */
4200
816ac0e579fb Move printer into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
49 class CFGPrinter extends CompilationPrinter {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
51 protected CiTarget target;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
52 protected LIR lir;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
53 protected LIRGenerator lirGenerator;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
54 protected ControlFlowGraph cfg;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 * Creates a control flow graph printer.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 * @param buffer where the output generated via this printer shown be written
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 */
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
61 public CFGPrinter(OutputStream out) {
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
62 super(out);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 * Prints the control flow graph denoted by a given block map.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 * @param label A label describing the compilation phase that produced the control flow graph.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 * @param blockMap A data structure describing the blocks in a method and how they are connected.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 */
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
71 public void printCFG(String label, BciBlockMapping blockMap) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 begin("cfg");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 out.print("name \"").print(label).println('"');
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
74 for (BciBlockMapping.Block block : blockMap.blocks) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 begin("block");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 printBlock(block);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 end("block");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 end("cfg");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
82 private void printBlock(BciBlockMapping.Block block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 out.print("name \"B").print(block.startBci).println('"');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 out.print("from_bci ").println(block.startBci);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 out.print("to_bci ").println(block.endBci);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 out.println("predecessors ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 out.print("successors ");
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
90 for (BciBlockMapping.Block succ : block.successors) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 if (!succ.isExceptionEntry) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 out.print("\"B").print(succ.startBci).print("\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 out.print("xhandlers");
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
98 for (BciBlockMapping.Block succ : block.successors) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 if (succ.isExceptionEntry) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 out.print("\"B").print(succ.startBci).print("\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 out.print("flags ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 if (block.isExceptionEntry) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 out.print("\"ex\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 if (block.isLoopHeader) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 out.print("\"plh\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 out.print("loop_depth ").println(Long.bitCount(block.loops));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
118 private NodeMap<Block> latestScheduling;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
119 private NodeBitMap printedNodes;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
120
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
121 private boolean inFixedSchedule(Node node) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
122 return lir != null || node.isDeleted() || cfg.getNodeToBlock().get(node) != null;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
123 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
124
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 * Prints the specified list of blocks.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 * @param label A label describing the compilation phase that produced the control flow graph.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 * @param blocks The list of blocks to be printed.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 */
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
131 public void printCFG(String label, List<Block> blocks) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
132 if (lir == null) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
133 latestScheduling = new NodeMap<>(cfg.getNodeToBlock());
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
134 for (Block block : blocks) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
135 Node cur = block.getBeginNode();
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
136 while (true) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
137 assert inFixedSchedule(cur) && latestScheduling.get(cur) == block;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
138 scheduleInputs(cur, block);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
139
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
140 if (cur == block.getEndNode()) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
141 break;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
142 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
143 assert cur.successors().count() == 1;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
144 cur = cur.successors().first();
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
145 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
146 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
147 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
148 printedNodes = new NodeBitMap(cfg.graph);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
149
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 begin("cfg");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 out.print("name \"").print(label).println('"');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 for (Block block : blocks) {
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
153 printBlock(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 end("cfg");
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
156
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
157 latestScheduling = null;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
158 printedNodes = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
161 private void scheduleInputs(Node node, Block nodeBlock) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
162 if (node instanceof PhiNode) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
163 PhiNode phi = (PhiNode) node;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
164 assert nodeBlock.getBeginNode() == phi.merge();
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
165 for (Block pred : nodeBlock.getPredecessors()) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
166 schedule(phi.valueAt((EndNode) pred.getEndNode()), pred);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
167 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
168
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
169 } else {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
170 for (Node input : node.inputs()) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
171 schedule(input, nodeBlock);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
172 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
173 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
174 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
175
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
176 private void schedule(Node input, Block block) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
177 if (!inFixedSchedule(input)) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
178 Block inputBlock = block;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
179 if (latestScheduling.get(input) != null) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
180 inputBlock = ControlFlowGraph.commonDominator(inputBlock, latestScheduling.get(input));
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
181 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
182 if (inputBlock != latestScheduling.get(input)) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
183 latestScheduling.set(input, inputBlock);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
184 scheduleInputs(input, inputBlock);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
185 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
186 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
187 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
188
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
189 private void printBlock(Block block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 begin("block");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 out.print("name \"").print(blockToString(block)).println('"');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 out.println("from_bci -1");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 out.println("to_bci -1");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 out.print("predecessors ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 for (Block pred : block.getPredecessors()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 out.print("\"").print(blockToString(pred)).print("\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 out.print("successors ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 for (Block succ : block.getSuccessors()) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
204 if (!succ.isExceptionEntry()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 out.print("\"").print(blockToString(succ)).print("\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 out.print("xhandlers");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 for (Block succ : block.getSuccessors()) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
212 if (succ.isExceptionEntry()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 out.print("\"").print(blockToString(succ)).print("\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 out.print("flags ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 if (block.isLoopHeader()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 out.print("\"llh\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 if (block.isLoopEnd()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 out.print("\"lle\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 }
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
225 if (block.isExceptionEntry()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 out.print("\"ex\" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
230 if (block.getLoop() != null) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
231 out.print("loop_index ").println(block.getLoop().index);
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
232 out.print("loop_depth ").println(block.getLoop().depth);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
235 printNodes(block);
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
236 printLIR(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 end("block");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
240 private void printNodes(Block block) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 begin("IR");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 out.println("HIR");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 out.disableIndentation();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 if (block.getPredecessors().size() == 0) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 // Currently method parameters are not in the schedule, so print them separately here.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
247 for (ValueNode param : block.getBeginNode().graph().getNodes(LocalNode.class)) {
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
248 printNode(param, false);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 }
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
251 if (block.getBeginNode() instanceof MergeNode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252 // Currently phi functions are not in the schedule, so print them separately here.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
253 for (ValueNode phi : ((MergeNode) block.getBeginNode()).phis()) {
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
254 printNode(phi, false);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
258 if (lir != null) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
259 for (Node node : lir.nodesFor(block)) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
260 printNode(node, false);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
261 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
262 } else {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
263 Node cur = block.getBeginNode();
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
264 while (true) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
265 printNode(cur, false);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
266
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
267 if (cur == block.getEndNode()) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
268 for (Map.Entry<Node, Block> entry : latestScheduling.entries()) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
269 if (entry.getValue() == block && !inFixedSchedule(entry.getKey()) && !printedNodes.isMarked(entry.getKey())) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
270 printNode(entry.getKey(), true);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
271 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
272 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
273 break;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
274 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
275 assert cur.successors().count() == 1;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
276 cur = cur.successors().first();
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
277 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
278
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 }
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
280
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 out.enableIndentation();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 end("IR");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
285 private void printNode(Node node, boolean unscheduled) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
286 assert !printedNodes.isMarked(node);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
287 printedNodes.mark(node);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
288
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
289 if (!(node instanceof PhiNode)) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
290 for (Node input : node.inputs()) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
291 if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
292 printNode(input, true);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
293 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
294 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
295 }
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
296
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
297 if (unscheduled) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
298 assert lir == null : "unscheduled nodes can only be present before LIR generation";
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
299 out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4525
diff changeset
300 } else if (node instanceof FixedWithNextNode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 } else if (node instanceof FixedNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303 out.print("f ").print(HOVER_START).print("*").print(HOVER_SEP).print("fixed").print(HOVER_END).println(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
304 } else if (node instanceof FloatingNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 }
4278
b49981617b10 Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
307 out.print("tid ").print(nodeToString(node)).println(COLUMN_END);
b49981617b10 Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
308
b49981617b10 Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
309 if (lirGenerator != null) {
4260
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
310 CiValue operand = lirGenerator.nodeOperands.get(node);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 if (operand != null) {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
312 out.print("result ").print(operand.toString()).println(COLUMN_END);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 if (node instanceof StateSplit) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 StateSplit stateSplit = (StateSplit) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 if (stateSplit.stateAfter() != null) {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
319 String state = stateToString(stateSplit.stateAfter());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 out.print("st ").print(HOVER_START).print("st").print(HOVER_SEP).print(state).print(HOVER_END).println(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
324 Map<Object, Object> props = new TreeMap<>(node.getDebugProperties());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 out.print("d ").print(HOVER_START).print("d").print(HOVER_SEP);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326 out.println("=== Debug Properties ===");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
327 for (Map.Entry<Object, Object> entry : props.entrySet()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
328 out.print(entry.getKey().toString()).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
329 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
330 out.println("=== Inputs ===");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331 printNamedNodes(node, node.inputs().iterator(), "", "\n", null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 out.println("=== Succesors ===");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 printNamedNodes(node, node.successors().iterator(), "", "\n", null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 out.println("=== Usages ===");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
335 if (!node.usages().isEmpty()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 for (Node usage : node.usages()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 out.print(nodeToString(usage)).print(" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 out.println("=== Predecessor ===");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 out.print(nodeToString(node.predecessor())).print(" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 out.print(HOVER_END).println(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 out.print("instruction ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 out.print(HOVER_START).print(node.getNodeClass().shortName()).print(HOVER_SEP).print(node.getClass().getName()).print(HOVER_END).print(" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 printNamedNodes(node, node.inputs().iterator(), "", "", "#NDF");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 printNamedNodes(node, node.successors().iterator(), "#", "", "#NDF");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 for (Map.Entry<Object, Object> entry : props.entrySet()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 String key = entry.getKey().toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 if (key.startsWith("data.") && !key.equals("data.stamp")) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 out.print(key.substring("data.".length())).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).print(" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 out.print(COLUMN_END).print(' ').println(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358 private void printNamedNodes(Node node, NodeClassIterator iter, String prefix, String suffix, String hideSuffix) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 int lastIndex = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360 while (iter.hasNext()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
361 Position pos = iter.nextPosition();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
362 if (hideSuffix != null && node.getNodeClass().getName(pos).endsWith(hideSuffix)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 if (pos.index != lastIndex) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 if (lastIndex != -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 out.print(suffix);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 out.print(prefix).print(node.getNodeClass().getName(pos)).print(": ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 lastIndex = pos.index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 out.print(nodeToString(node.getNodeClass().get(node, pos))).print(" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 if (lastIndex != -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 out.print(suffix);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
380 private String stateToString(FrameState state) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 StringBuilder buf = new StringBuilder();
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
382 FrameState curState = state;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 do {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
384 buf.append(CiUtil.toLocation(curState.method(), curState.bci)).append('\n');
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
386 if (curState.stackSize() > 0) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 buf.append("stack: ");
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
388 for (int i = 0; i < curState.stackSize(); i++) {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
389 buf.append(stateValueToString(curState.stackAt(i))).append(' ');
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 buf.append("\n");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 buf.append("locals: ");
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
395 for (int i = 0; i < curState.localsSize(); i++) {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
396 buf.append(stateValueToString(curState.localAt(i))).append(' ');
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 buf.append("\n");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
400 curState = curState.outerFrameState();
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
401 } while (curState != null);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 return buf.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
406 private String stateValueToString(ValueNode value) {
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
407 String result = nodeToString(value);
4260
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
408 if (lirGenerator != null && lirGenerator.nodeOperands != null && value != null) {
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
409 CiValue operand = lirGenerator.nodeOperands.get(value);
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
410 if (operand != null) {
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
411 result += ": " + operand;
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
412 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 }
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
414 return result;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 * Prints the LIR for each instruction in a given block.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 * @param block the block to print
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 */
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
422 private void printLIR(Block block) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
423 List<LIRInstruction> lirInstructions = block.lir;
4260
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
424 if (lirInstructions == null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 begin("IR");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 out.println("LIR");
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
430
4260
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
431 for (int i = 0; i < lirInstructions.size(); i++) {
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
432 LIRInstruction inst = lirInstructions.get(i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 out.printf("nr %4d ", inst.id()).print(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 if (inst.info != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 int level = out.indentationLevel();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 out.adjustIndentation(-level);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 String state;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 if (inst.info.hasDebugInfo()) {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
440 state = debugInfoToString(inst.info.debugInfo().codePos, inst.info.debugInfo().registerRefMap, inst.info.debugInfo().frameRefMap, target.arch);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 } else {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
442 state = debugInfoToString(inst.info.topFrame, null, null, target.arch);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 if (state != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 out.print(" st ").print(HOVER_START).print("st").print(HOVER_SEP).print(state).print(HOVER_END).print(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447 out.adjustIndentation(level);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
450 out.print(" instruction ").print(inst.toString()).print(COLUMN_END);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451 out.println(COLUMN_END);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 end("IR");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456 private String nodeToString(Node node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 if (node == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 return "-";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460 String prefix;
4260
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
461 if (node instanceof BeginNode && lir == null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 prefix = "B";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463 } else if (node instanceof ValueNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 ValueNode value = (ValueNode) node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 if (value.kind() == CiKind.Illegal) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 prefix = "v";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 prefix = String.valueOf(value.kind().typeChar);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 prefix = "?";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 return prefix + node.toString(Verbosity.Id);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 private String blockToString(Block block) {
4260
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
477 if (lir == null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 // During all the front-end phases, the block schedule is built only for the debug output.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 // Therefore, the block numbers would be different for every CFG printed -> use the id of the first instruction.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
480 return "B" + block.getBeginNode().toString(Verbosity.Id);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 // LIR instructions contain references to blocks and these blocks are printed as the blockID -> use the blockID.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4295
diff changeset
483 return "B" + block.getId();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
488 public void printIntervals(String label, Interval[] intervals) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
489 begin("intervals");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 out.println(String.format("name \"%s\"", label));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 if (interval != null) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
494 printInterval(interval);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 end("intervals");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
501 private void printInterval(Interval interval) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4169
diff changeset
502 out.printf("%s %s ", interval.operand, (isRegister(interval.operand) ? "fixed" : interval.kind().name()));
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4169
diff changeset
503 if (isRegister(interval.operand)) {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
504 out.printf("\"[%s|%c]\"", interval.operand, interval.operand.kind.typeChar);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506 if (interval.location() != null) {
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
507 out.printf("\"[%s|%c]\"", interval.location(), interval.location().kind.typeChar);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
509 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
511 Interval hint = interval.locationHint(false);
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
512 out.printf("%s %s ", interval.splitParent().operand, hint != null ? hint.operand : -1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 // print ranges
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 Range cur = interval.first();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 while (cur != Range.EndMarker) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 out.printf("[%d, %d[", cur.from, cur.to);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 cur = cur.next;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519 assert cur != null : "range list not closed with range sentinel";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 // print use positions
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 int prev = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 UsePosList usePosList = interval.usePosList();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 for (int i = usePosList.size() - 1; i >= 0; --i) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526 assert prev < usePosList.usePos(i) : "use positions not sorted";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 out.printf("%d %s ", usePosList.usePos(i), usePosList.registerPriority(i));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 prev = usePosList.usePos(i);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 out.printf(" \"%s\"", interval.spillState());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
532 out.println();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 }
4295
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
534
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
535 public void printIntervals(String label, IntervalPrinter.Interval[] intervals) {
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
536 begin("intervals");
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
537 out.println(String.format("name \"%s\"", label));
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
538
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
539 for (IntervalPrinter.Interval interval : intervals) {
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
540 printInterval(interval);
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
541 }
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
542
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
543 end("intervals");
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
544 }
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
545
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
546 private void printInterval(IntervalPrinter.Interval interval) {
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
547 out.printf("%s %s \"%s\" %s %s ", interval.name, interval.type, interval.description, interval.variable, "no");
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
548 if (interval.ranges.size() == 0) {
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
549 // One range is required in the spec, so output a dummy range.
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
550 out.printf("[0, 0[ ");
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
551 } else {
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
552 for (IntervalPrinter.Range range : interval.ranges) {
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
553 out.printf("[%d, %d[ ", range.from, range.to);
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
554 }
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
555 }
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
556 for (IntervalPrinter.UsePosition usePos : interval.uses) {
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
557 out.printf("%d %s ", usePos.pos, usePos.kind);
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
558 }
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
559 out.printf("\"%s\"", "no");
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
560 out.println();
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
561 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
562 }
4295
1e3ecb08767d Output of lifetime intervals for new register allocator
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
563