use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMGenerator method emitConstant.
/* Constants */
@Override
public Value emitConstant(LIRKind kind, Constant constant) {
boolean uncompressedObject = isUncompressedObjectKind(kind);
LLVMTypeRef actualType = uncompressedObject ? builder.objectType(true) : ((LLVMKind) kind.getPlatformKind()).get();
LLVMValueRef value = emitLLVMConstant(actualType, (JavaConstant) constant);
Value val = new LLVMConstant(value, constant);
return uncompressedObject ? emitUncompress(val, ReferenceAccess.singleton().getCompressEncoding(), false) : val;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef 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;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMGenerator method emitLoadConstant.
@Override
public AllocatableValue emitLoadConstant(ValueKind<?> kind, Constant constant) {
LLVMValueRef value = builder.buildLoad(getLLVMPlaceholderForConstant(constant), ((LLVMKind) kind.getPlatformKind()).get());
AllocatableValue rawConstant = new LLVMVariable(value);
if (SubstrateOptions.SpawnIsolates.getValue() && ((LIRKind) kind).isReference(0) && !((LIRKind) kind).isCompressedReference(0)) {
return (AllocatableValue) emitUncompress(rawConstant, ReferenceAccess.singleton().getCompressEncoding(), false);
}
return rawConstant;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMGenerator method emitLogicCompareAndSwap.
@Override
public Variable emitLogicCompareAndSwap(LIRKind accessKind, Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue, MemoryOrderMode memoryOrder) {
LLVMValueRef success = buildCmpxchg(getVal(address), getVal(expectedValue), getVal(newValue), memoryOrder, false);
LLVMValueRef result = builder.buildSelect(success, getVal(trueValue), getVal(falseValue));
return new LLVMVariable(result);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMGenerator method buildInlineGetRegister.
private LLVMValueRef buildInlineGetRegister(String registerName) {
LLVMTypeRef inlineAsmType = builder.functionType(builder.rawPointerType());
String asmSnippet = LLVMTargetSpecific.get().getRegisterInlineAsm(registerName);
InlineAssemblyConstraint outputConstraint = new InlineAssemblyConstraint(Type.Output, Location.namedRegister(LLVMTargetSpecific.get().getLLVMRegisterName(registerName)));
LLVMValueRef getRegister = builder.buildInlineAsm(inlineAsmType, asmSnippet, false, false, outputConstraint);
LLVMValueRef call = builder.buildCall(getRegister);
builder.setCallSiteAttribute(call, Attribute.GCLeafFunction);
return call;
}
Aggregations