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);
}
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;
}
Aggregations