# HG changeset patch # User Josef Eisl # Date 1429781406 -7200 # Node ID a4b60873851bcb1cfeac04f65a704515b18c24ad # Parent 5557f74bfd300d9e183fdc06f2fe761e57596d65 LIRKind: add #merge(). diff -r 5557f74bfd30 -r a4b60873851b graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/LIRKind.java --- 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.