changeset 4650:8e39bd349bbb

added Condition.implies(...)
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 20 Feb 2012 14:37:32 +0100
parents 5195b780d253
children 4e9d904a4d1a
files graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/Condition.java
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/Condition.java	Mon Feb 20 14:34:51 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/Condition.java	Mon Feb 20 14:37:32 2012 +0100
@@ -134,6 +134,27 @@
         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;
+            case LE: return false;
+            case GT: return other == GE;
+            case GE: return false;
+            case BT: return other == BE;
+            case BE: return false;
+            case AT: return other == AE;
+            case AE: return false;
+            case OF: return false;
+            case NOF: 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