Search in sources :

Example 36 with LLVMValueRef

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

the class NodeLLVMBuilder method setResult.

@Override
public Value setResult(ValueNode node, Value operand) {
    LLVMValueWrapper llvmOperand;
    boolean typeOverride = false;
    if (operand instanceof LLVMValueWrapper) {
        llvmOperand = (LLVMValueWrapper) operand;
    } else if (operand instanceof ConstantValue) {
        /* This only happens when emitting null or illegal object constants */
        PlatformKind kind = operand.getPlatformKind();
        if (kind instanceof LLVMKind) {
            llvmOperand = new LLVMVariable(builder.constantNull(((LLVMKind) kind).get()));
        } else {
            assert kind == ValueKind.Illegal.getPlatformKind();
            llvmOperand = new LLVMVariable(builder.getUndef());
        }
    } else if (operand instanceof LLVMAddressValue) {
        LLVMAddressValue addressValue = (LLVMAddressValue) operand;
        Value wrappedBase = addressValue.getBase();
        Value index = addressValue.getIndex();
        if (wrappedBase instanceof LLVMPendingSpecialRegisterRead) {
            LLVMPendingSpecialRegisterRead pendingRead = (LLVMPendingSpecialRegisterRead) wrappedBase;
            if (index != null && index != Value.ILLEGAL) {
                pendingRead = new LLVMPendingSpecialRegisterRead(pendingRead, LLVMUtils.getVal(addressValue.getIndex()));
            }
            llvmOperand = pendingRead;
        } else {
            LLVMValueRef base = LLVMUtils.getVal(wrappedBase);
            LLVMTypeRef baseType = LLVMIRBuilder.typeOf(base);
            if (LLVMIRBuilder.isWordType(baseType)) {
                base = builder.buildIntToPtr(base, builder.rawPointerType());
            } else if (LLVMIRBuilder.isObjectType(baseType)) {
                typeOverride = true;
            } else {
                throw shouldNotReachHere(LLVMUtils.dumpValues("unsupported base for address", base));
            }
            LLVMValueRef intermediate;
            if (index == null || index == Value.ILLEGAL) {
                intermediate = base;
            } else {
                intermediate = builder.buildGEP(base, LLVMUtils.getVal(index));
            }
            llvmOperand = new LLVMVariable(intermediate);
        }
    } else if (operand instanceof RegisterValue) {
        RegisterValue registerValue = (RegisterValue) operand;
        llvmOperand = (LLVMValueWrapper) gen.emitReadRegister(registerValue.getRegister(), registerValue.getValueKind());
    } else {
        throw shouldNotReachHere("unknown operand: " + operand.toString());
    }
    assert typeOverride || LLVMIRBuilder.compatibleTypes(getLLVMType(node), LLVMIRBuilder.typeOf(llvmOperand.get())) : LLVMUtils.dumpValues("value type doesn't match node stamp (" + node.stamp(NodeView.DEFAULT).toString() + ")", llvmOperand.get());
    gen.getDebugInfoPrinter().setValueName(llvmOperand, node);
    valueMap.put(node, llvmOperand);
    return operand;
}
Also used : LLVMVariable(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable) RegisterValue(jdk.vm.ci.code.RegisterValue) LLVMAddressValue(com.oracle.svm.core.graal.llvm.lowering.LLVMAddressLowering.LLVMAddressValue) LLVMPendingSpecialRegisterRead(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMPendingSpecialRegisterRead) LLVMValueWrapper(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMValueWrapper) ConstantValue(org.graalvm.compiler.lir.ConstantValue) LLVMAddressValue(com.oracle.svm.core.graal.llvm.lowering.LLVMAddressLowering.LLVMAddressValue) Value(jdk.vm.ci.meta.Value) RegisterValue(jdk.vm.ci.code.RegisterValue) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) PlatformKind(jdk.vm.ci.meta.PlatformKind) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef) ConstantValue(org.graalvm.compiler.lir.ConstantValue) LLVMKind(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMKind)

Example 37 with LLVMValueRef

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

the class LLVMGenerator method emitIsNullMove.

Variable emitIsNullMove(Value value, Value trueValue, Value falseValue) {
    LLVMValueRef isNull = builder.buildIsNull(getVal(value));
    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 38 with LLVMValueRef

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

the class LLVMGenerator method emitMove.

@Override
public void emitMove(AllocatableValue dst, Value src) {
    LLVMValueRef source = getVal(src);
    LLVMTypeRef sourceType = typeOf(source);
    LLVMTypeRef destType = ((LLVMKind) dst.getPlatformKind()).get();
    /* Floating word cast */
    if (LLVMIRBuilder.isObjectType(destType) && LLVMIRBuilder.isWordType(sourceType)) {
        source = builder.buildIntToPtr(source, destType);
    } else if (LLVMIRBuilder.isWordType(destType) && LLVMIRBuilder.isObjectType(sourceType)) {
        source = builder.buildPtrToInt(source);
    }
    ((LLVMVariable) dst).set(source);
}
Also used : LLVMVariable(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMVariable) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) LLVMTypeRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef) LLVMKind(com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMKind)

Example 39 with LLVMValueRef

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

the class LLVMGenerator method buildStatepointCall.

LLVMValueRef buildStatepointCall(LLVMValueRef callee, boolean nativeABI, long statepointId, LLVMValueRef... args) {
    LLVMValueRef result;
    result = builder.buildCall(callee, args);
    builder.setCallSiteAttribute(result, Attribute.StatepointID, Long.toString(statepointId));
    if (!nativeABI) {
        for (SpecialRegister reg : SpecialRegister.registers()) {
            setSpecialRegisterValue(reg, builder.buildExtractValue(result, reg.index));
        }
        int numReturnValues = LLVMIRBuilder.countElementTypes(typeOf(result));
        return numReturnValues > SpecialRegister.count() ? builder.buildExtractValue(result, SpecialRegister.count()) : result;
    }
    return result;
}
Also used : LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) InlineAssemblyConstraint(com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)

Example 40 with LLVMValueRef

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

the class LLVMIRBuilder method getFunction.

public LLVMValueRef getFunction(String name, LLVMTypeRef type) {
    LLVMValueRef func = getNamedFunction(name);
    if (func == null) {
        func = addFunction(name, type);
        setLinkage(func, LinkageType.External);
    }
    return func;
}
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