Search in sources :

Example 6 with ArrayType

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

the class LLVMBitcodeInstructionVisitor method visit.

@Override
public void visit(InsertValueInstruction insert) {
    if (!(insert.getAggregate().getType() instanceof StructureType || insert.getAggregate().getType() instanceof ArrayType)) {
        throw new IllegalStateException("\'insertvalue\' can only insert values into arrays and structs!");
    }
    final AggregateType sourceType = (AggregateType) insert.getAggregate().getType();
    final LLVMExpressionNode sourceAggregate = symbols.resolve(insert.getAggregate());
    final LLVMExpressionNode valueToInsert = symbols.resolve(insert.getValue());
    final Type valueType = insert.getValue().getType();
    final int targetIndex = insert.getIndex();
    final LLVMExpressionNode resultAggregate = nodeFactory.createAlloca(runtime, sourceType);
    final long offset = runtime.getContext().getIndexOffset(targetIndex, sourceType);
    final LLVMExpressionNode result = nodeFactory.createInsertValue(runtime, resultAggregate, sourceAggregate, runtime.getContext().getByteSize(sourceType), offset, valueToInsert, valueType);
    createFrameWrite(result, insert);
}
Also used : ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) 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) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType)

Example 7 with ArrayType

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

the class LLVMParserRuntime method createGlobalInitialization.

private LLVMExpressionNode createGlobalInitialization(LLVMSymbolReadResolver symbolResolver, GlobalValueSymbol global) {
    if (global == null || global.getValue() == null) {
        return null;
    }
    LLVMExpressionNode constant = symbolResolver.resolve(global.getValue());
    if (constant != null) {
        final Type type = ((PointerType) global.getType()).getPointeeType();
        final int size = getContext().getByteSize(type);
        final LLVMExpressionNode globalVarAddress = getGlobalVariable(symbolResolver, global);
        if (size != 0) {
            final LLVMExpressionNode store;
            if (type instanceof ArrayType || type instanceof StructureType) {
                store = nodeFactory.createStore(this, globalVarAddress, constant, type, null);
            } else {
                final Type t = global.getValue().getType();
                store = nodeFactory.createStore(this, globalVarAddress, constant, t, null);
            }
            return store;
        }
    }
    return null;
}
Also used : ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) 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) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType)

Aggregations

ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)7 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)7 Type (com.oracle.truffle.llvm.runtime.types.Type)7 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)6 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)6 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)6 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)5 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)4 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)4 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)4 VectorType (com.oracle.truffle.llvm.runtime.types.VectorType)3 LLVMInteropType (com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType)2 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)2 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)2 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)1 NullConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant)1 IntegerConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant)1 TypesRecord (com.oracle.truffle.llvm.parser.records.TypesRecord)1 LLVMSourcePointerType (com.oracle.truffle.llvm.runtime.debug.LLVMSourcePointerType)1 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.LLVMSourceType)1