use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.
the class LLVMParserRuntime method getGlobalVariable.
private LLVMExpressionNode getGlobalVariable(LLVMSymbolReadResolver symbolResolver, GlobalValueSymbol global) {
LLVMSourceSymbol sourceSymbol = null;
SymbolImpl g = global;
while (g instanceof GlobalAlias) {
if (sourceSymbol == null) {
sourceSymbol = ((GlobalAlias) g).getSourceSymbol();
}
g = aliases.get(g);
}
if (sourceSymbol == null && g instanceof GlobalValueSymbol) {
sourceSymbol = ((GlobalValueSymbol) g).getSourceSymbol();
}
if (g instanceof GlobalValueSymbol) {
final GlobalValueSymbol variable = (GlobalValueSymbol) g;
final LLVMSourceSymbol finalSourceSymbol = sourceSymbol;
Object globalVariableDescriptor = scope.lookupOrCreateGlobal(variable.getName(), !Linkage.isFileLocal(variable.getLinkage()), () -> {
final Object globalValue;
if (global instanceof GlobalVariable) {
globalValue = nodeFactory.allocateGlobalVariable(this, (GlobalVariable) global, finalSourceSymbol);
} else if (global instanceof GlobalConstant) {
globalValue = nodeFactory.allocateGlobalConstant(this, (GlobalConstant) global, finalSourceSymbol);
} else {
throw new AssertionError("Cannot allocate global: " + global);
}
return globalValue;
});
return nodeFactory.createLiteral(this, globalVariableDescriptor, new PointerType(variable.getType()));
} else {
return symbolResolver.resolve(g);
}
}
use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.
the class LLVMRuntimeDebugInformation method registerStaticDebugSymbols.
void registerStaticDebugSymbols(FunctionDefinition fn) {
if (!isEnabled) {
return;
}
for (SourceVariable local : fn.getSourceFunction().getVariables()) {
if (local.isSingleDeclaration()) {
final DbgDeclareInstruction dbg = local.getSingleDeclaration();
FrameSlot frameSlot = null;
if (dbg.getValue() instanceof AllocateInstruction) {
frameSlot = frame.findFrameSlot(((AllocateInstruction) dbg.getValue()).getName());
}
if (frameSlot == null) {
continue;
}
final LLVMSourceSymbol symbol = local.getSymbol();
final LLVMFrameValueAccess alloc = factory.createDebugFrameValue(frameSlot, true);
notNullableSlots.add(frameSlot);
context.getSourceContext().registerFrameValue(symbol, alloc);
local.addStaticValue();
} else if (local.isSingleValue()) {
final DbgValueInstruction dbg = local.getSingleValue();
final MDExpression expr = dbg.getExpression();
final SymbolImpl value = dbg.getValue();
if (expr.getElementCount() != 0) {
continue;
}
final boolean mustDereference = mustDereferenceValue(expr, local.getSourceType(), value);
staticValueAccessVisitor.registerStaticAccess(local, value, mustDereference);
}
}
}
Aggregations