use of org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag in project graal by oracle.
the class SPARCControlFlow method emitBranch.
private static boolean emitBranch(CompilationResultBuilder crb, SPARCMacroAssembler masm, SPARCKind kind, ConditionFlag conditionFlag, LabelRef trueDestination, LabelRef falseDestination, boolean withDelayedNop, double trueDestinationProbability) {
Label actualTarget;
ConditionFlag actualConditionFlag;
boolean needJump;
BranchPredict predictTaken;
if (falseDestination != null && crb.isSuccessorEdge(trueDestination)) {
actualConditionFlag = conditionFlag != null ? conditionFlag.negate() : null;
actualTarget = falseDestination.label();
needJump = false;
predictTaken = trueDestinationProbability < .5d ? PREDICT_TAKEN : PREDICT_NOT_TAKEN;
} else {
actualConditionFlag = conditionFlag;
actualTarget = trueDestination.label();
needJump = falseDestination != null && !crb.isSuccessorEdge(falseDestination);
predictTaken = trueDestinationProbability > .5d ? PREDICT_TAKEN : PREDICT_NOT_TAKEN;
}
if (!withDelayedNop && needJump) {
// We cannot make use of the delay slot when we jump in true-case and false-case
return false;
}
if (kind.isFloat()) {
FBPCC.emit(masm, Fcc0, actualConditionFlag, NOT_ANNUL, predictTaken, actualTarget);
} else {
assert kind.isInteger();
CC cc = kind.equals(WORD) ? Icc : Xcc;
BPCC.emit(masm, cc, actualConditionFlag, NOT_ANNUL, predictTaken, actualTarget);
}
if (withDelayedNop) {
// delay slot
masm.nop();
}
if (needJump) {
masm.jmp(falseDestination.label());
}
return true;
}
use of org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag in project graal by oracle.
the class SPARCLIRGenerator method emitIntegerTestMove.
@Override
public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
emitIntegerTest(left, right);
Variable result = newVariable(trueValue.getValueKind());
ConditionFlag flag = SPARCControlFlow.fromCondition(true, Condition.EQ, false);
CC cc = CC.forKind(left.getPlatformKind());
append(new CondMoveOp(MOVicc, cc, flag, loadSimm11(trueValue), loadSimm11(falseValue), result));
return result;
}
use of org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag in project graal by oracle.
the class SPARCLIRGenerator method emitConditionalMove.
@Override
public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
// Emit compare
SPARCKind cmpSPARCKind = (SPARCKind) cmpKind;
boolean mirrored = emitCompare(cmpSPARCKind, left, right);
// Emit move
Value actualTrueValue = trueValue;
Value actualFalseValue = falseValue;
SPARCKind valueKind = (SPARCKind) trueValue.getPlatformKind();
CMOV cmove;
if (valueKind.isFloat()) {
// Floats cannot be immediate at all
actualTrueValue = load(trueValue);
actualFalseValue = load(falseValue);
cmove = valueKind.equals(SINGLE) ? FMOVSCC : FMOVDCC;
} else if (valueKind.isInteger()) {
actualTrueValue = loadSimm11(trueValue);
actualFalseValue = loadSimm11(falseValue);
cmove = MOVicc;
} else {
throw GraalError.shouldNotReachHere();
}
Variable result = newVariable(trueValue.getValueKind());
ConditionFlag finalCondition = SPARCControlFlow.fromCondition(cmpSPARCKind.isInteger(), mirrored ? cond.mirror() : cond, unorderedIsTrue);
CC cc = CC.forKind(cmpSPARCKind);
append(new CondMoveOp(cmove, cc, finalCondition, actualTrueValue, actualFalseValue, result));
return result;
}
use of org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag in project graal by oracle.
the class SPARCLIRGenerator method emitCompareBranch.
@Override
public void emitCompareBranch(PlatformKind cmpKind, Value x, Value y, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
AllocatableValue left;
Value right;
Condition actualCondition;
if (isJavaConstant(x)) {
left = load(y);
right = loadSimm13(x);
actualCondition = cond.mirror();
} else {
left = load(x);
right = loadSimm13(y);
actualCondition = cond;
}
SPARCKind actualCmpKind = (SPARCKind) cmpKind;
if (actualCmpKind.isInteger()) {
assert actualCmpKind.equals(XWORD) || actualCmpKind.equals(WORD) : "SPARC does not support compare of: " + actualCmpKind;
append(new SPARCControlFlow.CompareBranchOp(left, right, actualCondition, trueDestination, falseDestination, actualCmpKind, unorderedIsTrue, trueDestinationProbability));
} else if (actualCmpKind.isFloat()) {
emitFloatCompare(actualCmpKind, x, y, Fcc0);
ConditionFlag cf = SPARCControlFlow.fromCondition(false, cond, unorderedIsTrue);
append(new SPARCControlFlow.BranchOp(cf, trueDestination, falseDestination, actualCmpKind, trueDestinationProbability));
} else {
throw GraalError.shouldNotReachHere();
}
}
Aggregations