Repository navigation
[AUTOMATED] feat(types): decode the rest of <data_organization> so scalar widths are knowable per target - #301
Merged
Merged
Conversation
…alar widths are knowable per target
`Architecture::decode_data_organization` matched only integer_size / long_size /
pointer_size / char_size / wchar_size; `<short_size>` (54 vendored cspecs),
`<long_long_size>` (51), `<float_size>` (60), `<double_size>` (61) and
`<long_double_size>` (56) fell through its `_ => {}` arm. Nothing could ask for
them, so nothing downstream could tell an LP64 target from an LLP64 one by
anything other than a single `long == 8` bool -- which is not enough to name a
C type: an 8-byte integer is `long` under LP64 and `long long` under ILP32 or
LLP64, and the fleet carries both (x86-64 gcc long_size 8; x86-64 Windows
long_size 4 with 8-byte pointers).
Adds the five widths as TypeFactory state with defaulted trait accessors (so the
test-only TypeFactory stubs keep compiling), the matching cspec decode arms, and
`setup_sizes` fallbacks for the 37 of 107 cspecs that carry no
<data_organization> element at all -- every PowerPC 32-bit one among them. A
spec that declares no long double aliases it to double (MSVC, ARM32), which is
the fallback applied.
The existing `size_of_long` fallback (`long = 8 whenever int == 4`, wrong for
MIPS32 and every PPC32) is deliberately left alone: `get_size_of_long` is read
by type inference, not just by rendering, so correcting it changes decompiled
output and belongs in its own measured PR.
Inert by construction -- nothing reads the new fields yet. Verified: 0 differing
lines of `decompile-all` output on fmt_x86_64, i386_pie_nl, fmt_arm and
mips_gp_le32 against the pre-change build. No option, no catalog row, no count
bumps.
New gate `verify_dataorg_sizes` pins the decoded tuple per data model, including
the three cases a hard-coded 2/4/8 table gets wrong: LP64, ILP32, and the x87
long double (10 on x86 ELF, where no sizeof can ever match it).
Gates: make test 675/675 PARITY OK, make test-stages PARITY OK, make check-spec
green.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01JyfU1KXNMWieY7HkFx2YbN
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
Architecture::decode_data_organizationmatched onlyinteger_size/long_size/pointer_size/char_size/wchar_size. Everything else in the cspec's<data_organization>fell through its_ => {}arm:<double_size><float_size><long_double_size><short_size><long_long_size>So nothing downstream could tell one data model from another by more than a single
long == 8bool — and that is not enough to name a C type. An 8-byte integer islongunder LP64 andlong longunder ILP32 or LLP64, and the fleet carries both:x86-64-gcc.cspecdeclareslong_size8,x86-64-win.cspecdeclares 4 with 8-byte pointers.This PR adds the five widths as
TypeFactorystate, the matching decode arms, andsetup_sizesfallbacks. It reads nothing back — it is the prerequisite for a per-architecture C type speller, split out so that change can be reviewed purely as a spelling change.Notes for review
get_size_of_short() -> 2etc.) so the several test-onlyTypeFactorystubs (p4_calls/modelrules/tests.rs,p4_calls/fspec/tests.rs) keep compiling;TypeFactoryImploverrides each with the decoded value.<data_organization>element at all — every PowerPC 32-bit one among them. A spec that declares nolong doublemeans the target aliases it todouble(MSVC, ARM32), which is the fallback applied.<long_double_size>is a value width, notsizeof. The x86 cspecs record 10 for the x87 extended format and annotate the storage width in a comment (<!-- aligned-length=16 -->). Consumers must treat it as an approximation to name, never as a layout guarantee — nosizeofassertion on a 10-byte float can hold on any target.size_of_longfallback is deliberately untouched.setup_sizessetslong = 8 whenever int == 4, which is wrong for MIPS32 and all six PPC32 cspecs. Butget_size_of_longis read by type inference, not only by rendering, so correcting it changes decompiled output on those targets and belongs in its own measured PR.Verification
Inert by construction — nothing reads the new fields. Confirmed rather than assumed:
decompile-alloutput diffed against the pre-change build on four data models —fmt_x86_64(85 lines),i386_pie_nl(3,800),fmt_arm(123),mips_gp_le32(112) — 0 differing lines each.New gate
verify_dataorg_sizespins the decoded tuple per data model, including the three cases a hard-coded 2/4/8 table gets wrong:(char 1, short 2, int 4, long 8, long long 8, ptr 8, float 4, double 8, long double 10)— LP64 with an x87 long double(1, 2, 4, 4, 8, 4, 4, 8, 10)— ILP32, so 8 bytes must spelllong longplus an invariant that no width ever decodes to 0 and
long double >= doubleon every fixture.Gates
make test— 675/675 PARITY OKmake test-stages— PARITY OKmake check-spec— greenmake rust-test— run locally (internal PRs skip the workspace suite)No option, no catalog row, no count bumps, no DIV row (nothing diverges yet).
🤖 Generated with Claude Code
https://claude.ai/code/session_01JyfU1KXNMWieY7HkFx2YbN