Search in sources :

Example 36 with PointerType

use of com.oracle.truffle.llvm.runtime.types.PointerType in project sulong by graalvm.

the class LazyToTruffleConverterImpl method copyArgumentsToFrame.

private List<LLVMExpressionNode> copyArgumentsToFrame(FrameDescriptor frame) {
    List<FunctionParameter> parameters = method.getParameters();
    List<LLVMExpressionNode> formalParamInits = new ArrayList<>();
    LLVMExpressionNode stackPointerNode = nodeFactory.createFunctionArgNode(0, PrimitiveType.I64);
    formalParamInits.add(nodeFactory.createFrameWrite(runtime, PointerType.VOID, stackPointerNode, frame.findFrameSlot(LLVMStack.FRAME_ID), null));
    int argIndex = 1;
    if (method.getType().getReturnType() instanceof StructureType) {
        argIndex++;
    }
    for (FunctionParameter parameter : parameters) {
        LLVMExpressionNode parameterNode = nodeFactory.createFunctionArgNode(argIndex++, parameter.getType());
        FrameSlot slot = frame.findFrameSlot(parameter.getName());
        if (isStructByValue(parameter)) {
            Type type = ((PointerType) parameter.getType()).getPointeeType();
            formalParamInits.add(nodeFactory.createFrameWrite(runtime, parameter.getType(), nodeFactory.createCopyStructByValue(runtime, type, parameterNode), slot, null));
        } else {
            formalParamInits.add(nodeFactory.createFrameWrite(runtime, parameter.getType(), parameterNode, slot, null));
        }
    }
    return formalParamInits;
}
Also used : LLVMSourceFunctionType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceFunctionType) Type(com.oracle.truffle.llvm.runtime.types.Type) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayList(java.util.ArrayList) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionParameter(com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)

Example 37 with PointerType

use of com.oracle.truffle.llvm.runtime.types.PointerType in project sulong by graalvm.

the class LLVMFrameNullerUtil method nullObject.

public static void nullObject(VirtualFrame frame, FrameSlot frameSlot) {
    CompilerAsserts.partialEvaluationConstant(frameSlot.getInfo());
    CompilerAsserts.partialEvaluationConstant(frameSlot.getInfo() == null);
    if (frameSlot.getInfo() != null) {
        Type type = (Type) frameSlot.getInfo();
        CompilerAsserts.partialEvaluationConstant(Type.isFunctionOrFunctionPointer(type));
        CompilerAsserts.partialEvaluationConstant(type instanceof VectorType);
        CompilerAsserts.partialEvaluationConstant(type instanceof VariableBitWidthType);
        CompilerAsserts.partialEvaluationConstant(type instanceof PrimitiveType && ((PrimitiveType) type).getPrimitiveKind() == PrimitiveKind.X86_FP80);
        if (Type.isFunctionOrFunctionPointer(type)) {
            nullFunction(frame, frameSlot);
        } else if (type instanceof VectorType && ((VectorType) type).getElementType() instanceof PrimitiveType) {
            nullVector(frame, frameSlot, ((PrimitiveType) ((VectorType) type).getElementType()).getPrimitiveKind());
        } else if (type instanceof VectorType && ((VectorType) type).getElementType() instanceof PointerType) {
            frame.setObject(frameSlot, LLVMAddressVector.createNullVector());
        } else if (type instanceof VariableBitWidthType) {
            nullIVarBit(frame, frameSlot);
        } else if (type instanceof PrimitiveType && ((PrimitiveType) type).getPrimitiveKind() == PrimitiveKind.X86_FP80) {
            null80BitFloat(frame, frameSlot);
        }
    }
    // This is a best effort approach. It could still be that LLVMAddress clashes with some
    // other class.
    nullAddress(frame, frameSlot);
}
Also used : PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) VariableBitWidthType(com.oracle.truffle.llvm.runtime.types.VariableBitWidthType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) Type(com.oracle.truffle.llvm.runtime.types.Type) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) VariableBitWidthType(com.oracle.truffle.llvm.runtime.types.VariableBitWidthType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType)

Aggregations

PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)37 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)31 Type (com.oracle.truffle.llvm.runtime.types.Type)29 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)27 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)24 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)20 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)18 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)18 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)18 VectorType (com.oracle.truffle.llvm.runtime.types.VectorType)14 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)9 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)9 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)9 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)6 ArrayList (java.util.ArrayList)5 AttributesGroup (com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup)4 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)4 PrimitiveKind (com.oracle.truffle.llvm.runtime.types.PrimitiveType.PrimitiveKind)4 VariableBitWidthType (com.oracle.truffle.llvm.runtime.types.VariableBitWidthType)4 AttributesCodeEntry (com.oracle.truffle.llvm.parser.model.attributes.AttributesCodeEntry)3