use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method buildAtomicCmpXchg.
LLVMValueRef buildAtomicCmpXchg(LLVMValueRef addr, LLVMValueRef expected, LLVMValueRef newVal, MemoryOrderMode memoryOrder, boolean returnValue) {
boolean singleThread = !SubstrateOptions.MultiThreaded.getValue();
LLVMValueRef cas = LLVM.LLVMBuildAtomicCmpXchg(builder, addr, expected, newVal, atomicOrdering(memoryOrder, true), atomicOrdering(memoryOrder, false), singleThread ? TRUE : FALSE);
return buildExtractValue(cas, returnValue ? LLVM_CMPXCHG_VALUE : LLVM_CMPXCHG_SUCCESS);
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method getUniqueGlobal.
public LLVMValueRef getUniqueGlobal(String name, LLVMTypeRef type, boolean zeroInitialized) {
LLVMValueRef global = getGlobal(name);
if (global == null) {
global = LLVM.LLVMAddGlobalInAddressSpace(module, type, name, pointerAddressSpace(isObjectType(type), false));
if (zeroInitialized) {
setInitializer(global, LLVM.LLVMConstNull(type));
}
setLinkage(global, LinkageType.LinkOnceODR);
}
return global;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMHelperFunctions method buildAtomicObjectXchgFunction.
private LLVMValueRef buildAtomicObjectXchgFunction(boolean compressed) {
String funcName = compressed ? ATOMIC_COMPRESSED_OBJECT_XCHG_FUNCTION_NAME : ATOMIC_OBJECT_XCHG_FUNCTION_NAME;
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(builder.objectType(compressed), builder.objectType(false), builder.objectType(compressed)));
LLVMIRBuilder.setLinkage(func, LinkageType.LinkOnce);
builder.setFunctionAttribute(func, Attribute.AlwaysInline);
builder.setFunctionAttribute(func, Attribute.GCLeafFunction);
LLVMBasicBlockRef block = builder.appendBasicBlock(func, "main");
builder.positionAtEnd(block);
LLVMValueRef address = LLVMIRBuilder.getParam(func, 0);
LLVMValueRef value = LLVMIRBuilder.getParam(func, 1);
LLVMValueRef castedValue = builder.buildPtrToInt(value);
LLVMValueRef ret = builder.buildLLVMAtomicXchg(address, castedValue);
ret = builder.buildLLVMIntToPtr(ret, builder.objectType(compressed));
builder.buildRet(ret);
return func;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMHelperFunctions method buildUncompressFunction.
private LLVMValueRef buildUncompressFunction(boolean nonNull, int shift) {
String funcName = UNCOMPRESS_FUNCTION_BASE_NAME + (nonNull ? "_nonNull" : "") + "_" + shift;
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(builder.objectType(false), builder.objectType(true), builder.wordType()));
LLVMIRBuilder.setLinkage(func, LinkageType.LinkOnce);
builder.setFunctionAttribute(func, Attribute.AlwaysInline);
builder.setFunctionAttribute(func, Attribute.GCLeafFunction);
LLVMBasicBlockRef block = builder.appendBasicBlock(func, "main");
builder.positionAtEnd(block);
LLVMValueRef compressed = builder.buildPtrToInt(LLVMIRBuilder.getParam(func, 0));
LLVMValueRef heapBase = LLVMIRBuilder.getParam(func, 1);
if (shift != 0) {
compressed = builder.buildShl(compressed, builder.constantInt(shift));
}
LLVMValueRef uncompressed = builder.buildAdd(compressed, heapBase);
if (!nonNull) {
LLVMValueRef isNull = builder.buildIsNull(compressed);
uncompressed = builder.buildSelect(isNull, compressed, uncompressed);
}
uncompressed = builder.buildLLVMIntToPtr(uncompressed, builder.objectType(false));
builder.buildRet(uncompressed);
return func;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method buildVolatileStore.
public void buildVolatileStore(LLVMValueRef value, LLVMValueRef address, int alignment) {
LLVMValueRef store = LLVM.LLVMBuildStore(builder, value, address);
LLVM.LLVMSetOrdering(store, LLVM.LLVMAtomicOrderingRelease);
LLVM.LLVMSetAlignment(store, alignment);
}
Aggregations