Search in sources :

Example 31 with LLVMParserException

use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.

the class LLVMBitcodeInstructionVisitor method handleDebugIntrinsic.

private void handleDebugIntrinsic(SymbolImpl value, SourceVariable variable, MDExpression expression, long index, boolean isDeclaration) {
    if (index != 0) {
        // this is unsupported, it doesn't appear in LLVM 3.8+
        return;
    }
    int valueFrameSlot = -1;
    Object valueObject = null;
    if (value instanceof UndefinedConstant) {
        valueObject = symbols.resolve(new NullConstant(MetaType.DEBUG));
    } else if (value instanceof AbstractConstant) {
        valueObject = symbols.resolve(value);
    } else if (value instanceof GlobalValueSymbol) {
        valueObject = symbols.resolve(value);
    } else if (value instanceof SSAValue) {
        valueFrameSlot = symbols.findOrAddFrameSlot((SSAValue) value);
    } else {
        return;
    }
    if (valueObject == null && valueFrameSlot == -1) {
        return;
    }
    int partIndex = -1;
    int[] clearParts = null;
    if (ValueFragment.describesFragment(expression)) {
        ValueFragment fragment = ValueFragment.parse(expression);
        List<ValueFragment> siblings = variable.getFragments();
        List<Integer> clearSiblings = new ArrayList<>(siblings.size());
        partIndex = ValueFragment.getPartIndex(fragment, siblings, clearSiblings);
        if (!clearSiblings.isEmpty()) {
            clearParts = clearSiblings.stream().mapToInt(Integer::intValue).toArray();
        }
    }
    if (partIndex < 0 && variable.hasFragments()) {
        partIndex = variable.getFragmentIndex(0, (int) variable.getSymbol().getType().getSize());
        if (partIndex < 0) {
            throw new LLVMParserException("Cannot find index of value fragment!");
        }
        clearParts = new int[variable.getFragments().size() - 1];
        for (int i = 0; i < partIndex; i++) {
            clearParts[i] = i;
        }
        for (int i = partIndex; i < clearParts.length; i++) {
            clearParts[i] = i + 1;
        }
    }
    boolean mustDereference = isDeclaration || mustDereferenceValue(expression, variable.getSourceType(), value);
    if (clearParts != null && clearParts.length != 0) {
        debugInfo.add(new ClearLocalVariableParts(instructionNodes.size(), variable.getSymbol(), clearParts));
    }
    if (partIndex < 0 && clearParts == null) {
        debugInfo.add(new SimpleLocalVariable(instructionNodes.size(), mustDereference, valueObject, valueFrameSlot, variable.getSymbol()));
    } else if (partIndex >= 0) {
        debugInfo.add(new SetLocalVariablePart(instructionNodes.size(), mustDereference, valueObject, valueFrameSlot, variable.getSymbol(), partIndex));
    }
}
Also used : UndefinedConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant) ArrayList(java.util.ArrayList) NullConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant) SSAValue(com.oracle.truffle.llvm.runtime.types.symbols.SSAValue) SetLocalVariablePart(com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.SetLocalVariablePart) SimpleLocalVariable(com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.SimpleLocalVariable) GlobalValueSymbol(com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol) AbstractConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.AbstractConstant) ClearLocalVariableParts(com.oracle.truffle.llvm.parser.nodes.LLVMRuntimeDebugInformation.ClearLocalVariableParts) ValueFragment(com.oracle.truffle.llvm.parser.metadata.debuginfo.ValueFragment) LLVMParserException(com.oracle.truffle.llvm.runtime.except.LLVMParserException)

Example 32 with LLVMParserException

use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.

the class LLVMLanguage method parse.

@Override
protected ExecutableNode parse(InlineParsingRequest request) {
    Object globalScope = getScope(getContext());
    final DebugExprParser d = new DebugExprParser(request, globalScope);
    try {
        return new DebugExprExecutableNode(d.parse());
    } catch (DebugExprException | LLVMParserException e) {
        // error found during parsing
        String errorMessage = e.getMessage();
        return new ExecutableNode(this) {

            @Override
            public Object execute(VirtualFrame frame) {
                return errorMessage;
            }
        };
    }
}
Also used : VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) DebugExprParser(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.antlr.DebugExprParser) DebugExprException(com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprException) DebugExprExecutableNode(com.oracle.truffle.llvm.runtime.debug.debugexpr.nodes.DebugExprExecutableNode) ExecutableNode(com.oracle.truffle.api.nodes.ExecutableNode) DebugExprExecutableNode(com.oracle.truffle.llvm.runtime.debug.debugexpr.nodes.DebugExprExecutableNode) LLVMParserException(com.oracle.truffle.llvm.runtime.except.LLVMParserException)

Aggregations

LLVMParserException (com.oracle.truffle.llvm.runtime.except.LLVMParserException)32 Type (com.oracle.truffle.llvm.runtime.types.Type)12 FunctionType (com.oracle.truffle.llvm.runtime.types.FunctionType)11 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)11 ArrayType (com.oracle.truffle.llvm.runtime.types.ArrayType)10 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)10 AggregateType (com.oracle.truffle.llvm.runtime.types.AggregateType)9 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)9 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)7 AttributesGroup (com.oracle.truffle.llvm.parser.model.attributes.AttributesGroup)6 VectorType (com.oracle.truffle.llvm.runtime.types.VectorType)6 ArrayList (java.util.ArrayList)6 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)5 LLVMSourceType (com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType)5 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)5 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)4 TypeArrayBuilder (com.oracle.truffle.llvm.runtime.types.Type.TypeArrayBuilder)3 Matcher (java.util.regex.Matcher)3 CallTarget (com.oracle.truffle.api.CallTarget)2 TruffleFile (com.oracle.truffle.api.TruffleFile)2