use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class LLScanner method parseGlobal.
private void parseGlobal(String line) {
final Matcher matcher = GLOBAL_NAME_REGEX.matcher(line);
if (matcher.matches()) {
String globalName = matcher.group("globalName");
globalName = LLVMIdentifier.toGlobalIdentifier(globalName);
map.registerGlobal(globalName);
} else {
throw new LLVMParserException(getErrorMessage("global", line));
}
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class LLScanner method parseInstruction.
private void parseInstruction(String line) {
assert function != null;
String id = null;
Matcher matcher = VALUE_NAME_REGEX.matcher(line);
if (matcher.matches()) {
id = matcher.group("instructionName");
id = LLVMIdentifier.toLocalIdentifier(id);
}
matcher = OP_NAME_REGEX.matcher(line);
if (matcher.matches()) {
id = matcher.group("instructionName");
}
if (id != null) {
function.add(id, currentLine);
} else {
throw new LLVMParserException(getErrorMessage("instruction", line));
}
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class LLScanner method findAndScanLLFile.
static LLSourceMap findAndScanLLFile(String bcPath, String pathMappings, LLVMContext context, List<LLVMSourceFileReference> sourceFileReferences) {
if (bcPath == null) {
return NOT_FOUND;
}
final TruffleFile llFile = findLLPathMapping(bcPath, pathMappings, context);
if (llFile == null || !llFile.exists() || !llFile.isReadable()) {
printWarning("Cannot find .ll file for %s (decrease %s logging level to disable this message)\n", bcPath, LLVMContext.llDebugLogger().getName());
return NOT_FOUND;
}
try (BufferedReader llReader = llFile.newBufferedReader()) {
final Source llSource = Source.newBuilder("llvm", llFile).mimeType("text/x-llvmir").build();
final LLSourceMap sourceMap = new LLSourceMap(llSource);
EconomicSet<LLVMSourceFileReference> sourceFileWorkset = createSourceFileSet(sourceFileReferences);
if (sourceFileWorkset == null) {
printVerbose("No source file checksums found in %s\n", bcPath);
}
final LLScanner scanner = new LLScanner(sourceMap, sourceFileWorkset);
for (String line = llReader.readLine(); line != null; line = llReader.readLine()) {
if (!scanner.continueAfter(line)) {
break;
}
}
if (sourceFileWorkset != null && !sourceFileWorkset.isEmpty()) {
printVerbose("Checksums in the .ll file (%s) and the .bc file (%s) do not match!\n", llFile, bcPath);
printVerbose("The following files have changed in the .bc file:\n");
for (LLVMSourceFileReference sourceFileReference : sourceFileWorkset) {
printVerbose(" %s\n", LLVMSourceFileReference.toString(sourceFileReference));
}
}
return sourceMap;
} catch (IOException e) {
throw new LLVMParserException("Error while reading from file: " + llFile.getPath());
}
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException in project graal by oracle.
the class LLScanner method beginFunction.
private void beginFunction(String line) {
assert function == null;
final Matcher matcher = FUNCTION_NAME_REGEX.matcher(line);
if (matcher.matches()) {
String functionName = matcher.group("functionNameUnquoted");
if (functionName == null) {
functionName = matcher.group("functionNameQuoted");
}
functionName = LLVMIdentifier.toGlobalIdentifier(functionName);
function = new LLSourceMap.Function(functionName, currentLine);
map.registerFunction(functionName, function);
} else {
throw new LLVMParserException(getErrorMessage("function", line));
}
}
use of com.oracle.truffle.llvm.runtime.except.LLVMParserException 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();
}
Aggregations