Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java @ 9436:ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 29 Apr 2013 00:25:09 +0200 |
parents | 50f02c7d1cec |
children | 0942e34b6c7d |
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
25 import static com.oracle.graal.api.code.ValueUtil.*; |
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 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
30 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
31 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.compiler.alloc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.compiler.alloc.Interval.UsePosList; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.compiler.gen.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.graph.Node.Verbosity; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.graph.NodeClass.NodeClassIterator; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
38 import com.oracle.graal.graph.NodeClass.Position; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
39 import com.oracle.graal.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
40 import com.oracle.graal.lir.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
41 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
42 import com.oracle.graal.nodes.calc.*; |
6529
2e96dc4eb8e2
renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents:
6436
diff
changeset
|
43 import com.oracle.graal.nodes.cfg.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 |
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 * 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
|
47 */ |
4200
816ac0e579fb
Move printer into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4199
diff
changeset
|
48 class CFGPrinter extends CompilationPrinter { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
50 protected TargetDescription target; |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
51 protected LIR lir; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
52 protected LIRGenerator lirGenerator; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
53 protected ControlFlowGraph cfg; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
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 * Creates a control flow graph printer. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
57 * |
5711
4d7175cf3526
enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents:
5552
diff
changeset
|
58 * @param out where the output generated via this printer shown be written |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 */ |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
60 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
|
61 super(out); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 } |
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 * Prints the control flow graph denoted by a given block map. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
66 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 * @param label A label describing the compilation phase that produced the control flow graph. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
68 * @param blockMap A data structure describing the blocks in a method and how they are |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
69 * connected. |
3733
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 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
117 private NodeMap<Block> latestScheduling; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
118 private NodeBitMap printedNodes; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
119 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
120 private boolean inFixedSchedule(Node node) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
121 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
|
122 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
123 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 * Prints the specified list of blocks. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
126 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 * @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
|
128 * @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
|
129 */ |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
130 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
|
131 if (lir == null) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
132 latestScheduling = new NodeMap<>(cfg.getNodeToBlock()); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
133 for (Block block : blocks) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
134 Node cur = block.getBeginNode(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
135 while (true) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
136 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
|
137 scheduleInputs(cur, block); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
138 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
139 if (cur == block.getEndNode()) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
140 break; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
141 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
142 assert cur.successors().count() == 1; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
143 cur = cur.successors().first(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
144 } |
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 printedNodes = new NodeBitMap(cfg.graph); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
148 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 begin("cfg"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 out.print("name \"").print(label).println('"'); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 for (Block block : blocks) { |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
152 printBlock(block); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 end("cfg"); |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
155 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
156 latestScheduling = null; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
157 printedNodes = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
160 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
|
161 if (node instanceof PhiNode) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
162 PhiNode phi = (PhiNode) node; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
163 assert nodeBlock.getBeginNode() == phi.merge(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
164 for (Block pred : nodeBlock.getPredecessors()) { |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9336
diff
changeset
|
165 schedule(phi.valueAt((AbstractEndNode) pred.getEndNode()), pred); |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
166 } |
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 } else { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
169 for (Node input : node.inputs()) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
170 schedule(input, nodeBlock); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
171 } |
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 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
|
176 if (!inFixedSchedule(input)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
177 Block inputBlock = block; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
178 if (latestScheduling.get(input) != null) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
179 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
|
180 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
181 if (inputBlock != latestScheduling.get(input)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
182 latestScheduling.set(input, inputBlock); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
183 scheduleInputs(input, inputBlock); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
184 } |
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 private void printBlock(Block block) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 begin("block"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 out.print("name \"").print(blockToString(block)).println('"'); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 out.println("from_bci -1"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 out.println("to_bci -1"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 out.print("predecessors "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 for (Block pred : block.getPredecessors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 out.print("\"").print(blockToString(pred)).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
199 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 out.print("successors "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 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
|
203 if (!succ.isExceptionEntry()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 out.print("\"").print(blockToString(succ)).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 } |
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 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 out.print("xhandlers"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 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
|
211 if (succ.isExceptionEntry()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 out.print("\"").print(blockToString(succ)).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 } |
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 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 out.print("flags "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 if (block.isLoopHeader()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 out.print("\"llh\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 if (block.isLoopEnd()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 out.print("\"lle\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 } |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
224 if (block.isExceptionEntry()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 out.print("\"ex\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
229 if (block.getLoop() != null) { |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
230 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
|
231 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
|
232 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
234 printNodes(block); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
235 printLIR(block); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 end("block"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
239 private void printNodes(Block block) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 begin("IR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 out.println("HIR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 out.disableIndentation(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 |
7499
ca3e5df0e6cf
Small clean up of access to predecessor/successor of blocks.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6539
diff
changeset
|
244 if (block.getPredecessorCount() == 0) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 // 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
|
246 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
|
247 printNode(param, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 } |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
250 if (block.getBeginNode() instanceof MergeNode) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 // 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
|
252 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
|
253 printNode(phi, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 } |
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 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
257 if (lir != null) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
258 for (Node node : lir.nodesFor(block)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
259 printNode(node, false); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
260 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
261 } else { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
262 Node cur = block.getBeginNode(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
263 while (true) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
264 printNode(cur, false); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
265 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
266 if (cur == block.getEndNode()) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
267 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
|
268 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
|
269 printNode(entry.getKey(), true); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
270 } |
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 break; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
273 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
274 assert cur.successors().count() == 1; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
275 cur = cur.successors().first(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
276 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
277 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 } |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
279 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 out.enableIndentation(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 end("IR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
284 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
|
285 assert !printedNodes.isMarked(node); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
286 printedNodes.mark(node); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
287 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
288 if (!(node instanceof PhiNode)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
289 for (Node input : node.inputs()) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
290 if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
291 printNode(input, true); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
292 } |
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 if (unscheduled) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
297 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
|
298 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
|
299 } else if (node instanceof FixedWithNextNode) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 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
|
301 } else if (node instanceof FixedNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 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
|
303 } else if (node instanceof FloatingNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 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
|
305 } |
4278
b49981617b10
Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
306 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
|
307 |
b49981617b10
Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
308 if (lirGenerator != null) { |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
309 Value operand = lirGenerator.nodeOperands.get(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
310 if (operand != null) { |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
311 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
|
312 } |
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 if (node instanceof StateSplit) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 StateSplit stateSplit = (StateSplit) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 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
|
318 String state = stateToString(stateSplit.stateAfter()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 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
|
320 } |
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 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
323 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
|
324 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
|
325 out.println("=== Debug Properties ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 for (Map.Entry<Object, Object> entry : props.entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 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
|
328 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
329 out.println("=== Inputs ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
330 printNamedNodes(node, node.inputs().iterator(), "", "\n", null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 out.println("=== Succesors ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 printNamedNodes(node, node.successors().iterator(), "", "\n", null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 out.println("=== Usages ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 if (!node.usages().isEmpty()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
335 for (Node usage : node.usages()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 out.print(nodeToString(usage)).print(" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
340 out.println("=== Predecessor ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 out.print(nodeToString(node.predecessor())).print(" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 out.print(HOVER_END).println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 out.print("instruction "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
345 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
|
346 printNamedNodes(node, node.inputs().iterator(), "", "", "#NDF"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 printNamedNodes(node, node.successors().iterator(), "#", "", "#NDF"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 for (Map.Entry<Object, Object> entry : props.entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 String key = entry.getKey().toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 if (key.startsWith("data.") && !key.equals("data.stamp")) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
351 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
|
352 } |
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 out.print(COLUMN_END).print(' ').println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
355 } |
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 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
|
358 int lastIndex = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 while (iter.hasNext()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 Position pos = iter.nextPosition(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 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
|
362 continue; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 } |
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 if (pos.index != lastIndex) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
366 if (lastIndex != -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
367 out.print(suffix); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
368 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
369 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
|
370 lastIndex = pos.index; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
371 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
372 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
|
373 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 if (lastIndex != -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 out.print(suffix); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
376 } |
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 |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
379 private String stateToString(FrameState state) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
380 StringBuilder buf = new StringBuilder(); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
381 FrameState curState = state; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
382 do { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5711
diff
changeset
|
383 buf.append(MetaUtil.toLocation(curState.method(), curState.bci)).append('\n'); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
385 if (curState.stackSize() > 0) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
386 buf.append("stack: "); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
387 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
|
388 buf.append(stateValueToString(curState.stackAt(i))).append(' '); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 buf.append("\n"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 } |
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 buf.append("locals: "); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
394 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
|
395 buf.append(stateValueToString(curState.localAt(i))).append(' '); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
396 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
397 buf.append("\n"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
398 |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
399 buf.append("locks: "); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
400 for (int i = 0; i < curState.locksSize(); i++) { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
401 buf.append(stateValueToString(curState.lockAt(i))).append(' '); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
402 } |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
403 buf.append("\n"); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
404 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
405 curState = curState.outerFrameState(); |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
406 } while (curState != null); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
407 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
408 return buf.toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
409 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
411 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
|
412 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
|
413 if (lirGenerator != null && lirGenerator.nodeOperands != null && value != null) { |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
414 Value 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
|
415 if (operand != null) { |
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
416 result += ": " + operand; |
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
417 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 } |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
419 return result; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
421 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
422 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
423 * Prints the LIR for each instruction in a given block. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
424 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
425 * @param block the block to print |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
426 */ |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
427 private void printLIR(Block block) { |
6418
aa57aa781e86
fixed small regression in CFGPrinter
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
428 if (lir == null) { |
aa57aa781e86
fixed small regression in CFGPrinter
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
429 return; |
aa57aa781e86
fixed small regression in CFGPrinter
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
430 } |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6329
diff
changeset
|
431 List<LIRInstruction> lirInstructions = lir.lir(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
|
432 if (lirInstructions == null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 return; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 begin("IR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 out.println("LIR"); |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
438 |
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
|
439 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
|
440 LIRInstruction inst = lirInstructions.get(i); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
441 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
|
442 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
443 final StringBuilder stateString = new StringBuilder(); |
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
444 inst.forEachState(new LIRInstruction.StateProcedure() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
445 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
446 @Override |
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
447 protected void doState(LIRFrameState state) { |
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
448 if (state.hasDebugInfo()) { |
9336
47e7933283f1
added support for adding callee save information to a DebugInfo (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
449 DebugInfo di = state.debugInfo(); |
47e7933283f1
added support for adding callee save information to a DebugInfo (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
450 stateString.append(debugInfoToString(di.getBytecodePosition(), di.getRegisterRefMap(), di.getFrameRefMap(), di.getCalleeSaveInfo(), target.arch)); |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
451 } else { |
9336
47e7933283f1
added support for adding callee save information to a DebugInfo (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
452 stateString.append(debugInfoToString(state.topFrame, null, null, null, target.arch)); |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
453 } |
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
454 } |
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
455 }); |
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
456 if (stateString.length() > 0) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
457 int level = out.indentationLevel(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
458 out.adjustIndentation(-level); |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
459 out.print(" st ").print(HOVER_START).print("st").print(HOVER_SEP).print(stateString.toString()).print(HOVER_END).print(COLUMN_END); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 out.adjustIndentation(level); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
461 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
462 |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
463 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
|
464 out.println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
465 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
466 end("IR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
469 private String nodeToString(Node node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
470 if (node == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
471 return "-"; |
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 String prefix; |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9434
diff
changeset
|
474 if (node instanceof AbstractBeginNode && lir == null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
475 prefix = "B"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
476 } else if (node instanceof ValueNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
477 ValueNode value = (ValueNode) node; |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
478 if (value.kind() == Kind.Illegal) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
479 prefix = "v"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 } else { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6529
diff
changeset
|
481 prefix = String.valueOf(value.kind().getTypeChar()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 prefix = "?"; |
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 return prefix + node.toString(Verbosity.Id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
487 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
488 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
489 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
|
490 if (lir == null) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
491 // During all the front-end phases, the block schedule is built only for the debug |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
492 // output. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
493 // Therefore, the block numbers would be different for every CFG printed -> use the id |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
494 // of the first instruction. |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
495 return "B" + block.getBeginNode().toString(Verbosity.Id); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 } else { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
497 // LIR instructions contain references to blocks and these blocks are printed as the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
498 // blockID -> use the blockID. |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
499 return "B" + block.getId(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
503 public void printIntervals(String label, Interval[] intervals) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 begin("intervals"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 out.println(String.format("name \"%s\"", label)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 for (Interval interval : intervals) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 if (interval != null) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
509 printInterval(interval); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 end("intervals"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
516 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
|
517 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
|
518 if (isRegister(interval.operand)) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6529
diff
changeset
|
519 out.printf("\"[%s|%c]\"", interval.operand, interval.operand.getKind().getTypeChar()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 if (interval.location() != null) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6529
diff
changeset
|
522 out.printf("\"[%s|%c]\"", interval.location(), interval.location().getKind().getTypeChar()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
526 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
|
527 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
|
528 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 // print ranges |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
530 Range cur = interval.first(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
531 while (cur != Range.EndMarker) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 out.printf("[%d, %d[", cur.from, cur.to); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 cur = cur.next; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 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
|
535 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 // print use positions |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 int prev = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 UsePosList usePosList = interval.usePosList(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 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
|
541 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
|
542 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
|
543 prev = usePosList.usePos(i); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
545 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 out.printf(" \"%s\"", interval.spillState()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 } |