use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMRuntimeDebugInformation method handleDebugIntrinsic.
LLVMExpressionNode handleDebugIntrinsic(SymbolImpl value, SourceVariable variable, MDExpression expression, long index, boolean isDeclaration) {
if (!isEnabled || variable.hasStaticAllocation()) {
return null;
}
LLVMExpressionNode valueRead = null;
if (isDeclaration) {
if (value instanceof UndefinedConstant) {
if (variable.hasValue()) {
// know this from the presence of the value
return null;
}
valueRead = symbols.resolve(new NullConstant(MetaType.DEBUG));
} else if (value instanceof NullConstant) {
valueRead = symbols.resolve(new NullConstant(MetaType.DEBUG));
} else if (value instanceof GlobalValueSymbol || value.getType() instanceof PointerType) {
valueRead = symbols.resolve(value);
}
} else {
valueRead = symbols.resolve(value);
if (index != 0) {
// this is unsupported, it doesn't appear in LLVM 3.8+
return null;
}
}
if (valueRead == null) {
return null;
}
int partIndex = -1;
int[] clearParts = null;
if (ValueFragment.describesFragment(expression)) {
final ValueFragment fragment = ValueFragment.parse(expression);
final List<ValueFragment> siblings = variable.getFragments();
final List<Integer> clearSiblings = new ArrayList<>(siblings.size());
partIndex = ValueFragment.getPartIndex(fragment, siblings, clearSiblings);
if (clearSiblings.isEmpty()) {
// this will be the case most of the time
clearParts = CLEAR_NONE;
} else {
clearParts = clearSiblings.stream().mapToInt(Integer::intValue).toArray();
}
}
if (partIndex < 0 && variable.hasFragments()) {
partIndex = variable.getFragmentIndex(0, (int) variable.getSymbol().getType().getSize());
if (partIndex < 0) {
throw new IllegalStateException("Cannot find index of value fragment!");
}
clearParts = new int[variable.getFragments().size() - 1];
for (int i = 0; i < partIndex; i++) {
clearParts[i] = i;
}
for (int i = partIndex; i < clearParts.length; i++) {
clearParts[i] = i + 1;
}
}
final boolean mustDereference = isDeclaration || mustDereferenceValue(expression, variable.getSourceType(), value);
final FrameSlot targetSlot = frame.findOrAddFrameSlot(variable.getSymbol(), MetaType.DEBUG, FrameSlotKind.Object);
final LLVMExpressionNode containerRead = factory.createFrameRead(runtime, MetaType.DEBUG, targetSlot);
return factory.createDebugWrite(mustDereference, valueRead, targetSlot, containerRead, partIndex, clearParts);
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LazyToTruffleConverterImpl method copyArgumentsToFrame.
private List<LLVMExpressionNode> copyArgumentsToFrame(FrameDescriptor frame) {
List<FunctionParameter> parameters = method.getParameters();
List<LLVMExpressionNode> formalParamInits = new ArrayList<>();
LLVMExpressionNode stackPointerNode = nodeFactory.createFunctionArgNode(0, PrimitiveType.I64);
formalParamInits.add(nodeFactory.createFrameWrite(runtime, PointerType.VOID, stackPointerNode, frame.findFrameSlot(LLVMStack.FRAME_ID), null));
int argIndex = 1;
if (method.getType().getReturnType() instanceof StructureType) {
argIndex++;
}
for (FunctionParameter parameter : parameters) {
LLVMExpressionNode parameterNode = nodeFactory.createFunctionArgNode(argIndex++, parameter.getType());
FrameSlot slot = frame.findFrameSlot(parameter.getName());
if (isStructByValue(parameter)) {
Type type = ((PointerType) parameter.getType()).getPointeeType();
formalParamInits.add(nodeFactory.createFrameWrite(runtime, parameter.getType(), nodeFactory.createCopyStructByValue(runtime, type, parameterNode), slot, null));
} else {
formalParamInits.add(nodeFactory.createFrameWrite(runtime, parameter.getType(), parameterNode, slot, null));
}
}
return formalParamInits;
}
use of com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode in project sulong by graalvm.
the class LLVMBasicBlockNode method getLastAvailableSourceLocation.
private LLVMSourceLocation getLastAvailableSourceLocation(int i) {
CompilerAsserts.neverPartOfCompilation();
for (int j = i; j >= 0; j--) {
LLVMExpressionNode node = statements[j];
if (node instanceof InstrumentableNode.WrapperNode) {
node = (LLVMExpressionNode) ((InstrumentableNode.WrapperNode) node).getDelegateNode();
}
LLVMSourceLocation location = node.getSourceLocation();
if (location != null) {
return location;
}
}
return null;
}
Aggregations