Search in sources :

Example 1 with LLVMVariable

use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.

the class LLVMGenerator method emitLoadConstant.

@Override
public AllocatableValue emitLoadConstant(ValueKind<?> kind, Constant constant) {
    LLVMValueRef value = builder.buildLoad(getLLVMPlaceholderForConstant(constant), ((LLVMKind) kind.getPlatformKind()).get());
    AllocatableValue rawConstant = new LLVMVariable(value);
    if (SubstrateOptions.SpawnIsolates.getValue() && ((LIRKind) kind).isReference(0) && !((LIRKind) kind).isCompressedReference(0)) {
        return (AllocatableValue) emitUncompress(rawConstant, ReferenceAccess.singleton().getCompressEncoding(), false);
    }
    return rawConstant;
}
Also used : LLVMVariable(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) LIRKind(org.graalvm.compiler.core.common.LIRKind) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 2 with LLVMVariable

use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.

the class LLVMGenerator method emitLogicCompareAndSwap.

@Override
public Variable emitLogicCompareAndSwap(LIRKind accessKind, Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue, MemoryOrderMode memoryOrder) {
    LLVMValueRef success = buildCmpxchg(getVal(address), getVal(expectedValue), getVal(newValue), memoryOrder, false);
    LLVMValueRef result = builder.buildSelect(success, getVal(trueValue), getVal(falseValue));
    return new LLVMVariable(result);
}
Also used : LLVMVariable(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Example 3 with LLVMVariable

use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable in project graal by oracle.

the class LLVMGenerator method emitConditionalMove.

@Override
public Variable emitConditionalMove(PlatformKind cmpKind, Value leftVal, Value rightVal, Condition cond, boolean unorderedIsTrue, Value trueVal, Value falseVal) {
    LLVMValueRef condition = builder.buildCompare(cond, getVal(leftVal), getVal(rightVal), unorderedIsTrue);
    LLVMValueRef select;
    LLVMValueRef trueValue = getVal(trueVal);
    LLVMValueRef falseValue = getVal(falseVal);
    if (LLVMVersionChecker.useExplicitSelects() && LLVMIRBuilder.isObjectType(typeOf(trueValue))) {
        select = buildExplicitSelect(condition, trueValue, falseValue);
    } else {
        select = builder.buildSelect(condition, trueValue, 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 4 with LLVMVariable

use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable 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 5 with LLVMVariable

use of com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable 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)

Aggregations

LLVMVariable (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable)9 LLVMValueRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)9 LLVMKind (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMKind)2 LLVMTypeRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)2 SubstrateCallingConvention (com.oracle.svm.core.graal.code.SubstrateCallingConvention)1 SubstrateCallingConventionType (com.oracle.svm.core.graal.code.SubstrateCallingConventionType)1 LLVMAddressValue (com.oracle.svm.core.graal.llvm.lowering.LLVMAddressLowering.LLVMAddressValue)1 LLVMPendingSpecialRegisterRead (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMPendingSpecialRegisterRead)1 LLVMValueWrapper (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMValueWrapper)1 CallingConvention (jdk.vm.ci.code.CallingConvention)1 DebugInfo (jdk.vm.ci.code.DebugInfo)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 PlatformKind (jdk.vm.ci.meta.PlatformKind)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 Value (jdk.vm.ci.meta.Value)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1 ConstantValue (org.graalvm.compiler.lir.ConstantValue)1