Architecture¶
At a high level, hugr-qir takes a HUGR package, runs a Rust lowering pipeline, and emits QIR as LLVM IR or bitcode.
Main flow¶
Input HUGR is loaded through the CLI or the Python wrapper.
The Rust backend validates and transforms the package.
The backend lowers the result into an LLVM module.
The module is emitted as LLVM IR or bitcode.
The Python wrapper can optionally validate the generated QIR.
Main entrypoints¶
Native executable entry:
src/main.rsCLI argument handling:
src/cli.rsPython wrapper:
python/hugr_qir/cli.py
Wasm integration¶
Wasm metadata is parsed once when a Wasm file is provided, then validated at lookup time when a specific Wasm function is actually referenced. This keeps unrelated functions in the module from causing spurious failures.
The Wasm implementation lives in src/qir/wasm_ext.rs.