Search in sources :

Example 1 with LLVMBasicBlockRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.

the class LLVMGenerator method buildStatepointInvoke.

LLVMValueRef buildStatepointInvoke(LLVMValueRef callee, boolean nativeABI, LLVMBasicBlockRef successor, LLVMBasicBlockRef handler, long statepointId, LLVMValueRef... args) {
    LLVMBasicBlockRef successorBlock;
    LLVMBasicBlockRef handlerBlock;
    if (!nativeABI) {
        successorBlock = builder.appendBasicBlock(currentBlock.toString() + "_invoke_successor");
        handlerBlock = builder.appendBasicBlock(currentBlock.toString() + "_invoke_handler");
        splitBlockEndMap.put(currentBlock, successorBlock);
    } else {
        successorBlock = successor;
        handlerBlock = handler;
    }
    LLVMValueRef result = builder.buildInvoke(callee, successorBlock, handlerBlock, args);
    builder.setCallSiteAttribute(result, Attribute.StatepointID, Long.toString(statepointId));
    if (!nativeABI) {
        builder.positionAtEnd(handlerBlock);
        builder.buildLandingPad();
        for (SpecialRegister reg : SpecialRegister.registers()) {
            setHandlerSpecialRegisterValue(reg, getSpecialRegisterValue(reg));
        }
        builder.buildBranch(handler);
        builder.positionAtEnd(successorBlock);
        int numReturnValues = LLVMIRBuilder.countElementTypes(typeOf(result));
        for (SpecialRegister reg : SpecialRegister.registers()) {
            assert reg.index < numReturnValues;
            setSpecialRegisterValue(reg, builder.buildExtractValue(result, reg.index));
        }
        result = numReturnValues > SpecialRegister.count() ? builder.buildExtractValue(result, SpecialRegister.count()) : result;
        builder.buildBranch(successor);
    }
    return result;
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) InlineAssemblyConstraint(com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)

Example 2 with LLVMBasicBlockRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.

the class NodeLLVMBuilder method emitForeignCall.

@Override
public void emitForeignCall(ForeignCall i) {
    ForeignCallLinkage linkage = gen.getForeignCalls().lookupForeignCall(i.getDescriptor());
    LIRFrameState state = state(i);
    Value[] args = i.operands(this);
    Value result = null;
    if (i instanceof ForeignCallNode) {
        result = gen.emitForeignCall(linkage, state, args);
    } else if (i instanceof ForeignCallWithExceptionNode) {
        ForeignCallWithExceptionNode foreignCallWithExceptionNode = (ForeignCallWithExceptionNode) i;
        LLVMBasicBlockRef successor = gen.getBlock(foreignCallWithExceptionNode.next());
        LLVMBasicBlockRef handler = gen.getBlock(foreignCallWithExceptionNode.exceptionEdge());
        result = gen.emitForeignCall(linkage, state, successor, handler, args);
    } else {
        throw shouldNotReachHere();
    }
    if (result != null) {
        setResult(i.asNode(), result);
    }
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) ConstantValue(org.graalvm.compiler.lir.ConstantValue) LLVMAddressValue(com.oracle.svm.core.graal.llvm.lowering.LLVMAddressLowering.LLVMAddressValue) Value(jdk.vm.ci.meta.Value) RegisterValue(jdk.vm.ci.code.RegisterValue) ForeignCallWithExceptionNode(org.graalvm.compiler.nodes.extended.ForeignCallWithExceptionNode) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage)

Example 3 with LLVMBasicBlockRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.

the class NodeLLVMBuilder method visitEndNode.

@Override
public void visitEndNode(AbstractEndNode i) {
    LLVMBasicBlockRef nextBlock = gen.getBlock(i.merge());
    builder.buildBranch(nextBlock);
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef)

Example 4 with LLVMBasicBlockRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.

the class NodeLLVMBuilder method emitIf.

/* Control flow nodes */
@Override
public void emitIf(IfNode i) {
    LLVMValueRef condition = emitCondition(i.condition());
    LLVMBasicBlockRef thenBlock = gen.getBlock(i.trueSuccessor());
    LLVMBasicBlockRef elseBlock = gen.getBlock(i.falseSuccessor());
    LLVMValueRef instr = builder.buildIf(condition, thenBlock, elseBlock);
    int trueProbability = expandProbability(i.getTrueSuccessorProbability());
    int falseProbability = expandProbability(1 - i.getTrueSuccessorProbability());
    LLVMValueRef branchWeights = builder.branchWeights(builder.constantInt(trueProbability), builder.constantInt(falseProbability));
    builder.setMetadata(instr, "prof", branchWeights);
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) Safepoint(com.oracle.svm.core.thread.Safepoint)

Example 5 with LLVMBasicBlockRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef in project graal by oracle.

the class NodeLLVMBuilder method emitSwitch.

@Override
public void emitSwitch(SwitchNode switchNode) {
    if (switchNode instanceof TypeSwitchNode) {
        emitTypeSwitch((TypeSwitchNode) switchNode);
        return;
    }
    int numCases = switchNode.keyCount();
    LLVMValueRef[] values = new LLVMValueRef[numCases];
    LLVMBasicBlockRef[] blocks = new LLVMBasicBlockRef[numCases];
    LLVMValueRef[] weights = new LLVMValueRef[numCases + 1];
    int defaultProbability = expandProbability(switchNode.probability(switchNode.defaultSuccessor()));
    weights[0] = builder.constantInt(defaultProbability);
    for (int i = 0; i < numCases; ++i) {
        JavaConstant key = (JavaConstant) switchNode.keyAt(i);
        values[i] = builder.constantInt(key.asInt());
        blocks[i] = gen.getBlock(switchNode.keySuccessor(i));
        int keyProbability = expandProbability(switchNode.probability(switchNode.keySuccessor(i)));
        weights[i + 1] = builder.constantInt(keyProbability);
    }
    LLVMValueRef switchInstr = builder.buildSwitch(llvmOperand(switchNode.value()), gen.getBlock(switchNode.defaultSuccessor()), values, blocks);
    LLVMValueRef branchWeights = builder.branchWeights(weights);
    builder.setMetadata(switchInstr, "prof", branchWeights);
}
Also used : TypeSwitchNode(org.graalvm.compiler.nodes.java.TypeSwitchNode) LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) JavaConstant(jdk.vm.ci.meta.JavaConstant) Safepoint(com.oracle.svm.core.thread.Safepoint)

Aggregations

LLVMBasicBlockRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef)20 LLVMValueRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)17 Safepoint (com.oracle.svm.core.thread.Safepoint)4 LLVMTypeRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)3 SpecialRegister (com.oracle.svm.core.graal.llvm.LLVMGenerator.SpecialRegister)2 InlineAssemblyConstraint (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)2 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)2 ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)2 Block (org.graalvm.compiler.nodes.cfg.Block)2 ForeignCallNode (org.graalvm.compiler.nodes.extended.ForeignCallNode)2 ForeignCallWithExceptionNode (org.graalvm.compiler.nodes.extended.ForeignCallWithExceptionNode)2 TypeSwitchNode (org.graalvm.compiler.nodes.java.TypeSwitchNode)2 LLVMAddressValue (com.oracle.svm.core.graal.llvm.lowering.LLVMAddressLowering.LLVMAddressValue)1 LLVMIRBuilder (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder)1 LLVMPendingSpecialRegisterRead (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMPendingSpecialRegisterRead)1 CGlobalDataLoadAddressNode (com.oracle.svm.core.graal.nodes.CGlobalDataLoadAddressNode)1 SafepointCheckNode (com.oracle.svm.core.nodes.SafepointCheckNode)1 ArrayList (java.util.ArrayList)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1