Search in sources :

Example 11 with LLVMExpressionNode

use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.

the class LLVMBitcodeInstructionVisitor method visitDebugIntrinsic.

private void visitDebugIntrinsic(SymbolImpl value, SourceVariable variable, MDExpression expression, long index, boolean isDeclaration) {
    FrameSlot valueSlot = null;
    if (value instanceof ValueInstruction) {
        valueSlot = frame.findFrameSlot(((ValueInstruction) value).getName());
    } else if (value instanceof FunctionParameter) {
        valueSlot = frame.findFrameSlot(((FunctionParameter) value).getName());
    }
    if (valueSlot != null) {
        final LLVMExpressionNode typeNode = nodeFactory.registerSourceType(valueSlot, variable.getSourceType());
        if (typeNode != null) {
            addInstructionUnchecked(typeNode);
        }
    }
    final LLVMExpressionNode dbgIntrinsic = dbgInfoHandler.handleDebugIntrinsic(value, variable, expression, index, isDeclaration);
    if (dbgIntrinsic != null) {
        addInstructionUnchecked(dbgIntrinsic);
    }
    handleNullerInfo();
}
Also used : DbgValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.DbgValueInstruction) ExtractValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.ExtractValueInstruction) ValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction) InsertValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.InsertValueInstruction) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) FunctionParameter(com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)

Example 12 with LLVMExpressionNode

use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.

the class LLVMBitcodeInstructionVisitor method visit.

@Override
public void visit(BinaryOperationInstruction operation) {
    LLVMExpressionNode lhs = symbols.resolve(operation.getLHS());
    LLVMExpressionNode rhs = symbols.resolve(operation.getRHS());
    final Type type = operation.getType();
    final LLVMArithmeticInstructionType opA = LLVMBitcodeTypeHelper.toArithmeticInstructionType(operation.getOperator());
    if (opA != null) {
        final LLVMExpressionNode result = nodeFactory.createArithmeticOperation(runtime, lhs, rhs, opA, type, operation.getFlags());
        createFrameWrite(result, operation);
        return;
    }
    final LLVMLogicalInstructionKind opL = LLVMBitcodeTypeHelper.toLogicalInstructionType(operation.getOperator());
    if (opL != null) {
        final LLVMExpressionNode result = nodeFactory.createLogicalOperation(runtime, lhs, rhs, opL, type, operation.getFlags());
        createFrameWrite(result, operation);
        return;
    }
    throw new RuntimeException("Missed a binary operator");
}
Also used : LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) LLVMConversionType(com.oracle.truffle.llvm.parser.instructions.LLVMConversionType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) LLVMLogicalInstructionKind(com.oracle.truffle.llvm.parser.instructions.LLVMLogicalInstructionKind)

Example 13 with LLVMExpressionNode

use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.

the class LLVMBitcodeInstructionVisitor method visit.

@Override
public void visit(AllocateInstruction allocate) {
    final Type type = allocate.getPointeeType();
    int alignment;
    if (allocate.getAlign() == 0) {
        alignment = runtime.getContext().getByteAlignment(type);
    } else {
        alignment = 1 << (allocate.getAlign() - 1);
    }
    if (alignment == 0) {
        alignment = LLVMStack.NO_ALIGNMENT_REQUIREMENTS;
    }
    final SymbolImpl count = allocate.getCount();
    final LLVMExpressionNode result;
    if (count instanceof NullConstant) {
        result = nodeFactory.createAlloca(runtime, type, alignment);
    } else if (count instanceof IntegerConstant) {
        long numElements = (int) ((IntegerConstant) count).getValue();
        if (numElements == 1) {
            result = nodeFactory.createAlloca(runtime, type, alignment);
        } else {
            assert numElements == (int) numElements;
            ArrayType arrayType = new ArrayType(type, (int) numElements);
            result = nodeFactory.createAlloca(runtime, arrayType, alignment);
        }
    } else {
        LLVMExpressionNode num = symbols.resolve(count);
        result = nodeFactory.createAllocaArray(runtime, type, num, alignment);
    }
    // we never want to step on allocations, only to actual assignments in the source
    createFrameWrite(result, allocate, null);
}
Also used : ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) LLVMConversionType(com.oracle.truffle.llvm.parser.instructions.LLVMConversionType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) NullConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant) IntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant)

Example 14 with LLVMExpressionNode

use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.

the class LLVMBitcodeInstructionVisitor method visit.

@Override
public void visit(StoreInstruction store) {
    final LLVMExpressionNode pointerNode = symbols.resolve(store.getDestination());
    final LLVMExpressionNode valueNode = symbols.resolve(store.getSource());
    Type type = store.getSource().getType();
    LLVMSourceLocation source = null;
    if (!(store.getSource() instanceof CallInstruction)) {
        // otherwise the debugger would stop on both the call and the store of the return value
        source = sourceFunction.getSourceLocation(store);
    }
    final LLVMExpressionNode node = nodeFactory.createStore(runtime, pointerNode, valueNode, type, source);
    addInstruction(node);
}
Also used : CallInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.CallInstruction) VoidCallInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.VoidCallInstruction) LLVMConversionType(com.oracle.truffle.llvm.parser.instructions.LLVMConversionType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)

Example 15 with LLVMExpressionNode

use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.

the class LLVMBitcodeInstructionVisitor method visit.

@Override
public void visit(IndirectBranchInstruction branch) {
    if (branch.getSuccessorCount() > 1) {
        int[] labelTargets = new int[branch.getSuccessorCount()];
        for (int i = 0; i < labelTargets.length; i++) {
            labelTargets[i] = branch.getSuccessor(i).getBlockIndex();
        }
        LLVMExpressionNode value = symbols.resolve(branch.getAddress());
        LLVMControlFlowNode node = nodeFactory.createIndirectBranch(runtime, value, labelTargets, getPhiWriteNodes(branch), sourceFunction.getSourceLocation(branch));
        setControlFlowNode(node);
    } else {
        assert branch.getSuccessorCount() == 1;
        LLVMControlFlowNode node = nodeFactory.createUnconditionalBranch(runtime, branch.getSuccessor(0).getBlockIndex(), getPhiWriteNodes(branch)[0], sourceFunction.getSourceLocation(branch));
        setControlFlowNode(node);
    }
}
Also used : LLVMControlFlowNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMControlFlowNode) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)

Aggregations

LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)53 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)39 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)38 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)35 Type (com.oracle.truffle.llvm.runtime.types.Type)33 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)27 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)26 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)24 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)24 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)24 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)12 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)11 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)8 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)7 LLVMControlFlowNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMControlFlowNode)7 ArrayList (java.util.ArrayList)7 LLVMUnsupportedInlineAssemblerNode (com.oracle.truffle.llvm.nodes.others.LLVMUnsupportedInlineAssemblerNode)5 Phi (com.oracle.truffle.llvm.parser.LLVMPhiManager.Phi)4 AttributesGroup (com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup)4 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)4