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);
}
}
Aggregations