Note: This project has been superseded by CirC, which is a Rust re-implementation of the compiler infrastructure.
It is archived here for reference purposes.
Currently we have frontends for:
- C
- circom
We have backends for:
- R1CS (proofs via libsnark)
- SMT
Once the dependencies are installed, you should be able to build the compiler:
stack build
stack test
To run an individual test (e.g., C value test), use:
stack test --ta '-p C value test'
We use brittany. You can format all files (slow) with make fmt.
You can format all files changed since a git-ref REF in a directory using
./scripts/format.bash REF DIR
You can format all files in a directory using
./scripts/format.bash all DIR
The formatting script will not format files which have unstaged changes.
For usage information:
stack exec compiler-exe -- -h
For example, to run function foo in file bar, use:
stack exec compiler-exe c foo bar.c -- --solve
There is a configuration system in src/Util/Cfg.hs. You can add new
configuration options there. Configuration options can be set by environmental
variables, like so:
C_cfg_with_underscores_instead_of_dashes=value stack run -- ...
One particularly useful configuration options is C_streams, which enables
logging streams. You can log to named streams using logIf in
src/Util/Log.hs, and the output will only appear if the specified stream is
enabled.
βββ app -- Compiler executable
βββ src
βΒ Β βββ AST -- Circom AST and C AST helpers
βΒ Β βββ Codegen -- Machinery for generating circuits
βΒ Β βΒ Β βββ Circify -- Language-indended machinery (branches, fns, scopes)
βΒ Β βΒ Β β βββ Memory-- Stack allocations and accesses
βΒ Β βΒ Β βββ Circom -- Circom
βΒ Β βΒ Β βββ C -- C
βΒ Β βββ IR -- The typed SMT intermediate representation
βΒ Β βΒ Β βββ SMT -- Logging
βΒ Β βΒ Β β βββ TySmt -- Sort-typed SMT terms
βΒ Β βΒ Β β βββ Assert-- Monad for accumulating SMT assertions
βΒ Β βΒ Β β βββ Opt -- Optimizations over SMT
βΒ Β βΒ Β β βββ ToPf -- Converting SMT to R1cs
βΒ Β βΒ Β βββ R1cs -- R1cs
βΒ Β βΒ Β βββ Opt -- Optimizations over R1cs
βΒ Β βββ Parser -- Machinery for parsing source files
βΒ Β βββ Targets -- TBD: Alex after code changes
βΒ Β βββ Util -- Utilities (e.g., logging)
βΒ Β Β Β βββ Log -- Logging
βΒ Β Β Β βββ Cfg -- Configuration
βββ test -- Tests