diff graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java @ 10694:31266ceb86ef

SPARC: Can compile and run two or three methods of a bootstrap.
author twisti
date Wed, 10 Jul 2013 12:50:45 -0700
parents 73122b5edf6a
children 7a8d6ba83a04
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java	Wed Jul 10 17:46:27 2013 +0200
+++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java	Wed Jul 10 12:50:45 2013 -0700
@@ -107,14 +107,10 @@
         }
     }
 
-    public static class Clr {
+    public static class Clr extends Or {
 
-        public Clr(SPARCAssembler asm, Register dst) {
-            new Or(g0, g0, dst).emit(asm);
-        }
-
-        public Clr(SPARCAssembler asm, SPARCAddress addr) {
-            new Stw(g0, addr).emit(asm);
+        public Clr(Register dst) {
+            super(g0, g0, dst);
         }
     }
 
@@ -279,12 +275,19 @@
         }
     }
 
-    @SuppressWarnings("unused")
     public static class Setuw {
 
-        public Setuw(SPARCAssembler masm, int value, Register dst) {
+        private int value;
+        private Register dst;
+
+        public Setuw(int value, Register dst) {
+            this.value = value;
+            this.dst = dst;
+        }
+
+        public void emit(SPARCMacroAssembler masm) {
             if (value == 0) {
-                new Clr(masm, dst);
+                new Clr(dst).emit(masm);
             } else if (-4095 <= value && value <= 4096) {
                 new Or(g0, value, dst).emit(masm);
             } else if (value >= 0 && ((value & 0x3FFF) == 0)) {
@@ -298,41 +301,54 @@
 
     public static class Setx {
 
-        public Setx(SPARCAssembler asm, long value, Register tmp, Register dst) {
+        private long value;
+        private Register tmp;
+        private Register dst;
+
+        public Setx(long value, Register tmp, Register dst) {
+            this.value = value;
+            this.tmp = tmp;
+            this.dst = dst;
+        }
+
+        public void emit(SPARCMacroAssembler masm) {
             int hi = (int) (value >> 32);
             int lo = (int) (value & ~0);
 
             if (isSimm13(lo) && value == lo) {
-                new Or(g0, lo, dst).emit(asm);
+                new Or(g0, lo, dst).emit(masm);
             } else if (hi == 0) {
-                new Sethi(lo, dst).emit(asm);   // hardware version zero-extends to upper 32
+                new Sethi(lo, dst).emit(masm);   // hardware version zero-extends to upper 32
                 if (lo10(lo) != 0) {
-                    new Or(dst, lo10(lo), dst).emit(asm);
+                    new Or(dst, lo10(lo), dst).emit(masm);
                 }
             } else if (hi == -1) {
-                new Sethi(~lo, dst).emit(asm);  // hardware version zero-extends to upper 32
-                new Xor(dst, lo10(lo) ^ ~lo10(~0), dst).emit(asm);
+                new Sethi(~lo, dst).emit(masm);  // hardware version zero-extends to upper 32
+                new Xor(dst, ~lo10(~0), dst).emit(masm);
+                new Add(dst, lo10(lo), dst).emit(masm);
             } else if (lo == 0) {
                 if (isSimm13(hi)) {
-                    new Or(g0, hi, dst).emit(asm);
+                    new Or(g0, hi, dst).emit(masm);
                 } else {
-                    new Sethi(hi, dst).emit(asm);   // hardware version zero-extends to upper 32
+                    new Sethi(hi, dst).emit(masm);   // hardware version zero-extends to upper 32
                     if (lo10(hi) != 0) {
-                        new Or(dst, lo10(hi), dst).emit(asm);
+                        new Or(dst, lo10(hi), dst).emit(masm);
                     }
                 }
-                new Sllx(dst, 32, dst).emit(asm);
+                new Sllx(dst, 32, dst).emit(masm);
             } else {
-                new Sethi(hi, tmp).emit(asm);
-                new Sethi(lo, dst).emit(asm); // macro assembler version sign-extends
+                // TODO Use the same logic as in MacroAssembler::internal_sethi, which doesn't need
+// a scratch register.
+                new Sethi(hi, tmp).emit(masm);
+                new Sethi(lo, dst).emit(masm); // macro assembler version sign-extends
                 if (lo10(hi) != 0) {
-                    new Or(tmp, lo10(hi), tmp).emit(asm);
+                    new Or(tmp, lo10(hi), tmp).emit(masm);
                 }
                 if (lo10(lo) != 0) {
-                    new Or(dst, lo10(lo), dst).emit(asm);
+                    new Or(dst, lo10(lo), dst).emit(masm);
                 }
-                new Sllx(tmp, 32, tmp).emit(asm);
-                new Or(dst, tmp, dst).emit(asm);
+                new Sllx(tmp, 32, tmp).emit(masm);
+                new Or(dst, tmp, dst).emit(masm);
             }
         }
     }