Search in sources :

Example 1 with LLVMValueRef

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

the class LLVMGenerator method emitConstant.

/* Constants */
@Override
public Value emitConstant(LIRKind kind, Constant constant) {
    boolean uncompressedObject = isUncompressedObjectKind(kind);
    LLVMTypeRef actualType = uncompressedObject ? builder.objectType(true) : ((LLVMKind) kind.getPlatformKind()).get();
    LLVMValueRef value = emitLLVMConstant(actualType, (JavaConstant) constant);
    Value val = new LLVMConstant(value, constant);
    return uncompressedObject ? emitUncompress(val, ReferenceAccess.singleton().getCompressEncoding(), false) : val;
}
Also used : Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) RegisterValue(jdk.vm.ci.code.RegisterValue) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef) LLVMConstant(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMConstant)

Example 2 with LLVMValueRef

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

the class LLVMGenerator method buildStatepointInvoke.

LLVMValueRef buildStatepointInvoke(LLVMValueRef callee, boolean nativeABI, LLVMBasicBlockRef successor, LLVMBasicBlockRef handler, long statepointId, LLVMValueRef... args) {
    LLVMBasicBlockRef successorBlock;
    LLVMBasicBlockRef handlerBlock;
    if (!nativeABI) {
        successorBlock = builder.appendBasicBlock(currentBlock.toString() + "_invoke_successor");
        handlerBlock = builder.appendBasicBlock(currentBlock.toString() + "_invoke_handler");
        splitBlockEndMap.put(currentBlock, successorBlock);
    } else {
        successorBlock = successor;
        handlerBlock = handler;
    }
    LLVMValueRef result = builder.buildInvoke(callee, successorBlock, handlerBlock, args);
    builder.setCallSiteAttribute(result, Attribute.StatepointID, Long.toString(statepointId));
    if (!nativeABI) {
        builder.positionAtEnd(handlerBlock);
        builder.buildLandingPad();
        for (SpecialRegister reg : SpecialRegister.registers()) {
            setHandlerSpecialRegisterValue(reg, getSpecialRegisterValue(reg));
        }
        builder.buildBranch(handler);
        builder.positionAtEnd(successorBlock);
        int numReturnValues = LLVMIRBuilder.countElementTypes(typeOf(result));
        for (SpecialRegister reg : SpecialRegister.registers()) {
            assert reg.index < numReturnValues;
            setSpecialRegisterValue(reg, builder.buildExtractValue(result, reg.index));
        }
        result = numReturnValues > SpecialRegister.count() ? builder.buildExtractValue(result, SpecialRegister.count()) : result;
        builder.buildBranch(successor);
    }
    return result;
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) InlineAssemblyConstraint(com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)

Example 3 with LLVMValueRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef 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 4 with LLVMValueRef

use of com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef 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 5 with LLVMValueRef

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

the class LLVMGenerator method buildInlineGetRegister.

private LLVMValueRef buildInlineGetRegister(String registerName) {
    LLVMTypeRef inlineAsmType = builder.functionType(builder.rawPointerType());
    String asmSnippet = LLVMTargetSpecific.get().getRegisterInlineAsm(registerName);
    InlineAssemblyConstraint outputConstraint = new InlineAssemblyConstraint(Type.Output, Location.namedRegister(LLVMTargetSpecific.get().getLLVMRegisterName(registerName)));
    LLVMValueRef getRegister = builder.buildInlineAsm(inlineAsmType, asmSnippet, false, false, outputConstraint);
    LLVMValueRef call = builder.buildCall(getRegister);
    builder.setCallSiteAttribute(call, Attribute.GCLeafFunction);
    return call;
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) InlineAssemblyConstraint(com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)

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