I am wondering that whether there is a BNF-grammar to describe LLVM IR? like C BNF grammar describing C language, etc.
相关问题
- CMakeList file to generate LLVM bitcode file from
- LLVM OPT not giving optimised file as output.
- Python numba / llvmlite on Debian 8 - i can't
- llvm::DIInstruction getFilename returns filename w
- Specifically what does a compiler do to aggressive
相关文章
- How to clone or create an AST Stmt node of clang?
- Libclang API to get function definitions defined i
- No format security warnings in Xcode 4.4
- LLVM retrieve name of AllocaInst
- In LLVM IR, I want to copy a set of Instructions a
- compiling with clang and plugin
- How to get the filename and directory from a LLVM
- At which level does one unit test lock-free code?
I just found LLIR ("Unofficial libraries for interacting with LLVM IR"), which includes a (WIP?) grammar repository ("BNF grammar for LLVM IR assembly").
This Eclipse plugin contains an Xtext grammar for LLVM IR.
Yes. Go to the file "LLParser.cpp" in "LLVM/lib/AsmParser"; the EBNF is spread throughput the file, for instance, the function
LLParser::ParseNamedType()
around line 350 has the following function-comment:I'm sure a regular-expression would happily extract the EBNF. I'm doing so by hand as I go through the parser.
My parser for LLVM assembly language, written for a YACC-like parser generator, can serve as a BNF definition for the language.
In reply to @tschwinge
One of the original authors here. The grammar repository is indeed a work in process, and the aim is to define a BNF grammar for the assembly language representation of LLVM IR. It's current progress may be tracked at https://github.com/llir/llvm/blob/master/current.md
In the future, my friends and I would wish to contribute this grammar back to the official LLVM project, and would love it if the lexer and parser were one day generated from a BNF grammar, as that would ensure an up-to-date specification of the language.
A problem we've encountered when writing the BNF grammar is that there is no single source of truth (well except the source code of course). We've compared the BNF comments of the source code against the LangRef documentation, and sometimes these were not in sync with the actual C++ code, which has lead to some confusion.
The current status of the BNF grammar is that it supports all instructions and constants expressions of LLVM IR. There are still some minor additions to be added to support all LLVM IR concepts, and currently we are working on supporting DWARF metadata. General metadata nodes are already supported.
Cheerful regards, /u & i
There isn't a published BNF grammar, but there is a polygen grammer file which is partially maintained, and used for exactly the purpose of randomly generating inputs to use to test the LLVM IR parser and lexer.
You can see the current version of the grammar here:
http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm.grm?revision=112427&view=markup