# HG changeset patch # User Josef Eisl # Date 1397751132 -7200 # Node ID 97eed257999b45e071cb9587848e44c9243eac8f # Parent 38f9b0506cc4c829b13ccf5c6cd24f19823a4347 Move Condition to graal.compiler.common. diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java --- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Thu Apr 17 18:12:12 2014 +0200 @@ -28,8 +28,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.*; -import com.oracle.graal.nodes.calc.*; public class PTXAssembler extends AbstractPTXAssembler { diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java --- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Thu Apr 17 18:12:12 2014 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.bytecode.*; import com.oracle.graal.compiler.alloc.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; @@ -44,7 +45,6 @@ import com.oracle.graal.java.BciBlockMapping.LocalLiveness; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.phases.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Apr 17 18:12:12 2014 +0200 @@ -36,6 +36,7 @@ import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; @@ -68,7 +69,6 @@ import com.oracle.graal.lir.amd64.AMD64Move.StackLeaOp; import com.oracle.graal.lir.amd64.AMD64Move.ZeroExtendLoadOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.util.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java Thu Apr 17 18:12:12 2014 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.debug.*; import com.oracle.graal.lir.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/calc/Condition.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/calc/Condition.java Thu Apr 17 18:12:12 2014 +0200 @@ -0,0 +1,634 @@ +/* + * Copyright (c) 2009, 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.compiler.common.calc; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; + +/** + * Condition codes used in conditionals. + */ +public enum Condition { + /** + * Equal. + */ + EQ("=="), + + /** + * Not equal. + */ + NE("!="), + + /** + * Signed less than. + */ + LT("<"), + + /** + * Signed less than or equal. + */ + LE("<="), + + /** + * Signed greater than. + */ + GT(">"), + + /** + * Signed greater than or equal. + */ + GE(">="), + + /** + * Unsigned greater than or equal ("above than or equal"). + */ + AE("|>=|"), + + /** + * Unsigned less than or equal ("below than or equal"). + */ + BE("|<=|"), + + /** + * Unsigned greater than ("above than"). + */ + AT("|>|"), + + /** + * Unsigned less than ("below than"). + */ + BT("|<|"); + + public final String operator; + + private Condition(String operator) { + this.operator = operator; + } + + public boolean check(int left, int right) { + switch (this) { + case EQ: + return left == right; + case NE: + return left != right; + case LT: + return left < right; + case LE: + return left <= right; + case GT: + return left > right; + case GE: + return left >= right; + case AE: + return UnsignedMath.aboveOrEqual(left, right); + case BE: + return UnsignedMath.belowOrEqual(left, right); + case AT: + return UnsignedMath.aboveThan(left, right); + case BT: + return UnsignedMath.belowThan(left, right); + } + throw new IllegalArgumentException(this.toString()); + } + + /** + * Given a condition and its negation, this method returns true for one of the two and false for + * the other one. This can be used to keep comparisons in a canonical form. + * + * @return true if this condition is considered to be the canonical form, false otherwise. + */ + public boolean isCanonical() { + switch (this) { + case EQ: + return true; + case NE: + return false; + case LT: + return true; + case LE: + return false; + case GT: + return false; + case GE: + return false; + case BT: + return true; + case BE: + return false; + case AT: + return false; + case AE: + return false; + } + throw new IllegalArgumentException(this.toString()); + } + + /** + * Returns true if the condition needs to be mirrored to get to a canonical condition. The + * result of the mirroring operation might still need to be negated to achieve a canonical form. + */ + public boolean canonicalMirror() { + switch (this) { + case EQ: + return false; + case NE: + return false; + case LT: + return false; + case LE: + return true; + case GT: + return true; + case GE: + return false; + case BT: + return false; + case BE: + return true; + case AT: + return true; + case AE: + return false; + } + throw new IllegalArgumentException(this.toString()); + } + + /** + * Returns true if the condition needs to be negated to get to a canonical condition. The result + * of the negation might still need to be mirrored to achieve a canonical form. + */ + public boolean canonicalNegate() { + switch (this) { + case EQ: + return false; + case NE: + return true; + case LT: + return false; + case LE: + return true; + case GT: + return false; + case GE: + return true; + case BT: + return false; + case BE: + return true; + case AT: + return false; + case AE: + return true; + } + throw new IllegalArgumentException(this.toString()); + } + + /** + * Negate this conditional. + * + * @return the condition that represents the negation + */ + public final Condition negate() { + switch (this) { + case EQ: + return NE; + case NE: + return EQ; + case LT: + return GE; + case LE: + return GT; + case GT: + return LE; + case GE: + return LT; + case BT: + return AE; + case BE: + return AT; + case AT: + return BE; + case AE: + return BT; + } + throw new IllegalArgumentException(this.toString()); + } + + public boolean implies(Condition other) { + if (other == this) { + return true; + } + switch (this) { + case EQ: + return other == LE || other == GE || other == BE || other == AE; + case NE: + return false; + case LT: + return other == LE || other == NE; + case LE: + return false; + case GT: + return other == GE || other == NE; + case GE: + return false; + case BT: + return other == BE || other == NE; + case BE: + return false; + case AT: + return other == AE || other == NE; + case AE: + return false; + } + throw new IllegalArgumentException(this.toString()); + } + + /** + * Mirror this conditional (i.e. commute "a op b" to "b op' a") + * + * @return the condition representing the equivalent commuted operation + */ + public final Condition mirror() { + switch (this) { + case EQ: + return EQ; + case NE: + return NE; + case LT: + return GT; + case LE: + return GE; + case GT: + return LT; + case GE: + return LE; + case BT: + return AT; + case BE: + return AE; + case AT: + return BT; + case AE: + return BE; + } + throw new IllegalArgumentException(); + } + + /** + * Returns true if this condition represents an unsigned comparison. EQ and NE are not + * considered to be unsigned. + */ + public final boolean isUnsigned() { + return this == Condition.BT || this == Condition.BE || this == Condition.AT || this == Condition.AE; + } + + /** + * Checks if this conditional operation is commutative. + * + * @return {@code true} if this operation is commutative + */ + public final boolean isCommutative() { + return this == EQ || this == NE; + } + + /** + * Attempts to fold a comparison between two constants and return the result. + * + * @param lt the constant on the left side of the comparison + * @param rt the constant on the right side of the comparison + * @param constantReflection needed to compare constants + * @return {@link Boolean#TRUE} if the comparison is known to be true, {@link Boolean#FALSE} if + * the comparison is known to be false + */ + public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection) { + assert !lt.getKind().isNumericFloat() && !rt.getKind().isNumericFloat(); + return foldCondition(lt, rt, constantReflection, false); + } + + /** + * Attempts to fold a comparison between two constants and return the result. + * + * @param lt the constant on the left side of the comparison + * @param rt the constant on the right side of the comparison + * @param constantReflection needed to compare constants + * @param unorderedIsTrue true if an undecided float comparison should result in "true" + * @return true if the comparison is known to be true, false if the comparison is known to be + * false + */ + public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection, boolean unorderedIsTrue) { + switch (lt.getKind()) { + case Boolean: + case Byte: + case Char: + case Short: + case Int: { + int x = lt.asInt(); + int y = rt.asInt(); + switch (this) { + case EQ: + return x == y; + case NE: + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + case AE: + return UnsignedMath.aboveOrEqual(x, y); + case BE: + return UnsignedMath.belowOrEqual(x, y); + case AT: + return UnsignedMath.aboveThan(x, y); + case BT: + return UnsignedMath.belowThan(x, y); + default: + throw new GraalInternalError("expected condition: %s", this); + } + } + case Long: { + long x = lt.asLong(); + long y = rt.asLong(); + switch (this) { + case EQ: + return x == y; + case NE: + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + case AE: + return UnsignedMath.aboveOrEqual(x, y); + case BE: + return UnsignedMath.belowOrEqual(x, y); + case AT: + return UnsignedMath.aboveThan(x, y); + case BT: + return UnsignedMath.belowThan(x, y); + default: + throw new GraalInternalError("expected condition: %s", this); + } + } + case Object: { + Boolean equal = constantReflection.constantEquals(lt, rt); + if (equal != null) { + switch (this) { + case EQ: + return equal.booleanValue(); + case NE: + return !equal.booleanValue(); + default: + throw new GraalInternalError("expected condition: %s", this); + } + } + } + case Float: { + float x = lt.asFloat(); + float y = rt.asFloat(); + if (Float.isNaN(x) || Float.isNaN(y)) { + return unorderedIsTrue; + } + switch (this) { + case EQ: + return x == y; + case NE: + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + default: + throw new GraalInternalError("expected condition: %s", this); + } + } + case Double: { + double x = lt.asDouble(); + double y = rt.asDouble(); + if (Double.isNaN(x) || Double.isNaN(y)) { + return unorderedIsTrue; + } + switch (this) { + case EQ: + return x == y; + case NE: + return x != y; + case LT: + return x < y; + case LE: + return x <= y; + case GT: + return x > y; + case GE: + return x >= y; + default: + throw new GraalInternalError("expected condition: %s", this); + } + } + default: + throw new GraalInternalError("expected value kind %s while folding condition: %s", lt.getKind(), this); + } + } + + public Condition join(Condition other) { + if (other == this) { + return this; + } + switch (this) { + case EQ: + if (other == LE || other == GE || other == BE || other == AE) { + return EQ; + } else { + return null; + } + case NE: + if (other == LT || other == GT || other == BT || other == AT) { + return other; + } else if (other == LE) { + return LT; + } else if (other == GE) { + return GT; + } else if (other == BE) { + return BT; + } else if (other == AE) { + return AT; + } else { + return null; + } + case LE: + if (other == GE || other == EQ) { + return EQ; + } else if (other == NE || other == LT) { + return LT; + } else { + return null; + } + case LT: + if (other == NE || other == LE) { + return LT; + } else { + return null; + } + case GE: + if (other == LE || other == EQ) { + return EQ; + } else if (other == NE || other == GT) { + return GT; + } else { + return null; + } + case GT: + if (other == NE || other == GE) { + return GT; + } else { + return null; + } + case BE: + if (other == AE || other == EQ) { + return EQ; + } else if (other == NE || other == BT) { + return BT; + } else { + return null; + } + case BT: + if (other == NE || other == BE) { + return BT; + } else { + return null; + } + case AE: + if (other == BE || other == EQ) { + return EQ; + } else if (other == NE || other == AT) { + return AT; + } else { + return null; + } + case AT: + if (other == NE || other == AE) { + return AT; + } else { + return null; + } + } + throw new IllegalArgumentException(this.toString()); + } + + public Condition meet(Condition other) { + if (other == this) { + return this; + } + switch (this) { + case EQ: + if (other == LE || other == GE || other == BE || other == AE) { + return other; + } else if (other == LT) { + return LE; + } else if (other == GT) { + return GE; + } else if (other == BT) { + return BE; + } else if (other == AT) { + return AE; + } else { + return null; + } + case NE: + if (other == LT || other == GT || other == BT || other == AT) { + return NE; + } else { + return null; + } + case LE: + if (other == EQ || other == LT) { + return LE; + } else { + return null; + } + case LT: + if (other == EQ || other == LE) { + return LE; + } else if (other == NE || other == GT) { + return NE; + } else { + return null; + } + case GE: + if (other == EQ || other == GT) { + return GE; + } else { + return null; + } + case GT: + if (other == EQ || other == GE) { + return GE; + } else if (other == NE || other == LT) { + return NE; + } else { + return null; + } + case BE: + if (other == EQ || other == BT) { + return BE; + } else { + return null; + } + case BT: + if (other == EQ || other == BE) { + return BE; + } else if (other == NE || other == AT) { + return NE; + } else { + return null; + } + case AE: + if (other == EQ || other == AT) { + return AE; + } else { + return null; + } + case AT: + if (other == EQ || other == AE) { + return AE; + } else if (other == NE || other == BT) { + return NE; + } else { + return null; + } + } + throw new IllegalArgumentException(this.toString()); + } +} diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java --- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Thu Apr 17 18:12:12 2014 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; @@ -51,7 +52,6 @@ import com.oracle.graal.lir.hsail.HSAILMove.MoveFromRegOp; import com.oracle.graal.lir.hsail.HSAILMove.MoveToRegOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; import com.oracle.graal.phases.util.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 17 18:12:12 2014 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; @@ -58,7 +59,6 @@ import com.oracle.graal.lir.ptx.PTXMove.MoveFromRegOp; import com.oracle.graal.lir.ptx.PTXMove.MoveToRegOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.type.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Thu Apr 17 18:12:12 2014 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.asm.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.JumpOp; @@ -58,7 +59,6 @@ import com.oracle.graal.lir.sparc.SPARCMove.MoveToRegOp; import com.oracle.graal.lir.sparc.SPARCMove.StackLoadAddressOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.util.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java Thu Apr 17 18:12:12 2014 +0200 @@ -29,7 +29,7 @@ import org.junit.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.compiler.common.calc.*; public class ConditionTest { diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 17 18:12:12 2014 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.common.spi.*; import com.oracle.graal.compiler.common.type.*; @@ -43,7 +44,6 @@ import com.oracle.graal.lir.StandardOp.LabelOp; import com.oracle.graal.lir.StandardOp.NoOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.options.*; import com.oracle.graal.phases.util.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Thu Apr 17 18:12:12 2014 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.gen.LIRGenerator.LoadConstant; import com.oracle.graal.compiler.target.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 17 18:12:12 2014 +0200 @@ -34,6 +34,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.amd64.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; @@ -55,7 +56,6 @@ import com.oracle.graal.lir.amd64.AMD64Move.StoreConstantOp; import com.oracle.graal.lir.amd64.AMD64Move.StoreOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; /** diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMemoryPeephole.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMemoryPeephole.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMemoryPeephole.java Thu Apr 17 18:12:12 2014 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.asm.amd64.*; import com.oracle.graal.compiler.amd64.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.data.*; import com.oracle.graal.hotspot.meta.*; @@ -38,7 +39,6 @@ import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp; import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; /** diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Thu Apr 17 18:12:12 2014 +0200 @@ -28,6 +28,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.hsail.*; import com.oracle.graal.hotspot.*; @@ -51,7 +52,6 @@ import com.oracle.graal.lir.hsail.HSAILMove.StoreConstantOp; import com.oracle.graal.lir.hsail.HSAILMove.StoreOp; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.phases.util.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Thu Apr 17 18:12:12 2014 +0200 @@ -35,10 +35,10 @@ import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.bytecode.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.debug.*; import com.oracle.graal.java.BciBlockMapping.BciBlock; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; import com.oracle.graal.options.*; import com.oracle.graal.phases.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Apr 17 18:12:12 2014 +0200 @@ -37,6 +37,7 @@ import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.bytecode.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.ValueNumberable; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Thu Apr 17 18:12:12 2014 +0200 @@ -34,11 +34,11 @@ import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.SwitchStrategy.BaseSwitchClosure; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; public class AMD64ControlFlow { diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Thu Apr 17 18:12:12 2014 +0200 @@ -27,9 +27,9 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.hsail.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; /** * Implementation of compare operations. diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Thu Apr 17 18:12:12 2014 +0200 @@ -30,12 +30,12 @@ import com.oracle.graal.asm.*; import com.oracle.graal.asm.hsail.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.hsail.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.SwitchStrategy.BaseSwitchClosure; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; /** * Implementation of control flow instructions. diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Thu Apr 17 18:12:12 2014 +0200 @@ -29,9 +29,9 @@ import com.oracle.graal.asm.ptx.*; import com.oracle.graal.asm.ptx.PTXAssembler.Setp; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; public enum PTXCompare { ICMP, diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Thu Apr 17 18:12:12 2014 +0200 @@ -22,9 +22,9 @@ */ package com.oracle.graal.lir.ptx; +import static com.oracle.graal.compiler.common.calc.Condition.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import static com.oracle.graal.lir.LIRValueUtil.*; -import static com.oracle.graal.nodes.calc.Condition.*; import com.oracle.graal.api.code.CompilationResult.JumpTable; import com.oracle.graal.api.meta.*; @@ -34,11 +34,11 @@ import com.oracle.graal.asm.ptx.*; import com.oracle.graal.asm.ptx.PTXMacroAssembler.Mov; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.SwitchStrategy.BaseSwitchClosure; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; public class PTXControlFlow { diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Thu Apr 17 18:12:12 2014 +0200 @@ -28,8 +28,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.asm.ptx.PTXAssembler.Setp; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; public class PTXTestOp extends PTXLIRInstruction { diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Thu Apr 17 18:12:12 2014 +0200 @@ -49,11 +49,11 @@ import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Nop; import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Ret; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.BlockEndOp; import com.oracle.graal.lir.SwitchStrategy.BaseSwitchClosure; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; public class SPARCControlFlow { diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.lir/src/com/oracle/graal/lir/SwitchStrategy.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/SwitchStrategy.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/SwitchStrategy.java Thu Apr 17 18:12:12 2014 +0200 @@ -26,8 +26,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; /** * This class encapsulates different strategies on how to generate code for switch instructions. diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Thu Apr 17 18:12:12 2014 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -27,6 +27,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; import com.oracle.graal.api.meta.ProfilingInfo.TriState; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -24,6 +24,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/Condition.java Thu Apr 17 18:01:21 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,634 +0,0 @@ -/* - * Copyright (c) 2009, 2012, 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.calc; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.common.*; - -/** - * Condition codes used in conditionals. - */ -public enum Condition { - /** - * Equal. - */ - EQ("=="), - - /** - * Not equal. - */ - NE("!="), - - /** - * Signed less than. - */ - LT("<"), - - /** - * Signed less than or equal. - */ - LE("<="), - - /** - * Signed greater than. - */ - GT(">"), - - /** - * Signed greater than or equal. - */ - GE(">="), - - /** - * Unsigned greater than or equal ("above than or equal"). - */ - AE("|>=|"), - - /** - * Unsigned less than or equal ("below than or equal"). - */ - BE("|<=|"), - - /** - * Unsigned greater than ("above than"). - */ - AT("|>|"), - - /** - * Unsigned less than ("below than"). - */ - BT("|<|"); - - public final String operator; - - private Condition(String operator) { - this.operator = operator; - } - - public boolean check(int left, int right) { - switch (this) { - case EQ: - return left == right; - case NE: - return left != right; - case LT: - return left < right; - case LE: - return left <= right; - case GT: - return left > right; - case GE: - return left >= right; - case AE: - return UnsignedMath.aboveOrEqual(left, right); - case BE: - return UnsignedMath.belowOrEqual(left, right); - case AT: - return UnsignedMath.aboveThan(left, right); - case BT: - return UnsignedMath.belowThan(left, right); - } - throw new IllegalArgumentException(this.toString()); - } - - /** - * Given a condition and its negation, this method returns true for one of the two and false for - * the other one. This can be used to keep comparisons in a canonical form. - * - * @return true if this condition is considered to be the canonical form, false otherwise. - */ - public boolean isCanonical() { - switch (this) { - case EQ: - return true; - case NE: - return false; - case LT: - return true; - case LE: - return false; - case GT: - return false; - case GE: - return false; - case BT: - return true; - case BE: - return false; - case AT: - return false; - case AE: - return false; - } - throw new IllegalArgumentException(this.toString()); - } - - /** - * Returns true if the condition needs to be mirrored to get to a canonical condition. The - * result of the mirroring operation might still need to be negated to achieve a canonical form. - */ - public boolean canonicalMirror() { - switch (this) { - case EQ: - return false; - case NE: - return false; - case LT: - return false; - case LE: - return true; - case GT: - return true; - case GE: - return false; - case BT: - return false; - case BE: - return true; - case AT: - return true; - case AE: - return false; - } - throw new IllegalArgumentException(this.toString()); - } - - /** - * Returns true if the condition needs to be negated to get to a canonical condition. The result - * of the negation might still need to be mirrored to achieve a canonical form. - */ - public boolean canonicalNegate() { - switch (this) { - case EQ: - return false; - case NE: - return true; - case LT: - return false; - case LE: - return true; - case GT: - return false; - case GE: - return true; - case BT: - return false; - case BE: - return true; - case AT: - return false; - case AE: - return true; - } - throw new IllegalArgumentException(this.toString()); - } - - /** - * Negate this conditional. - * - * @return the condition that represents the negation - */ - public final Condition negate() { - switch (this) { - case EQ: - return NE; - case NE: - return EQ; - case LT: - return GE; - case LE: - return GT; - case GT: - return LE; - case GE: - return LT; - case BT: - return AE; - case BE: - return AT; - case AT: - return BE; - case AE: - return BT; - } - throw new IllegalArgumentException(this.toString()); - } - - public boolean implies(Condition other) { - if (other == this) { - return true; - } - switch (this) { - case EQ: - return other == LE || other == GE || other == BE || other == AE; - case NE: - return false; - case LT: - return other == LE || other == NE; - case LE: - return false; - case GT: - return other == GE || other == NE; - case GE: - return false; - case BT: - return other == BE || other == NE; - case BE: - return false; - case AT: - return other == AE || other == NE; - case AE: - return false; - } - throw new IllegalArgumentException(this.toString()); - } - - /** - * Mirror this conditional (i.e. commute "a op b" to "b op' a") - * - * @return the condition representing the equivalent commuted operation - */ - public final Condition mirror() { - switch (this) { - case EQ: - return EQ; - case NE: - return NE; - case LT: - return GT; - case LE: - return GE; - case GT: - return LT; - case GE: - return LE; - case BT: - return AT; - case BE: - return AE; - case AT: - return BT; - case AE: - return BE; - } - throw new IllegalArgumentException(); - } - - /** - * Returns true if this condition represents an unsigned comparison. EQ and NE are not - * considered to be unsigned. - */ - public final boolean isUnsigned() { - return this == Condition.BT || this == Condition.BE || this == Condition.AT || this == Condition.AE; - } - - /** - * Checks if this conditional operation is commutative. - * - * @return {@code true} if this operation is commutative - */ - public final boolean isCommutative() { - return this == EQ || this == NE; - } - - /** - * Attempts to fold a comparison between two constants and return the result. - * - * @param lt the constant on the left side of the comparison - * @param rt the constant on the right side of the comparison - * @param constantReflection needed to compare constants - * @return {@link Boolean#TRUE} if the comparison is known to be true, {@link Boolean#FALSE} if - * the comparison is known to be false - */ - public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection) { - assert !lt.getKind().isNumericFloat() && !rt.getKind().isNumericFloat(); - return foldCondition(lt, rt, constantReflection, false); - } - - /** - * Attempts to fold a comparison between two constants and return the result. - * - * @param lt the constant on the left side of the comparison - * @param rt the constant on the right side of the comparison - * @param constantReflection needed to compare constants - * @param unorderedIsTrue true if an undecided float comparison should result in "true" - * @return true if the comparison is known to be true, false if the comparison is known to be - * false - */ - public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection, boolean unorderedIsTrue) { - switch (lt.getKind()) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: { - int x = lt.asInt(); - int y = rt.asInt(); - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - case AE: - return UnsignedMath.aboveOrEqual(x, y); - case BE: - return UnsignedMath.belowOrEqual(x, y); - case AT: - return UnsignedMath.aboveThan(x, y); - case BT: - return UnsignedMath.belowThan(x, y); - default: - throw new GraalInternalError("expected condition: %s", this); - } - } - case Long: { - long x = lt.asLong(); - long y = rt.asLong(); - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - case AE: - return UnsignedMath.aboveOrEqual(x, y); - case BE: - return UnsignedMath.belowOrEqual(x, y); - case AT: - return UnsignedMath.aboveThan(x, y); - case BT: - return UnsignedMath.belowThan(x, y); - default: - throw new GraalInternalError("expected condition: %s", this); - } - } - case Object: { - Boolean equal = constantReflection.constantEquals(lt, rt); - if (equal != null) { - switch (this) { - case EQ: - return equal.booleanValue(); - case NE: - return !equal.booleanValue(); - default: - throw new GraalInternalError("expected condition: %s", this); - } - } - } - case Float: { - float x = lt.asFloat(); - float y = rt.asFloat(); - if (Float.isNaN(x) || Float.isNaN(y)) { - return unorderedIsTrue; - } - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - default: - throw new GraalInternalError("expected condition: %s", this); - } - } - case Double: { - double x = lt.asDouble(); - double y = rt.asDouble(); - if (Double.isNaN(x) || Double.isNaN(y)) { - return unorderedIsTrue; - } - switch (this) { - case EQ: - return x == y; - case NE: - return x != y; - case LT: - return x < y; - case LE: - return x <= y; - case GT: - return x > y; - case GE: - return x >= y; - default: - throw new GraalInternalError("expected condition: %s", this); - } - } - default: - throw new GraalInternalError("expected value kind %s while folding condition: %s", lt.getKind(), this); - } - } - - public Condition join(Condition other) { - if (other == this) { - return this; - } - switch (this) { - case EQ: - if (other == LE || other == GE || other == BE || other == AE) { - return EQ; - } else { - return null; - } - case NE: - if (other == LT || other == GT || other == BT || other == AT) { - return other; - } else if (other == LE) { - return LT; - } else if (other == GE) { - return GT; - } else if (other == BE) { - return BT; - } else if (other == AE) { - return AT; - } else { - return null; - } - case LE: - if (other == GE || other == EQ) { - return EQ; - } else if (other == NE || other == LT) { - return LT; - } else { - return null; - } - case LT: - if (other == NE || other == LE) { - return LT; - } else { - return null; - } - case GE: - if (other == LE || other == EQ) { - return EQ; - } else if (other == NE || other == GT) { - return GT; - } else { - return null; - } - case GT: - if (other == NE || other == GE) { - return GT; - } else { - return null; - } - case BE: - if (other == AE || other == EQ) { - return EQ; - } else if (other == NE || other == BT) { - return BT; - } else { - return null; - } - case BT: - if (other == NE || other == BE) { - return BT; - } else { - return null; - } - case AE: - if (other == BE || other == EQ) { - return EQ; - } else if (other == NE || other == AT) { - return AT; - } else { - return null; - } - case AT: - if (other == NE || other == AE) { - return AT; - } else { - return null; - } - } - throw new IllegalArgumentException(this.toString()); - } - - public Condition meet(Condition other) { - if (other == this) { - return this; - } - switch (this) { - case EQ: - if (other == LE || other == GE || other == BE || other == AE) { - return other; - } else if (other == LT) { - return LE; - } else if (other == GT) { - return GE; - } else if (other == BT) { - return BE; - } else if (other == AT) { - return AE; - } else { - return null; - } - case NE: - if (other == LT || other == GT || other == BT || other == AT) { - return NE; - } else { - return null; - } - case LE: - if (other == EQ || other == LT) { - return LE; - } else { - return null; - } - case LT: - if (other == EQ || other == LE) { - return LE; - } else if (other == NE || other == GT) { - return NE; - } else { - return null; - } - case GE: - if (other == EQ || other == GT) { - return GE; - } else { - return null; - } - case GT: - if (other == EQ || other == GE) { - return GE; - } else if (other == NE || other == LT) { - return NE; - } else { - return null; - } - case BE: - if (other == EQ || other == BT) { - return BE; - } else { - return null; - } - case BT: - if (other == EQ || other == BE) { - return BE; - } else if (other == NE || other == AT) { - return NE; - } else { - return null; - } - case AE: - if (other == EQ || other == AT) { - return AE; - } else { - return null; - } - case AT: - if (other == EQ || other == AE) { - return AE; - } else if (other == NE || other == BT) { - return NE; - } else { - return null; - } - } - throw new IllegalArgumentException(this.toString()); - } -} diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -25,6 +25,7 @@ import static com.oracle.graal.nodes.calc.CompareNode.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatEqualsNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatEqualsNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatEqualsNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.nodes.calc; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.type.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatLessThanNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatLessThanNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatLessThanNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.nodes.calc; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerBelowThanNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerBelowThanNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerBelowThanNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.nodes.calc; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.nodes.calc; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerLessThanNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerLessThanNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerLessThanNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.nodes.calc; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.nodes.calc; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.nodes.extended; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Apr 17 18:12:12 2014 +0200 @@ -37,6 +37,7 @@ import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType; import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java Thu Apr 17 18:12:12 2014 +0200 @@ -28,6 +28,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.replacements.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java Thu Apr 17 18:12:12 2014 +0200 @@ -22,7 +22,7 @@ */ package com.oracle.graal.replacements; -import static com.oracle.graal.nodes.calc.Condition.*; +import static com.oracle.graal.compiler.common.calc.Condition.*; import static com.oracle.graal.nodes.calc.ConditionalNode.*; import com.oracle.graal.api.code.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.truffle.nodes.typesystem; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadMacroNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadMacroNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadMacroNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.truffle.nodes.typesystem; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java Thu Apr 17 18:12:12 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.truffle.nodes.typesystem; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java Thu Apr 17 18:12:12 2014 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.nodes.HeapAccess.BarrierType; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; diff -r 38f9b0506cc4 -r 97eed257999b graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Thu Apr 17 18:01:21 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Thu Apr 17 18:12:12 2014 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.compiler.common.*; +import com.oracle.graal.compiler.common.calc.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; diff -r 38f9b0506cc4 -r 97eed257999b mx/projects --- a/mx/projects Thu Apr 17 18:01:21 2014 +0200 +++ b/mx/projects Thu Apr 17 18:12:12 2014 +0200 @@ -253,7 +253,7 @@ # graal.graph project@com.oracle.graal.graph@subDir=graal project@com.oracle.graal.graph@sourceDirs=src -project@com.oracle.graal.graph@dependencies=com.oracle.graal.debug,com.oracle.graal.api.code,com.oracle.graal.compiler.common,FINDBUGS +project@com.oracle.graal.graph@dependencies=com.oracle.graal.debug,com.oracle.graal.compiler.common,FINDBUGS project@com.oracle.graal.graph@javaCompliance=1.8 project@com.oracle.graal.graph@workingSets=Graal,Graph @@ -502,7 +502,7 @@ # graal.compiler.common project@com.oracle.graal.compiler.common@subDir=graal project@com.oracle.graal.compiler.common@sourceDirs=src -project@com.oracle.graal.compiler.common@dependencies=com.oracle.graal.api.meta +project@com.oracle.graal.compiler.common@dependencies=com.oracle.graal.api.code project@com.oracle.graal.compiler.common@checkstyle=com.oracle.graal.graph project@com.oracle.graal.compiler.common@javaCompliance=1.8 project@com.oracle.graal.compiler.common@workingSets=Graal,Java