changeset 15109:e17fe8c1287d

Introduce HIRLoop.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 10 Apr 2014 15:47:41 +0200
parents b6711b514576
children ca92d97bb0d6
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/HIRLoop.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Loop.java
diffstat 3 files changed, 40 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Wed Apr 09 17:38:16 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Thu Apr 10 15:47:41 2014 +0200
@@ -237,7 +237,7 @@
         for (Block block : reversePostOrder) {
             Node beginNode = block.getBeginNode();
             if (beginNode instanceof LoopBeginNode) {
-                Loop<Block> loop = new Loop<>(block.getLoop(), loops.size(), block);
+                Loop<Block> loop = new HIRLoop(block.getLoop(), loops.size(), block);
                 loops.add(loop);
 
                 LoopBeginNode loopBegin = (LoopBeginNode) beginNode;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/HIRLoop.java	Thu Apr 10 15:47:41 2014 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes.cfg;
+
+import com.oracle.graal.nodes.*;
+
+public class HIRLoop extends Loop<Block> {
+
+    protected HIRLoop(Loop<Block> parent, int index, Block header) {
+        super(parent, index, header);
+    }
+
+    @Override
+    public long numBackedges() {
+        return ((LoopBeginNode) header.getBeginNode()).loopEnds().count();
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Loop.java	Wed Apr 09 17:38:16 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Loop.java	Thu Apr 10 15:47:41 2014 +0200
@@ -24,7 +24,7 @@
 
 import java.util.*;
 
-public class Loop<T extends AbstractBlock<T>> {
+public abstract class Loop<T extends AbstractBlock<T>> {
 
     public final Loop<T> parent;
     public final List<Loop<T>> children;
@@ -50,9 +50,7 @@
         this.exits = new ArrayList<>();
     }
 
-    public long numBackedges() {
-        return header.getPredecessors().stream().filter(b -> b.getId() >= header.getId()).count();
-    }
+    public abstract long numBackedges();
 
     @Override
     public String toString() {