Skip to content

Support checked Whale numeric operations and standardize Rust formatting - #860

Merged
LunaStev merged 4 commits into
wavefnd:masterfrom
LunaStev:feat/whale-checked-numerics
Oct 7, 2026
Merged

LunaStev merged 4 commits into
wavefnd:masterfrom
LunaStev:feat/whale-checked-numerics

Conversation

@LunaStev

@LunaStev LunaStev commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Summary

The Whale adapter previously rejected shifts and float-to-integer conversions. This change lowers them with Wave's existing HIR rules: shift counts are checked before narrowing, and invalid floating conversions trap before the cast. Invalid constants retain frontend diagnostics, while short-circuited operands remain unevaluated.

  • Update the official Whale master dependency to 020d2a4cf312123518ec75cc865eea1d257c5689 and round-trip generated format-3 IR through its reader and verifier.
  • Support checked left/right shifts and f32/f64-to-integer conversions for the adapter's existing 8–128-bit integer types. Preserve ordered conversions and signedness.
  • Include the repository's Rust style standardization with EditorConfig, rustfmt settings, and the function-spacing helper. Fix the helper's handling of bodyless trait declarations so it agrees with rustfmt. The broad frontend and LLVM diffs are formatting changes.

The PR also retains the existing README logo/header presentation change in fd07427.

Motivation

Advance the opt-in Whale backend under #93 using the established Wave semantics. The upstream verifier and text reader now allow the adapter to validate serialized IR as well as its in-memory representation.

Target and compatibility impact

Whale remains opt-in through --whale, limited to Linux amd64, O0, and IR output. LLVM remains the default. This does not add native Whale execution, wider runtime integer types, or new language semantics.

Untyped wide shift literals retain their original value until the range check; supporting those literals does not enable runtime integers wider than 128 bits. Tests inspect the emitted guard behavior and IR round trips, not native execution parity. This does not complete #773.

Validation

Passed locally with Rust 1.89 and LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 where needed:

  • cargo +1.89 test --locked --jobs 2 -p whale — 6 tests, including integer-width matrices, float boundaries, NaN/infinities, ordered conversions, and IR round trips.
  • cargo +1.89 test --locked --jobs 2 --test whale_backend — 11 tests.
  • cargo +1.89 test --locked --jobs 2 --no-default-features --features llvm-target-wasm --test whale_backend — 11 tests, validating Whale independence from native LLVM targets.
  • cargo +1.89 clippy --locked --jobs 2 --workspace --all-targets -- -D warnings.
  • RUSTUP_TOOLCHAIN=1.89 python3 tools/format-rust.py --check.
  • Bodyless trait declaration and function-spacing idempotence smoke checks.
  • git diff --check.

Cross-platform validation is left to PR CI.

Checklist

  • Commits include a DCO Signed-off-by line.
  • Tests cover new behavior or the PR explains why no test is needed.
  • User-facing changes include documentation or diagnostics updates.
  • The change preserves the license boundary between the compiler and std/.

Issues

Closes #862, closes #863, closes #864, closes #865, closes #866, closes #867.

Related to #93 and #773.

@LunaStev
LunaStev merged commit c5ab63f into wavefnd:master Oct 7, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment