Search in sources :

Example 1 with BranchPredict

use of org.graalvm.compiler.asm.sparc.SPARCAssembler.BranchPredict 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)

Aggregations

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 CC (org.graalvm.compiler.asm.sparc.SPARCAssembler.CC)1 ConditionFlag (org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag)1 FBPCC (org.graalvm.compiler.asm.sparc.SPARCAssembler.FBPCC)1