src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/calc/Condition.java
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/calc/Condition.java Fri Feb 02 10:37:48 2018 -0500
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/calc/Condition.java Fri Feb 02 17:28:17 2018 -0800
@@ -115,6 +115,55 @@
throw new IllegalArgumentException(this.toString());
}
+ public static final class CanonicalizedCondition {
+ private final CanonicalCondition canonicalCondition;
+ private final boolean mirror;
+ private final boolean negate;
+
+ private CanonicalizedCondition(CanonicalCondition canonicalCondition, boolean mirror, boolean negate) {
+ this.canonicalCondition = canonicalCondition;
+ this.mirror = mirror;
+ this.negate = negate;
+ }
+
+ public CanonicalCondition getCanonicalCondition() {
+ return canonicalCondition;
+ }
+
+ public boolean mustMirror() {
+ return mirror;
+ }
+
+ public boolean mustNegate() {
+ return negate;
+ }
+ }
+
+ public CanonicalizedCondition canonicalize() {
+ CanonicalCondition canonicalCondition;
+ switch (this) {
+ case EQ:
+ case NE:
+ canonicalCondition = CanonicalCondition.EQ;
+ break;
+ case LT:
+ case LE:
+ case GT:
+ case GE:
+ canonicalCondition = CanonicalCondition.LT;
+ break;
+ case BT:
+ case BE:
+ case AT:
+ case AE:
+ canonicalCondition = CanonicalCondition.BT;
+ break;
+ default:
+ throw new IllegalArgumentException(this.toString());
+ }
+ return new CanonicalizedCondition(canonicalCondition, canonicalMirror(), canonicalNegate());
+ }
+
/**
* 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.
@@ -151,7 +200,7 @@
* 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() {
+ private boolean canonicalMirror() {
switch (this) {
case EQ:
return false;
@@ -181,7 +230,7 @@
* 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() {
+ private boolean canonicalNegate() {
switch (this) {
case EQ:
return false;