Repository navigation
Emit a dispatcher for every table of functions - #4468
Merged
Merged
Conversation
`dispatch/fn_tables.rs` of each crate gets `<table>_auto()`, a safe function returning the best table the CPU supports of those of the same interface and data whose names are the table's own followed by `_<SUFFIX>` (`Rust.tableGroupsOf`), ranked as their suffixes in lowercase in the module of the table's first function (`Rust.tableDispatcher`). A function taking tables is proven for every table of their interface, and computes the same with any of the same data (`Abi.withTables`), so the Rust code can call it with the dispatcher's table, as it calls a function's dispatcher, instead of choosing the table itself, as `hashes::tables::TableHash` does today. The function dispatchers' `Arm` now holds an `Impl` (a name, a module, its features and `cfg` predicates) instead of an `Artifact`, so that both kinds share `armsOf`, `condOf` and the ranking. The coverage merge drops an unreached table dispatcher (`pub fn`) as it does a function's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHE2dqL6Q2PDogxfD5f
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHE2dqL6Q2PDogxfD5f
alex
enabled auto-merge
November 7, 2026 15:42
alex
pushed a commit
that referenced
this pull request
Nov 7, 2026
Main removed declarations only this branch still used (#4336, #4367, #4514): `fin64_exec_li_lit`, the RISC-V Miller–Rabin search pieces the sieved parameter candidate calls, and three of `ModExpWin`'s WP lemmas. They return, unchanged, as FFDH-only modules (`Proof/Ffdh/RISCV64/Li.lean`, `Impl/Ffdh/RISCV64/Search.lean`, `Proof/Ffdh/RISCV64/Search.lean`) and local lemmas in `Cached/Rows.lean`. The registrations drop `consts :=` (#4380). The generated code takes #4514's Montgomery schedule and #4468's dispatcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHHEKNw8eCDhgbwoFBL
alex
pushed a commit
that referenced
this pull request
Nov 15, 2026
Main removed declarations only this branch still used (#4336, #4367, #4514): `fin64_exec_li_lit`, the RISC-V Miller–Rabin search pieces the sieved parameter candidate calls, and three of `ModExpWin`'s WP lemmas. They return, unchanged, as FFDH-only modules (`Proof/Ffdh/RISCV64/Li.lean`, `Impl/Ffdh/RISCV64/Search.lean`, `Proof/Ffdh/RISCV64/Search.lean`) and local lemmas in `Cached/Rows.lean`. The registrations drop `consts :=` (#4380). The generated code takes #4514's Montgomery schedule and #4468's dispatcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHHEKNw8eCDhgbwoFBL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a TCB change (
lean/VerifiedGarbage/TCB/Rust.lean, the emitter). It adds Rust that the emitter writes; no ISA model, contract,Spec/or proof changes.Why
#4428 gave every function a generated dispatcher,
<fn>_auto, so that the Rust code stops choosing implementations by CPU feature. The hash functions can't follow until their tables of functions get the same. RSAES-OAEP, RSASSA-PSS and deterministic ECDSA take a hash function as a table (VG_HASH_SHA256,_SHANI,_AVX2, …). Today the Rust chooses which one throughhashes::tables::TableHash→<Hash>Backend::select(f).tables(). This PR adds the generated choice; the hash migration that uses it (deleting every<Hash>Backend) follows separately.What the emitter now writes
Each crate gets
dispatch/fn_tables.rs(Rust.tableDispatcher). For every table that needs no CPU feature, it gets a safe function returning the best table the CPU supports among its implementations:Rust.tableGroupsOf): the tables of the same interface and the same words of data whose names are its own followed by_<SUFFIX>.VG.Dispatch.rankingin the module of the table's first function, exactly as for functions, withextra,vendorand compound suffixes.Why returning any of them is sound
A function that takes tables is proven for every table of their interface (
Abi.withTables: the parameter holds the words of one of them). What it computes depends on which one only through the table's data. For example, OAEP's contract names the hash function at the index in the table's first word of data (HashTable.hashAt,Spec/RsaOaep/Tables.lean). So tables with the same interface and data give the same results, and the dispatcher only checks that the CPU has the chosen table's features.Requiring equal data is what keeps, say,
VG_HASH_SHA512_224from being taken as a variant ofVG_HASH_SHA512. A test checks this case.Abi.withTables's documentation already said "the Rust caller chooses the table by the CPU's features".Refactor
The function dispatchers'
Armnow holds anImpl(a name, the module of its item and features constant, its features andcfgpredicates) instead of anArtifact, so that tables sharearmsOf,condOfand the ranking. The generated function dispatchers are byte for byte unchanged: the only changes undercrates/are each target's newdispatch/fn_tables.rsand itsmodline.Checks
<Hash>Backend::select. For example, x86-64 tries SHA-NI, then AVX2, then the baseline, and AArch64's SHA-512 tries_SHA3, then the baseline.VerifiedGarbageTest/Dispatch.lean, on made-up tables:cfggates;ci/merge_rust_coverage.pydrops an unreached table dispatcher (pub fn) as it does a function's, with a test. Nothing calls them yet.lean/README.mdmention the table dispatchers.Static checksstep;cargo fmt --check;-D warnings) on x86-64, AArch64, ARMv7, x86, RISC-V and PPC64LE;Generated by Claude Code