Search in sources :

Example 16 with LLVMBasicBlockRef

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

the class LLVMGenerator method appendBasicBlock.

/* Basic blocks */
void appendBasicBlock(Block block) {
    LLVMBasicBlockRef basicBlock = builder.appendBasicBlock(block.toString());
    basicBlockMap.put(block.getBeginNode(), basicBlock);
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef)

Example 17 with LLVMBasicBlockRef

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

the class NodeLLVMBuilder method emitTypeSwitch.

private void emitTypeSwitch(TypeSwitchNode switchNode) {
    int numCases = switchNode.keyCount();
    LLVMValueRef value = llvmOperand(switchNode.value());
    LLVMBasicBlockRef defaultSuccessor = gen.getBlock(switchNode.defaultSuccessor());
    switch(numCases) {
        case 0:
            builder.buildBranch(defaultSuccessor);
            break;
        case 1:
            LLVMValueRef hub = gen.emitLLVMConstant(builder.objectType(false), (JavaConstant) switchNode.keyAt(0));
            LLVMValueRef cond = builder.buildCompare(Condition.EQ, value, hub, false);
            builder.buildIf(cond, gen.getBlock(switchNode.keySuccessor(0)), defaultSuccessor);
            break;
        default:
            throw unimplemented();
    }
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef) Safepoint(com.oracle.svm.core.thread.Safepoint)

Example 18 with LLVMBasicBlockRef

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

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

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

the class LLVMIRBuilder method positionAtStart.

public void positionAtStart() {
    LLVMBasicBlockRef firstBlock = LLVM.LLVMGetFirstBasicBlock(function);
    LLVMValueRef firstInstruction = LLVM.LLVMGetFirstInstruction(firstBlock);
    if (firstInstruction != null) {
        LLVM.LLVMPositionBuilderBefore(builder, firstInstruction);
    }
}
Also used : LLVMBasicBlockRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef) LLVMValueRef(com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)

Aggregations

LLVMBasicBlockRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMBasicBlockRef)20 LLVMValueRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMValueRef)17 Safepoint (com.oracle.svm.core.thread.Safepoint)4 LLVMTypeRef (com.oracle.svm.shadowed.org.bytedeco.llvm.LLVM.LLVMTypeRef)3 SpecialRegister (com.oracle.svm.core.graal.llvm.LLVMGenerator.SpecialRegister)2 InlineAssemblyConstraint (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder.InlineAssemblyConstraint)2 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)2 ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)2 Block (org.graalvm.compiler.nodes.cfg.Block)2 ForeignCallNode (org.graalvm.compiler.nodes.extended.ForeignCallNode)2 ForeignCallWithExceptionNode (org.graalvm.compiler.nodes.extended.ForeignCallWithExceptionNode)2 TypeSwitchNode (org.graalvm.compiler.nodes.java.TypeSwitchNode)2 LLVMAddressValue (com.oracle.svm.core.graal.llvm.lowering.LLVMAddressLowering.LLVMAddressValue)1 LLVMIRBuilder (com.oracle.svm.core.graal.llvm.util.LLVMIRBuilder)1 LLVMPendingSpecialRegisterRead (com.oracle.svm.core.graal.llvm.util.LLVMUtils.LLVMPendingSpecialRegisterRead)1 CGlobalDataLoadAddressNode (com.oracle.svm.core.graal.nodes.CGlobalDataLoadAddressNode)1 SafepointCheckNode (com.oracle.svm.core.nodes.SafepointCheckNode)1 ArrayList (java.util.ArrayList)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1