Search in sources :

Example 1 with BCFileRoot

use of com.oracle.truffle.llvm.parser.listeners.BCFileRoot in project graal by oracle.

the class LLVMScanner method parseBitcode.

public static void parseBitcode(ByteSequence bitcode, ModelModule model, Source bcSource) {
    final BitStream bitstream = BitStream.create(bitcode);
    final BCFileRoot fileParser = new BCFileRoot(model, bcSource);
    final LLVMScanner scanner = new LLVMScanner(bitstream, fileParser);
    final long actualMagicWord = scanner.read(Integer.SIZE);
    if (actualMagicWord != Magic.BC_MAGIC_WORD.magic) {
        throw new LLVMParserException("Not a valid Bitcode File!");
    }
    scanner.scanToEnd();
    // the root block does not exist in the LLVM file and is therefore never exited by the
    // scanner
    fileParser.exit();
}
Also used : BCFileRoot(com.oracle.truffle.llvm.parser.listeners.BCFileRoot) LLVMParserException(com.oracle.truffle.llvm.runtime.except.LLVMParserException)

Example 2 with BCFileRoot

use of com.oracle.truffle.llvm.parser.listeners.BCFileRoot in project sulong by graalvm.

the class LLVMScanner method parseBitcodeBlock.

private static void parseBitcodeBlock(Source source, ByteBuffer bitcode, ModelModule model) {
    final BitStream bitstream = BitStream.create(bitcode);
    final BCFileRoot fileParser = new BCFileRoot(source, model);
    final LLVMScanner scanner = new LLVMScanner(bitstream, fileParser);
    final long actualMagicWord = scanner.read(Integer.SIZE);
    if (actualMagicWord != BC_MAGIC_WORD) {
        throw new RuntimeException("Not a valid Bitcode File!");
    }
    scanner.scanToEnd();
    // the root block does not exist in the LLVM file and is therefore never exited by the
    // scanner
    fileParser.exit();
}
Also used : BCFileRoot(com.oracle.truffle.llvm.parser.listeners.BCFileRoot)

Aggregations

BCFileRoot (com.oracle.truffle.llvm.parser.listeners.BCFileRoot)2 LLVMParserException (com.oracle.truffle.llvm.runtime.except.LLVMParserException)1