# HG changeset patch # User Morris Meyer # Date 1370133742 14400 # Node ID 91a1041ec905c83cb6b91a983997f9dfa7a97ad9 # Parent 204e8f3209e9d43bb6a6bdea8f54d1ff199d7550 SPARCLIRGenerator, sqrt, condition move, breakpoint op, partial bit ops diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java --- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java Sat Jun 01 12:44:42 2013 -0400 +++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java Sat Jun 01 20:42:22 2013 -0400 @@ -190,7 +190,7 @@ assert rs1 >= 0 && rs1 < 0x20; assert rd >= 0 && rd < 0x20; - masm.emitInt(op << 30 | rd << 25 | op3 << 19 | rs1 << 14); + masm.emitInt(op << 30 | rd << 25 | op3 << 19 | rs1 << 14); } } @@ -204,6 +204,16 @@ } } + public static class Fmt4a { + public Fmt4a(SPARCAssembler masm, int op, int op3, int cc, int rs1, int regOrImmediate, int rd) { + assert op == 2; + assert rs1 >= 0 && rs1 < 0x20; + assert rd >= 0 && rd < 0x10; + + masm.emitInt(op << 30 | rd << 25 | op3 << 19 | rs1 << 14 | ((cc << 11) & 0x000001800) | regOrImmediate); + } + } + public static class Fmt4c { public Fmt4c(SPARCAssembler masm, int op, int op3, int cond, int cc, int rs2, int rd) { assert op == 2; @@ -401,6 +411,10 @@ Fdivd(0x4D, "fdivd"), Fdivq(0x4E, "fdivq"), + Fsqrts(0x29, "fsqrts"), + Fsqrtd(0x2A, "fsqrtd"), + Fsqrtq(0x2B, "fsqrtq"), + Fsmuld(0x69, "fsmuld"), Fmulq(0x6B, "fmulq"), Fdmuldq(0x6E, "fdmulq"), @@ -477,7 +491,7 @@ } } - public enum Condition { + public enum ConditionFlag { // for FBfcc & FBPfcc instruction F_Never(0, "f_never"), @@ -524,7 +538,7 @@ private final int value; private final String operator; - private Condition(int value, String op) { + private ConditionFlag(int value, String op) { this.value = value; this.operator = op; } @@ -687,11 +701,11 @@ public static class Bpa extends Fmt2c { public Bpa(SPARCAssembler masm, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Always.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Always.getValue(), Op2s.Bp.getValue(), CC.Icc.getValue(), 1, simmm19); } public Bpa(SPARCAssembler masm, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Always.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Always.getValue(), Op2s.Bp.getValue(), CC.Icc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -699,11 +713,11 @@ public static class Bpcc extends Fmt2c { public Bpcc(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.CarryClear.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.CarryClear.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpcc(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.CarryClear.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.CarryClear.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -711,11 +725,11 @@ public static class Bpcs extends Fmt2c { public Bpcs(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.CarrySet.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.CarrySet.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpcs(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.CarrySet.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.CarrySet.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -723,11 +737,11 @@ public static class Bpe extends Fmt2c { public Bpe(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Equal.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Equal.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpe(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Equal.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Equal.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -735,11 +749,11 @@ public static class Bpg extends Fmt2c { public Bpg(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Greater.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Greater.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpg(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Greater.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Greater.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -747,11 +761,11 @@ public static class Bpge extends Fmt2c { public Bpge(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.GreaterEqual.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.GreaterEqual.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpge(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.GreaterEqual.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.GreaterEqual.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -759,11 +773,11 @@ public static class Bpgu extends Fmt2c { public Bpgu(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.GreaterUnsigned.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.GreaterUnsigned.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpgu(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.GreaterUnsigned.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.GreaterUnsigned.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -771,11 +785,11 @@ public static class Bpl extends Fmt2c { public Bpl(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Less.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Less.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpl(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Less.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Less.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -783,11 +797,11 @@ public static class Bple extends Fmt2c { public Bple(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.LessEqual.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.LessEqual.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bple(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.LessEqual.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.LessEqual.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -795,11 +809,11 @@ public static class Bpleu extends Fmt2c { public Bpleu(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.LessEqualUnsigned.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.LessEqualUnsigned.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpleu(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.LessEqualUnsigned.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.LessEqualUnsigned.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -807,11 +821,11 @@ public static class Bpn extends Fmt2c { public Bpn(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Never.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Never.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpn(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Never.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Never.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -819,11 +833,11 @@ public static class Bpne extends Fmt2c { public Bpne(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.NotZero.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.NotZero.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpne(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.NotZero.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.NotZero.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -831,11 +845,11 @@ public static class Bpneg extends Fmt2c { public Bpneg(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Negative.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Negative.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpneg(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Negative.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Negative.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -843,11 +857,11 @@ public static class Bppos extends Fmt2c { public Bppos(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Positive.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Positive.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bppos(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.Positive.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.Positive.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -855,11 +869,11 @@ public static class Bpvc extends Fmt2c { public Bpvc(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.OverflowClear.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.OverflowClear.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpvc(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.OverflowClear.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.OverflowClear.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -867,11 +881,11 @@ public static class Bpvs extends Fmt2c { public Bpvs(SPARCAssembler masm, CC cc, int simmm19) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.OverflowSet.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.OverflowSet.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, simmm19); } public Bpvs(SPARCAssembler masm, CC cc, Label label) { - super(masm, Ops.BranchOp.getValue(), 0, Condition.OverflowSet.getValue(), + super(masm, Ops.BranchOp.getValue(), 0, ConditionFlag.OverflowSet.getValue(), Op2s.Bp.getValue(), cc.getValue(), 1, label.isBound() ? label.position() : patchUnbound(masm, label)); } @@ -965,6 +979,14 @@ } } + public static class Fsqrtd extends Fmt3p { + public Fsqrtd(SPARCAssembler masm, Register src2, Register dst) { + super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fsqrtd.getValue(), + 0, src2.encoding(), dst.encoding()); + } + } + + public static class Fsubs extends Fmt3p { public Fsubs(SPARCAssembler masm, Register src1, Register src2, Register dst) { super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fsubs.getValue(), @@ -1050,11 +1072,11 @@ } public static class Movcc extends Fmt4c { - public Movcc(SPARCAssembler masm, Condition cond, CC cca, Register src2, Register dst) { + public Movcc(SPARCAssembler masm, ConditionFlag cond, CC cca, Register src2, Register dst) { super(masm, Ops.ArithOp.getValue(), Op3s.Movcc.getValue(), cond.getValue(), cca.getValue(), src2.encoding(), dst.encoding()); } - public Movcc(SPARCAssembler masm, Condition cond, CC cca, int simm11a, Register dst) { + public Movcc(SPARCAssembler masm, ConditionFlag cond, CC cca, int simm11a, Register dst) { super(masm, Ops.ArithOp.getValue(), Op3s.Movcc.getValue(), cond.getValue(), cca.getValue(), simm11a, dst.encoding()); } @@ -1409,6 +1431,17 @@ } } + public static class Ta extends Fmt4a { + public Ta(SPARCAssembler asm, CC cc, Register src1, int trap) { + super(asm, Ops.ArithOp.getValue(), Op3s.Trap.getValue(), cc.getValue(), + src1.encoding(), trap, ConditionFlag.Always.getValue()); + } + public Ta(SPARCAssembler asm, CC cc, Register src1, Register src2) { + super(asm, Ops.ArithOp.getValue(), Op3s.Trap.getValue(), cc.getValue(), + src1.encoding(), src2.encoding(), ConditionFlag.Always.getValue()); + } + } + public static class Taddcc extends Fmt3b { public Taddcc(SPARCAssembler masm, Register src1, int simm13, Register dst) { super(masm, Ops.ArithOp.getValue(), Op3s.Taddcc.getValue(), src1.encoding(), simm13, dst.encoding()); diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java --- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java Sat Jun 01 12:44:42 2013 -0400 +++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java Sat Jun 01 20:42:22 2013 -0400 @@ -22,6 +22,8 @@ */ package com.oracle.graal.asm.sparc; +import static com.oracle.graal.asm.sparc.SPARCAssembler.CC.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.sparc.*; @@ -317,4 +319,12 @@ } } + @SuppressWarnings("unused") + public static class Trap { + + public Trap(SPARCAssembler asm, int trap) { + assert trap >= 0 && trap <= 0x7f; + new Ta(asm, Icc, SPARC.g0, trap); + } + } } diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Sat Jun 01 12:44:42 2013 -0400 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Sat Jun 01 20:42:22 2013 -0400 @@ -25,6 +25,8 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRValueUtil.*; +import static com.oracle.graal.lir.sparc.SPARCBitManipulationOp.IntrinsicOpcode.*; +import static com.oracle.graal.lir.sparc.SPARCMathIntrinsicOp.IntrinsicOpcode.*; import static com.oracle.graal.lir.sparc.SPARCArithmetic.*; import static com.oracle.graal.lir.sparc.SPARCCompare.*; @@ -34,32 +36,38 @@ import com.oracle.graal.api.code.ForeignCallLinkage; import com.oracle.graal.api.code.StackSlot; import com.oracle.graal.api.code.TargetDescription; -import com.oracle.graal.api.meta.AllocatableValue; -import com.oracle.graal.api.meta.Constant; -import com.oracle.graal.api.meta.Kind; -import com.oracle.graal.api.meta.Value; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.NumUtil; import com.oracle.graal.compiler.gen.LIRGenerator; import com.oracle.graal.compiler.target.LIRGenLowerable; import com.oracle.graal.graph.GraalInternalError; import com.oracle.graal.lir.*; import com.oracle.graal.lir.StandardOp.*; -import com.oracle.graal.lir.sparc.*; +import com.oracle.graal.lir.sparc.SPARCAddressValue; +import com.oracle.graal.lir.sparc.SPARCArithmetic.BinaryRegConst; import com.oracle.graal.lir.sparc.SPARCArithmetic.Op1Stack; import com.oracle.graal.lir.sparc.SPARCArithmetic.Op2Stack; import com.oracle.graal.lir.sparc.SPARCArithmetic.Op2Reg; import com.oracle.graal.lir.sparc.SPARCArithmetic.ShiftOp; import com.oracle.graal.lir.sparc.SPARCArithmetic.Unary1Op; import com.oracle.graal.lir.sparc.SPARCArithmetic.Unary2Op; +import com.oracle.graal.lir.sparc.SPARCBitManipulationOp; +import com.oracle.graal.lir.sparc.SPARCBreakpointOp; +import com.oracle.graal.lir.sparc.SPARCByteSwapOp; import com.oracle.graal.lir.sparc.SPARCCompare.CompareOp; import com.oracle.graal.lir.sparc.SPARCControlFlow.BranchOp; +import com.oracle.graal.lir.sparc.SPARCControlFlow.CondMoveOp; +import com.oracle.graal.lir.sparc.SPARCControlFlow.FloatCondMoveOp; import com.oracle.graal.lir.sparc.SPARCControlFlow.ReturnOp; import com.oracle.graal.lir.sparc.SPARCControlFlow.SequentialSwitchOp; +import com.oracle.graal.lir.sparc.SPARCControlFlow.SwitchRangesOp; import com.oracle.graal.lir.sparc.SPARCControlFlow.TableSwitchOp; +import com.oracle.graal.lir.sparc.SPARCMathIntrinsicOp; import com.oracle.graal.lir.sparc.SPARCMove.LoadOp; import com.oracle.graal.lir.sparc.SPARCMove.MembarOp; import com.oracle.graal.lir.sparc.SPARCMove.MoveFromRegOp; import com.oracle.graal.lir.sparc.SPARCMove.MoveToRegOp; +import com.oracle.graal.lir.sparc.SPARCMove.NullCheckOp; import com.oracle.graal.lir.sparc.SPARCMove.StackLoadAddressOp; import com.oracle.graal.lir.sparc.SPARCMove.StoreOp; import com.oracle.graal.lir.sparc.SPARCTestOp; @@ -71,7 +79,7 @@ import com.oracle.graal.nodes.SafepointNode; import com.oracle.graal.nodes.StructuredGraph; import com.oracle.graal.nodes.ValueNode; -import com.oracle.graal.nodes.calc.Condition; +import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.ConvertNode.Op; import com.oracle.graal.nodes.java.CompareAndSwapNode; @@ -165,6 +173,7 @@ @Override public void emitOverflowCheckBranch(LabelRef label, boolean negated) { // append(new BranchOp(negated ? ConditionFlag.NoOverflow : ConditionFlag.Overflow, label)); + throw GraalInternalError.shouldNotReachHere("emitOverflowCheckBranch: unimp"); } @Override @@ -199,13 +208,76 @@ } @Override - public Variable emitConditionalMove(Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) { - throw new InternalError("NYI"); + public Variable emitConditionalMove(Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + boolean mirrored = emitCompare(left, right); + Condition finalCondition = mirrored ? cond.mirror() : cond; + + Variable result = newVariable(trueValue.getKind()); + switch (left.getKind().getStackKind()) { + case Int: + case Long: + case Object: + append(new CondMoveOp(result, finalCondition, load(trueValue), loadNonConst(falseValue))); + break; + case Float: + case Double: + append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue))); + break; + default: + throw GraalInternalError.shouldNotReachHere("" + left.getKind()); + } + return result; + } + + /** + * This method emits the compare instruction, and may reorder the operands. It returns true if + * it did so. + * + * @param a the left operand of the comparison + * @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) { + Variable left; + Value right; + boolean mirrored; + if (LIRValueUtil.isVariable(b)) { + left = load(b); + right = loadNonConst(a); + mirrored = true; + } else { + left = load(a); + right = loadNonConst(b); + mirrored = false; + } + switch (left.getKind().getStackKind()) { + case Int: + append(new CompareOp(ICMP, left, right)); + break; + case Long: + append(new CompareOp(LCMP, left, right)); + break; + case Object: + append(new CompareOp(ACMP, left, right)); + break; + case Float: + append(new CompareOp(FCMP, left, right)); + break; + case Double: + append(new CompareOp(DCMP, left, right)); + break; + default: + throw GraalInternalError.shouldNotReachHere(); + } + return mirrored; } @Override - public Variable emitIntegerTestMove(Value leftVal, Value right, Value trueValue, Value falseValue) { - throw new InternalError("NYI"); + public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) { + emitIntegerTest(left, right); + Variable result = newVariable(trueValue.getKind()); + append(new CondMoveOp(result, Condition.EQ, load(trueValue), loadNonConst(falseValue))); + return result; } @Override @@ -237,7 +309,7 @@ @Override protected void emitSwitchRanges(int[] lowKeys, int[] highKeys, LabelRef[] targets, LabelRef defaultTarget, Value key) { - throw new InternalError("NYI"); + append(new SwitchRangesOp(lowKeys, highKeys, targets, defaultTarget, key)); } @Override @@ -250,52 +322,60 @@ @Override public void emitBitCount(Variable result, Value operand) { - throw new InternalError("NYI"); + if (operand.getKind().getStackKind() == Kind.Int) { + append(new SPARCBitManipulationOp(IPOPCNT, result, asAllocatable(operand))); + } else { + append(new SPARCBitManipulationOp(LPOPCNT, result, asAllocatable(operand))); + } } @Override public void emitBitScanForward(Variable result, Value operand) { - throw new InternalError("NYI"); + append(new SPARCBitManipulationOp(BSF, result, asAllocatable(operand))); } @Override public void emitBitScanReverse(Variable result, Value operand) { - throw new InternalError("NYI"); + if (operand.getKind().getStackKind() == Kind.Int) { + append(new SPARCBitManipulationOp(IBSR, result, asAllocatable(operand))); + } else { + append(new SPARCBitManipulationOp(LBSR, result, asAllocatable(operand))); + } } @Override public void emitMathAbs(Variable result, Variable input) { - throw new InternalError("NYI"); + append(new BinaryRegConst(DAND, result, input, Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL)))); } @Override public void emitMathSqrt(Variable result, Variable input) { - throw new InternalError("NYI"); + append(new SPARCMathIntrinsicOp(SQRT, result, input)); } @Override public void emitMathLog(Variable result, Variable input, boolean base10) { - throw new InternalError("NYI"); + append(new SPARCMathIntrinsicOp(LOG, result, input)); } @Override public void emitMathCos(Variable result, Variable input) { - throw new InternalError("NYI"); + append(new SPARCMathIntrinsicOp(COS, result, input)); } @Override public void emitMathSin(Variable result, Variable input) { - throw new InternalError("NYI"); + append(new SPARCMathIntrinsicOp(SIN, result, input)); } @Override public void emitMathTan(Variable result, Variable input) { - throw new InternalError("NYI"); + append(new SPARCMathIntrinsicOp(TAN, result, input)); } @Override - public void emitByteSwap(Variable result, Value operand) { - throw new InternalError("NYI"); + public void emitByteSwap(Variable result, Value input) { + append(new SPARCByteSwapOp(result, input)); } @Override @@ -512,12 +592,34 @@ @Override public Value emitUDiv(Value a, Value b, DeoptimizingNode deopting) { - throw new InternalError("NYI"); + @SuppressWarnings("unused") + LIRFrameState state = state(deopting); + switch (a.getKind()) { + case Int: + // emitDivRem(IUDIV, a, b, state); + // return emitMove(RAX_I); + case Long: + // emitDivRem(LUDIV, a, b, state); + // return emitMove(RAX_L); + default: + throw GraalInternalError.shouldNotReachHere(); + } } @Override public Value emitURem(Value a, Value b, DeoptimizingNode deopting) { - throw new InternalError("NYI"); + @SuppressWarnings("unused") + LIRFrameState state = state(deopting); + switch (a.getKind()) { + case Int: + // emitDivRem(IUREM, a, b, state); + // return emitMove(RDX_I); + case Long: + // emitDivRem(LUREM, a, b, state); + // return emitMove(RDX_L); + default: + throw GraalInternalError.shouldNotReachHere(); + } } @Override @@ -715,8 +817,14 @@ } @Override - public void visitBreakpointNode(BreakpointNode i) { - throw new InternalError("NYI"); + public void visitBreakpointNode(BreakpointNode node) { + JavaType[] sig = new JavaType[node.arguments().size()]; + for (int i = 0; i < sig.length; i++) { + sig[i] = node.arguments().get(i).stamp().javaType(runtime); + } + + Value[] parameters = visitInvokeArguments(frameMap.registerConfig.getCallingConvention(CallingConvention.Type.JavaCall, null, sig, target(), false), node.arguments()); + append(new SPARCBreakpointOp(parameters)); } @Override @@ -727,7 +835,7 @@ @Override public void emitNullCheck(ValueNode v, DeoptimizingNode deopting) { assert v.kind() == Kind.Object; - append(new SPARCMove.NullCheckOp(load(operand(v)), state(deopting))); + append(new NullCheckOp(load(operand(v)), state(deopting))); } @Override diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Sat Jun 01 12:44:42 2013 -0400 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Sat Jun 01 20:42:22 2013 -0400 @@ -74,6 +74,35 @@ MOV_I2F, MOV_L2D, MOV_F2I, MOV_D2L; /** + * Binary operation with single source/destination operand and one constant. + */ + public static class BinaryRegConst extends SPARCLIRInstruction { + @Opcode private final SPARCArithmetic opcode; + @Def({REG, HINT}) protected AllocatableValue result; + @Use({REG, STACK}) protected AllocatableValue x; + protected Constant y; + + public BinaryRegConst(SPARCArithmetic opcode, AllocatableValue result, AllocatableValue x, Constant y) { + this.opcode = opcode; + this.result = result; + this.x = x; + this.y = y; + } + + @Override + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler masm) { + SPARCMove.move(tasm, masm, result, x); + emit(tasm, masm, opcode, result, y, null); + } + + @Override + public void verify() { + super.verify(); + verifyKind(opcode, result, x, y); + } + } + + /** * Unary operation with separate source and destination operand. */ public static class Unary2Op extends SPARCLIRInstruction { @@ -397,6 +426,9 @@ case LUSHR: new Sra(masm, asLongReg(src1), asIntReg(src2), asLongReg(dst)); break; + case LDIVREM: + case LUDIV: + case LUREM: case LREM: throw new InternalError("NYI"); case FADD: diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Sat Jun 01 20:42:22 2013 -0400 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.sparc; + +import static com.oracle.graal.asm.sparc.SPARCAssembler.Popc; +import static com.oracle.graal.asm.sparc.SPARCAssembler.Srl; +import static com.oracle.graal.asm.sparc.SPARCAssembler.isSimm13; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.asm.sparc.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.lir.asm.*; +import com.oracle.graal.sparc.SPARC; + +public class SPARCBitManipulationOp extends SPARCLIRInstruction { + + public enum IntrinsicOpcode { + IPOPCNT, LPOPCNT, IBSR, LBSR, BSF; + } + + @Opcode private final IntrinsicOpcode opcode; + @Def protected AllocatableValue result; + @Use({OperandFlag.REG, OperandFlag.STACK}) protected AllocatableValue input; + + public SPARCBitManipulationOp(IntrinsicOpcode opcode, AllocatableValue result, AllocatableValue input) { + this.opcode = opcode; + this.result = result; + this.input = input; + } + + @Override + @SuppressWarnings("unused") + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler masm) { + Register dst = ValueUtil.asIntReg(result); + if (ValueUtil.isRegister(input)) { + Register src = ValueUtil.asRegister(input); + switch (opcode) { + case IPOPCNT: + // clear upper word for 64 bit POPC + new Srl(masm, src, SPARC.g0, dst); + new Popc(masm, src, dst); + break; + case LPOPCNT: + new Popc(masm, src, dst); + break; + case BSF: // masm.bsfq(dst, src); + case IBSR: // masm.bsrl(dst, src); + case LBSR: // masm.bsrq(dst, src); + default: + throw GraalInternalError.shouldNotReachHere("missing: " + opcode); + + } + } else if (ValueUtil.isConstant(input) && isSimm13(tasm.asIntConst(input))) { + switch (opcode) { + case IPOPCNT: + new Popc(masm, tasm.asIntConst(input), dst); + break; + case LPOPCNT: + new Popc(masm, tasm.asIntConst(input), dst); + break; + default: + throw GraalInternalError.shouldNotReachHere("missing: " + opcode); + } + } else { + SPARCAddress src = (SPARCAddress) tasm.asAddress(input); + switch (opcode) { + case IPOPCNT: + // masm.popcntl(dst, src); + break; + case LPOPCNT: + // masm.popcntq(dst, src); + break; + case BSF: + // masm.bsfq(dst, src); + break; + case IBSR: + // masm.bsrl(dst, src); + break; + case LBSR: + // masm.bsrq(dst, src); + break; + } + } + } + +} diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBreakpointOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBreakpointOp.java Sat Jun 01 20:42:22 2013 -0400 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.sparc; + +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.asm.sparc.SPARCAssembler; +import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Trap; +import com.oracle.graal.lir.LIRInstruction.*; +import com.oracle.graal.lir.asm.*; + +/** + * Emits a breakpoint. + */ +@Opcode("BREAKPOINT") +public class SPARCBreakpointOp extends SPARCLIRInstruction { + + // historical - from hotspot src/cpu/sparc/vm + // promises that the system will not use traps 16-31 + // We want to use ST_BREAKPOINT here, but the debugger is confused by it. + public static final int ST_RESERVED_FOR_USER_0 = 0x10; + + /** + * A set of values loaded into the Java ABI parameter locations (for inspection by a debugger). + */ + @Use({REG, STACK}) protected Value[] parameters; + + public SPARCBreakpointOp(Value[] parameters) { + this.parameters = parameters; + } + + @Override + @SuppressWarnings("unused") + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler asm) { + new Trap(asm, ST_RESERVED_FOR_USER_0); + } +} diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java Sat Jun 01 20:42:22 2013 -0400 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.sparc; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.asm.sparc.*; +import com.oracle.graal.lir.LIRInstruction.Opcode; +import com.oracle.graal.lir.asm.*; + +@Opcode("BSWAP") +public class SPARCByteSwapOp extends SPARCLIRInstruction { + + @Def({OperandFlag.REG, OperandFlag.HINT}) protected Value result; + @Use protected Value input; + + public SPARCByteSwapOp(Value result, Value input) { + this.result = result; + this.input = input; + } + + @Override + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler masm) { + SPARCMove.move(tasm, masm, result, input); + switch (input.getKind()) { + // case Int: + // masm.bswapl(ValueUtil.asIntReg(result)); + // case Long: + // masm.bswapq(ValueUtil.asLongReg(result)); + } + } +} diff -r 204e8f3209e9 -r 91a1041ec905 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 Sat Jun 01 12:44:42 2013 -0400 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Sat Jun 01 20:42:22 2013 -0400 @@ -31,13 +31,15 @@ import com.oracle.graal.asm.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.asm.sparc.SPARCAssembler.CC; +import com.oracle.graal.asm.sparc.SPARCAssembler.ConditionFlag; import com.oracle.graal.asm.sparc.SPARCAssembler.Bpe; import com.oracle.graal.asm.sparc.SPARCAssembler.Subcc; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.LIRInstruction.*; import com.oracle.graal.lir.StandardOp.*; import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.calc.Condition; import com.oracle.graal.sparc.SPARC; public class SPARCControlFlow { @@ -74,6 +76,147 @@ } } + @Opcode("CMOVE") + public static class CondMoveOp extends SPARCLIRInstruction { + + @Def({REG, HINT}) protected Value result; + @Alive({REG}) protected Value trueValue; + @Use({REG, STACK, CONST}) protected Value falseValue; + + private final ConditionFlag condition; + + public CondMoveOp(Variable result, Condition condition, Variable trueValue, Value falseValue) { + this.result = result; + this.condition = intCond(condition); + this.trueValue = trueValue; + this.falseValue = falseValue; + } + + @Override + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler masm) { + cmove(tasm, masm, result, false, condition, false, trueValue, falseValue); + } + } + + @Opcode("CMOVE") + public static class FloatCondMoveOp extends SPARCLIRInstruction { + + @Def({REG}) protected Value result; + @Alive({REG}) protected Value trueValue; + @Alive({REG}) protected Value falseValue; + private final ConditionFlag condition; + private final boolean unorderedIsTrue; + + public FloatCondMoveOp(Variable result, Condition condition, boolean unorderedIsTrue, Variable trueValue, Variable falseValue) { + this.result = result; + this.condition = floatCond(condition); + this.unorderedIsTrue = unorderedIsTrue; + this.trueValue = trueValue; + this.falseValue = falseValue; + } + + @Override + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler masm) { + cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); + } + } + + private static void cmove(TargetMethodAssembler tasm, SPARCAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + // check that we don't overwrite an input operand before it is used. + assert !result.equals(trueValue); + + SPARCMove.move(tasm, masm, result, falseValue); + cmove(tasm, masm, result, condition, trueValue); + + if (isFloat) { + if (unorderedIsTrue && !trueOnUnordered(condition)) { + // cmove(tasm, masm, result, ConditionFlag.Parity, trueValue); + } else if (!unorderedIsTrue && trueOnUnordered(condition)) { + // cmove(tasm, masm, result, ConditionFlag.Parity, falseValue); + } + } + } + + @SuppressWarnings("unused") + private static void cmove(TargetMethodAssembler tasm, SPARCAssembler masm, Value result, ConditionFlag cond, Value other) { + if (isRegister(other)) { + assert !asRegister(other).equals(asRegister(result)) : "other already overwritten by previous move"; + switch (other.getKind()) { + case Int: + // masm.cmovl(cond, asRegister(result), asRegister(other)); + break; + case Long: + // masm.cmovq(cond, asRegister(result), asRegister(other)); + break; + default: + throw GraalInternalError.shouldNotReachHere(); + } + } else { + SPARCAddress addr = (SPARCAddress) tasm.asAddress(other); + switch (other.getKind()) { + case Int: + // masm.cmovl(cond, asRegister(result), addr); + break; + case Long: + // masm.cmovq(cond, asRegister(result), addr); + break; + default: + throw GraalInternalError.shouldNotReachHere(); + } + } + } + + private static ConditionFlag intCond(Condition cond) { + switch (cond) { + case EQ: + return ConditionFlag.Equal; + case NE: + return ConditionFlag.NotEqual; + case LT: + return ConditionFlag.Less; + case LE: + return ConditionFlag.LessEqual; + case GE: + return ConditionFlag.GreaterEqual; + case GT: + return ConditionFlag.Greater; + case BE: + case AE: + case AT: + case BT: + default: + throw GraalInternalError.shouldNotReachHere(); + } + } + + private static ConditionFlag floatCond(Condition cond) { + switch (cond) { + case EQ: + return ConditionFlag.Equal; + case NE: + return ConditionFlag.NotEqual; + case LT: + case LE: + case GE: + case GT: + default: + throw GraalInternalError.shouldNotReachHere(); + } + } + + private static boolean trueOnUnordered(ConditionFlag condition) { + switch (condition) { + case NotEqual: + case Less: + return false; + case Equal: + case GreaterEqual: + return true; + default: + throw GraalInternalError.shouldNotReachHere(); + } + } + public static class ReturnOp extends SPARCLIRInstruction { @Use({REG, ILLEGAL}) protected Value x; @@ -163,6 +306,84 @@ } } + public static class SwitchRangesOp extends SPARCLIRInstruction implements FallThroughOp { + + private final LabelRef[] keyTargets; + private LabelRef defaultTarget; + private final int[] lowKeys; + private final int[] highKeys; + @Alive protected Value key; + + public SwitchRangesOp(int[] lowKeys, int[] highKeys, LabelRef[] keyTargets, LabelRef defaultTarget, Value key) { + this.lowKeys = lowKeys; + this.highKeys = highKeys; + this.keyTargets = keyTargets; + this.defaultTarget = defaultTarget; + this.key = key; + } + + @Override + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler masm) { + assert isSorted(lowKeys) && isSorted(highKeys); + + @SuppressWarnings("unused") + Label actualDefaultTarget = defaultTarget == null ? new Label() : defaultTarget.label(); + int prevHighKey = 0; + boolean skipLowCheck = false; + for (int i = 0; i < lowKeys.length; i++) { + int lowKey = lowKeys[i]; + int highKey = highKeys[i]; + if (lowKey == highKey) { + // masm.cmpl(asIntReg(key), lowKey); + // masm.jcc(ConditionFlag.Equal, keyTargets[i].label()); + skipLowCheck = false; + } else { + if (!skipLowCheck || (prevHighKey + 1) != lowKey) { + // masm.cmpl(asIntReg(key), lowKey); + // masm.jcc(ConditionFlag.Less, actualDefaultTarget); + } + // masm.cmpl(asIntReg(key), highKey); + // masm.jcc(ConditionFlag.LessEqual, keyTargets[i].label()); + skipLowCheck = true; + } + prevHighKey = highKey; + } + if (defaultTarget != null) { + // masm.jmp(defaultTarget.label()); + } else { + // masm.bind(actualDefaultTarget); + // masm.hlt(); + } + } + + @Override + protected void verify() { + super.verify(); + assert lowKeys.length == keyTargets.length; + assert highKeys.length == keyTargets.length; + assert key.getKind() == Kind.Int; + } + + @Override + public LabelRef fallThroughTarget() { + return defaultTarget; + } + + @Override + public void setFallThroughTarget(LabelRef target) { + defaultTarget = target; + } + + private static boolean isSorted(int[] values) { + for (int i = 1; i < values.length; i++) { + if (values[i - 1] >= values[i]) { + return false; + } + } + return true; + } + } + public static class TableSwitchOp extends SPARCLIRInstruction { private final int lowKey; diff -r 204e8f3209e9 -r 91a1041ec905 graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java Sat Jun 01 20:42:22 2013 -0400 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.sparc; + +import static com.oracle.graal.api.code.ValueUtil.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.asm.sparc.SPARCAssembler; +import com.oracle.graal.asm.sparc.SPARCAssembler.Fsqrtd; +import com.oracle.graal.graph.*; +import com.oracle.graal.lir.asm.*; + +public class SPARCMathIntrinsicOp extends SPARCLIRInstruction { + + public enum IntrinsicOpcode { + SQRT, SIN, COS, TAN, LOG, LOG10 + } + + @Opcode private final IntrinsicOpcode opcode; + @Def protected Value result; + @Use protected Value input; + + public SPARCMathIntrinsicOp(IntrinsicOpcode opcode, Value result, Value input) { + this.opcode = opcode; + this.result = result; + this.input = input; + } + + @Override + @SuppressWarnings("unused") + public void emitCode(TargetMethodAssembler tasm, SPARCAssembler asm) { + switch (opcode) { + case SQRT: + new Fsqrtd(asm, asDoubleReg(result), asDoubleReg(input)); + break; + case LOG: + case LOG10: + case SIN: + case COS: + case TAN: + default: + throw GraalInternalError.shouldNotReachHere(); + } + } +}