Search in sources :

Example 1 with ConditionFlag

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;
}
Also used : BPCC(org.graalvm.compiler.asm.sparc.SPARCAssembler.BPCC) FBPCC(org.graalvm.compiler.asm.sparc.SPARCAssembler.FBPCC) CC(org.graalvm.compiler.asm.sparc.SPARCAssembler.CC) BranchPredict(org.graalvm.compiler.asm.sparc.SPARCAssembler.BranchPredict) Label(org.graalvm.compiler.asm.Label) ConditionFlag(org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag)

Example 2 with ConditionFlag

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;
}
Also used : FMOVSCC(org.graalvm.compiler.asm.sparc.SPARCAssembler.FMOVSCC) CC(org.graalvm.compiler.asm.sparc.SPARCAssembler.CC) FMOVDCC(org.graalvm.compiler.asm.sparc.SPARCAssembler.FMOVDCC) Variable(org.graalvm.compiler.lir.Variable) CondMoveOp(org.graalvm.compiler.lir.sparc.SPARCControlFlow.CondMoveOp) ConditionFlag(org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag)

Example 3 with ConditionFlag

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;
}
Also used : FMOVSCC(org.graalvm.compiler.asm.sparc.SPARCAssembler.FMOVSCC) CC(org.graalvm.compiler.asm.sparc.SPARCAssembler.CC) FMOVDCC(org.graalvm.compiler.asm.sparc.SPARCAssembler.FMOVDCC) Variable(org.graalvm.compiler.lir.Variable) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCImmediateAddressValue(org.graalvm.compiler.lir.sparc.SPARCImmediateAddressValue) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) CondMoveOp(org.graalvm.compiler.lir.sparc.SPARCControlFlow.CondMoveOp) SPARCKind(jdk.vm.ci.sparc.SPARCKind) CMOV(org.graalvm.compiler.asm.sparc.SPARCAssembler.CMOV) ConditionFlag(org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag)

Example 4 with ConditionFlag

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();
    }
}
Also used : Condition(org.graalvm.compiler.core.common.calc.Condition) BranchOp(org.graalvm.compiler.lir.sparc.SPARCControlFlow.BranchOp) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCImmediateAddressValue(org.graalvm.compiler.lir.sparc.SPARCImmediateAddressValue) SPARCAddressValue(org.graalvm.compiler.lir.sparc.SPARCAddressValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCKind(jdk.vm.ci.sparc.SPARCKind) SPARCControlFlow(org.graalvm.compiler.lir.sparc.SPARCControlFlow) ConditionFlag(org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag)

Aggregations

ConditionFlag (org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag)4 CC (org.graalvm.compiler.asm.sparc.SPARCAssembler.CC)3 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 Value (jdk.vm.ci.meta.Value)2 SPARCKind (jdk.vm.ci.sparc.SPARCKind)2 FMOVDCC (org.graalvm.compiler.asm.sparc.SPARCAssembler.FMOVDCC)2 FMOVSCC (org.graalvm.compiler.asm.sparc.SPARCAssembler.FMOVSCC)2 Variable (org.graalvm.compiler.lir.Variable)2 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)2 CondMoveOp (org.graalvm.compiler.lir.sparc.SPARCControlFlow.CondMoveOp)2 SPARCImmediateAddressValue (org.graalvm.compiler.lir.sparc.SPARCImmediateAddressValue)2 Label (org.graalvm.compiler.asm.Label)1 BPCC (org.graalvm.compiler.asm.sparc.SPARCAssembler.BPCC)1 BranchPredict (org.graalvm.compiler.asm.sparc.SPARCAssembler.BranchPredict)1 CMOV (org.graalvm.compiler.asm.sparc.SPARCAssembler.CMOV)1 FBPCC (org.graalvm.compiler.asm.sparc.SPARCAssembler.FBPCC)1 Condition (org.graalvm.compiler.core.common.calc.Condition)1 SPARCControlFlow (org.graalvm.compiler.lir.sparc.SPARCControlFlow)1 BranchOp (org.graalvm.compiler.lir.sparc.SPARCControlFlow.BranchOp)1