Search in sources :

Example 51 with LLVMValueRef

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

the class NodeLLVMBuilder method emitInvoke.

/* Invoke */
@Override
public void emitInvoke(Invoke i) {
    LoweredCallTargetNode callTarget = (LoweredCallTargetNode) i.callTarget();
    ResolvedJavaMethod targetMethod = callTarget.targetMethod();
    NodeInputList<ValueNode> arguments = callTarget.arguments();
    LIRFrameState state = state(i);
    state.initDebugInfo(null, false);
    DebugInfo debugInfo = state.debugInfo();
    LLVMValueRef callee;
    boolean isVoid;
    LLVMValueRef[] args = getCallArguments(arguments, callTarget.callType());
    long patchpointId = LLVMGenerator.nextPatchpointId.getAndIncrement();
    if (callTarget instanceof DirectCallTargetNode) {
        callee = gen.getFunction(targetMethod);
        isVoid = gen.isVoidReturnType(gen.getLLVMFunctionReturnType(targetMethod, false));
        gen.getCompilationResult().recordCall(NumUtil.safeToInt(patchpointId), 0, targetMethod, debugInfo, true);
    } else if (callTarget instanceof IndirectCallTargetNode) {
        LLVMValueRef computedAddress = llvmOperand(((IndirectCallTargetNode) callTarget).computedAddress());
        LLVMTypeRef functionType;
        if (targetMethod != null) {
            functionType = gen.getLLVMFunctionPointerType(targetMethod);
            isVoid = gen.isVoidReturnType(gen.getLLVMFunctionReturnType(targetMethod, false));
        } else {
            LLVMTypeRef returnType = getUnknownCallReturnType(callTarget);
            isVoid = gen.isVoidReturnType(returnType);
            LLVMTypeRef[] argTypes = getUnknownCallArgumentTypes(callTarget);
            assert args.length == argTypes.length;
            functionType = builder.functionPointerType(returnType, argTypes);
        }
        if (LLVMIRBuilder.isObjectType(LLVMIRBuilder.typeOf(computedAddress))) {
            callee = builder.buildBitcast(builder.buildAddrSpaceCast(computedAddress, builder.rawPointerType()), functionType);
        } else {
            callee = builder.buildIntToPtr(computedAddress, functionType);
        }
        gen.getCompilationResult().recordCall(NumUtil.safeToInt(patchpointId), 0, targetMethod, debugInfo, false);
        gen.getDebugInfoPrinter().printIndirectCall(targetMethod, callee);
    } else {
        throw shouldNotReachHere();
    }
    LLVMValueRef call = emitCall(i, callTarget, callee, patchpointId, args);
    if (!isVoid) {
        setResult(i.asNode(), call);
    }
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) DirectCallTargetNode(org.graalvm.compiler.nodes.DirectCallTargetNode) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) IndirectCallTargetNode(org.graalvm.compiler.nodes.IndirectCallTargetNode) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef) ValueNode(org.graalvm.compiler.nodes.ValueNode) LoweredCallTargetNode(org.graalvm.compiler.nodes.LoweredCallTargetNode) DebugInfo(jdk.vm.ci.code.DebugInfo) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

LLVMValueRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)51 LLVMBasicBlockRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef)17 LLVMTypeRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)14 LLVMVariable (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable)9 InlineAssemblyConstraint (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)7 Safepoint (com.oracle.svm.core.thread.Safepoint)4 SpecialRegister (com.oracle.svm.core.graal.llvm.LLVMGenerator.SpecialRegister)3 SubstrateCallingConventionType (com.oracle.svm.core.graal.code.SubstrateCallingConventionType)2 LLVMKind (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMKind)2 LLVMPendingSpecialRegisterRead (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMPendingSpecialRegisterRead)2 SafepointCheckNode (com.oracle.svm.core.nodes.SafepointCheckNode)2 DebugInfo (jdk.vm.ci.code.DebugInfo)2 RegisterValue (jdk.vm.ci.code.RegisterValue)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 Value (jdk.vm.ci.meta.Value)2 DirectCallTargetNode (org.graalvm.compiler.nodes.DirectCallTargetNode)2 IndirectCallTargetNode (org.graalvm.compiler.nodes.IndirectCallTargetNode)2 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)2 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)2