# HG changeset patch # User Stefan Anzinger # Date 1407515084 25200 # Node ID 3461ae3a4b0662559f982690d532fe9285a591c9 # Parent 949347518b664f27e2b1bfe7d393b96a63d3a102 [SPARC] Fixing branching on fp condition codes, introducing branching on carry set. diff -r 949347518b66 -r 3461ae3a4b06 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Fri Aug 08 09:22:51 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Fri Aug 08 09:24:44 2014 -0700 @@ -206,12 +206,15 @@ } public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) { + Variable newValueTemp = newVariable(newValue.getLIRKind()); + emitMove(newValueTemp, newValue); + 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); + append(new CompareAndSwapOp(asAllocatable(addressValue), asAllocatable(expectedValue), asAllocatable(newValueTemp))); + return emitConditionalMove(memKind, expectedValue, newValueTemp, Condition.EQ, true, trueValue, falseValue); } public StackSlot getDeoptimizationRescueSlot() { diff -r 949347518b66 -r 3461ae3a4b06 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 Fri Aug 08 09:22:51 2014 -0700 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Fri Aug 08 09:24:44 2014 -0700 @@ -62,30 +62,44 @@ } public static class BranchOp extends SPARCLIRInstruction implements StandardOp.BranchOp { - + // TODO: Conditioncode/flag handling needs to be improved; protected final Condition condition; + protected final ConditionFlag conditionFlag; protected final LabelRef trueDestination; protected final LabelRef falseDestination; protected final Kind kind; + public BranchOp(ConditionFlag condition, LabelRef trueDestination, LabelRef falseDestination, Kind kind) { + this.conditionFlag = condition; + this.trueDestination = trueDestination; + this.falseDestination = falseDestination; + this.kind = kind; + this.condition = null; + } + public BranchOp(Condition condition, LabelRef trueDestination, LabelRef falseDestination, Kind kind) { this.condition = condition; this.trueDestination = trueDestination; this.falseDestination = falseDestination; this.kind = kind; + this.conditionFlag = null; } @Override public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + assert condition == null && conditionFlag != null || condition != null && conditionFlag == null; Label actualTarget; Condition actualCondition; + ConditionFlag actualConditionFlag; boolean needJump; if (crb.isSuccessorEdge(trueDestination)) { - actualCondition = condition.negate(); + actualCondition = condition != null ? condition.negate() : null; + actualConditionFlag = conditionFlag != null ? conditionFlag.negate() : null; actualTarget = falseDestination.label(); needJump = false; } else { actualCondition = condition; + actualConditionFlag = conditionFlag; actualTarget = trueDestination.label(); needJump = !crb.isSuccessorEdge(falseDestination); } @@ -94,7 +108,13 @@ emitFloatCompare(masm, actualTarget, actualCondition); } else { CC cc = kind == Kind.Int ? CC.Icc : CC.Xcc; - emitCompare(masm, actualTarget, actualCondition, cc); + if (actualCondition != null) { + emitCompare(masm, actualTarget, actualCondition, cc); + } else if (actualConditionFlag != null) { + emitCompare(masm, actualTarget, actualConditionFlag, cc); + } else { + GraalInternalError.shouldNotReachHere(); + } new Nop().emit(masm); // delay slot } if (needJump) { @@ -104,7 +124,7 @@ } private static void emitFloatCompare(SPARCMacroAssembler masm, Label target, Condition actualCondition) { - switch (actualCondition.mirror()) { + switch (actualCondition) { case EQ: new Fbe(false, target).emit(masm); break; @@ -134,6 +154,10 @@ new Nop().emit(masm); } + private static void emitCompare(SPARCMacroAssembler masm, Label target, ConditionFlag actualCondition, CC cc) { + new Fmt00b(false, actualCondition, Op2s.Br, target).emit(masm); + } + private static void emitCompare(SPARCMacroAssembler masm, Label target, Condition actualCondition, CC cc) { switch (actualCondition) { case EQ: