changeset 16532:2dd966b157e8

Merge
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 15 Jul 2014 21:26:34 -0700
parents fb1c21844758 (current diff) 98686250ed46 (diff)
children d5c4bb0039d8
files
diffstat 21 files changed, 719 insertions(+), 262 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java	Tue Jul 15 21:26:34 2014 -0700
@@ -28,6 +28,7 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
+import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.sparc.*;
 
 /**
@@ -49,33 +50,95 @@
 
     // @formatter:off
     /**
+     * Instruction format for Fmt00 instructions. This abstraction is needed as it
+     * makes the patching easier later on.
+     *
+     * | 00  |  ??    | op2 |               ??                        |
+     * |31 30|29    25|24 22|21                                      0|
+     */
+    // @formatter:on
+    public static abstract class Fmt00 {
+
+        protected static final int OP_SHIFT = 30;
+        protected static final int OP2_SHIFT = 22;
+
+        // @formatter:off
+        protected static final int OP_MASK  = 0b11000000000000000000000000000000;
+        protected static final int OP2_MASK = 0b00000001110000000000000000000000;
+        // @formatter:off
+
+        private int op2;
+
+        public Fmt00(int op2) {
+            this.op2 = op2;
+        }
+
+        public static Fmt00 read(SPARCAssembler masm, int pos) {
+            final int inst = masm.getInt(pos);
+            Op2s op2 = Op2s.byValue((inst&OP2_MASK) >> OP2_SHIFT);
+            switch(op2) {
+                case Fb:
+                    return Fmt00b.read(masm, op2, pos);
+                case Sethi:
+                case Illtrap:
+                    return Fmt00a.read(masm, pos);
+                case Bp:
+                    return Fmt00c.read(masm, pos);
+                default:
+                    throw GraalInternalError.shouldNotReachHere("Unknown op2 " + op2);
+            }
+        }
+
+        public void write(SPARCAssembler masm, int pos) {
+            verify();
+            masm.emitInt(getInstructionBits(), pos);
+        }
+
+        public Op2s getOp2s() {
+            return Op2s.byValue(op2);
+        }
+
+        protected int getInstructionBits() {
+            return Ops.BranchOp.getValue() << OP_SHIFT | op2 << OP2_SHIFT;
+        }
+
+        public void verify() {
+            assert ((op2 << OP2_SHIFT) & OP2_MASK) == (op2 << OP2_SHIFT);
+            assert Op2s.byValue(op2) != null : op2;
+        }
+        /**
+         * Sets the immediate (displacement) value on this instruction.
+         *
+         * @see SPARCAssembler#patchJumpTarget(int, int)
+         * @param imm Displacement/imediate value. Can either be a 22 or 19 bit immediate (dependent on the instruction)
+         */
+        public abstract void setImm(int imm);
+    }
+
+    // @formatter:off
+    /**
      * Instruction format for sethi.
      *
      * | 00  |  rd    | op2 |               imm22                     |
      * |31 30|29    25|24 22|21                                      0|
      */
     // @formatter:on
-    public static class Fmt00a {
-
-        private static final int OP_SHIFT = 30;
+    public static class Fmt00a extends Fmt00 {
+
         private static final int RD_SHIFT = 25;
-        private static final int OP2_SHIFT = 22;
         private static final int IMM22_SHIFT = 0;
 
         // @formatter:off
-        private static final int OP_MASK    = 0b11000000000000000000000000000000;
         private static final int RD_MASK    = 0b00111110000000000000000000000000;
-        private static final int OP2_MASK   = 0b00000001110000000000000000000000;
         private static final int IMM22_MASK = 0b00000000001111111111111111111111;
         // @formatter:on
 
         private int rd;
-        private int op2;
         private int imm22;
 
         private Fmt00a(int rd, int op2, int imm22) {
+            super(op2);
             this.rd = rd;
-            this.op2 = op2;
             this.imm22 = imm22;
             verify();
         }
@@ -84,8 +147,9 @@
             this(rd.encoding(), op2.getValue(), imm22);
         }
 
-        private int getInstructionBits() {
-            return Ops.BranchOp.getValue() << OP_SHIFT | rd << RD_SHIFT | op2 << OP2_SHIFT | (imm22 & IMM22_MASK) << IMM22_SHIFT;
+        @Override
+        protected int getInstructionBits() {
+            return super.getInstructionBits() | rd << RD_SHIFT | (imm22 & IMM22_MASK) << IMM22_SHIFT;
         }
 
         public static Fmt00a read(SPARCAssembler masm, int pos) {
@@ -103,21 +167,26 @@
             return new Fmt00a(op2, imm22, rd);
         }
 
-        public void write(SPARCAssembler masm, int pos) {
-            verify();
-            masm.emitInt(getInstructionBits(), pos);
-        }
-
         public void emit(SPARCAssembler masm) {
             verify();
             masm.emitInt(getInstructionBits());
         }
 
+        @Override
         public void verify() {
+            super.verify();
             assert ((rd << RD_SHIFT) & RD_MASK) == (rd << RD_SHIFT);
-            assert ((op2 << OP2_SHIFT) & OP2_MASK) == (op2 << OP2_SHIFT);
             assert ((imm22 << IMM22_SHIFT) & IMM22_MASK) == (imm22 << IMM22_SHIFT) : String.format("imm22: %d (%x)", imm22, imm22);
         }
+
+        @Override
+        public void setImm(int imm) {
+            setImm22(imm);
+        }
+
+        public void setImm22(int imm22) {
+            this.imm22 = imm22;
+        }
     }
 
     // @formatter:off
@@ -128,14 +197,128 @@
      * |31 30|29|28  25|24 22|21                                      0|
      */
     // @formatter:on
-    public static class Fmt00b {
-
-        public Fmt00b(SPARCAssembler masm, int op, int a, int cond, int op2, int disp22) {
-            assert op == 0;
-            assert op == 0;
-            assert cond < 0x10;
-            assert op2 < 0x8;
-            masm.emitInt(op << 30 | a << 29 | cond << 25 | op2 << 22 | (disp22 & 0x003fffff));
+    public static class Fmt00b extends Fmt00 {
+        private int a;
+        private int cond;
+        private int disp22;
+        private Label label;
+
+        private static final int A_SHIFT = 29;
+        private static final int COND_SHIFT = 25;
+        private static final int DISP22_SHIFT = 0;
+
+        // @formatter:off
+        private static final int A_MASK      = 0b00100000000000000000000000000000;
+        private static final int COND_MASK   = 0b00011110000000000000000000000000;
+        private static final int DISP22_MASK = 0b00000000001111111111111111111111;
+        // @formatter:on
+
+        public Fmt00b(boolean annul, FCond cond, Op2s op2, Label label) {
+            this(annul ? 1 : 0, cond.getValue(), op2.getValue(), 0, label);
+        }
+
+        public Fmt00b(int annul, int cond, int op2, Label label) {
+            this(annul, cond, op2, 0, label);
+        }
+
+        public Fmt00b(boolean annul, FCond cond, Op2s op2, int disp22) {
+            this(annul ? 1 : 0, cond.getValue(), op2.getValue(), disp22, null);
+        }
+
+        public Fmt00b(int annul, int cond, int op2, int disp22) {
+            this(annul, cond, op2, disp22, null);
+        }
+
+        public Fmt00b(int a, int cond, int op2, int disp22, Label label) {
+            super(op2);
+            setA(a);
+            setCond(cond);
+            setDisp22(disp22);
+            setLabel(label);
+        }
+
+        public void emit(SPARCAssembler masm) {
+            if (label != null) {
+                final int pos = label.isBound() ? label.position() : patchUnbound(masm, label);
+                final int disp = pos - masm.position();
+                setDisp22(disp);
+            }
+            verify();
+            masm.emitInt(getInstructionBits());
+        }
+
+        private static int patchUnbound(SPARCAssembler masm, Label label) {
+            label.addPatchAt(masm.position());
+            return 0;
+        }
+
+        @Override
+        protected int getInstructionBits() {
+            int inst = super.getInstructionBits() | a << A_SHIFT | cond << COND_SHIFT | (disp22 & DISP22_MASK) << DISP22_SHIFT;
+            return inst;
+        }
+
+        protected static Fmt00b read(SPARCAssembler masm, Op2s op2, int pos) {
+            final int inst = masm.getInt(pos);
+
+            // Make sure it's the right instruction:
+            final int op = (inst & OP_MASK) >> OP_SHIFT;
+            assert op == Ops.BranchOp.getValue();
+            final int op2Read = (inst & OP2_MASK) >> OP2_SHIFT;
+            assert op2Read == op2.getValue() : "Op2 value read: " + op2Read + " Required op2: " + op2;
+
+            // Get the instruction fields:
+            final int a = (inst & A_MASK) >> A_SHIFT;
+            final int cond = (inst & COND_MASK) >> COND_SHIFT;
+            final int disp22 = (inst & DISP22_MASK) >> DISP22_SHIFT << 2;
+
+            Fmt00b fmt = new Fmt00b(a, cond, op2.getValue(), disp22);
+            fmt.verify();
+            return fmt;
+        }
+
+        public int getA() {
+            return a;
+        }
+
+        public void setA(int a) {
+            this.a = a;
+        }
+
+        public int getCond() {
+            return cond;
+        }
+
+        public void setCond(int cond) {
+            this.cond = cond;
+        }
+
+        public int getDisp22() {
+            return disp22 << 2;
+        }
+
+        @Override
+        public void setImm(int imm) {
+            setDisp22(imm);
+        }
+
+        public void setDisp22(int disp22) {
+            this.disp22 = disp22 >> 2;
+        }
+
+        public Label getLabel() {
+            return label;
+        }
+
+        public void setLabel(Label label) {
+            this.label = label;
+        }
+
+        @Override
+        public void verify() {
+            super.verify();
+            assert (getA() << A_SHIFT & ~A_MASK) == 0 : getA();
+            assert (getCond() << COND_SHIFT & ~COND_MASK) == 0 : getCond();
         }
     }
 
@@ -147,21 +330,17 @@
      * |31 30|29|28  25|24 22|21 |20 |19|                             0|
      */
     // @formatter:on
-    public static class Fmt00c {
-
-        private static final int OP_SHIFT = 30;
+    public static class Fmt00c extends Fmt00 {
+
         private static final int A_SHIFT = 29;
         private static final int COND_SHIFT = 25;
-        private static final int OP2_SHIFT = 22;
         private static final int CC_SHIFT = 20;
         private static final int P_SHIFT = 19;
         private static final int DISP19_SHIFT = 0;
 
         // @formatter:off
-        private static final int OP_MASK     = 0b11000000000000000000000000000000;
         private static final int A_MASK      = 0b00100000000000000000000000000000;
         private static final int COND_MASK   = 0b00011110000000000000000000000000;
-        private static final int OP2_MASK    = 0b00000001110000000000000000000000;
         private static final int CC_MASK     = 0b00000000001100000000000000000000;
         private static final int P_MASK      = 0b00000000000010000000000000000000;
         private static final int DISP19_MASK = 0b00000000000001111111111111111111;
@@ -169,16 +348,15 @@
 
         private int a;
         private int cond;
-        private int op2;
         private int cc;
         private int p;
         private int disp19;
         private Label label;
 
         private Fmt00c(int a, int cond, int op2, int cc, int p, int disp19) {
+            super(op2);
             setA(a);
             setCond(cond);
-            setOp2(op2);
             setCc(cc);
             setP(p);
             setDisp19(disp19);
@@ -210,14 +388,6 @@
             this.cond = cond;
         }
 
-        public int getOp2() {
-            return op2;
-        }
-
-        public void setOp2(int op2) {
-            this.op2 = op2;
-        }
-
         public int getCc() {
             return cc;
         }
@@ -248,8 +418,14 @@
             this.disp19 = disp19 >> 2;
         }
 
-        private int getInstructionBits() {
-            return Ops.BranchOp.getValue() << OP_SHIFT | a << A_SHIFT | cond << COND_SHIFT | op2 << OP2_SHIFT | cc << CC_SHIFT | p << P_SHIFT | (disp19 & DISP19_MASK) << DISP19_SHIFT;
+        @Override
+        public void setImm(int imm) {
+            setDisp19(imm);
+        }
+
+        @Override
+        protected int getInstructionBits() {
+            return super.getInstructionBits() | a << A_SHIFT | cond << COND_SHIFT | cc << CC_SHIFT | p << P_SHIFT | (disp19 & DISP19_MASK) << DISP19_SHIFT;
         }
 
         public static Fmt00c read(SPARCAssembler masm, int pos) {
@@ -272,11 +448,6 @@
             return fmt;
         }
 
-        public void write(SPARCAssembler masm, int pos) {
-            verify();
-            masm.emitInt(getInstructionBits(), pos);
-        }
-
         public void emit(SPARCAssembler masm) {
             if (label != null) {
                 final int pos = label.isBound() ? label.position() : patchUnbound(masm, label);
@@ -292,10 +463,16 @@
             return 0;
         }
 
+        @Override
         public void verify() {
+            super.verify();
             assert p < 2;
             assert cond < 0x10;
-            assert op2 < 0x8;
+        }
+
+        @Override
+        public String toString() {
+            return "Fmt00c [a=" + a + ", cond=" + cond + ", cc=" + cc + ", p=" + p + ", disp19=" + disp19 + ", label=" + label + "]";
         }
     }
 
@@ -412,15 +589,31 @@
     }
 
     public static class Fmt3n {
-
-        public Fmt3n(SPARCAssembler masm, int op, int op3, int opf, int rs2, int rd) {
+        private int op;
+        private int op3;
+        private int opf;
+        private int rs2;
+        private int rd;
+
+        public Fmt3n(int op, int op3, int opf, int rs2, int rd) {
+            this.op = op;
+            this.op3 = op3;
+            this.opf = opf;
+            this.rs2 = rs2;
+            this.rd = rd;
+        }
+
+        public void emit(SPARCAssembler masm) {
+            verify();
+            masm.emitInt(op << 30 | rd << 25 | op3 << 19 | opf << 5 | rs2);
+        }
+
+        public void verify() {
             assert op == 2 || op == 3;
             assert op3 >= 0 && op3 < 0x40;
             assert opf >= 0 && opf < 0x200;
             assert rs2 >= 0 && rs2 < 0x20;
             assert rd >= 0 && rd < 0x20;
-
-            masm.emitInt(op << 30 | rd << 25 | op3 << 19 | opf << 5 | rs2);
         }
     }
 
@@ -443,12 +636,12 @@
         }
 
         public void emit(SPARCAssembler masm) {
-            assert op == 2 || op == 3;
-            assert op3 >= 0 && op3 < 0x40;
-            assert opf >= 0 && opf < 0x200;
-            assert rs1 >= 0 && rs1 < 0x20;
-            assert rs2 >= 0 && rs2 < 0x20;
-            assert rd >= 0 && rd < 0x20;
+            assert op == 2 || op == 3 : op;
+            assert op3 >= 0 && op3 < 0x40 : op3;
+            assert opf >= 0 && opf < 0x200 : opf;
+            assert rs1 >= 0 && rs1 < 0x20 : rs1;
+            assert rs2 >= 0 && rs2 < 0x20 : rs2;
+            assert rd >= 0 && rd < 0x20 : rd;
 
             masm.emitInt(op << 30 | rd << 25 | op3 << 19 | rs1 << 14 | opf << 5 | rs2);
         }
@@ -963,13 +1156,14 @@
         // @formatter:off
 
         Illtrap(0b000),
-        Bpr(3),
-        Fb(6),
-        Fbp(5),
-        Br(2),
-        Bp(1),
-        Cb(7),
-        Sethi(0b100);
+        Bpr    (0b011),
+        Fb     (0b110),
+        Fbp    (0b101),
+        Br     (0b010),
+        Bp     (0b001),
+        Cb     (0b111),
+        Sethi  (0b100);
+
 
         // @formatter:on
 
@@ -982,6 +1176,15 @@
         public int getValue() {
             return value;
         }
+
+        public static Op2s byValue(int value) {
+            for (Op2s op : values()) {
+                if (op.getValue() == value) {
+                    return op;
+                }
+            }
+            return null;
+        }
     }
 
     public enum Op3s {
@@ -1046,8 +1249,8 @@
 
         Fpop1(0b11_0100, "fpop1"),
         Fpop2(0x35, "fpop2"),
-        Impdep1(0x36, "impdep1"),
-        Impdep2(0x37, "impdep2"),
+        Impdep1(0b11_0110, "impdep1"),
+        Impdep2(0b11_0111, "impdep2"),
         Jmpl(0x38, "jmpl"),
         Rett(0x39, "rett"),
         Trap(0x3a, "trap"),
@@ -1082,7 +1285,10 @@
         Staf(0x26, "staf"),
         Stdf(0b100111, "stdf"),
 
-        Fcmp(0b110101, "fcmp");
+        Fcmp(0b110101, "fcmp"),
+
+        Ldxa (0b01_1011, "ldxa"),
+        Lduwa(0b01_0000, "lduwa");
 
         // @formatter:on
 
@@ -1199,6 +1405,8 @@
         Fsrc2s(0x79, "fsrc2s"),
         Foned(0x7E, "foned"),
         Fones(0x7F, "fones"),
+        Fandd(0b0_0111_0000, "fandd"),
+        Fands(0b0_0111_0001, "fands"),
         // end VIS1
 
         // start VIS2
@@ -2028,22 +2236,22 @@
 
     public static class Cmask8 extends Fmt3n {
 
-        public Cmask8(SPARCAssembler asm, Register src2) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Cmask8.getValue(), src2.encoding(), 0);
+        public Cmask8(Register src2) {
+            super(Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Cmask8.getValue(), src2.encoding(), 0);
         }
     }
 
     public static class Cmask16 extends Fmt3n {
 
-        public Cmask16(SPARCAssembler asm, Register src2) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Cmask16.getValue(), src2.encoding(), 0);
+        public Cmask16(Register src2) {
+            super(Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Cmask16.getValue(), src2.encoding(), 0);
         }
     }
 
     public static class Cmask32 extends Fmt3n {
 
-        public Cmask32(SPARCAssembler asm, Register src2) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Cmask32.getValue(), src2.encoding(), 0);
+        public Cmask32(Register src2) {
+            super(Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Cmask32.getValue(), src2.encoding(), 0);
         }
     }
 
@@ -2678,15 +2886,15 @@
 
     public static class Fnegs extends Fmt3n {
 
-        public Fnegs(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegs.getValue(), src2.encoding(), dst.encoding());
+        public Fnegs(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegs.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
     public static class Fnegd extends Fmt3n {
 
-        public Fnegd(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegd.getValue(), src2.encoding(), dst.encoding());
+        public Fnegd(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegd.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
@@ -2760,29 +2968,29 @@
 
     public static class Fstoi extends Fmt3n {
 
-        public Fstoi(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fstoi.getValue(), src2.encoding(), dst.encoding());
+        public Fstoi(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fstoi.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
     public static class Fstox extends Fmt3n {
 
-        public Fstox(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fstox.getValue(), src2.encoding(), dst.encoding());
+        public Fstox(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fstox.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
     public static class Fdtox extends Fmt3n {
 
-        public Fdtox(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fdtox.getValue(), src2.encoding(), dst.encoding());
+        public Fdtox(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fdtox.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
     public static class Fstod extends Fmt3n {
 
-        public Fstod(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fstod.getValue(), src2.encoding(), dst.encoding());
+        public Fstod(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fstod.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
@@ -2791,29 +2999,29 @@
      */
     public static class Fdtoi extends Fmt3n {
 
-        public Fdtoi(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fdtoi.getValue(), src2.encoding(), dst.encoding());
+        public Fdtoi(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fdtoi.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
     public static class Fitos extends Fmt3n {
 
-        public Fitos(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fitos.getValue(), src2.encoding(), dst.encoding());
+        public Fitos(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fitos.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
     public static class Fitod extends Fmt3n {
 
-        public Fitod(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fitod.getValue(), src2.encoding(), dst.encoding());
+        public Fitod(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fitod.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
     public static class Fxtod extends Fmt3n {
 
-        public Fxtod(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fxtod.getValue(), src2.encoding(), dst.encoding());
+        public Fxtod(Register src2, Register dst) {
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fxtod.getValue(), src2.encoding(), dst.encoding());
         }
     }
 
@@ -3004,17 +3212,17 @@
 
     public static class Fzeros extends Fmt3n {
 
-        public Fzeros(SPARCAssembler asm, Register dst) {
+        public Fzeros(Register dst) {
             /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fzeros.getValue(), 0, dst.encoding());
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fzeros.getValue(), 0, dst.encoding());
         }
     }
 
     public static class Fzerod extends Fmt3n {
 
-        public Fzerod(SPARCAssembler asm, Register dst) {
+        public Fzerod(Register dst) {
             /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fzerod.getValue(), 0, dst.encoding());
+            super(Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fzerod.getValue(), 0, dst.encoding());
         }
     }
 
@@ -3025,10 +3233,163 @@
         }
     }
 
-    public static class Fbfcc extends Fmt00b {
-
-        public Fbfcc(SPARCAssembler asm, FCond cond, boolean annul, int disp) {
-            super(asm, Ops.BranchOp.getValue(), annul ? 1 : 0, cond.getValue(), 0b110, disp);
+    public static class Fba extends Fmt00b {
+        public Fba(boolean annul, Label label) {
+            super(annul, FCond.Fba, Op2s.Fb, label);
+        }
+
+        public Fba(boolean annul, int disp) {
+            super(annul, FCond.Fba, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbn extends Fmt00b {
+        public Fbn(boolean annul, Label label) {
+            super(annul, FCond.Fbn, Op2s.Fb, label);
+        }
+
+        public Fbn(boolean annul, int disp) {
+            super(annul, FCond.Fbn, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbu extends Fmt00b {
+        public Fbu(boolean annul, Label label) {
+            super(annul, FCond.Fbu, Op2s.Fb, label);
+        }
+
+        public Fbu(boolean annul, int disp) {
+            super(annul, FCond.Fbu, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbg extends Fmt00b {
+        public Fbg(boolean annul, Label label) {
+            super(annul, FCond.Fbg, Op2s.Fb, label);
+        }
+
+        public Fbg(boolean annul, int disp) {
+            super(annul, FCond.Fbg, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbug extends Fmt00b {
+        public Fbug(boolean annul, Label label) {
+            super(annul, FCond.Fbug, Op2s.Fb, label);
+        }
+
+        public Fbug(boolean annul, int disp) {
+            super(annul, FCond.Fbug, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbl extends Fmt00b {
+        public Fbl(boolean annul, Label label) {
+            super(annul, FCond.Fbl, Op2s.Fb, label);
+        }
+
+        public Fbl(boolean annul, int disp) {
+            super(annul, FCond.Fbl, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbul extends Fmt00b {
+        public Fbul(boolean annul, Label label) {
+            super(annul, FCond.Fbul, Op2s.Fb, label);
+        }
+
+        public Fbul(boolean annul, int disp) {
+            super(annul, FCond.Fbul, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fblg extends Fmt00b {
+        public Fblg(boolean annul, Label label) {
+            super(annul, FCond.Fblg, Op2s.Fb, label);
+        }
+
+        public Fblg(boolean annul, int disp) {
+            super(annul, FCond.Fblg, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbne extends Fmt00b {
+        public Fbne(boolean annul, Label label) {
+            super(annul, FCond.Fbne, Op2s.Fb, label);
+        }
+
+        public Fbne(boolean annul, int disp) {
+            super(annul, FCond.Fbne, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbe extends Fmt00b {
+        public Fbe(boolean annul, Label label) {
+            super(annul, FCond.Fbe, Op2s.Fb, label);
+        }
+
+        public Fbe(boolean annul, int disp) {
+            super(annul, FCond.Fbe, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbue extends Fmt00b {
+        public Fbue(boolean annul, Label label) {
+            super(annul, FCond.Fbue, Op2s.Fb, label);
+        }
+
+        public Fbue(boolean annul, int disp) {
+            super(annul, FCond.Fbue, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbge extends Fmt00b {
+        public Fbge(boolean annul, Label label) {
+            super(annul, FCond.Fbge, Op2s.Fb, label);
+        }
+
+        public Fbge(boolean annul, int disp) {
+            super(annul, FCond.Fbge, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbuge extends Fmt00b {
+        public Fbuge(boolean annul, Label label) {
+            super(annul, FCond.Fbuge, Op2s.Fb, label);
+        }
+
+        public Fbuge(boolean annul, int disp) {
+            super(annul, FCond.Fbuge, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fble extends Fmt00b {
+        public Fble(boolean annul, Label label) {
+            super(annul, FCond.Fble, Op2s.Fb, label);
+        }
+
+        public Fble(boolean annul, int disp) {
+            super(annul, FCond.Fble, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbule extends Fmt00b {
+        public Fbule(boolean annul, Label label) {
+            super(annul, FCond.Fbule, Op2s.Fb, label);
+        }
+
+        public Fbule(boolean annul, int disp) {
+            super(annul, FCond.Fbule, Op2s.Fb, disp);
+        }
+    }
+
+    public static class Fbo extends Fmt00b {
+        public Fbo(boolean annul, Label label) {
+            super(annul, FCond.Fbo, Op2s.Fb, label);
+        }
+
+        public Fbo(boolean annul, int disp) {
+            super(annul, FCond.Fbo, Op2s.Fb, disp);
         }
     }
 
@@ -3110,6 +3471,20 @@
         }
     }
 
+    public static class Ldxa extends Fmt11 {
+
+        public Ldxa(Register src1, Register src2, Register dst, Asi asi) {
+            super(Op3s.Ldxa, src1, src2, dst, asi);
+        }
+    }
+
+    public static class Lduwa extends Fmt11 {
+
+        public Lduwa(Register src1, Register src2, Register dst, Asi asi) {
+            super(Op3s.Lduwa, src1, src2, dst, asi);
+        }
+    }
+
     public static class Membar extends Fmt10 {
 
         public Membar(int barriers) {
@@ -3451,6 +3826,18 @@
         }
     }
 
+    public static class Fandd extends Fmt3p {
+        public Fandd(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fandd, src1, src2, dst);
+        }
+    }
+
+    public static class Fands extends Fmt3p {
+        public Fands(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fands, src1, src2, dst);
+        }
+    }
+
     public static class Stb extends Fmt11 {
 
         public Stb(Register dst, SPARCAddress addr) {
--- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java	Tue Jul 15 21:26:34 2014 -0700
@@ -59,8 +59,8 @@
     @Override
     protected final void patchJumpTarget(int branch, int branchTarget) {
         final int disp = branchTarget - branch;
-        Fmt00c fmt = Fmt00c.read(this, branch);
-        fmt.setDisp19(disp);
+        Fmt00 fmt = Fmt00.read(this, branch);
+        fmt.setImm(disp);
         fmt.write(this, branch);
     }
 
@@ -286,7 +286,6 @@
 
         public Not(Register src1, Register dst) {
             super(src1, g0, dst);
-            assert src1.encoding() != dst.encoding();
         }
 
         public Not(Register dst) {
--- a/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/AMD64AllocatorTest.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/AMD64AllocatorTest.java	Tue Jul 15 21:26:34 2014 -0700
@@ -26,8 +26,15 @@
 
 import com.oracle.graal.compiler.test.backend.*;
 
+import static org.junit.Assume.*;
+
 public class AMD64AllocatorTest extends AllocatorTest {
 
+    @Before
+    public void setUp() {
+        assumeTrue(isArchitecture("AMD64"));
+    }
+
     @Test
     public void test1() {
         test("test1snippet", 3, 1, 0);
--- a/graal/com.oracle.graal.compiler.sparc.test/src/com/oracle/graal/compiler/sparc/test/SPARCAllocatorTest.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.compiler.sparc.test/src/com/oracle/graal/compiler/sparc/test/SPARCAllocatorTest.java	Tue Jul 15 21:26:34 2014 -0700
@@ -22,15 +22,22 @@
  */
 package com.oracle.graal.compiler.sparc.test;
 
+import static org.junit.Assume.*;
+
 import org.junit.*;
 
 import com.oracle.graal.compiler.test.backend.*;
 
 public class SPARCAllocatorTest extends AllocatorTest {
 
+    @Before
+    public void setUp() {
+        assumeTrue(isArchitecture("SPARC"));
+    }
+
     @Test
     public void test1() {
-        test("test1snippet", 3, 1, 0);
+        test("test1snippet", 1, 0, 0);
     }
 
     public static long test1snippet(long x) {
@@ -39,17 +46,16 @@
 
     @Test
     public void test2() {
-        test("test2snippet", 3, 0, 0);
+        test("test2snippet", 1, 0, 0);
     }
 
     public static long test2snippet(long x) {
         return x * 5;
     }
 
-    @Ignore
     @Test
     public void test3() {
-        test("test3snippet", 4, 1, 0);
+        test("test3snippet", 4, 0, 0);
     }
 
     public static long test3snippet(long x) {
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Tue Jul 15 21:26:34 2014 -0700
@@ -230,14 +230,10 @@
             case Object:
                 append(new BranchOp(finalCondition, trueDestination, falseDestination, kind));
                 break;
-            // case Float:
-            // append(new CompareOp(FCMP, x, y));
-            // append(new BranchOp(condition, label));
-            // break;
-            // case Double:
-            // append(new CompareOp(DCMP, x, y));
-            // append(new BranchOp(condition, label));
-            // break;
+            case Float:
+            case Double:
+                append(new BranchOp(cond, trueDestination, falseDestination, kind));
+                break;
             default:
                 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
         }
@@ -295,7 +291,7 @@
      * @param b the right operand of the comparison
      * @return true if the left and right operands were switched, false otherwise
      */
-    private boolean emitCompare(Value a, Value b) {
+    protected boolean emitCompare(Value a, Value b) {
         Variable left;
         Value right;
         boolean mirrored;
@@ -396,7 +392,7 @@
     @Override
     public Value emitMathAbs(Value input) {
         Variable result = newVariable(LIRKind.derive(input));
-        append(new BinaryRegConst(DAND, result, asAllocatable(input), Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL))));
+        append(new BinaryRegConst(DAND, result, asAllocatable(input), Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL)), null));
         return result;
     }
 
@@ -438,7 +434,7 @@
     @Override
     public Value emitByteSwap(Value input) {
         Variable result = newVariable(LIRKind.derive(input));
-        append(new SPARCByteSwapOp(result, input));
+        append(new SPARCByteSwapOp(this, result, input));
         return result;
     }
 
@@ -486,17 +482,17 @@
         return result;
     }
 
-    private Variable emitBinary(SPARCArithmetic op, boolean commutative, Value a, Value b) {
+    private Variable emitBinary(SPARCArithmetic op, boolean commutative, Value a, Value b, LIRFrameState state) {
         if (isConstant(b)) {
-            return emitBinaryConst(op, commutative, asAllocatable(a), asConstant(b));
+            return emitBinaryConst(op, commutative, asAllocatable(a), asConstant(b), state);
         } else if (commutative && isConstant(a)) {
-            return emitBinaryConst(op, commutative, asAllocatable(b), asConstant(a));
+            return emitBinaryConst(op, commutative, asAllocatable(b), asConstant(a), state);
         } else {
-            return emitBinaryVar(op, commutative, asAllocatable(a), asAllocatable(b));
+            return emitBinaryVar(op, commutative, asAllocatable(a), asAllocatable(b), state);
         }
     }
 
-    private Variable emitBinaryConst(SPARCArithmetic op, boolean commutative, AllocatableValue a, Constant b) {
+    private Variable emitBinaryConst(SPARCArithmetic op, boolean commutative, AllocatableValue a, Constant b, LIRFrameState state) {
         switch (op) {
             case IADD:
             case LADD:
@@ -512,21 +508,21 @@
             case LMUL:
                 if (NumUtil.isInt(b.asLong())) {
                     Variable result = newVariable(LIRKind.derive(a, b));
-                    append(new BinaryRegConst(op, result, a, b));
+                    append(new BinaryRegConst(op, result, a, b, state));
                     return result;
                 }
                 break;
         }
 
-        return emitBinaryVar(op, commutative, a, asAllocatable(b));
+        return emitBinaryVar(op, commutative, a, asAllocatable(b), state);
     }
 
-    private Variable emitBinaryVar(SPARCArithmetic op, boolean commutative, AllocatableValue a, AllocatableValue b) {
+    private Variable emitBinaryVar(SPARCArithmetic op, boolean commutative, AllocatableValue a, AllocatableValue b, LIRFrameState state) {
         Variable result = newVariable(LIRKind.derive(a, b));
         if (commutative) {
             append(new BinaryCommutative(op, result, a, b));
         } else {
-            append(new BinaryRegReg(op, result, a, b));
+            append(new BinaryRegReg(op, result, a, b, state));
         }
         return result;
     }
@@ -535,13 +531,13 @@
     public Variable emitAdd(Value a, Value b) {
         switch (a.getKind().getStackKind()) {
             case Int:
-                return emitBinary(IADD, true, a, b);
+                return emitBinary(IADD, true, a, b, null);
             case Long:
-                return emitBinary(LADD, true, a, b);
+                return emitBinary(LADD, true, a, b, null);
             case Float:
-                return emitBinary(FADD, true, a, b);
+                return emitBinary(FADD, true, a, b, null);
             case Double:
-                return emitBinary(DADD, true, a, b);
+                return emitBinary(DADD, true, a, b, null);
             default:
                 throw GraalInternalError.shouldNotReachHere();
         }
@@ -603,24 +599,24 @@
 
     @Override
     public Value emitDiv(Value a, Value b, LIRFrameState state) {
-        Variable result = newVariable(LIRKind.derive(a, b));
+        SPARCArithmetic op = null;
         switch (a.getKind().getStackKind()) {
             case Int:
-                append(new BinaryRegReg(IDIV, result, a, loadNonConst(b)));
+                op = IDIV;
                 break;
             case Long:
-                append(new BinaryRegReg(LDIV, result, a, loadNonConst(b), state));
+                op = LDIV;
                 break;
             case Float:
-                append(new Op2Stack(FDIV, result, a, loadNonConst(b)));
+                op = FDIV;
                 break;
             case Double:
-                append(new Op2Stack(DDIV, result, a, loadNonConst(b)));
+                op = DDIV;
                 break;
             default:
                 throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
         }
-        return result;
+        return emitBinary(op, false, a, b, state);
     }
 
     @Override
@@ -739,7 +735,7 @@
         Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
         AllocatableValue input = asAllocatable(a);
         if (isConstant(b)) {
-            append(new BinaryRegConst(op, result, input, asConstant(b)));
+            append(new BinaryRegConst(op, result, input, asConstant(b), null));
         } else {
             append(new BinaryRegReg(op, result, input, b));
         }
@@ -902,7 +898,7 @@
             assert inputVal.getKind() == Kind.Long;
             Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long));
             long mask = IntegerStamp.defaultMask(fromBits);
-            append(new BinaryRegConst(SPARCArithmetic.LAND, result, asAllocatable(inputVal), Constant.forLong(mask)));
+            append(new BinaryRegConst(SPARCArithmetic.LAND, result, asAllocatable(inputVal), Constant.forLong(mask), null));
             return result;
         } else {
             assert inputVal.getKind() == Kind.Int || inputVal.getKind() == Kind.Short || inputVal.getKind() == Kind.Byte : inputVal.getKind();
@@ -910,7 +906,7 @@
             int mask = (int) IntegerStamp.defaultMask(fromBits);
             Constant constant = Constant.forInt(mask);
             if (canInlineConstant(constant)) {
-                append(new BinaryRegConst(SPARCArithmetic.IAND, result, asAllocatable(inputVal), constant));
+                append(new BinaryRegConst(SPARCArithmetic.IAND, result, asAllocatable(inputVal), constant, null));
             } else {
                 Variable maskVar = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int));
                 emitMove(maskVar, constant);
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCNodeLIRBuilder.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCNodeLIRBuilder.java	Tue Jul 15 21:26:34 2014 -0700
@@ -25,8 +25,8 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.gen.*;
+import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.gen.*;
 import com.oracle.graal.lir.sparc.*;
 import com.oracle.graal.nodes.*;
@@ -59,7 +59,6 @@
 
     @Override
     public void visitInfopointNode(InfopointNode i) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented();
+        append(new InfopointOp(stateFor(i.getState()), i.reason));
     }
 }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Jul 15 21:26:34 2014 -0700
@@ -743,4 +743,15 @@
     protected static boolean iterationCount(double i, boolean cond) {
         return cond;
     }
+
+    /**
+     * Test if the current test runs on the given platform. The name must match the name given in
+     * the {@link Architecture#getName()}.
+     *
+     * @param name The name to test
+     * @return true if we run on the architecture given by name
+     */
+    protected boolean isArchitecture(String name) {
+        return name.equals(backend.getTarget().arch.getName());
+    }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Tue Jul 15 21:26:34 2014 -0700
@@ -30,6 +30,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.sparc.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
@@ -39,10 +40,7 @@
 import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
 import com.oracle.graal.lir.gen.*;
 import com.oracle.graal.lir.sparc.*;
-import com.oracle.graal.lir.sparc.SPARCMove.LoadOp;
-import com.oracle.graal.lir.sparc.SPARCMove.NullCheckOp;
-import com.oracle.graal.lir.sparc.SPARCMove.StoreConstantOp;
-import com.oracle.graal.lir.sparc.SPARCMove.StoreOp;
+import com.oracle.graal.lir.sparc.SPARCMove.*;
 
 public class SPARCHotSpotLIRGenerator extends SPARCLIRGenerator implements HotSpotLIRGenerator {
 
@@ -189,14 +187,12 @@
     }
 
     public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitNot(Value input) {
-        GraalInternalError.shouldNotReachHere("binary negation not implemented");
-        return null;
+        LIRKind kind = newValue.getLIRKind();
+        assert kind.equals(expectedValue.getLIRKind());
+        Kind memKind = (Kind) kind.getPlatformKind();
+        SPARCAddressValue addressValue = asAddressValue(address);
+        append(new CompareAndSwapOp(asAllocatable(addressValue), asAllocatable(expectedValue), asAllocatable(newValue)));
+        return emitConditionalMove(memKind, expectedValue, newValue, Condition.EQ, true, trueValue, falseValue);
     }
 
     public StackSlot getDeoptimizationRescueSlot() {
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Tue Jul 15 21:26:34 2014 -0700
@@ -30,6 +30,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.sparc.*;
+import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
@@ -139,4 +140,13 @@
         append(new SPARCPrefetchOp(addr, getGen().config.allocatePrefetchInstr));
     }
 
+    @Override
+    public void visitInfopointNode(InfopointNode i) {
+        if (i.getState() != null && i.getState().bci == BytecodeFrame.AFTER_BCI) {
+            Debug.log("Ignoring InfopointNode for AFTER_BCI");
+        } else {
+            super.visitInfopointNode(i);
+        }
+    }
+
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Tue Jul 15 21:26:34 2014 -0700
@@ -110,7 +110,11 @@
             // @formatter:off
             registers = new Register[]{
                         // TODO this is not complete
-                        o0, o1, o2, o3, o4, o5, /*o6,*/ o7,
+                        // o7 cannot be used as register because it is always overwritten on call
+                        // and the current register handler would ignore this fact if the called
+                        // method still does not modify registers, in fact o7 is modified by the Call instruction
+                        // There would be some extra handlin necessary to be able to handle the o7 properly for local usage
+                        o0, o1, o2, o3, o4, o5, /*o6, o7,*/
                         l0, l1, l2, l3, l4, l5, l6, l7,
                         i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/
                         f0, f1, f2, f3, f4, f5, f6, f7
@@ -120,7 +124,7 @@
             // @formatter:off
             registers = new Register[]{
                         // TODO this is not complete
-                        o0, o1, o2, o3, o4, o5, /*o6,*/ o7,
+                        o0, o1, o2, o3, o4, o5, /*o6, o7,*/
                         l0, l1, l2, l3, l4, l5, l6, l7,
                         i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/
                         f0, f1, f2, f3, f4, f5, f6, f7
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Tue Jul 15 21:26:34 2014 -0700
@@ -56,7 +56,7 @@
 
         @Opcode private final SPARCArithmetic opcode;
         @Def({REG}) protected AllocatableValue result;
-        @Use({REG, STACK}) protected AllocatableValue x;
+        @Use({REG}) protected AllocatableValue x;
 
         public Unary2Op(SPARCArithmetic opcode, AllocatableValue result, AllocatableValue x) {
             this.opcode = opcode;
@@ -158,13 +158,15 @@
         @Opcode private final SPARCArithmetic opcode;
         @Def({REG}) protected AllocatableValue result;
         @Use({REG}) protected AllocatableValue x;
+        @State protected LIRFrameState state;
         protected Constant y;
 
-        public BinaryRegConst(SPARCArithmetic opcode, AllocatableValue result, AllocatableValue x, Constant y) {
+        public BinaryRegConst(SPARCArithmetic opcode, AllocatableValue result, AllocatableValue x, Constant y, LIRFrameState state) {
             this.opcode = opcode;
             this.result = result;
             this.x = x;
             this.y = y;
+            this.state = state;
         }
 
         @Override
@@ -188,12 +190,18 @@
         @Def({REG, HINT}) protected AllocatableValue result;
         @Use({REG}) protected AllocatableValue x;
         @Use({REG}) protected AllocatableValue y;
+        @State protected LIRFrameState state;
 
         public BinaryCommutative(SPARCArithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y) {
+            this(opcode, result, x, y, null);
+        }
+
+        public BinaryCommutative(SPARCArithmetic opcode, AllocatableValue result, AllocatableValue x, AllocatableValue y, LIRFrameState state) {
             this.opcode = opcode;
             this.result = result;
             this.x = x;
             this.y = y;
+            this.state = state;
         }
 
         @Override
@@ -274,15 +282,16 @@
             switch (opcode) {
                 case ISUB:
                     assert isSimm13(crb.asIntConst(src1));
-                    new Add(asIntReg(src2), -(crb.asIntConst(src1)), asIntReg(dst)).emit(masm);
+                    new Sub(SPARC.g0, asIntReg(src2), asIntReg(src2)).emit(masm);
+                    new Add(asIntReg(src2), crb.asIntConst(src1), asIntReg(dst)).emit(masm);
                     break;
                 case IAND:
                     throw GraalInternalError.unimplemented();
                 case IDIV:
-                    assert isSimm13(crb.asIntConst(src1));
-                    throw GraalInternalError.unimplemented();
-                    // new Sdivx(masm, asIntReg(src1), asIntReg(src2),
-                    // asIntReg(dst));
+                    new Setx(((PrimitiveConstant) src1).asInt(), asIntReg(dst), false).emit(masm);
+                    exceptionOffset = masm.position();
+                    new Sdivx(asIntReg(dst), asIntReg(src2), asIntReg(dst)).emit(masm);
+                    break;
                 case LDIV:
                     int c = crb.asIntConst(src1);
                     assert isSimm13(c);
@@ -297,7 +306,7 @@
                 default:
                     throw GraalInternalError.shouldNotReachHere();
             }
-        } else if (isConstant(src2)) {
+        } else if (!isConstant(src1) && isConstant(src2)) {
             switch (opcode) {
                 case IADD:
                     assert isSimm13(crb.asIntConst(src2));
@@ -313,7 +322,6 @@
                     break;
                 case IDIV:
                     assert isSimm13(crb.asIntConst(src2));
-                    new Signx(asIntReg(src1), asIntReg(src1)).emit(masm);
                     new Sdivx(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm);
                     break;
                 case IAND:
@@ -390,6 +398,11 @@
                     assert isSimm13(crb.asIntConst(src2));
                     new Srlx(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm);
                     break;
+                case DAND:
+                    SPARCAddress addr = (SPARCAddress) crb.recordDataReferenceInCode(asConstant(src2), 4);
+                    new Lddf(addr, asDoubleReg(dst)).emit(masm);
+                    new Fandd(asDoubleReg(src1), asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
+                    break;
                 case FADD:
                 case FMUL:
                 case FDIV:
@@ -412,7 +425,7 @@
                     break;
                 case IDIV:
                     new Signx(asIntReg(src1), asIntReg(src1)).emit(masm);
-                    new Signx(asIntReg(src2), asIntReg(src2)).emit(masm);
+                    exceptionOffset = masm.position();
                     new Sdivx(asIntReg(src1), asIntReg(src2), asIntReg(dst)).emit(masm);
                     break;
                 case IAND:
@@ -589,7 +602,6 @@
         }
     }
 
-    @SuppressWarnings("unused")
     public static void emit(CompilationResultBuilder crb, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src, LIRFrameState info) {
         int exceptionOffset = -1;
         if (isRegister(src)) {
@@ -612,9 +624,9 @@
                 case L2D:
                     if (src.getPlatformKind() == Kind.Long) {
                         new Movxtod(asLongReg(src), asDoubleReg(dst)).emit(masm);
-                        new Fxtod(masm, asDoubleReg(dst), asDoubleReg(dst));
+                        new Fxtod(asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
                     } else if (src.getPlatformKind() == Kind.Double) {
-                        new Fxtod(masm, asDoubleReg(src), asDoubleReg(dst));
+                        new Fxtod(asDoubleReg(src), asDoubleReg(dst)).emit(masm);
                     } else {
                         throw GraalInternalError.shouldNotReachHere("cannot handle source register " + src.getPlatformKind());
                     }
@@ -644,49 +656,49 @@
                 case I2F:
                     if (src.getPlatformKind() == Kind.Int) {
                         new Movwtos(asIntReg(src), asFloatReg(dst)).emit(masm);
-                        new Fitos(masm, asFloatReg(dst), asFloatReg(dst));
+                        new Fitos(asFloatReg(dst), asFloatReg(dst)).emit(masm);
                     } else if (src.getPlatformKind() == Kind.Float) {
-                        new Fitos(masm, asFloatReg(src), asFloatReg(dst));
+                        new Fitos(asFloatReg(src), asFloatReg(dst)).emit(masm);
                     } else {
                         throw GraalInternalError.shouldNotReachHere("cannot handle source register " + src.getPlatformKind());
                     }
                     break;
                 case F2D:
-                    new Fstod(masm, asFloatReg(src), asDoubleReg(dst));
+                    new Fstod(asFloatReg(src), asDoubleReg(dst)).emit(masm);
                     break;
                 case F2L:
                     new Fcmp(CC.Fcc0, Opfs.Fcmps, asFloatReg(dst), asFloatReg(dst)).emit(masm);
-                    new Fbfcc(masm, FCond.Fbo, false, 4);
-                    new Fstox(masm, asFloatReg(src), asFloatReg(dst));
-                    new Fitos(masm, asFloatReg(dst), asFloatReg(dst));
+                    new Fbe(false, 4).emit(masm);
+                    new Fstox(asFloatReg(src), asFloatReg(dst)).emit(masm);
+                    new Fitos(asFloatReg(dst), asFloatReg(dst)).emit(masm);
                     new Fsubs(asFloatReg(dst), asFloatReg(dst), asFloatReg(dst)).emit(masm);
                     break;
                 case F2I:
                     new Fcmp(CC.Fcc0, Opfs.Fcmps, asFloatReg(dst), asFloatReg(dst)).emit(masm);
-                    new Fbfcc(masm, FCond.Fbo, false, 4);
-                    new Fstoi(masm, asFloatReg(src), asFloatReg(dst));
-                    new Fitos(masm, asFloatReg(dst), asFloatReg(dst));
+                    new Fbo(false, 4).emit(masm);
+                    new Fstoi(asFloatReg(src), asFloatReg(dst)).emit(masm);
+                    new Fitos(asFloatReg(dst), asFloatReg(dst)).emit(masm);
                     new Fsubs(asFloatReg(dst), asFloatReg(dst), asFloatReg(dst)).emit(masm);
                     break;
                 case D2L:
                     new Fcmp(CC.Fcc0, Opfs.Fcmpd, asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
-                    new Fbfcc(masm, FCond.Fbo, false, 4);
-                    new Fdtox(masm, asDoubleReg(src), asDoubleReg(dst));
-                    new Fxtod(masm, asDoubleReg(dst), asDoubleReg(dst));
+                    new Fbo(false, 4).emit(masm);
+                    new Fdtox(asDoubleReg(src), asDoubleReg(dst)).emit(masm);
+                    new Fxtod(asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
                     new Fsubd(asDoubleReg(dst), asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
                     break;
                 case D2I:
                     new Fcmp(CC.Fcc0, Opfs.Fcmpd, asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
-                    new Fbfcc(masm, FCond.Fbo, false, 4);
-                    new Fdtoi(masm, asDoubleReg(src), asDoubleReg(dst));
-                    new Fitod(masm, asDoubleReg(dst), asDoubleReg(dst));
+                    new Fbo(false, 4).emit(masm);
+                    new Fdtoi(asDoubleReg(src), asDoubleReg(dst)).emit(masm);
+                    new Fitod(asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
                     new Fsubd(asDoubleReg(dst), asDoubleReg(dst), asDoubleReg(dst)).emit(masm);
                     break;
                 case FNEG:
-                    new Fnegs(masm, asFloatReg(src), asFloatReg(dst));
+                    new Fnegs(asFloatReg(src), asFloatReg(dst)).emit(masm);
                     break;
                 case DNEG:
-                    new Fnegd(masm, asDoubleReg(src), asDoubleReg(dst));
+                    new Fnegd(asDoubleReg(src), asDoubleReg(dst)).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere("missing: " + opcode);
@@ -699,7 +711,7 @@
         } else {
             switch (opcode) {
                 default:
-                    throw GraalInternalError.shouldNotReachHere("missing: " + opcode);
+                    throw GraalInternalError.shouldNotReachHere("missing: " + opcode + " " + src);
             }
         }
 
@@ -764,6 +776,7 @@
                 yk = y.getKind();
                 assert rk == Kind.Float && xk == Kind.Float && yk == Kind.Float;
                 break;
+            case DAND:
             case DADD:
             case DSUB:
             case DMUL:
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java	Tue Jul 15 21:26:34 2014 -0700
@@ -36,7 +36,6 @@
 import com.oracle.graal.asm.sparc.SPARCAssembler.Srlx;
 import com.oracle.graal.asm.sparc.SPARCAssembler.Sub;
 import com.oracle.graal.asm.sparc.*;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Mov;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
@@ -54,16 +53,14 @@
 
     @Opcode private final IntrinsicOpcode opcode;
     @Def protected AllocatableValue result;
-    @Use({REG}) protected AllocatableValue input;
-    @Def({REG}) protected Value scratch;
+    @Alive({REG}) protected AllocatableValue input;
+    @Temp({REG}) protected Value scratch;
 
     public SPARCBitManipulationOp(IntrinsicOpcode opcode, AllocatableValue result, AllocatableValue input, LIRGeneratorTool gen) {
         this.opcode = opcode;
         this.result = result;
         this.input = input;
-        if (opcode == IntrinsicOpcode.IBSR || opcode == IntrinsicOpcode.LBSR) {
-            scratch = gen.newVariable(LIRKind.derive(input));
-        }
+        scratch = gen.newVariable(LIRKind.derive(input));
     }
 
     @Override
@@ -75,7 +72,7 @@
                 case IPOPCNT:
                     // clear upper word for 64 bit POPC
                     new Srl(src, g0, dst).emit(masm);
-                    new Popc(src, dst).emit(masm);
+                    new Popc(dst, dst).emit(masm);
                     break;
                 case LPOPCNT:
                     new Popc(src, dst).emit(masm);
@@ -111,13 +108,12 @@
                     new Srl(dst, 16, tmp).emit(masm);
                     new Or(dst, tmp, dst).emit(masm);
                     new Popc(dst, dst).emit(masm);
-                    new Mov(ikind.getBitCount(), tmp).emit(masm);
-                    new Sub(tmp, dst, dst).emit(masm);
+                    new Sub(dst, 1, dst).emit(masm);
                     break;
                 }
                 case LBSR: {
                     Kind lkind = input.getKind();
-                    assert lkind == Kind.Int;
+                    assert lkind == Kind.Long;
                     Register tmp = asRegister(scratch);
                     new Srlx(src, 1, tmp).emit(masm);
                     new Or(src, tmp, dst).emit(masm);
@@ -132,8 +128,7 @@
                     new Srlx(dst, 32, tmp).emit(masm);
                     new Or(dst, tmp, dst).emit(masm);
                     new Popc(dst, dst).emit(masm);
-                    new Mov(lkind.getBitCount(), tmp).emit(masm);
-                    new Sub(tmp, dst, dst).emit(masm);
+                    new Sub(dst, 1, dst).emit(masm); // This is required to fit the given structure.
                     break;
                 }
                 default:
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java	Tue Jul 15 21:26:34 2014 -0700
@@ -22,31 +22,49 @@
  */
 package com.oracle.graal.lir.sparc;
 
+import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+
+import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
+import com.oracle.graal.asm.sparc.SPARCAssembler.*;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
+import com.oracle.graal.lir.gen.*;
 
 @Opcode("BSWAP")
 public class SPARCByteSwapOp extends SPARCLIRInstruction {
 
-    @Def({OperandFlag.REG, OperandFlag.HINT}) protected Value result;
-    @Use protected Value input;
+    @Def({REG, HINT}) protected Value result;
+    @Use({REG}) protected Value input;
+    @Temp({REG}) protected Value tempIndex;
+    @Use({STACK}) protected StackSlot tmpSlot;
 
-    public SPARCByteSwapOp(Value result, Value input) {
+    public SPARCByteSwapOp(LIRGeneratorTool tool, Value result, Value input) {
         this.result = result;
         this.input = input;
+        this.tmpSlot = tool.getResult().getFrameMap().allocateSpillSlot(LIRKind.value(Kind.Long));
+        this.tempIndex = tool.newVariable(LIRKind.value(Kind.Long));
     }
 
     @Override
     public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
-        SPARCMove.move(crb, masm, result, input);
+        SPARCMove.move(crb, masm, tmpSlot, input);
+        SPARCAddress addr = (SPARCAddress) crb.asAddress(tmpSlot);
+        if (addr.getIndex().equals(Register.None)) {
+            Register tempReg = ValueUtil.asLongReg(tempIndex);
+            new SPARCMacroAssembler.Setx(addr.getDisplacement(), tempReg, false).emit(masm);
+            addr = new SPARCAddress(addr.getBase(), tempReg);
+        }
         switch (input.getKind()) {
             case Int:
-                // masm.bswapl(ValueUtil.asIntReg(result));
+                new SPARCAssembler.Lduwa(addr.getBase(), addr.getIndex(), asIntReg(result), Asi.ASI_PRIMARY_LITTLE).emit(masm);
+                break;
             case Long:
-                // masm.bswapq(ValueUtil.asLongReg(result));
+                new SPARCAssembler.Ldxa(addr.getBase(), addr.getIndex(), asLongReg(result), Asi.ASI_PRIMARY_LITTLE).emit(masm);
+                break;
             default:
                 throw GraalInternalError.shouldNotReachHere();
         }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java	Tue Jul 15 21:26:34 2014 -0700
@@ -60,10 +60,11 @@
         @Override
         protected void verify() {
             super.verify();
-
             // @formatter:off
-            assert  (name().startsWith("I") && (x.getKind() == Kind.Int || x.getKind()==Kind.Byte) &&
-                            (y.getKind().getStackKind() == Kind.Int || y.getKind().getStackKind() == Kind.Byte)) ||
+            assert  (name().startsWith("I") &&
+                            (!(x.getKind() == Kind.Int) || y.getKind().getStackKind() == Kind.Int) &&
+                            (!(x.getKind() == Kind.Short) || y.getKind().getStackKind() == Kind.Int) &&
+                            (!(x.getKind() == Kind.Byte) || y.getKind().getStackKind() == Kind.Int)) ||
                     (name().startsWith("L") && x.getKind() == Kind.Long && y.getKind() == Kind.Long) ||
                     (name().startsWith("A") && x.getKind() == Kind.Object && y.getKind() == Kind.Object) ||
                     (name().startsWith("F") && x.getKind() == Kind.Float && y.getKind() == Kind.Float) ||
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java	Tue Jul 15 21:26:34 2014 -0700
@@ -30,26 +30,8 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.sparc.*;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bpe;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bpg;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bpge;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bpgu;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bpl;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bple;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bpleu;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Bpne;
-import com.oracle.graal.asm.sparc.SPARCAssembler.CC;
-import com.oracle.graal.asm.sparc.SPARCAssembler.ConditionFlag;
-import com.oracle.graal.asm.sparc.SPARCAssembler.FCond;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Fbfcc;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Movcc;
-import com.oracle.graal.asm.sparc.SPARCAssembler.Sub;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Bpgeu;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Bplu;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Cmp;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Jmp;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Nop;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Ret;
+import com.oracle.graal.asm.sparc.SPARCAssembler.*;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.calc.*;
 import com.oracle.graal.lir.*;
@@ -107,16 +89,51 @@
                 actualTarget = trueDestination.label();
                 needJump = !crb.isSuccessorEdge(falseDestination);
             }
-            assert kind == Kind.Int || kind == Kind.Long || kind == Kind.Object;
-            CC cc = kind == Kind.Int ? CC.Icc : CC.Xcc;
-            emitCompare(masm, actualTarget, actualCondition, cc);
-            new Nop().emit(masm);  // delay slot
+            assert kind == Kind.Int || kind == Kind.Long || kind == Kind.Object || kind == Kind.Double || kind == Kind.Float : kind;
+            if (kind == Kind.Double || kind == Kind.Float) {
+                emitFloatCompare(masm, actualTarget, actualCondition);
+            } else {
+                CC cc = kind == Kind.Int ? CC.Icc : CC.Xcc;
+                emitCompare(masm, actualTarget, actualCondition, cc);
+                new Nop().emit(masm);  // delay slot
+            }
             if (needJump) {
                 masm.jmp(falseDestination.label());
             }
         }
     }
 
+    private static void emitFloatCompare(SPARCMacroAssembler masm, Label target, Condition actualCondition) {
+        switch (actualCondition.mirror()) {
+            case EQ:
+                new Fbe(false, target).emit(masm);
+                break;
+            case NE:
+                new Fbne(false, target).emit(masm);
+                break;
+            case LT:
+                new Fbl(false, target).emit(masm);
+                break;
+            case LE:
+                new Fble(false, target).emit(masm);
+                break;
+            case GT:
+                new Fbg(false, target).emit(masm);
+                break;
+            case GE:
+                new Fbge(false, target).emit(masm);
+                break;
+            case AE:
+            case AT:
+            case BT:
+            case BE:
+                GraalInternalError.unimplemented("Should not be required for float/dobule");
+            default:
+                throw GraalInternalError.shouldNotReachHere();
+        }
+        new Nop().emit(masm);
+    }
+
     private static void emitCompare(SPARCMacroAssembler masm, Label target, Condition actualCondition, CC cc) {
         switch (actualCondition) {
             case EQ:
@@ -332,7 +349,6 @@
         }
     }
 
-    @SuppressWarnings("unused")
     private static void cmove(CompilationResultBuilder crb, SPARCMacroAssembler masm, Kind kind, Value result, ConditionFlag cond, Value other) {
         if (!isRegister(other)) {
             SPARCMove.move(crb, masm, result, other);
@@ -349,34 +365,32 @@
                 break;
             case Float:
             case Double:
-                FCond fc = null;
                 switch (cond) {
                     case Equal:
-                        fc = FCond.Fbne;
+                        new Fbne(true, 2 * 4).emit(masm);
                         break;
                     case Greater:
-                        fc = FCond.Fble;
+                        new Fble(true, 2 * 4).emit(masm);
                         break;
                     case GreaterEqual:
-                        fc = FCond.Fbl;
+                        new Fbl(true, 2 * 4).emit(masm);
                         break;
                     case Less:
-                        fc = FCond.Fbge;
+                        new Fbge(true, 2 * 4).emit(masm);
                         break;
                     case LessEqual:
-                        fc = FCond.Fbg;
+                        new Fbg(true, 2 * 4).emit(masm);
                         break;
                     case F_Ordered:
-                        fc = FCond.Fbo;
+                        new Fbo(true, 2 * 4).emit(masm);
                         break;
                     case F_Unordered:
-                        fc = FCond.Fbu;
+                        new Fbu(true, 2 * 4).emit(masm);
                         break;
                     default:
                         GraalInternalError.shouldNotReachHere("Unknown condition code " + cond);
                         break;
                 }
-                new Fbfcc(masm, fc, true, 2);
                 SPARCMove.move(crb, masm, result, other);
                 break;
             default:
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Tue Jul 15 21:26:34 2014 -0700
@@ -395,7 +395,6 @@
         }
     }
 
-    @SuppressWarnings("unused")
     private static void reg2reg(SPARCAssembler masm, Value result, Value input) {
         final Register src = asRegister(input);
         final Register dst = asRegister(result);
@@ -423,7 +422,7 @@
                         new Fmovs(src, dst).emit(masm);
                         break;
                     case Double:
-                        new Fstod(masm, src, dst);
+                        new Fstod(src, dst).emit(masm);
                         break;
                     default:
                         throw GraalInternalError.shouldNotReachHere();
@@ -518,12 +517,13 @@
                 new Ldf(scratch, asFloatReg(result)).emit(masm);
                 break;
             case Double:
-                crb.asDoubleConstRef(input);
+                // before we load this from memory and do the complicated lookup,
+                // just load it directly into a scratch register
                 scratch = g5;
                 // First load the address into the scratch register
-                new Setx(0, scratch, true).emit(masm);
+                new Setx(Double.doubleToLongBits(input.asDouble()), scratch, true).emit(masm);
                 // Now load the float value
-                new Lddf(scratch, asDoubleReg(result)).emit(masm);
+                new Movxtod(scratch, asDoubleReg(result)).emit(masm);
                 break;
             case Object:
                 if (input.isNull()) {
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java	Tue Jul 15 21:26:34 2014 -0700
@@ -24,12 +24,13 @@
 
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+import static com.oracle.graal.asm.sparc.SPARCAssembler.*;
+import static com.oracle.graal.sparc.SPARC.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.asm.sparc.SPARCAssembler.Ldsw;
 import com.oracle.graal.asm.sparc.SPARCAssembler.Ldx;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Cmp;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.lir.asm.*;
 
@@ -48,10 +49,10 @@
         if (isRegister(y)) {
             switch (x.getKind()) {
                 case Int:
-                    new Cmp(asIntReg(x), asIntReg(y)).emit(masm);
+                    new Andcc(asIntReg(x), asIntReg(y), g0).emit(masm);
                     break;
                 case Long:
-                    new Cmp(asLongReg(x), asLongReg(y)).emit(masm);
+                    new Andcc(asLongReg(x), asLongReg(y), g0).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere();
@@ -59,10 +60,10 @@
         } else if (isConstant(y)) {
             switch (x.getKind()) {
                 case Int:
-                    new Cmp(asIntReg(x), crb.asIntConst(y)).emit(masm);
+                    new Andcc(asIntReg(x), crb.asIntConst(y), g0).emit(masm);
                     break;
                 case Long:
-                    new Cmp(asLongReg(x), crb.asIntConst(y)).emit(masm);
+                    new Andcc(asLongReg(x), crb.asIntConst(y), g0).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere();
@@ -71,11 +72,11 @@
             switch (x.getKind()) {
                 case Int:
                     new Ldsw((SPARCAddress) crb.asIntAddr(y), asIntReg(y)).emit(masm);
-                    new Cmp(asIntReg(x), asIntReg(y)).emit(masm);
+                    new Andcc(asIntReg(x), asIntReg(y), g0).emit(masm);
                     break;
                 case Long:
                     new Ldx((SPARCAddress) crb.asLongAddr(y), asLongReg(y)).emit(masm);
-                    new Cmp(asLongReg(x), asLongReg(y)).emit(masm);
+                    new Andcc(asLongReg(x), asLongReg(y), g0).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere();
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraysSubstitutions.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraysSubstitutions.java	Tue Jul 15 21:26:34 2014 -0700
@@ -28,7 +28,7 @@
 /**
  * Substitutions for {@link java.util.Arrays} methods.
  */
-@ClassSubstitution(java.util.Arrays.class)
+@ClassSubstitution(value = java.util.Arrays.class, defaultGuard = UnsafeSubstitutions.GetAndSetGuard.class)
 public class ArraysSubstitutions {
 
     @MethodSubstitution
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java	Tue Jul 15 21:26:34 2014 -0700
@@ -33,7 +33,7 @@
 /**
  * Substitutions for {@link java.lang.Math} methods.
  */
-@ClassSubstitution(java.lang.Math.class)
+@ClassSubstitution(value = java.lang.Math.class, defaultGuard = UnsafeSubstitutions.GetAndSetGuard.class)
 public class MathSubstitutionsX86 {
 
     private static final double PI_4 = Math.PI / 4;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java	Tue Jul 15 16:45:05 2014 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java	Tue Jul 15 21:26:34 2014 -0700
@@ -35,7 +35,7 @@
 /**
  * Substitutions for {@link java.lang.String} methods.
  */
-@ClassSubstitution(java.lang.String.class)
+@ClassSubstitution(value = java.lang.String.class, defaultGuard = UnsafeSubstitutions.GetAndSetGuard.class)
 public class StringSubstitutions {
 
     /**
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Tue Jul 15 16:45:05 2014 -0700
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Tue Jul 15 21:26:34 2014 -0700
@@ -267,8 +267,8 @@
   } else if (value->is_a(Constant::klass())){
     record_metadata_in_constant(value, oop_recorder);
     if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BOOLEAN || type == T_BYTE) {
-      jlong prim = PrimitiveConstant::primitive(value);
-      return new ConstantIntValue(*(jint*)&prim);
+      jint prim = (jint)PrimitiveConstant::primitive(value);
+      return new ConstantIntValue(prim);
     } else if (type == T_LONG || type == T_DOUBLE) {
       jlong prim = PrimitiveConstant::primitive(value);
       second = new ConstantIntValue(0);