lumbda/c
russell@unturf.com 816ca9c33e
host: C-tier port of walk-circuit-ops + op-specs->bytes + count-lumbda-ops
Direct C translations of our Python-tier primitives at lumbda.py
_walk_circuit_ops / _op_specs_to_bytes / _count_lumbda_ops (commit
99701c8). Same algorithms; native dispatch via interned-Value identity
on cached symbol globals.

NO_SLOT representation differs from Python tier. Python stores the
literal 18446744073709551615 fixnum (arbitrary-precision int). C-tier
fixnums cap at 48 bits via NaN-boxing PAYLOAD_MASK, so we substitute
VAL_FALSE as our slot sentinel inside op-spec vectors; pack_u64_slot
writes 0xFFFFFFFFFFFFFFFF whenever it sees VAL_FALSE. Both tiers
produce byte-identical QECCOPS1 output.

API:
- (walk-circuit-ops registers ops) -> list of 7-element op-spec vectors
- (op-specs->bytes specs) -> latin-1 string of 56*N bytes
- (count-lumbda-ops ops) -> 3-element vector (toffoli clifford total)

Symbol cache (g_sym_ccx / g_sym_x / ...) initializes lazily on first
call; intern() is idempotent so repeat init costs nothing. Layout uses
make_hashtable + ht_set/ht_ref/ht_delete for O(1) qubit-base lookup
matching our Python dict-based implementation.

Measured wall on foxhop ecdsa's canonical p=11 textbook+refined emit
pair inside our QEMU guest:

  Python tier: 6.9 sec    (baseline after primitive lift)
  C tier:      0.71 sec   (9.7x over Python)

Output verified byte-identical against Python-tier reference files via
cmp on both textbook & refined paths.

Asm tier port deferred. Asm tier's documented role serves bulk 9024-
shot validation (simulator runs against an emitted ops.bin, 160x Python
on portal round-trip per whitepaper s6.6.4) — emit pipeline targets
Python / C tier. ~700-900 lines of hand-written x86_64 asm + QEMU
debug cycles, 2-4 day effort, no current asm-tier emit consumer.
2026-06-06 09:30:19 -04:00
..
.gitignore rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
bench.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
builtins.c host: C-tier port of walk-circuit-ops + op-specs->bytes + count-lumbda-ops 2026-06-06 09:30:19 -04:00
eval.c c: fix buffer overflow in load_file on non-seekable inputs 2026-06-04 12:44:43 -04:00
jit.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
jit.h rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
lumbda.h c: vm restores cur_code across CALL/RETURN, fixing JIT named-let hang 2026-06-04 01:11:18 -04:00
main.c c: enable Boehm GC by default, GC_INIT, file ops, regression test 2026-06-04 00:55:31 -04:00
Makefile c: enable Boehm GC by default, GC_INIT, file ops, regression test 2026-06-04 00:55:31 -04:00
portal.c portal-rng: add (random-seed-from-os!) across all three tiers 2026-04-20 15:50:26 -04:00
printer.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
reader.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
test.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
types.c cl-compat: run Zoë Trout's favorites unchanged (ticket 0004) 2026-04-24 07:02:21 -04:00
vm.c c: vm restores cur_code across CALL/RETURN, fixing JIT named-let hang 2026-06-04 01:11:18 -04:00