Search in sources :

Example 1 with GlobalValueSymbol

use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol in project sulong by graalvm.

the class MDUpgrade method visit.

@Override
public void visit(MDGlobalVariable mdGlobal) {
    final SymbolImpl symbol = MDSymbolExtractor.getSymbol(mdGlobal.getVariable());
    if (symbol instanceof GlobalValueSymbol) {
        final GlobalValueSymbol global = (GlobalValueSymbol) symbol;
        attachSymbol(global, mdGlobal);
    }
    if (currentCU != null) {
        mdGlobal.setCompileUnit(currentCU);
    }
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)

Example 2 with GlobalValueSymbol

use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol in project sulong by graalvm.

the class ModelModule method accept.

public void accept(ModelVisitor visitor) {
    visitor.visit(targetDataLayout);
    targetInfo.forEach(visitor::visit);
    types.forEach(visitor::visit);
    for (GlobalValueSymbol variable : globals) {
        variable.accept(visitor);
    }
    defines.forEach(visitor::visit);
    declares.forEach(visitor::visit);
}
Also used : GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)

Example 3 with GlobalValueSymbol

use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol in project sulong by graalvm.

the class BCFileRoot method exit.

@Override
public void exit() {
    int globalIndex = 0;
    for (GlobalValueSymbol variable : module.getGlobals()) {
        if (variable.getName().equals(LLVMIdentifier.UNKNOWN)) {
            variable.setName(String.valueOf(globalIndex++));
        }
    }
    SymbolNameMangling.demangleGlobals(module);
    DebugInfoModuleProcessor.processModule(module, source, scope.getMetadata());
}
Also used : GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)

Example 4 with GlobalValueSymbol

use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol in project sulong by graalvm.

the class Module method createGlobalVariable.

private void createGlobalVariable(long[] args) {
    final int recordOffset = useStrTab() ? STRTAB_RECORD_OFFSET : 0;
    final long typeField = args[GLOBALVAR_TYPE + recordOffset];
    final long flagField = args[GLOBALVAR_FLAGS + recordOffset];
    Type type = types.get(typeField);
    if ((flagField & GLOBALVAR_EXPLICICTTYPE_MASK) != 0) {
        type = new PointerType(type);
    }
    final boolean isConstant = (flagField & GLOBALVAR_ISCONSTANT_MASK) != 0;
    final int initialiser = (int) args[GLOBALVAR_INTITIALIZER + recordOffset];
    final long linkage = args[GLOBALVAR_LINKAGE + recordOffset];
    final int align = (int) args[GLOBALVAR_ALIGN + recordOffset];
    long visibility = Visibility.DEFAULT.getEncodedValue();
    if (GLOBALVAR_VISIBILITY + recordOffset < args.length) {
        visibility = args[GLOBALVAR_VISIBILITY + recordOffset];
    }
    final GlobalValueSymbol global;
    if (isConstant) {
        global = GlobalConstant.create(type, align, linkage, visibility, scope.getSymbols(), initialiser);
    } else {
        global = GlobalVariable.create(type, align, linkage, visibility, scope.getSymbols(), initialiser);
    }
    if (useStrTab()) {
        readNameFromStrTab(args, global);
    }
    module.addGlobalSymbol(global);
    scope.addSymbol(global, global.getType());
}
Also used : PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) Type(com.oracle.truffle.llvm.runtime.types.Type) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)

Example 5 with GlobalValueSymbol

use of com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol in project sulong by graalvm.

the class LLVMLivenessAnalysis method resolve.

private static int resolve(FrameDescriptor frame, SymbolImpl symbol) {
    if (symbol instanceof ValueSymbol && !(symbol instanceof GlobalValueSymbol || symbol instanceof FunctionDefinition || symbol instanceof FunctionDeclaration)) {
        String name = ((ValueSymbol) symbol).getName();
        assert name != null;
        FrameSlot frameSlot = frame.findFrameSlot(name);
        assert frameSlot != null : "No Frameslot for ValueSymbol: " + symbol;
        return frameSlot.getIndex();
    }
    return -1;
}
Also used : FunctionDeclaration(com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) FunctionDefinition(com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition) GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol) ValueSymbol(com.oracle.truffle.llvm.parser.model.ValueSymbol) GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)

Aggregations

GlobalValueSymbol (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)8 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)3 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)2 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)2 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)2 RootCallTarget (com.oracle.truffle.api.RootCallTarget)1 ValueFragment (com.oracle.truffle.llvm.parser.metadata.debuginfo.ValueFragment)1 ValueSymbol (com.oracle.truffle.llvm.parser.model.ValueSymbol)1 FunctionDeclaration (com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration)1 FunctionDefinition (com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)1 NullConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant)1 UndefinedConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant)1 GlobalAlias (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalAlias)1 GlobalConstant (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalConstant)1 GlobalVariable (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalVariable)1 LLVMSourceSymbol (com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol)1 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)1 Type (com.oracle.truffle.llvm.runtime.types.Type)1 ArrayList (java.util.ArrayList)1