use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method getExternalObject.
/*
* External globals are globals which are not created by LLVM but need to be accessed from the
* code, while unique globals are values created by the LLVM backend, potentially in multiple
* functions, and are then conflated by the LLVM linker.
*/
public LLVMValueRef getExternalObject(String name, boolean compressed) {
LLVMValueRef val = getGlobal(name);
if (val == null) {
val = LLVM.LLVMAddGlobalInAddressSpace(module, objectType(compressed), name, pointerAddressSpace(true, false));
setLinkage(val, LinkageType.External);
}
return val;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMIRBuilder method buildLandingPad.
public void buildLandingPad() {
LLVMValueRef landingPad = LLVM.LLVMBuildLandingPad(builder, tokenType(), null, 1, DEFAULT_INSTR_NAME);
LLVM.LLVMAddClause(landingPad, constantNull(rawPointerType()));
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMHelperFunctions method buildCompressFunction.
private LLVMValueRef buildCompressFunction(boolean nonNull, int shift) {
String funcName = COMPRESS_FUNCTION_BASE_NAME + (nonNull ? "_nonNull" : "") + "_" + shift;
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(builder.objectType(true), builder.objectType(false), 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 uncompressed = builder.buildPtrToInt(LLVMIRBuilder.getParam(func, 0));
LLVMValueRef heapBase = LLVMIRBuilder.getParam(func, 1);
LLVMValueRef compressed = builder.buildSub(uncompressed, heapBase);
if (!nonNull) {
LLVMValueRef isNull = builder.buildIsNull(uncompressed);
compressed = builder.buildSelect(isNull, uncompressed, compressed);
}
if (shift != 0) {
compressed = builder.buildShr(compressed, builder.constantInt(shift));
}
compressed = builder.buildLLVMIntToPtr(compressed, builder.objectType(true));
builder.buildRet(compressed);
return func;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMHelperFunctions method buildIntToObjectFunction.
private LLVMValueRef buildIntToObjectFunction(boolean compressed) {
String funcName = compressed ? INT_TO_COMPRESSED_OBJECT_FUNCTION_NAME : INT_TO_OBJECT_FUNCTION_NAME;
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(builder.objectType(compressed), 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 arg = LLVMIRBuilder.getParam(func, 0);
LLVMValueRef ref = builder.buildLLVMIntToPtr(arg, builder.objectType(compressed));
builder.buildRet(ref);
return func;
}
use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.
the class LLVMHelperFunctions method buildLoadObjectFromUntrackedPointerFunction.
private LLVMValueRef buildLoadObjectFromUntrackedPointerFunction(boolean compressed) {
String funcName = compressed ? LOAD_COMPRESSED_OBJECT_FROM_UNTRACKED_POINTER_FUNCTION_NAME : LOAD_OBJECT_FROM_UNTRACKED_POINTER_FUNCTION_NAME;
LLVMValueRef func = builder.addFunction(funcName, builder.functionType(builder.objectType(compressed), builder.rawPointerType()));
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 castedAddress = builder.buildBitcast(address, builder.pointerType(builder.objectType(compressed), false, false));
LLVMValueRef loadedValue = builder.buildLoad(castedAddress);
builder.buildRet(loadedValue);
return func;
}
Aggregations