65816-llvm-mos/compare/README.md
Scott Duensing d95c30e819 Update.
2026-05-20 20:14:20 -05:00

44 lines
1.6 KiB
Markdown

# compare/ — backend output side-by-side with Calypsi 5.16
Each test case lives as three files:
- `<name>.c` — the C source.
- `<name>.ours.s` — our backend's assembly (`clang --target=w65816 -O2 -S`).
- `<name>.calypsi.lst` — Calypsi's listing file with source, hex bytes, and asm
in one document (`cc65816 --speed -O 2 --64bit-doubles`).
Calypsi's `--output` flag emits an ELF object, not text — its `--list-file` is the
human-readable artifact. (32-bit-doubles is Calypsi's default; we pass
`--64bit-doubles` so FP-heavy tests compare apples to apples against our IEEE-754
`double` ABI.)
## Regenerating
```
bash compare/regen.sh
```
Recompiles every `*.c` in this directory under both compilers and prints an
instruction-count summary:
```
test ours calypsi ratio
---- ---- ------- -----
evalAt 472 254 1.86x
mul16to32 1 4 0.25x
sumSquares 26 31 0.84x
```
(Numbers above are current as of 2026-05-20 — re-run for latest.)
## Adding a new comparison
Drop a `<name>.c` in this directory and run `regen.sh`. No other wiring needed.
## Counting methodology
The summary counts asm-line opcodes (lda/sta/jsl/...) on our side and listing
lines that begin with a hex byte (Calypsi's emit-byte column) on theirs.
Both metrics are static instruction counts, NOT bytes. They underestimate
calls-to-runtime (each libcall counts as one `jsl`, not the body it expands to).
For cycle counts, use `scripts/benchCycles.sh`.