use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(SwitchInstruction zwitch) {
LLVMExpressionNode cond = symbols.resolve(zwitch.getCondition());
int[] successors = new int[zwitch.getCaseCount() + 1];
for (int i = 0; i < successors.length - 1; i++) {
successors[i] = zwitch.getCaseBlock(i).getBlockIndex();
}
successors[successors.length - 1] = zwitch.getDefaultBlock().getBlockIndex();
Type llvmType = zwitch.getCondition().getType();
LLVMExpressionNode[] cases = new LLVMExpressionNode[zwitch.getCaseCount()];
for (int i = 0; i < cases.length; i++) {
cases[i] = symbols.resolve(zwitch.getCaseValue(i));
}
LLVMControlFlowNode node = nodeFactory.createSwitch(runtime, cond, successors, cases, llvmType, getPhiWriteNodes(zwitch), sourceFunction.getSourceLocation(zwitch));
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(CompareInstruction compare) {
LLVMExpressionNode result = nodeFactory.createComparison(runtime, compare.getOperator(), compare.getLHS().getType(), symbols.resolve(compare.getLHS()), symbols.resolve(compare.getRHS()));
createFrameWrite(result, compare);
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(CastInstruction cast) {
LLVMConversionType type = LLVMBitcodeTypeHelper.toConversionType(cast.getOperator());
LLVMExpressionNode fromNode = symbols.resolve(cast.getValue());
Type from = cast.getValue().getType();
Type to = cast.getType();
LLVMExpressionNode result = nodeFactory.createCast(runtime, fromNode, to, from, type);
createFrameWrite(result, cast);
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(ReturnInstruction ret) {
LLVMControlFlowNode node;
if (ret.getValue() == null) {
node = nodeFactory.createRetVoid(runtime, sourceFunction.getSourceLocation(ret));
} else {
final Type type = ret.getValue().getType();
final LLVMExpressionNode value = symbols.resolve(ret.getValue());
node = nodeFactory.createNonVoidRet(runtime, value, type, sourceFunction.getSourceLocation(ret));
}
setControlFlowNode(node);
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method createFrameWrite.
private void createFrameWrite(LLVMExpressionNode result, ValueInstruction source, LLVMSourceLocation sourceLocation) {
final LLVMExpressionNode node = nodeFactory.createFrameWrite(runtime, source.getType(), result, getSlot(source.getName()), sourceLocation);
addInstruction(node);
}
Aggregations