Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/ir/Value.java @ 2581:4a36a0bd6d18
added GraalGraph to classpath, Node as superclass of Value
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Thu, 05 May 2011 13:27:48 +0200 |
parents | e1b3db8031ee |
children | 51ebe5f0516f |
comparison
equal
deleted
inserted
replaced
2579:4984c8ebd6c7 | 2581:4a36a0bd6d18 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.sun.c1x.ir; | 23 package com.sun.c1x.ir; |
24 | 24 |
25 import com.sun.c1x.*; | 25 import com.oracle.graal.graph.*; |
26 import com.sun.c1x.debug.*; | 26 import com.sun.c1x.debug.*; |
27 import com.sun.c1x.opt.*; | 27 import com.sun.c1x.opt.*; |
28 import com.sun.cri.ci.*; | 28 import com.sun.cri.ci.*; |
29 import com.sun.cri.ri.*; | 29 import com.sun.cri.ri.*; |
30 | 30 |
31 /** | 31 /** |
32 * This class represents a value within the HIR graph, including local variables, phis, and | 32 * This class represents a value within the HIR graph, including local variables, phis, and |
33 * all other instructions. | 33 * all other instructions. |
34 */ | 34 */ |
35 public abstract class Value { | 35 public abstract class Value extends Node { |
36 | 36 |
37 public enum Flag { | 37 public enum Flag { |
38 NonNull, // this value is non-null | 38 NonNull, // this value is non-null |
39 | 39 |
40 PhiDead, // phi is illegal because local is dead | 40 PhiDead, // phi is illegal because local is dead |
49 * This kind is guaranteed to be a {@linkplain CiKind#stackKind() stack kind}. | 49 * This kind is guaranteed to be a {@linkplain CiKind#stackKind() stack kind}. |
50 */ | 50 */ |
51 public final CiKind kind; | 51 public final CiKind kind; |
52 | 52 |
53 /** | 53 /** |
54 * Unique identifier for this value. This field's value is lazily initialized by {@link #id()}. | |
55 */ | |
56 private int id; | |
57 | |
58 /** | |
59 * A mask of {@linkplain Flag flags} denoting extra properties of this value. | 54 * A mask of {@linkplain Flag flags} denoting extra properties of this value. |
60 */ | 55 */ |
61 private int flags; | 56 private int flags; |
62 | 57 |
63 protected CiValue operand = CiValue.IllegalValue; | 58 protected CiValue operand = CiValue.IllegalValue; |
70 public abstract BlockBegin block(); | 65 public abstract BlockBegin block(); |
71 | 66 |
72 /** | 67 /** |
73 * Creates a new value with the specified kind. | 68 * Creates a new value with the specified kind. |
74 * @param kind the type of this value | 69 * @param kind the type of this value |
75 */ | 70 * @param inputCount |
76 public Value(CiKind kind) { | 71 * @param successorCount |
72 * @param graph | |
73 */ | |
74 public Value(CiKind kind, int inputCount, int successorCount, Graph graph) { | |
75 super(inputCount, successorCount, graph == null ? new Graph() : graph); | |
77 assert kind == kind.stackKind() : kind + " != " + kind.stackKind(); | 76 assert kind == kind.stackKind() : kind + " != " + kind.stackKind(); |
78 this.kind = kind; | 77 this.kind = kind; |
79 } | 78 } |
79 | |
80 /////////////// | |
81 // TODO: remove when Value class changes are completed | |
82 | |
83 public Value(CiKind kind) { | |
84 this(kind, 0, 0, null); | |
85 } | |
86 | |
87 @Override | |
88 public Node copy(Graph into) { | |
89 throw new UnsupportedOperationException(); | |
90 } | |
91 | |
92 @Override | |
93 protected Object clone() throws CloneNotSupportedException { | |
94 throw new CloneNotSupportedException(); | |
95 } | |
96 | |
97 ///////////////// | |
80 | 98 |
81 /** | 99 /** |
82 * Gets the instruction that should be substituted for this one. Note that this | 100 * Gets the instruction that should be substituted for this one. Note that this |
83 * method is recursive; if the substituted instruction has a substitution, then | 101 * method is recursive; if the substituted instruction has a substitution, then |
84 * the final substituted instruction will be returned. If there is no substitution | 102 * the final substituted instruction will be returned. If there is no substitution |
295 */ | 313 */ |
296 public abstract void accept(ValueVisitor v); | 314 public abstract void accept(ValueVisitor v); |
297 | 315 |
298 public abstract void print(LogStream out); | 316 public abstract void print(LogStream out); |
299 | 317 |
300 /** | |
301 * This method returns a unique identification number for this value. The number returned is unique | |
302 * only to the compilation that produced this node and is computed lazily by using the current compilation | |
303 * for the current thread. Thus the first access is a hash lookup using {@link java.lang.ThreadLocal} and | |
304 * should not be considered fast. Because of the potentially slow first access, use of this ID should be | |
305 * restricted to debugging output. | |
306 * @return a unique ID for this value | |
307 */ | |
308 public int id() { | |
309 if (id == 0) { | |
310 C1XMetrics.UniqueValueIdsAssigned++; | |
311 id = C1XCompilation.compilation().nextID(); | |
312 } | |
313 return id; | |
314 } | |
315 } | 318 } |