10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24
25 package org.graalvm.compiler.nodes;
26
27 import static org.graalvm.compiler.nodeinfo.InputType.Association;
28 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_1;
29 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
30 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1;
31
32 import java.util.Collections;
33
34 import org.graalvm.compiler.graph.Node;
35 import org.graalvm.compiler.graph.NodeClass;
36 import org.graalvm.compiler.nodeinfo.NodeCycles;
37 import org.graalvm.compiler.nodeinfo.NodeInfo;
38 import org.graalvm.compiler.nodeinfo.NodeSize;
39 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
40
41 /**
42 * LoopEnd nodes represent a loop back-edge. When a LoopEnd is reached, execution continues at the
43 * {@linkplain #loopBegin() loop header}.
44 */
45 @NodeInfo(cycles = CYCLES_1, cyclesRationale = "Backedge jmp", size = SIZE_1, sizeRationale = "Backedge jmp")
46 public final class LoopEndNode extends AbstractEndNode {
47
48 public static final NodeClass<LoopEndNode> TYPE = NodeClass.create(LoopEndNode.class);
49
50 /*
126 * Since a LoopBeginNode also has {@linkplain LoopBeginNode#forwardEnds() forward ends}, this is
127 * <b>not</b> the index into {@link PhiNode} values at the loop begin. Use
128 * {@link LoopBeginNode#phiPredecessorIndex(AbstractEndNode)} for this purpose.
129 *
130 */
131 int endIndex() {
132 return endIndex;
133 }
134
135 void setEndIndex(int idx) {
136 this.endIndex = idx;
137 }
138
139 @Override
140 public Iterable<? extends Node> cfgSuccessors() {
141 return Collections.emptyList();
142 }
143
144 @Override
145 public NodeCycles estimatedNodeCycles() {
146 if (canSafepoint()) {
147 // jmp+read
148 return CYCLES_2;
149 }
150 return super.estimatedNodeCycles();
151 }
152
153 @Override
154 public NodeSize estimatedNodeSize() {
155 if (canSafepoint()) {
156 return NodeSize.SIZE_2;
157 }
158 return super.estimatedNodeSize();
159 }
160 }
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24
25 package org.graalvm.compiler.nodes;
26
27 import static org.graalvm.compiler.nodeinfo.InputType.Association;
28 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_1;
29 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
30 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_UNKNOWN;
31 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1;
32 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_2;
33 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_UNKNOWN;
34
35 import java.util.Collections;
36
37 import org.graalvm.compiler.graph.Node;
38 import org.graalvm.compiler.graph.NodeClass;
39 import org.graalvm.compiler.nodeinfo.NodeCycles;
40 import org.graalvm.compiler.nodeinfo.NodeInfo;
41 import org.graalvm.compiler.nodeinfo.NodeSize;
42 import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
43
44 /**
45 * LoopEnd nodes represent a loop back-edge. When a LoopEnd is reached, execution continues at the
46 * {@linkplain #loopBegin() loop header}.
47 */
48 @NodeInfo(cycles = CYCLES_1, cyclesRationale = "Backedge jmp", size = SIZE_1, sizeRationale = "Backedge jmp")
49 public final class LoopEndNode extends AbstractEndNode {
50
51 public static final NodeClass<LoopEndNode> TYPE = NodeClass.create(LoopEndNode.class);
52
53 /*
129 * Since a LoopBeginNode also has {@linkplain LoopBeginNode#forwardEnds() forward ends}, this is
130 * <b>not</b> the index into {@link PhiNode} values at the loop begin. Use
131 * {@link LoopBeginNode#phiPredecessorIndex(AbstractEndNode)} for this purpose.
132 *
133 */
134 int endIndex() {
135 return endIndex;
136 }
137
138 void setEndIndex(int idx) {
139 this.endIndex = idx;
140 }
141
142 @Override
143 public Iterable<? extends Node> cfgSuccessors() {
144 return Collections.emptyList();
145 }
146
147 @Override
148 public NodeCycles estimatedNodeCycles() {
149 if (loopBegin() == null) {
150 return CYCLES_UNKNOWN;
151 }
152 if (canSafepoint()) {
153 // jmp+read
154 return CYCLES_2;
155 }
156 return super.estimatedNodeCycles();
157 }
158
159 @Override
160 public NodeSize estimatedNodeSize() {
161 if (loopBegin() == null) {
162 return SIZE_UNKNOWN;
163 }
164 if (canSafepoint()) {
165 return SIZE_2;
166 }
167 return super.estimatedNodeSize();
168 }
169 }
|