Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/ir/Instruction.java @ 2820:2b8ef0a06391
Clean up in the graph builder.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Mon, 30 May 2011 16:24:22 +0200 |
parents | c3f64b66fc78 |
children | 244921d7cf50 |
comparison
equal
deleted
inserted
replaced
2819:774d2bc06148 | 2820:2b8ef0a06391 |
---|---|
64 */ | 64 */ |
65 public Instruction next() { | 65 public Instruction next() { |
66 return (Instruction) successors().get(super.successorCount() + SUCCESSOR_NEXT); | 66 return (Instruction) successors().get(super.successorCount() + SUCCESSOR_NEXT); |
67 } | 67 } |
68 | 68 |
69 private Node setNext(Instruction next) { | 69 public Node setNext(Instruction next) { |
70 return successors().set(super.successorCount() + SUCCESSOR_NEXT, next); | 70 return successors().set(super.successorCount() + SUCCESSOR_NEXT, next); |
71 } | 71 } |
72 | 72 |
73 public int nextIndex() { | 73 public int nextIndex() { |
74 return super.successorCount() + SUCCESSOR_NEXT; | 74 return super.successorCount() + SUCCESSOR_NEXT; |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 public static final int SYNCHRONIZATION_ENTRY_BCI = -1; | 78 public static final int SYNCHRONIZATION_ENTRY_BCI = -1; |
79 | |
80 private boolean isAppended = false; | |
81 | 79 |
82 /** | 80 /** |
83 * Constructs a new instruction with the specified value type. | 81 * Constructs a new instruction with the specified value type. |
84 * @param kind the value type for this instruction | 82 * @param kind the value type for this instruction |
85 * @param inputCount | 83 * @param inputCount |
88 public Instruction(CiKind kind, int inputCount, int successorCount, Graph graph) { | 86 public Instruction(CiKind kind, int inputCount, int successorCount, Graph graph) { |
89 super(kind, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); | 87 super(kind, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph); |
90 C1XMetrics.HIRInstructions++; | 88 C1XMetrics.HIRInstructions++; |
91 } | 89 } |
92 | 90 |
93 /** | |
94 * Checks whether this instruction has already been added to its basic block. | |
95 * @return {@code true} if this instruction has been added to the basic block containing it | |
96 */ | |
97 public final boolean isAppended() { | |
98 return isAppended; | |
99 } | |
100 | |
101 | |
102 /** | |
103 * Sets the next instruction for this instruction. Note that it is illegal to | |
104 * set the next field of a phi, block end, or local instruction. | |
105 * @param next the next instruction | |
106 * @param bci the bytecode index of the next instruction | |
107 * @return the new next instruction | |
108 */ | |
109 public final Instruction appendNext(Instruction next) { | |
110 setNext(next); | |
111 if (next != null) { | |
112 assert !(this instanceof BlockEnd); | |
113 next.isAppended = true; | |
114 } | |
115 return next; | |
116 } | |
117 | 91 |
118 /** | 92 /** |
119 * Gets the list of predecessors of this block. | 93 * Gets the list of predecessors of this block. |
120 * @return the predecessor list | 94 * @return the predecessor list |
121 */ | 95 */ |
122 @SuppressWarnings({ "unchecked", "rawtypes" }) | 96 @SuppressWarnings({ "unchecked", "rawtypes" }) |
123 public List<Instruction> blockPredecessors() { | 97 public List<Instruction> blockPredecessors() { |
124 /*if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { | 98 return (List) Collections.unmodifiableList(predecessors()); |
125 return Collections.EMPTY_LIST; | |
126 } else {)*/ | |
127 return (List) Collections.unmodifiableList(predecessors()); | |
128 //} | |
129 } | 99 } |
130 | 100 |
131 /** | 101 /** |
132 * Get the number of predecessors. | 102 * Get the number of predecessors. |
133 * @return the number of predecessors | 103 * @return the number of predecessors |
134 */ | 104 */ |
135 public int numberOfPreds() { | 105 public int numberOfPreds() { |
136 // ignore the graph root | 106 return predecessors().size(); |
137 /*if (predecessors().size() == 1 && predecessors().get(0) == graph().start()) { | |
138 return 0; | |
139 } else {*/ | |
140 return predecessors().size(); | |
141 //} | |
142 } | 107 } |
143 | 108 |
144 public Instruction predAt(int j) { | 109 public Instruction predAt(int j) { |
145 return (Instruction) predecessors().get(j); | 110 return (Instruction) predecessors().get(j); |
146 } | 111 } |