use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visitDebugIntrinsic.
private void visitDebugIntrinsic(SymbolImpl value, SourceVariable variable, MDExpression expression, long index, boolean isDeclaration) {
FrameSlot valueSlot = null;
if (value instanceof ValueInstruction) {
valueSlot = frame.findFrameSlot(((ValueInstruction) value).getName());
} else if (value instanceof FunctionParameter) {
valueSlot = frame.findFrameSlot(((FunctionParameter) value).getName());
}
if (valueSlot != null) {
final LLVMExpressionNode typeNode = nodeFactory.registerSourceType(valueSlot, variable.getSourceType());
if (typeNode != null) {
addInstructionUnchecked(typeNode);
}
}
final LLVMExpressionNode dbgIntrinsic = dbgInfoHandler.handleDebugIntrinsic(value, variable, expression, index, isDeclaration);
if (dbgIntrinsic != null) {
addInstructionUnchecked(dbgIntrinsic);
}
handleNullerInfo();
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(BinaryOperationInstruction operation) {
LLVMExpressionNode lhs = symbols.resolve(operation.getLHS());
LLVMExpressionNode rhs = symbols.resolve(operation.getRHS());
final Type type = operation.getType();
final LLVMArithmeticInstructionType opA = LLVMBitcodeTypeHelper.toArithmeticInstructionType(operation.getOperator());
if (opA != null) {
final LLVMExpressionNode result = nodeFactory.createArithmeticOperation(runtime, lhs, rhs, opA, type, operation.getFlags());
createFrameWrite(result, operation);
return;
}
final LLVMLogicalInstructionKind opL = LLVMBitcodeTypeHelper.toLogicalInstructionType(operation.getOperator());
if (opL != null) {
final LLVMExpressionNode result = nodeFactory.createLogicalOperation(runtime, lhs, rhs, opL, type, operation.getFlags());
createFrameWrite(result, operation);
return;
}
throw new RuntimeException("Missed a binary operator");
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(AllocateInstruction allocate) {
final Type type = allocate.getPointeeType();
int alignment;
if (allocate.getAlign() == 0) {
alignment = runtime.getContext().getByteAlignment(type);
} else {
alignment = 1 << (allocate.getAlign() - 1);
}
if (alignment == 0) {
alignment = LLVMStack.NO_ALIGNMENT_REQUIREMENTS;
}
final SymbolImpl count = allocate.getCount();
final LLVMExpressionNode result;
if (count instanceof NullConstant) {
result = nodeFactory.createAlloca(runtime, type, alignment);
} else if (count instanceof IntegerConstant) {
long numElements = (int) ((IntegerConstant) count).getValue();
if (numElements == 1) {
result = nodeFactory.createAlloca(runtime, type, alignment);
} else {
assert numElements == (int) numElements;
ArrayType arrayType = new ArrayType(type, (int) numElements);
result = nodeFactory.createAlloca(runtime, arrayType, alignment);
}
} else {
LLVMExpressionNode num = symbols.resolve(count);
result = nodeFactory.createAllocaArray(runtime, type, num, alignment);
}
// we never want to step on allocations, only to actual assignments in the source
createFrameWrite(result, allocate, null);
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBitcodeInstructionVisitor method visit.
@Override
public void visit(StoreInstruction store) {
final LLVMExpressionNode pointerNode = symbols.resolve(store.getDestination());
final LLVMExpressionNode valueNode = symbols.resolve(store.getSource());
Type type = store.getSource().getType();
LLVMSourceLocation source = null;
if (!(store.getSource() instanceof CallInstruction)) {
// otherwise the debugger would stop on both the call and the store of the return value
source = sourceFunction.getSourceLocation(store);
}
final LLVMExpressionNode node = nodeFactory.createStore(runtime, pointerNode, valueNode, type, source);
addInstruction(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(IndirectBranchInstruction branch) {
if (branch.getSuccessorCount() > 1) {
int[] labelTargets = new int[branch.getSuccessorCount()];
for (int i = 0; i < labelTargets.length; i++) {
labelTargets[i] = branch.getSuccessor(i).getBlockIndex();
}
LLVMExpressionNode value = symbols.resolve(branch.getAddress());
LLVMControlFlowNode node = nodeFactory.createIndirectBranch(runtime, value, labelTargets, getPhiWriteNodes(branch), sourceFunction.getSourceLocation(branch));
setControlFlowNode(node);
} else {
assert branch.getSuccessorCount() == 1;
LLVMControlFlowNode node = nodeFactory.createUnconditionalBranch(runtime, branch.getSuccessor(0).getBlockIndex(), getPhiWriteNodes(branch)[0], sourceFunction.getSourceLocation(branch));
setControlFlowNode(node);
}
}
Aggregations