Chapter 13: double (Floating-Point) Support - #22
Merged
Merged
Conversation
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Cover NCC-defined behaviors the book's suite can't (UB in standard C): - out-of-range / +inf / NaN double->int and ->long yield the cvttsd2si "integer indefinite" (target MIN); discriminating comparisons avoid the 8-bit exit-code masking INT_MIN/LONG_MIN. - extend the return-fall-off regression with a double-returning function (synthetic return must target XMM0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
The pinned @beta action defaulted to the retired claude-sonnet-4-20250514 model, causing the Claude Code Review job to fail with a 404 not_found_error on every PR. Bump both workflows to @v1 (current default model), rename the now-required direct_prompt -> prompt input, and check out submodules in claude.yml so the @claude bot can run the test suite. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Chapter 13:
double(Floating-Point) SupportAdds
double(64-bit IEEE-754) end-to-end, removes the deprecated text-based emitter, adds linker-library / object-file inputs, and fixes a pre-existing tackifier panic.Language features
doubletype, floating-point constants (decimal/exponent lexing), arithmetic (+ - * /), unary negation, comparisons, and implicit/explicit conversions to and from every integer type.-Woverflow.Pipeline
ConstantDoubletoken + maximal-munch float regex;doublekeyword.Type::Double,Const::ConstDouble(f64),is_integer()helper, float-literal-Woverflow; extractedlocal_label_prefix().StaticInt→StaticInitwith aDoubleInit(f64)variant; double constant folding using the same rules as runtime (cvttsd2si-matchingdouble→intbounds);doublerejected inswitch/case; warning guards so integer-only diagnostics (div-by-zero, shift-count, constant-conversion) skip doubles;ConstEvalError::InvalidType.IntToDouble/UIntToDouble/DoubleToInt/DoubleToUIntconversion instructions (+ inline LLVM-correspondence docs).Reg;AssemblyType::Double; a.rodataconstant pool (ConstantPool, deduped byf64::to_bits, per-use 8/16-byte alignment); SSE lowerings —addsd/subsd/mulsd/divsd,xorpdnegation (-0.0mask),comisd, andcvtsi2sd/cvttsd2siwith the SSE2 workarounds for the unsigned conversions; System V ABI updated to passdoubleargs in XMM0–7 and return in XMM0 (sharedclassify_operandsfor callee/caller); pseudo-replacement andfix_invalidlegalize the new SSE forms (XMM14/XMM15 scratch).movsd/addsd/…/comisd/cvt*, emits the.rodatapool, addssetp/setnp+jp/jnp;-Sprints the constant pool as bit-exact.quad 0x… # <decimal>. Fixed the disassembly symbol resolver so immediates (e.g.$0) are no longer mis-symbolized to a code symbol at address 0.IEEE-754 / NaN semantics
Comparisons use
comisd(unsigned-style flags) and handle unordered (NaN) per IEEE:</<=swap operands to the carry-clearA/AE(false on NaN),==/!=combine the parity flag (NaN == xfalse,NaN != xtrue), andNaNis truthy in conditions.CondCodegainedP/NPwith per-variant docs.Deterministic / "Safer C" edges
double→integer truncates toward zero; out-of-range or NaN yields the x86cvttsd2si"integer indefinite" value (target MIN). Constant evaluation matches runtime for all of the above.Bug fix (pre-existing since ch12)
A non-
mainfunction with an unsigned return type that falls off the end panicked the tackifier — the synthetic-return only handledint/long, so unsigned/double hitunreachable!. Now a real syntheticretis emitted for every scalar return type. Regression test:tests/c_programs/unsigned/implicit_return_falloff.c(returns 2; fall-off values are deliberately unobserved per C §6.9.1p12).Removed: text-based emitter
Deleted
src/emit.rsand the--no-icedflag (the iced path is the sole, fully-featured backend;-Salready provides readable disassembly). Removed the now-orphanedCondCode::ins_suffixandStaticInit::data_directive.New CLI
-l <lib>(e.g.-lm) — forwarded to the linker (libwild /ld)..oinputs are accepted and passed straight to the linker (caller-owned, not cleaned up).Test harness (
tests/runner.rs)requires_mathlib→-lm(Linux; macOS uses libSystem).helper_libs/excluded from standalone discovery; thelibsmapping is honored — helpers are gcc-compiled and linked via NCC (exercising NCC's linker with external objects).CHAPTER_COMPLETED/EXTRA_COMPLETED12 → 13.Docs
README (Data Types table, grammar, IEEE/NaN note,
-l/.o) and CLAUDE.md (type system, Floating Point note) updated;--no-iced/emit.rsreferences removed.🤖 Generated with Claude Code