You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Translate sizeof/_Alignof to opaque c_sizeof/c_alignof
Previously, the proposed sizeof support (on the 'sizeof' branch)
constant-folded sizeof / _Alignof to integer literals using clang's
target ABI. This commits to a specific platform layout in the emitted
F* code, which we want to avoid.
This change introduces a small Pulse library 'Pulse.Lib.C.Sizeof'
that declares:
- a reified 'c_type' inductive (Void / Bool / SizeT / PtrdiffT /
Int / Pointer / Array / Named)
- opaque c_sizeof : c_type -> SizeT.t
- opaque c_alignof : c_type -> SizeT.t
- axioms relating these to standard C facts (positivity, array
decomposition, sign-independence, sizeof(intN_t) == N/8).
The translation pipeline now lowers C 'sizeof(T)' / '_Alignof(T)' to
opaque calls, with the type structure preserved as a c_type term
(e.g. sizeof(int) -> c_sizeof (C_Int true 32)
sizeof(T[8]) -> c_sizeof (C_Array (C_Int true 32) 8)
sizeof(s) -> c_sizeof (C_Named "ty_s") for typedefs/structs).
Hauntedc (the spec mini-parser) understands sizeof(<type>) and
_Alignof(<type>) inside _ensures / _requires, so verified specs can
refer to the same opaque values as the function body.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments