Repository navigation
t27o: second golden port -- csr_map.rs to specs/host/csr_map.t27 - #11255
Merged
Merged
Conversation
… t27o converts all 10 fns (Closes #11235) Step (a) of the second golden port. csr_offsets_strictly_increasing and csr_offsets_step_is_four loop over CSR_OFFSETS by index; status_masks_are_powers_of_two uses x != 0 && (x & (x - 1)) == 0. The meaning of each test is unchanged: cargo test host::csr_map ends with 10 passed, 0 failed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nd reviewed (Closes #11235) Step (c) of the second golden port. The spec is the 30 pub consts of the hand file and its 10 tests as test blocks (10 of 10 fns converted), plus one negative control and three oracle tests that pin every offset, bit position and mask. t27b test: 14 passed, 0 failed. No spec in specs/ defines a const of these names or mirrors this map. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…trap/src/host/csr_map.rs, mounted from host/mod.rs (Closes #11235) Steps (d) and (e) of the second golden port. t27c gen-rust writes the 30 pub consts of specs/host/csr_map.t27; host/mod.rs mounts the file by #[path] as module csr_map the way it mounts bitmask, so driver.rs and dma.rs (use super::csr_map) are unchanged. The 214-line hand file is deleted. cargo check --all-targets -p t27c ends with exit 0. The spec header now names the rust_std items gen-rust splices into the generated file. Hand lines: +1 / -215 (mod.rs +1 -1, csr_map.rs -214). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… HostCsrMap (Closes #11235) Steps (c) and (g) of the second golden port. tri t27o kept the hand tests as they were, and `t27c test-report` counted 10 of the 14 as vacuous passes (an assert on two constants folds at compile time, T730): tri pr preflight refuses that. The tests now read the constants out of const arrays at a loop index, keeping every hand test's name and property; the two oracle tests are merged into one table walk and one for bits and masks. test-report: 13 tests, 13 pass, vacuous passes 0 of 13. t27c seal --save writes .trinity/seals/host_HostCsrMap.json (closure: rust_std.t27); seal --verify: all hashes MATCH. The generated Rust differs from the previous commit only in its test count (14 to 13). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
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.
Closes #11235
The second golden port of step 4 of #9000, by the recipe of the first (#11157, bitmask).
bootstrap/src/host/csr_map.rs(214 lines: the BitNet AXI-Lite CSR address map and its 10 tests) is deleted; its spec, converted bytri t27oand read by eye, isspecs/host/csr_map.t27, andt27c gen-rustwritesbootstrap/gen/rust/host/csr_map.rs, whichbootstrap/src/host/mod.rsmounts by#[path]as modulecsr_map.driver.rsanddma.rs(use super::csr_map) andmain.rsare not touched.What is in the diff
bootstrap/src/host/csr_map.rsbootstrap/src/host/mod.rspub mod csr_map;line becomes the#[path]mount (+1 -1)specs/host/csr_map.t27pub consts, 13testblocksbootstrap/gen/rust/host/csr_map.rst27c gen-rust(never hand-edited).trinity/seals/host_HostCsrMap.jsonrust_std.t27Hand lines (the counted foreign files): +1 / -215, net -214. The own-language budget, compiled from the merge base's (
e10a1bb7c)gen/c/policy/own_language.cand fedgit diff --numstat --no-renames BASE...HEAD, endsrc=0(a control line of +5 / -0 hand Rust makes the same gate exit 1).How it was done, step by step
tri t27orefused were rewritten with index loops and a bit test (csr_offsets_strictly_increasingandcsr_offsets_step_is_fourusedwindows(2);status_masks_are_powers_of_twousedis_power_of_two; the bit test isx != 0 && (x & (x - 1)) == 0).cargo test host::csr_mapon that commit: 10 passed, 0 failed.tri t27o bootstrap/src/host/csr_map.rs:10 fn seen, 10 converted (10 of 10 tests), 0 refused.specs/defines a const of these names or mirrors this map (git grepon the names and the values);python3 -I tools/dupe_scan.py --likesays no function body long enough to compare, and the full scan on this head and on its merge base gives the same 4 findings (none head-only).t27c gen-rust, hand file deleted, mounted likebitmask.Evidence
pub const. The old file (git show origin/master:bootstrap/src/host/csr_map.rs) and the generated one were compiled into one rustc harness (throwaway, not committed) that compares each of the 30 oldpub consts by value, with both sides forced to one type: 30 compared, 0 disagree. The same harness with two planted differences reports them (5 disagreements, the table included), so it can fail. Every name of the old file is present in the new one.cargo check --all-targets -p t27cexit 0;cargo test -p t27c --bin t27c host::567 passed, 0 failed.t27b test: 13 passed, 0 failed.t27c test-report: 13 pass, vacuous passes 0 of 13.t27c seal --save,seal --verifyall hashes MATCH,tri seals sync-twinswrites 0 files,python3 tools/check_seal_currency.pyexit 0 (0 stale generated-code hashes of 2943 seals),python3 tools/check_seal_coverage.pyexit 0 (2943 seals, 2830 hold, 113 known-broken as inseal_baseline.txt). Both ran with a releaset27cbuilt from this head (merged with mastere10a1bb7c); a debug build madet27c sealfail for 245 other specs (the one I opened panicked on an integer overflow that a release build wraps), so it is not a valid instrument for those two checks.Read this when reviewing
tri t27okept the hand tests as they were, andt27c test-reportcounted 10 of the 14 spec tests as vacuous passes:assert(CSR_COUNT == 12)has two constants as operands, Zig folds it, and the test executes 0 runtime asserts (T730);tri pr preflightrefuses that. The tests now read the constants out of const arrays at a loop index, so each assert runs. Every hand test keeps its name and the property it pinned; the header of the spec says so.oracle_*tests that pin every offset, bit position and mask (the hand tests only pinned order, step, first and last, not which name sits at which offset).count_ones_u32,count_ones_u64,B_UNDERSCORE,alpha,digit,same,word. gen-rust splices them fromtools::t27o::rust_stdbecause one test callsrust_std::count_ones_u32;bitmask.rshas the same. Nothing outside the spec uses them, andrust_std.t27is in this seal's closure.#[test]s no longer exist ascargo testtests: they aretestblocks run byt27bandt27c test-report(the host test count of the crate falls by 10, the checks do not).CSR_OFFSETSis written[u32; CSR_COUNT as usize]by gen-rust; the type is[u32; 12]as before (the harness above would not compile otherwise).Known and not mine
tri pr preflight --quickon this branch:changes,check,tests,seal,types,dupes,census,budget,devhome,keptPASS.ledgersFAILs for the one reason a new spec always has:docs/reports/t27b_expectations.jsonhas no row for it. The row is{"path": "specs/host/csr_map.t27", "t27b": "pass"}(asspecs/host/bitmask.t27has); the steward applies it, this PR does not edit the ledger.suiteis NOT RUN under--quick.Not run
The full
tri pr preflight(corpus ratchet, about 11 minutes); the wholecargo testof the crate (onlyhost::);t27c test-reporton the corpus; a silicon or Verilog check of the spec (the map is host-side).🤖 Generated with Claude Code