Search in sources :

Example 21 with LLVMValueRef

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;
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Example 22 with LLVMValueRef

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()));
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Example 23 with LLVMValueRef

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;
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Example 24 with LLVMValueRef

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;
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Example 25 with LLVMValueRef

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;
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Aggregations

LLVMValueRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)51 LLVMBasicBlockRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef)17 LLVMTypeRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)14 LLVMVariable (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable)9 InlineAssemblyConstraint (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)7 Safepoint (com.oracle.svm.core.thread.Safepoint)4 SpecialRegister (com.oracle.svm.core.graal.llvm.LLVMGenerator.SpecialRegister)3 SubstrateCallingConventionType (com.oracle.svm.core.graal.code.SubstrateCallingConventionType)2 LLVMKind (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMKind)2 LLVMPendingSpecialRegisterRead (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMPendingSpecialRegisterRead)2 SafepointCheckNode (com.oracle.svm.core.nodes.SafepointCheckNode)2 DebugInfo (jdk.vm.ci.code.DebugInfo)2 RegisterValue (jdk.vm.ci.code.RegisterValue)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 Value (jdk.vm.ci.meta.Value)2 DirectCallTargetNode (org.graalvm.compiler.nodes.DirectCallTargetNode)2 IndirectCallTargetNode (org.graalvm.compiler.nodes.IndirectCallTargetNode)2 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)2 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)2