use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method convertToPhiWriteNodes.
private LLVMExpressionNode[] convertToPhiWriteNodes(ArrayList<Phi>[] phisPerSuccessor) {
if (phisPerSuccessor.length == 0) {
return LLVMExpressionNode.NO_EXPRESSIONS;
}
LLVMExpressionNode[] result = new LLVMExpressionNode[phisPerSuccessor.length];
for (int i = 0; i < result.length; i++) {
LLVMExpressionNode[] from = new LLVMExpressionNode[phisPerSuccessor[i].size()];
FrameSlot[] to = new FrameSlot[phisPerSuccessor[i].size()];
Type[] types = new Type[phisPerSuccessor[i].size()];
for (int j = 0; j < phisPerSuccessor[i].size(); j++) {
Phi phi = phisPerSuccessor[i].get(j);
to[j] = getSlot(phi.getPhiValue().getName());
from[j] = symbols.resolve(phi.getValue());
types[j] = phi.getValue().getType();
}
result[i] = nodeFactory.createPhi(runtime, from, to, types);
}
return result;
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(ReadModifyWriteInstruction rmw) {
final LLVMExpressionNode pointerNode = symbols.resolve(rmw.getPtr());
final LLVMExpressionNode valueNode = symbols.resolve(rmw.getValue());
final Type type = rmw.getValue().getType();
final LLVMExpressionNode result = nodeFactory.createReadModifyWrite(runtime, rmw.getOperator(), pointerNode, valueNode, type);
createFrameWrite(result, rmw);
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode 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.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(ConditionalBranchInstruction branch) {
LLVMExpressionNode conditionNode = symbols.resolve(branch.getCondition());
int trueIndex = branch.getTrueSuccessor().getBlockIndex();
int falseIndex = branch.getFalseSuccessor().getBlockIndex();
LLVMExpressionNode[] phiWriteNodes = getPhiWriteNodes(branch);
LLVMControlFlowNode node = nodeFactory.createConditionalBranch(runtime, trueIndex, falseIndex, conditionNode, phiWriteNodes[0], phiWriteNodes[1], sourceFunction.getSourceLocation(branch));
setControlFlowNode(node);
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(FenceInstruction fence) {
final LLVMExpressionNode node = nodeFactory.createFence(runtime);
addInstruction(node);
}
Aggregations