diff graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java @ 4183:9e0c1b4cfef5

Move all isXxx and asXxx out of CiValue and into their own util class.
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Mon, 02 Jan 2012 17:39:20 -0800
parents de7b3e7ae528
children
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java	Mon Jan 02 14:38:17 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/sun/cri/ci/CiAddress.java	Mon Jan 02 17:39:20 2012 -0800
@@ -22,6 +22,8 @@
  */
 package com.sun.cri.ci;
 
+import static com.sun.cri.ci.CiValueUtil.*;
+
 /**
  * Represents an address in target machine memory, specified via some combination of a base register, an index register,
  * a displacement and a scale. Note that the base and index registers may be {@link CiVariable variable}, that is as yet
@@ -33,7 +35,7 @@
     /**
      * A sentinel value used as a place holder in an instruction stream for an address that will be patched.
      */
-    public static final CiAddress Placeholder = new CiAddress(CiKind.Illegal, CiRegister.None.asValue());
+    public static final CiAddress Placeholder = new CiAddress(CiKind.Illegal, CiValue.IllegalValue);
 
     /**
      * Base register that defines the start of the address computation; always present.
@@ -95,7 +97,7 @@
         super(kind);
 
         this.base = base;
-        if (index.isConstant()) {
+        if (isConstant(index)) {
             long longIndex = ((CiConstant) index).asLong();
             long longDisp = displacement + longIndex * scale.value;
             if ((int) longIndex != longIndex || (int) longDisp != longDisp) {
@@ -105,8 +107,8 @@
             this.index = IllegalValue;
             this.scale = Scale.Times1;
         } else {
-            assert base.isIllegal() || base.isVariableOrRegister();
-            assert index.isIllegal() || index.isVariableOrRegister();
+            assert isIllegal(base) || isVariable(base) || isRegister(base);
+            assert isIllegal(index) || isVariable(index) || isRegister(index);
 
             this.index = index;
             this.scale = scale;
@@ -156,26 +158,6 @@
     }
 
     /**
-     * If the base register is a {@link CiRegisterValue} returns the associated {@link CiRegister}
-     * otherwise raises an exception..
-     * @return the base {@link CiRegister}
-     * @exception Error  if {@code base} is not a {@link CiRegisterValue}
-     */
-    public CiRegister base() {
-        return base.asRegister();
-    }
-
-    /**
-     * If the index register is a {@link CiRegisterValue} returns the associated {@link CiRegister}
-     * otherwise raises an exception..
-     * @return the base {@link CiRegister}
-     * @exception Error  if {@code index} is not a {@link CiRegisterValue}
-     */
-    public CiRegister index() {
-        return index.asRegister();
-    }
-
-    /**
      * Encodes the possible addressing modes as a simple value.
      */
     public enum Format {
@@ -194,8 +176,8 @@
         if (this == Placeholder) {
             return Format.PLACEHOLDER;
         }
-        assert base.isLegal();
-        if (index.isLegal()) {
+        assert isLegal(base);
+        if (isLegal(index)) {
             if (displacement != 0) {
                 return Format.BASE_INDEX_DISP;
             } else {
@@ -211,10 +193,10 @@
     }
 
     private static String s(CiValue location) {
-        if (location.isRegister()) {
-            return location.asRegister().name;
+        if (isRegister(location)) {
+            return asRegister(location).name;
         }
-        assert location.isVariable();
+        assert isVariable(location);
         return "v" + ((CiVariable) location).index;
     }