use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias in project sulong by graalvm.
the class LLVMParserRuntime method registerFunctions.
private void registerFunctions(ModelModule model) {
for (FunctionDefinition function : model.getDefinedFunctions()) {
registerFunction(function, model);
}
for (Map.Entry<GlobalAlias, SymbolImpl> entry : aliases.entrySet()) {
GlobalAlias alias = entry.getKey();
SymbolImpl value = entry.getValue();
if (value instanceof FunctionDefinition) {
registerFunctionAlias(alias, (FunctionDefinition) value);
}
}
}
use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias in project sulong by graalvm.
the class Module method createGlobalAliasNew.
private void createGlobalAliasNew(long[] args) {
final int recordOffset = useStrTab() ? STRTAB_RECORD_OFFSET : 0;
final Type type = new PointerType(types.get(args[GLOBALALIAS_TYPE + recordOffset]));
// idx = 1 is address space information
final int value = (int) args[GLOBALALIAS_NEW_VALUE + recordOffset];
final long linkage = args[GLOBALALIAS_NEW_LINKAGE + recordOffset];
final GlobalAlias global = GlobalAlias.create(type, linkage, Visibility.DEFAULT.ordinal(), scope.getSymbols(), value);
if (useStrTab()) {
readNameFromStrTab(args, global);
}
module.addGlobalSymbol(global);
scope.addSymbol(global, global.getType());
}
use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias in project sulong by graalvm.
the class Module method createGlobalAliasOld.
private void createGlobalAliasOld(long[] args) {
final int recordOffset = useStrTab() ? STRTAB_RECORD_OFFSET : 0;
final Type type = types.get(args[GLOBALALIAS_TYPE + recordOffset]);
int value = (int) args[GLOBALALIAS_OLD_VALUE + recordOffset];
long linkage = args[GLOBALALIAS_OLD_LINKAGE + recordOffset];
final GlobalAlias global = GlobalAlias.create(type, linkage, Visibility.DEFAULT.ordinal(), scope.getSymbols(), value);
if (useStrTab()) {
readNameFromStrTab(args, global);
}
module.addGlobalSymbol(global);
scope.addSymbol(global, global.getType());
}
use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias 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);
}
}
Aggregations