Search in sources :

Example 26 with LLVMValueRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.

the class LLVMHelperFunctions method buildObjectsCmpxchgFunction.

private LLVMValueRef buildObjectsCmpxchgFunction(boolean compressed, MemoryOrderMode memoryOrder, boolean returnsValue) {
    String funcName = compressed ? returnsValue ? COMPRESSED_OBJECTS_VALUE_CMPXCHG_FUNCTION_NAME : COMPRESSED_OBJECTS_LOGIC_CMPXCHG_FUNCTION_NAME : returnsValue ? OBJECTS_VALUE_CMPXCHG_FUNCTION_NAME : OBJECTS_LOGIC_CMPXCHG_FUNCTION_NAME;
    LLVMTypeRef exchangeType = builder.objectType(compressed);
    LLVMValueRef func = builder.addFunction(funcName, builder.functionType(returnsValue ? exchangeType : builder.booleanType(), builder.pointerType(exchangeType, true, false), exchangeType, exchangeType));
    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 addr = LLVMIRBuilder.getParam(func, 0);
    LLVMValueRef expected = LLVMIRBuilder.getParam(func, 1);
    LLVMValueRef newVal = LLVMIRBuilder.getParam(func, 2);
    LLVMValueRef result = builder.buildAtomicCmpXchg(addr, expected, newVal, memoryOrder, returnsValue);
    builder.buildRet(result);
    return func;
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)

Example 27 with LLVMValueRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.

the class LLVMUtils method dumpValues.

public static String dumpValues(String prefix, LLVMValueRef... values) {
    StringBuilder builder = new StringBuilder(prefix);
    for (LLVMValueRef value : values) {
        builder.append(" ");
        builder.append(LLVM.LLVMPrintValueToString(value).getString());
    }
    return builder.toString();
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Example 28 with LLVMValueRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.

the class LLVMGenerator method emitIntegerTestMove.

@Override
public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
    LLVMValueRef and = builder.buildAnd(getVal(left), getVal(right));
    LLVMValueRef isNull = builder.buildIsNull(and);
    LLVMValueRef select = builder.buildSelect(isNull, getVal(trueValue), getVal(falseValue));
    return new LLVMVariable(select);
}
Also used : LLVMVariable(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Example 29 with LLVMValueRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.

the class LLVMGenerator method emitForeignCall.

public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, LLVMBasicBlockRef successor, LLVMBasicBlockRef handler, Value... arguments) {
    ResolvedJavaMethod targetMethod = ((SnippetRuntime.SubstrateForeignCallDescriptor) linkage.getDescriptor()).findMethod(getMetaAccess());
    DebugInfo debugInfo = null;
    if (state != null) {
        state.initDebugInfo(null, false);
        debugInfo = state.debugInfo();
    }
    long patchpointId = nextPatchpointId.getAndIncrement();
    compilationResult.recordCall(NumUtil.safeToInt(patchpointId), 0, targetMethod, debugInfo, true);
    LLVMValueRef callee = getFunction(targetMethod);
    LLVMValueRef[] args = Arrays.stream(arguments).map(LLVMUtils::getVal).toArray(LLVMValueRef[]::new);
    CallingConvention.Type callType = ((SubstrateCallingConvention) linkage.getOutgoingCallingConvention()).getType();
    LLVMValueRef[] callArguments = getCallArguments(args, callType);
    LLVMValueRef call;
    boolean nativeABI = ((SubstrateCallingConventionType) callType).nativeABI();
    if (successor == null && handler == null) {
        call = buildStatepointCall(callee, nativeABI, patchpointId, callArguments);
    } else {
        assert successor != null && handler != null;
        call = buildStatepointInvoke(callee, nativeABI, successor, handler, patchpointId, callArguments);
    }
    return (isVoidReturnType(getLLVMFunctionReturnType(targetMethod, false))) ? null : new LLVMVariable(call);
}
Also used : SubstrateCallingConvention(com.oracle.svm.core.graal.code.SubstrateCallingConvention) CallingConvention(jdk.vm.ci.code.CallingConvention) LLVMVariable(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable) SubstrateCallingConventionType(com.oracle.svm.core.graal.code.SubstrateCallingConventionType) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) DebugInfo(jdk.vm.ci.code.DebugInfo) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) SubstrateCallingConvention(com.oracle.svm.core.graal.code.SubstrateCallingConvention)

Example 30 with LLVMValueRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef in project graal by oracle.

the class LLVMGenerator method emitReadCallerStackPointer.

@Override
public Value emitReadCallerStackPointer(Stamp wordStamp) {
    LLVMValueRef basePointer = builder.buildFrameAddress(builder.constantInt(0));
    LLVMValueRef callerSP = builder.buildAdd(builder.buildPtrToInt(basePointer), builder.constantLong(16));
    return new LLVMVariable(callerSP);
}
Also used : LLVMVariable(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable) 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