Search in sources :

Example 1 with ValueInstruction

use of com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction in project sulong by graalvm.

the class LLVMBitcodeInstructionVisitor method visitDebugIntrinsic.

private void visitDebugIntrinsic(SymbolImpl value, SourceVariable variable, MDExpression expression, long index, boolean isDeclaration) {
    FrameSlot valueSlot = null;
    if (value instanceof ValueInstruction) {
        valueSlot = frame.findFrameSlot(((ValueInstruction) value).getName());
    } else if (value instanceof FunctionParameter) {
        valueSlot = frame.findFrameSlot(((FunctionParameter) value).getName());
    }
    if (valueSlot != null) {
        final LLVMExpressionNode typeNode = nodeFactory.registerSourceType(valueSlot, variable.getSourceType());
        if (typeNode != null) {
            addInstructionUnchecked(typeNode);
        }
    }
    final LLVMExpressionNode dbgIntrinsic = dbgInfoHandler.handleDebugIntrinsic(value, variable, expression, index, isDeclaration);
    if (dbgIntrinsic != null) {
        addInstructionUnchecked(dbgIntrinsic);
    }
    handleNullerInfo();
}
Also used : DbgValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.DbgValueInstruction) ExtractValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.ExtractValueInstruction) ValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction) InsertValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.InsertValueInstruction) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) LLVMExpressionNode(com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode) FunctionParameter(com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)

Example 2 with ValueInstruction

use of com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction in project sulong by graalvm.

the class FunctionDefinition method exitLocalScope.

public void exitLocalScope() {
    int symbolIndex = 0;
    // in K&R style function declarations the parameters are not assigned names
    for (final FunctionParameter parameter : parameters) {
        if (LLVMIdentifier.UNKNOWN.equals(parameter.getName())) {
            parameter.setName(String.valueOf(symbolIndex++));
        }
    }
    final Set<String> explicitBlockNames = Arrays.stream(blocks).map(InstructionBlock::getName).filter(blockName -> !LLVMIdentifier.UNKNOWN.equals(blockName)).collect(Collectors.toSet());
    for (final InstructionBlock block : blocks) {
        if (block.getName().equals(LLVMIdentifier.UNKNOWN)) {
            do {
                block.setName(LLVMIdentifier.toImplicitBlockName(symbolIndex++));
            // avoid name clashes
            } while (explicitBlockNames.contains(block.getName()));
        }
        for (int i = 0; i < block.getInstructionCount(); i++) {
            final Instruction instruction = block.getInstruction(i);
            if (instruction instanceof ValueInstruction) {
                final ValueInstruction value = (ValueInstruction) instruction;
                if (value.getName().equals(LLVMIdentifier.UNKNOWN)) {
                    value.setName(String.valueOf(symbolIndex++));
                }
            }
        }
    }
}
Also used : Instruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.Instruction) Arrays(java.util.Arrays) MetadataAttachmentHolder(com.oracle.truffle.llvm.parser.metadata.MetadataAttachmentHolder) ValueSymbol(com.oracle.truffle.llvm.parser.model.ValueSymbol) SymbolVisitor(com.oracle.truffle.llvm.parser.model.visitors.SymbolVisitor) Linkage(com.oracle.truffle.llvm.parser.model.enums.Linkage) LLVMIdentifier(com.oracle.truffle.llvm.runtime.types.symbols.LLVMIdentifier) ArrayList(java.util.ArrayList) DebugInfoModuleProcessor(com.oracle.truffle.llvm.parser.metadata.debuginfo.DebugInfoModuleProcessor) Type(com.oracle.truffle.llvm.runtime.types.Type) SourceSection(com.oracle.truffle.api.source.SourceSection) MDAttachment(com.oracle.truffle.llvm.parser.metadata.MDAttachment) Constant(com.oracle.truffle.llvm.parser.model.symbols.constants.Constant) CompilerAsserts(com.oracle.truffle.api.CompilerAsserts) AttributesGroup(com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup) ValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction) Set(java.util.Set) SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) InstructionBlock(com.oracle.truffle.llvm.parser.model.blocks.InstructionBlock) AttributesCodeEntry(com.oracle.truffle.llvm.parser.model.attributes.AttributesCodeEntry) Collectors(java.util.stream.Collectors) List(java.util.List) FunctionType(com.oracle.truffle.llvm.runtime.types.FunctionType) LLVMSourceLocation(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceLocation) SourceFunction(com.oracle.truffle.llvm.parser.metadata.debuginfo.SourceFunction) FunctionVisitor(com.oracle.truffle.llvm.parser.model.visitors.FunctionVisitor) ValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction) InstructionBlock(com.oracle.truffle.llvm.parser.model.blocks.InstructionBlock) Instruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.Instruction) ValueInstruction(com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction)

Aggregations

ValueInstruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.ValueInstruction)2 CompilerAsserts (com.oracle.truffle.api.CompilerAsserts)1 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 MDAttachment (com.oracle.truffle.llvm.parser.metadata.MDAttachment)1 MetadataAttachmentHolder (com.oracle.truffle.llvm.parser.metadata.MetadataAttachmentHolder)1 DebugInfoModuleProcessor (com.oracle.truffle.llvm.parser.metadata.debuginfo.DebugInfoModuleProcessor)1 SourceFunction (com.oracle.truffle.llvm.parser.metadata.debuginfo.SourceFunction)1 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)1 ValueSymbol (com.oracle.truffle.llvm.parser.model.ValueSymbol)1 AttributesCodeEntry (com.oracle.truffle.llvm.parser.model.attributes.AttributesCodeEntry)1 AttributesGroup (com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup)1 InstructionBlock (com.oracle.truffle.llvm.parser.model.blocks.InstructionBlock)1 Linkage (com.oracle.truffle.llvm.parser.model.enums.Linkage)1 FunctionParameter (com.oracle.truffle.llvm.parser.model.functions.FunctionParameter)1 Constant (com.oracle.truffle.llvm.parser.model.symbols.constants.Constant)1 DbgValueInstruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.DbgValueInstruction)1 ExtractValueInstruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.ExtractValueInstruction)1 InsertValueInstruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.InsertValueInstruction)1 Instruction (com.oracle.truffle.llvm.parser.model.symbols.instructions.Instruction)1