annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java @ 2913:81dab15b45e5

fixes to Phi.removeInput and DCE
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 08 Jun 2011 17:50:16 +0200
parents d90bf514d647
children 41318fcb6b56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1 /*
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
4 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
7 * published by the Free Software Foundation.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
8 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
13 * accompanied this code).
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
14 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
18 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
21 * questions.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
22 */
2874
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
23 package com.oracle.max.graal.compiler.ir;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
24
2874
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
25 import com.oracle.max.graal.compiler.debug.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
26 import com.oracle.max.graal.graph.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
27 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
28
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
30 * The {@code Phi} instruction represents the merging of dataflow
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
31 * in the instruction graph. It refers to a join block and a variable.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
32 */
2847
caf55daa41dc Fixed/FLoating Node
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2827
diff changeset
33 public final class Phi extends FixedNode {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
34
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
35 private static final int DEFAULT_MAX_VALUES = 2;
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
36
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
37 private static final int INPUT_COUNT = 1;
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
38 private static final int INPUT_MERGE = 0;
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
39
2827
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
40 private final int maxValues;
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
41
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
42 private static final int SUCCESSOR_COUNT = 0;
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
43
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
44 private int usedInputCount;
2821
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2805
diff changeset
45 private boolean isDead;
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
46
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
47 @Override
2827
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
48 protected int inputCount() {
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
49 return super.inputCount() + INPUT_COUNT + maxValues;
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
50 }
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
51
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
52 @Override
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
53 protected int successorCount() {
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
54 return super.successorCount() + SUCCESSOR_COUNT;
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
55 }
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
56
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
57 /**
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
58 * The merge node for this phi.
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
59 */
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
60 public Merge merge() {
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
61 return (Merge) inputs().get(super.inputCount() + INPUT_MERGE);
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
62 }
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
63
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
64 public Value setMerge(Value n) {
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
65 return (Merge) inputs().set(super.inputCount() + INPUT_MERGE, n);
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
66 }
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
67
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
68 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
69 * Create a new Phi for the specified join block and local variable (or operand stack) slot.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
70 * @param kind the type of the variable
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
71 * @param merge the join point
2603
01c5c0443158 new node layout: Phi
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
72 * @param graph
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
73 */
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
74 public Phi(CiKind kind, Merge merge, Graph graph) {
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
75 this(kind, merge, DEFAULT_MAX_VALUES, graph);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
76 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
77
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
78 public Phi(CiKind kind, Merge merge, int maxValues, Graph graph) {
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
79 super(kind, INPUT_COUNT + maxValues, SUCCESSOR_COUNT, graph);
2827
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
80 this.maxValues = maxValues;
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
81 usedInputCount = 0;
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
82 setMerge(merge);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
83 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
84
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
85 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
86 * Get the instruction that produces the value associated with the i'th predecessor
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
87 * of the join block.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
88 * @param i the index of the predecessor
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
89 * @return the instruction that produced the value in the i'th predecessor
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
90 */
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
91 public Value valueAt(int i) {
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
92 return (Value) inputs().get(INPUT_COUNT + i);
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
93 }
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
94
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
95 public Node setValueAt(int i, Node x) {
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
96 return inputs().set(INPUT_COUNT + i, x);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
97 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
98
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
99 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
100 * Get the number of inputs to this phi (i.e. the number of predecessors to the join block).
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
101 * @return the number of inputs in this phi
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
102 */
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
103 public int valueCount() {
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
104 return usedInputCount;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
105 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
106
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
108 public void accept(ValueVisitor v) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
109 v.visitPhi(this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
110 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
111
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
112 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
113 * Make this phi illegal if types were not merged correctly.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
114 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
115 public void makeDead() {
2821
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2805
diff changeset
116 isDead = true;
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2805
diff changeset
117 }
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2805
diff changeset
118
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2805
diff changeset
119 public boolean isDead() {
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2805
diff changeset
120 return isDead;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
121 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
122
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
123 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
124 public void print(LogStream out) {
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
125 out.print("phi function (");
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
126 for (int i = 0; i < valueCount(); ++i) {
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
127 if (i != 0) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
128 out.print(' ');
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
129 }
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
130 out.print(valueAt(i));
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
131 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
132 out.print(')');
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
133 }
2616
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2603
diff changeset
134
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2603
diff changeset
135 @Override
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2603
diff changeset
136 public String shortName() {
2799
e1dad0edd57a first part of loop reworking
Lukas Stadler <lukas.stadler@jku.at>
parents: 2793
diff changeset
137 StringBuilder str = new StringBuilder();
2842
7596ae867a7b basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 2827
diff changeset
138 for (int i = 0; i < valueCount(); ++i) {
7596ae867a7b basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 2827
diff changeset
139 if (i != 0) {
2799
e1dad0edd57a first part of loop reworking
Lukas Stadler <lukas.stadler@jku.at>
parents: 2793
diff changeset
140 str.append(' ');
e1dad0edd57a first part of loop reworking
Lukas Stadler <lukas.stadler@jku.at>
parents: 2793
diff changeset
141 }
2842
7596ae867a7b basic inlining passes all tests, including optimistic inlining
Lukas Stadler <lukas.stadler@jku.at>
parents: 2827
diff changeset
142 str.append(valueAt(i) == null ? "-" : valueAt(i).id());
2799
e1dad0edd57a first part of loop reworking
Lukas Stadler <lukas.stadler@jku.at>
parents: 2793
diff changeset
143 }
e1dad0edd57a first part of loop reworking
Lukas Stadler <lukas.stadler@jku.at>
parents: 2793
diff changeset
144 return "Phi: (" + str + ")";
2616
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2603
diff changeset
145 }
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2603
diff changeset
146
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
147 public Phi addInput(Node y) {
2763
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
148 assert !this.isDeleted() && !y.isDeleted();
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
149 Phi phi = this;
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
150 if (usedInputCount == maxValues) {
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
151 phi = new Phi(kind, merge(), maxValues * 2, graph());
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
152 for (int i = 0; i < valueCount(); ++i) {
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2763
diff changeset
153 phi.addInput(valueAt(i));
2763
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
154 }
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
155 phi.addInput(y);
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
156 this.replace(phi);
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
157 } else {
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
158 setValueAt(usedInputCount++, y);
2763
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
159 }
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
160 return phi;
5e8a69041cd7 Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
161 }
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
162
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
163 public void removeInput(int index) {
2866
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
164 assert index < valueCount() : "index: " + index + ", valueCount: " + valueCount() + "@phi " + id();
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
165 setValueAt(index, Node.Null);
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
166 for (int i = index + 1; i < valueCount(); ++i) {
7f14e6b48a9c added dead code elimination
Lukas Stadler <lukas.stadler@jku.at>
parents: 2842
diff changeset
167 setValueAt(i - 1, valueAt(i));
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
168 }
2913
81dab15b45e5 fixes to Phi.removeInput and DCE
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
169 setValueAt(valueCount() - 1, Node.Null);
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
170 usedInputCount--;
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
171 }
2827
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
172
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
173 @Override
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
174 public Node copy(Graph into) {
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
175 Phi x = new Phi(kind, null, maxValues, into);
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
176 x.usedInputCount = usedInputCount;
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
177 x.isDead = isDead;
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
178 return x;
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2821
diff changeset
179 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
180 }