use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method buildPhi.
public LLVMValueRef buildPhi(LLVMTypeRef phiType, LLVMValueRef[] incomingValues, LLVMBasicBlockRef[] incomingBlocks) {
LLVMValueRef phi = LLVM.LLVMBuildPhi(builder, phiType, DEFAULT_INSTR_NAME);
addIncoming(phi, incomingValues, incomingBlocks);
return phi;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method buildArrayAlloca.
public LLVMValueRef buildArrayAlloca(LLVMTypeRef type, int slots, int alignmentInBytes) {
LLVMValueRef alloca = LLVM.LLVMBuildArrayAlloca(builder, type, constantInt(slots), DEFAULT_INSTR_NAME);
LLVM.LLVMSetAlignment(alloca, alignmentInBytes);
return alloca;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method buildAtomicRMW.
private LLVMValueRef buildAtomicRMW(int operation, LLVMValueRef address, LLVMValueRef value) {
LLVMTypeRef valueType = LLVM.LLVMTypeOf(value);
LLVMValueRef castedAddress = buildBitcast(address, pointerType(valueType, isObjectType(typeOf(address)), false));
boolean singleThread = !SubstrateOptions.MultiThreaded.getValue();
return LLVM.LLVMBuildAtomicRMW(builder, operation, castedAddress, value, LLVM.LLVMAtomicOrderingMonotonic, singleThread ? TRUE : FALSE);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method positionAtStart.
public void positionAtStart() {
LLVMBasicBlockRef firstBlock = LLVM.LLVMGetFirstBasicBlock(function);
LLVMValueRef firstInstruction = LLVM.LLVMGetFirstInstruction(firstBlock);
if (firstInstruction != null) {
LLVM.LLVMPositionBuilderBefore(builder, firstInstruction);
}
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class NodeLLVMBuilder method emitCall.
private LLVMValueRef emitCall(Invoke invoke, LoweredCallTargetNode callTarget, LLVMValueRef callee, long patchpointId, LLVMValueRef... args) {
boolean nativeABI = ((SubstrateCallingConventionType) callTarget.callType()).nativeABI();
if (!SubstrateBackend.hasJavaFrameAnchor(callTarget)) {
assert SubstrateBackend.getNewThreadStatus(callTarget) == VMThreads.StatusSupport.STATUS_ILLEGAL;
return emitCallInstruction(invoke, nativeABI, callee, patchpointId, args);
}
assert VMThreads.StatusSupport.isValidStatus(SubstrateBackend.getNewThreadStatus(callTarget));
LLVMValueRef anchor = llvmOperand(SubstrateBackend.getJavaFrameAnchor(callTarget));
anchor = builder.buildIntToPtr(anchor, builder.rawPointerType());
LLVMValueRef lastSPAddr = builder.buildGEP(anchor, builder.constantInt(runtimeConfiguration.getJavaFrameAnchorLastSPOffset()));
Register stackPointer = gen.getRegisterConfig().getFrameRegister();
builder.buildStore(builder.buildReadRegister(builder.register(stackPointer.name)), builder.buildBitcast(lastSPAddr, builder.pointerType(builder.wordType())));
if (SubstrateOptions.MultiThreaded.getValue()) {
LLVMValueRef threadLocalArea = gen.getSpecialRegisterValue(SpecialRegister.ThreadPointer);
LLVMValueRef statusIndex = builder.constantInt(runtimeConfiguration.getVMThreadStatusOffset());
LLVMValueRef statusAddress = builder.buildGEP(builder.buildIntToPtr(threadLocalArea, builder.rawPointerType()), statusIndex);
LLVMValueRef newThreadStatus = builder.constantInt(SubstrateBackend.getNewThreadStatus(callTarget));
builder.buildVolatileStore(newThreadStatus, builder.buildBitcast(statusAddress, builder.pointerType(builder.intType())), Integer.BYTES);
}
LLVMValueRef wrapper = gen.createJNIWrapper(callee, nativeABI, args.length, runtimeConfiguration.getJavaFrameAnchorLastIPOffset());
LLVMValueRef[] newArgs = new LLVMValueRef[args.length + 2];
if (!nativeABI) {
System.arraycopy(args, 0, newArgs, 0, SpecialRegister.count());
newArgs[SpecialRegister.count() + 0] = anchor;
newArgs[SpecialRegister.count() + 1] = callee;
System.arraycopy(args, SpecialRegister.count(), newArgs, 2 + SpecialRegister.count(), args.length - SpecialRegister.count());
} else {
newArgs[0] = anchor;
newArgs[1] = callee;
System.arraycopy(args, 0, newArgs, 2, args.length);
}
return emitCallInstruction(invoke, nativeABI, wrapper, patchpointId, newArgs);
}
Aggregations