tools: generate the per-CPU SIMD inventory from LLVM's TableGen source - #330
Merged
Merged
Conversation
tools/gen_llvm_inventory.py reads llvm-project's X86.td, AArch64Processors.td and AArch64Features.td (plus the instruction/predicate .td files) at the llvmorg-* tag matching `rustc -vV` (22.1.8 under the pinned 1.98.1), resolves every processor's feature set, and writes: tools/llvm-inventory/inventory.json full per-CPU feature sets .claude/knowledge/llvm-cpu-inventory.md the human-readable table Each row also names the backend the simd.rs cfg ladder selects, and which instruction implements each crypto-relevant primitive (mul_lo32, variable u32 shift/permute, IFMA, carry-less multiply, AES round) on that CPU. The instruction defs and gating predicates are asserted to exist in the .td files, so an LLVM rename fails the generator instead of leaving a stale row. Like gen_ternlog_bodies.py, the output is committed and the script is its provenance; the default mode exits 1 if the committed output is stale. --verify-rustc compares every CPU (92 x86, 99 aarch64) with rustc's own `--print cfg -C target-cpu=...` over all features stable rustc exposes, using rustc's Rust<->LLVM name table parsed from rustc_codegen_llvm at the pinned release. 191/191 agree. The comparator failed first and drove five fixes: !listremove, the Architecture64 implied-list position, aarch64 architecture default extensions, the x86 ABI baseline, and tune records that imply ISA features (TuneOryon -> FullFP16/FP16FML/SPE). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
Contributor
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches📝 Generate docstrings
Comment |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_5884f8e0-4523-4c1d-9bf7-f996cf49d41f) |
AdaWorldAPI
marked this pull request as ready for review
September 24, 2026 22:59
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.
What this adds
tools/gen_llvm_inventory.pybuilds the per-CPU SIMD feature inventory from LLVM's public TableGen source instead of maintaining it by hand.X86.td,AArch64Processors.tdandAArch64Features.td, plus the instruction and predicate.tdfiles. They're read at thellvmorg-*tag that matchesrustc -vV, which isllvmorg-22.1.8under the pinned 1.98.1, so the inventory is the onecfg(target_feature)actually sees.!listconcat/!listremovechains,foreach P = [...]alias blocks,ProcessorAlias, implied-feature closure, aarch64 architecture default extensions, and tune records that imply ISA features.tools/llvm-inventory/inventory.json: full per-CPU feature sets for 92 x86 and 99 aarch64 CPUs;.claude/knowledge/llvm-cpu-inventory.md: the readable table. It includes the backend that thesimd.rscfg ladder selects, and which instruction implements each crypto-relevant primitive on that CPU:mul_lo32, variable u32 shift and permute, IFMA, carry-less multiply, and the AES round..tdfiles. An LLVM rename fails the run instead of leaving a stale row.It follows the
gen_ternlog_bodies.pypattern: the output is committed and the script is its provenance.Verification
--verify-rustccompares every CPU with rustc's own--print cfg -C target-cpu=.... It covers all features stable rustc exposes: 56 on x86 and 37 on aarch64. It uses rustc's own Rust↔LLVM feature-name table, parsed fromrustc_codegen_llvm/src/llvm_util.rsat the pinned release. 191/191 CPUs agree.The comparator failed first, and each failure drove a real fix:
!listremove;Architecture64's implied list from the right argument;ssbs);sse/sse2);TuneOryonimplies FullFP16, FP16FML and SPE).I also checked that the staleness mode fails: editing one row makes it exit 1, and regenerating clears it.
What the table shows
x86-64-v3, the portable baseline, has noaesand nopclmul. Compile-time dispatch on the v3 build cannot reach AES-NI or PCLMULQDQ.haswellhaspclmulbut notaesin LLVM's table.arrowlakehasavxifma, the VEX-encoded IFMA, without AVX-512.neoverse-v2(Graviton4, Grace) andcortex-x925have noaes, so no hardware AES and no 64-bit PMULL without an explicit+aes.Not in this PR
backendcolumn mirrors thesimd.rscfg ladder by hand; it isn't parsed fromsimd.rs.rustc/22.1-2026-05-19). Its AArch64.tdfiles matched the upstream tag byte for byte;--verify-rustcis the guard if that changes.src/changes. This is the generator's first stage; the missing primitives themselves come in later PRs.🤖 Generated with Claude Code
https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
Generated by Claude Code