My friends and I have written a BNF grammar for LLVM IR assembly by
cross-referencing the LLVM Language Reference Manual , LLVM blog
posts , and the source code and associated comments of the LLVM IR
assembly parser . We did this as we wanted to be able to write tools
for both generating arbitrary syntactically correct LLVM IR (e.g. csmith
) to validate the tool chain, to generate LLVM IR parsers based on
the BNF, and to create a source of truth for the grammar of the LLVM IR
The current version of the BNF covers the entire LLVM IR assembly
language as of 2018-02-19, and is based on the source code of
lib/AsmParser/LLParser.cpp at revision rL324928 .
Without further ado, find the BNF grammar attached to this message. It
is also made available through Gist at  and a BNF grammar with
annotated production actions for an LLVM IR parser in Go is at .