badc (performance)

CI Release crates.io License: MIT OS Arch

badc is a small cross-platform optimizing C compiler, and a compiler-as-library, that emits native binaries for five targets from any host. It carries its own linker, DWARF emitter, inline-asm encoder, in-process JIT, and SSA interpreter. To ensure correctness, CI runs over 80 jobs and a few thousand tests, and fuzzing jobs run daily.

Demos

demos/ wires each project below as a smoke test; demos/README.md says what each exercises.

Lineage

It started as a Rust port of Robert Swierczek’s C compiler in four functions, c4, and diverged enough to call the dialect c5. Hence the c5 module and the C5Error type. c4.c ships as a test fixture and self-hosts:

badc -O -o c4 tests/fixtures/c/c4.c   # compile c4 to a native binary
./c4 hello.c                          # which then runs hello.c

And you can really crank the fun up with something like

badc -O --jit tests/fixtures/c/c4.c tests/fixtures/c/c4.c tests/fixtures/c/c4.c tests/fixtures/c/c4.c

to run it quadro-nested under JIT :)

It has since grown from a stack IR through a 3-operand IR to SSA with an optimizing backend.

Documentation

Disclaimer for those legally enlightened

This is a personal educational/research project, it has not been sponsored or suggested by anyone, i.e. it is a product of my own volition. That said, in no event I’ll be responsible for how you use this project or what happens due to that. See LICENSE for the exact terms.

^ To the top