This is a Zig library for reading and writing LLVM bitcode, a binary serialization format for LLVM IR.
Status: experimental and incomplete. Please see issues for remaining work and bugs.
This project has 3 components:
bitstream
, a low-level interface to LLVM's abstract container and encoding format known as bitstream.bitcode
, which handles parsing and rendering LLVM IR bitcode files, based on the bitstream format.bcanalyzer
, a command-line tool for printing information about LLVM IR bitcode files.
Install a recent version of Zig and Clang.
Build and use the bcanalyzer
CLI tool to read a bitcode file:
clang -emit-llvm -c my_file.c
zig build
./zig-out/bin/bcanalyzer --dump my_file.bc
If successfully parsed, the structure is printed as JSON, so you can pipe it to jq
.
See zig build --help
for more options, as usual.