Search in sources :

Example 41 with LLVMValueRef

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

Example 42 with LLVMValueRef

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

Example 43 with LLVMValueRef

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

Example 44 with LLVMValueRef

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

Example 45 with LLVMValueRef

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);
}
Also used : 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