Mercurial > hg > truffle
annotate graal/GraalCompiler/src/com/sun/c1x/ir/Phi.java @ 2763:5e8a69041cd7
Model phi inputs as direct inputs in the graph instead of referring to the framestates of the predecessors.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Mon, 23 May 2011 14:51:18 +0200 |
parents | 7ed72769d51a |
children | 99912abb3ff7 |
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 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
23 package com.sun.c1x.ir; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
24 |
2603 | 25 import com.oracle.graal.graph.*; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
26 import com.sun.c1x.debug.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
27 import com.sun.c1x.value.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
28 import com.sun.cri.ci.*; |
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 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
31 * 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
|
32 * 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
|
33 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
34 public final class Phi extends Value { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
35 |
2603 | 36 private static final int INPUT_COUNT = 1; |
37 private static final int INPUT_BLOCK = 0; | |
38 | |
39 private static final int SUCCESSOR_COUNT = 0; | |
40 | |
41 @Override | |
42 protected int inputCount() { | |
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
|
43 return super.inputCount() + INPUT_COUNT + maxValues; |
2603 | 44 } |
45 | |
46 @Override | |
47 protected int successorCount() { | |
48 return super.successorCount() + SUCCESSOR_COUNT; | |
49 } | |
50 | |
51 /** | |
52 * The join block for this phi. | |
53 */ | |
54 @Override | |
55 public BlockBegin block() { | |
56 return (BlockBegin) inputs().get(super.inputCount() + INPUT_BLOCK); | |
57 } | |
58 | |
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
|
59 public Value setBlock(Value n) { |
2603 | 60 return (BlockBegin) inputs().set(super.inputCount() + INPUT_BLOCK, n); |
61 } | |
62 | |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
63 private final int index; |
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
|
64 private final int maxValues; |
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
|
65 private int usedInputCount; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
66 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
67 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
68 * 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
|
69 * @param kind the type of the variable |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
70 * @param block the join point |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
71 * @param index the index into the stack (if < 0) or local variables |
2603 | 72 * @param graph |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
73 */ |
2603 | 74 public Phi(CiKind kind, BlockBegin block, int index, Graph graph) { |
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
|
75 this(kind, block, index, 2, graph); |
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
|
76 } |
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
|
77 |
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
|
78 public Phi(CiKind kind, BlockBegin block, int index, int maxValues, Graph graph) { |
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
|
79 super(kind, INPUT_COUNT + maxValues, SUCCESSOR_COUNT, graph); |
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
|
80 usedInputCount = 1; |
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
|
81 this.maxValues = maxValues; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
82 this.index = index; |
2603 | 83 setBlock(block); |
2507
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 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
87 * Check whether this phi corresponds to a local variable. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
88 * @return {@code true} if this phi refers to a local variable |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
89 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
90 public boolean isLocal() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
91 return index >= 0; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
92 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
93 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
94 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
95 * Check whether this phi corresponds to a stack location. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
96 * @return {@code true} if this phi refers to a stack location |
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 public boolean isOnStack() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
99 return index < 0; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
100 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
101 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
102 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
103 * Get the local index of this phi. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
104 * @return the local index |
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 public int localIndex() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
107 assert isLocal(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
108 return index; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
109 } |
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 * Get the stack index of this phi. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
113 * @return the stack index of this phi |
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 int stackIndex() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
116 assert isOnStack(); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
117 return -(index + 1); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
118 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
119 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
120 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
121 * 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
|
122 * of the join block. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
123 * @param i the index of the predecessor |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
124 * @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
|
125 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
126 public Value inputAt(int 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
|
127 return (Value) inputs().get(i + INPUT_COUNT); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
128 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
129 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
130 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
131 * Gets the instruction that produces the value for this phi in the specified state. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
132 * @param state the state to access |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
133 * @return the instruction producing the value |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
134 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
135 public Value inputIn(FrameState state) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
136 if (isLocal()) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
137 return state.localAt(localIndex()); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
138 } else { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
139 return state.stackAt(stackIndex()); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
140 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
141 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
142 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
143 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
144 * 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
|
145 * @return the number of inputs in this phi |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
146 */ |
2582
768d77a1c7af
new node layout: Instruction
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
147 public int phiInputCount() { |
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 return usedInputCount - 1; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
149 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
150 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
151 @Override |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
152 public void accept(ValueVisitor v) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
153 v.visitPhi(this); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
154 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
155 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
156 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
157 * 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
|
158 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
159 public void makeDead() { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
160 setFlag(Flag.PhiCannotSimplify); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
161 setFlag(Flag.PhiDead); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
162 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
163 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
164 @Override |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
165 public void print(LogStream out) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
166 out.print("phi function"); |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
167 } |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
168 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
169 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
170 public String shortName() { |
2707
7ed72769d51a
exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2674
diff
changeset
|
171 return "Phi: " + index + " (" + phiInputCount() + ")"; |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
172 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
173 |
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
|
174 public Phi addInput(Value 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
|
175 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
|
176 Phi phi = this; |
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
|
177 if (usedInputCount == inputs().size()) { |
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
|
178 phi = new Phi(kind, block(), index, maxValues * 2, graph()); |
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
|
179 for (int i = 0; i < phiInputCount(); ++i) { |
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
|
180 phi.addInput(inputAt(i)); |
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
|
181 } |
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
|
182 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
|
183 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
|
184 } else { |
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
|
185 phi.inputs().set(usedInputCount++, 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
|
186 } |
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
|
187 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
|
188 } |
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
|
189 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2603
diff
changeset
|
190 |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
191 } |