Mercurial > hg > truffle
changeset 16928:3461ae3a4b06
[SPARC] Fixing branching on fp condition codes, introducing branching on carry set.
author | Stefan Anzinger <stefan.anzinger@gmail.com> |
---|---|
date | Fri, 08 Aug 2014 09:24:44 -0700 |
parents | 949347518b66 |
children | 5dc533f7565a |
files | graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java |
diffstat | 2 files changed, 33 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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() {
--- 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: