changeset 21195:a4b60873851b

LIRKind: add #merge().
author Josef Eisl <josef.eisl@jku.at>
date Thu, 23 Apr 2015 11:30:06 +0200
parents 5557f74bfd30
children 00bbd2badfd3
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LIRKind.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/PhiResolver.java
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LIRKind.java	Wed Apr 22 14:17:11 2015 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LIRKind.java	Thu Apr 23 11:30:06 2015 +0200
@@ -124,6 +124,27 @@
     }
 
     /**
+     * Merge the types of the inputs. The result will have the {@link PlatformKind} of one of the
+     * inputs. If all inputs are values (references), the result is a value (reference). Otherwise,
+     * the result is a derived reference.
+     *
+     * This method should be used to construct the result {@link LIRKind} of merge operation that do
+     * not modify values (e.g. phis).
+     */
+    public static LIRKind merge(Value... inputs) {
+        assert inputs.length > 0;
+        for (Value input : inputs) {
+            LIRKind kind = input.getLIRKind();
+            if (kind.isDerivedReference()) {
+                return kind;
+            }
+        }
+
+        // all inputs are values or references, just return one of them
+        return inputs[0].getLIRKind();
+    }
+
+    /**
      * Create a new {@link LIRKind} with the same reference information and a new
      * {@linkplain #getPlatformKind platform kind}. If the new kind is a longer vector than this,
      * the new elements are marked as untracked values.