Search in sources :

Example 1 with SymbolImpl

use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.

the class DebugInfoModuleProcessor method processModule.

public static void processModule(ModelModule irModel, Source bitcodeSource, MetadataValueList metadata) {
    MDUpgrade.perform(metadata);
    final DebugInfoCache cache = new DebugInfoCache(metadata, irModel.getSourceStaticMembers());
    final Map<LLVMSourceSymbol, SymbolImpl> globals = irModel.getSourceGlobals();
    final Map<LLVMSourceStaticMemberType, SymbolImpl> staticMembers = irModel.getSourceStaticMembers();
    irModel.accept(new SymbolProcessor(cache, bitcodeSource, globals, staticMembers));
    final MDBaseNode cuNode = metadata.getNamedNode(MDNamedNode.COMPILEUNIT_NAME);
    final MetadataProcessor mdParser = new MetadataProcessor(cache, globals, staticMembers);
    if (cuNode != null) {
        cuNode.accept(mdParser);
    }
    irModel.setFunctionProcessor(new DebugInfoFunctionProcessor(cache));
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) LLVMSourceSymbol(com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol) MDBaseNode(com.oracle.truffle.llvm.parser.metadata.MDBaseNode) LLVMSourceStaticMemberType(com.oracle.truffle.llvm.runtime.debug.LLVMSourceStaticMemberType)

Example 2 with SymbolImpl

use of com.oracle.truffle.llvm.parser.model.SymbolImpl 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 3 with SymbolImpl

use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.

the class MDUpgrade method visit.

@Override
public void visit(MDSubprogram md) {
    final SymbolImpl valueSymbol = MDSymbolExtractor.getSymbol(md.getFunction());
    if (valueSymbol instanceof FunctionDefinition) {
        final FunctionDefinition function = (FunctionDefinition) valueSymbol;
        attachSymbol(function, md);
    }
    if (currentCU != null && md.getCompileUnit() == MDVoidNode.INSTANCE) {
        md.setCompileUnit(currentCU);
    }
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) FunctionDefinition(com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)

Example 4 with SymbolImpl

use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.

the class LLVMSymbolReadResolver method resolveElementPointer.

public LLVMExpressionNode resolveElementPointer(SymbolImpl base, List<SymbolImpl> indices) {
    LLVMExpressionNode currentAddress = resolve(base);
    Type currentType = base.getType();
    for (int i = 0, indicesSize = indices.size(); i < indicesSize; i++) {
        final SymbolImpl indexSymbol = indices.get(i);
        final Type indexType = indexSymbol.getType();
        final Long indexInteger = evaluateLongIntegerConstant(indexSymbol);
        if (indexInteger == null) {
            // the index is determined at runtime
            if (currentType instanceof StructureType) {
                // according to http://llvm.org/docs/LangRef.html#getelementptr-instruction
                throw new IllegalStateException("Indices on structs must be constant integers!");
            }
            AggregateType aggregate = (AggregateType) currentType;
            final long indexedTypeLength = runtime.getContext().getIndexOffset(1, aggregate);
            currentType = aggregate.getElementType(1);
            final LLVMExpressionNode indexNode = resolve(indexSymbol);
            currentAddress = runtime.getNodeFactory().createTypedElementPointer(runtime, currentAddress, indexNode, indexedTypeLength, currentType);
        } else {
            // the index is a constant integer
            AggregateType aggregate = (AggregateType) currentType;
            final long addressOffset = runtime.getContext().getIndexOffset(indexInteger, aggregate);
            currentType = aggregate.getElementType(indexInteger);
            // computed by getelementptr even if it is the same as the basepointer
            if (addressOffset != 0 || i == indicesSize - 1) {
                final LLVMExpressionNode indexNode;
                if (indexType == PrimitiveType.I32) {
                    indexNode = runtime.getNodeFactory().createLiteral(runtime, 1, PrimitiveType.I32);
                } else if (indexType == PrimitiveType.I64) {
                    indexNode = runtime.getNodeFactory().createLiteral(runtime, 1L, PrimitiveType.I64);
                } else {
                    throw new AssertionError(indexType);
                }
                currentAddress = runtime.getNodeFactory().createTypedElementPointer(runtime, currentAddress, indexNode, addressOffset, currentType);
            }
        }
    }
    return currentAddress;
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) VariableBitWidthType(com.oracle.truffle.llvm.runtime.types.VariableBitWidthType) LLVMConversionType(com.oracle.truffle.llvm.parser.instructions.LLVMConversionType) PrimitiveType(com.oracle.truffle.llvm.runtime.types.PrimitiveType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) VectorType(com.oracle.truffle.llvm.runtime.types.VectorType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) ArrayType(com.oracle.truffle.llvm.runtime.types.ArrayType) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType) OpaqueType(com.oracle.truffle.llvm.runtime.types.OpaqueType) LLVMArithmeticInstructionType(com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType) Type(com.oracle.truffle.llvm.runtime.types.Type) PointerType(com.oracle.truffle.llvm.runtime.types.PointerType) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) StructureType(com.oracle.truffle.llvm.runtime.types.StructureType) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) AggregateType(com.oracle.truffle.llvm.runtime.types.AggregateType)

Example 5 with SymbolImpl

use of com.oracle.truffle.llvm.parser.model.SymbolImpl in project sulong by graalvm.

the class ParseUtil method asLong.

public static long asLong(long[] args, int index, Metadata md) {
    final int typeIndex = index << 1;
    if (typeIndex >= args.length) {
        return DEFAULT_NUMBER;
    }
    final Type type = md.getTypeById(args[typeIndex]);
    if (type == MetaType.METADATA || VoidType.INSTANCE.equals(type)) {
        return DEFAULT_NUMBER;
    }
    final int valueIndex = typeIndex + 1;
    final SymbolImpl value = md.getScope().getSymbols().getOrNull((int) args[valueIndex]);
    if (value instanceof IntegerConstant) {
        return ((IntegerConstant) value).getValue();
    } else if (value instanceof BigIntegerConstant) {
        return ((BigIntegerConstant) value).getValue().longValue();
    } else if (value instanceof NullConstant || value instanceof UndefinedConstant) {
        return 0L;
    } else {
        return DEFAULT_NUMBER;
    }
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) Type(com.oracle.truffle.llvm.runtime.types.Type) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) UndefinedConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant) NullConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant) IntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant)

Aggregations

SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)17 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)8 Type (com.oracle.truffle.llvm.runtime.types.Type)8 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)7 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)7 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)7 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)6 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)6 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)6 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)6 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)6 AttributesGroup (com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup)4 LLVMSourceLocation (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation)4 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)3 NullConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant)3 IntegerConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant)3 LLVMSourceSymbol (com.oracle.truffle.llvm.runtime.debug.LLVMSourceSymbol)3 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)3 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)3 ArrayList (java.util.ArrayList)3