# HG changeset patch # User Stefan Anzinger # Date 1406587790 25200 # Node ID e878be37db4caefc3485f955546572117a00655d # Parent a38fea2b8e14550d47876ca679306ded04e9434d [SPARC] Fixing TableSwitchOp when using default target diff -r a38fea2b8e14 -r e878be37db4c graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Mon Jul 28 14:29:52 2014 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Mon Jul 28 15:49:50 2014 -0700 @@ -252,18 +252,18 @@ Register scratchReg = asLongReg(scratch); // Compare index against jump table bounds - // int highKey = lowKey + targets.length - 1; + int highKey = lowKey + targets.length - 1; if (lowKey != 0) { // subtract the low value from the switch value - new Subcc(value, lowKey, value).emit(masm); - // masm.setp_gt_s32(value, highKey - lowKey); + new Sub(value, lowKey, value).emit(masm); + new Cmp(value, highKey - lowKey).emit(masm); } else { - // masm.setp_gt_s32(value, highKey); + new Cmp(value, highKey).emit(masm); } // Jump to default target if index is not within the jump table if (defaultTarget != null) { - new Bpl(CC.Icc, defaultTarget.label()).emit(masm); + new Bpgu(CC.Icc, defaultTarget.label()).emit(masm); new Nop().emit(masm); // delay slot } @@ -271,7 +271,7 @@ new Sll(value, 3, value).emit(masm); // Multiply by 8 new Rdpc(scratchReg).emit(masm); - // The jump table follows three instructions after rdpc + // The jump table follows four instructions after rdpc new Add(scratchReg, 4 * 4, scratchReg).emit(masm); new Jmpl(value, scratchReg, g0).emit(masm); new Sra(value, 3, value).emit(masm); // delay slot, correct the value (division by 8) @@ -279,17 +279,10 @@ // Emit jump table entries for (LabelRef target : targets) { Label label = target.label(); - if (label.isBound()) { - int disp19 = label.position() - masm.position(); - new Bpa(disp19).emit(masm); - new Nop().emit(masm); // delay slot - } else { - label.addPatchAt(masm.position()); - new Bpa(0).emit(masm); - new Nop().emit(masm); // delay slot - } + label.addPatchAt(masm.position()); + new Bpa(0).emit(masm); + new Nop().emit(masm); // delay slot } - // crb.compilationResult.addAnnotation(jt); } }