DEV Community

COMMENTERTHE9
COMMENTERTHE9

Posted on • Originally published at cx-lang.com

Cx Dev Log — 2026-03-28

Seven commits of real work landed, capped by the long-anticipated submain merge into the main branch. The backend transitioned from handling only scalar layouts to supporting full data type coverage and initiated the production of loop IR. This marked the single most substantial day of backend progress to date.

The submain merge

PR #27 finally merged after two days of anticipation. This brought together the accumulated submain work for main: the multi-file import pipeline, Phase 8 Round 1 scalar layout, five vital fixes from the recent audit, dead code elimination, output verification in the matrix runner, and 6 new matrix tests. The test matrix on main now stands robust at 78 tests.

Why does this matter? Apart from having hard blockers for our 0.1 milestone cleared up, these new integrations bridge significant gaps, particularly around multi-file imports that had been stuck in the branch limbo.

Locking compound type layouts

Three pivotal Phase 8 commits saw to it that the remaining data type layouts for 0.1 are locked down. With yesterday's completion of scalar layout, every unanswered layout question in the ABI doc is now tied up.

Struct layout sticks to a declaration-order field format with natural alignment and padding. With seven tests in src/ir/types.rs, we're set for structs.

Array layout boasts a fixed-size, contiguous, stride-based setup. The offset is the product of the element's stride and its index, proven by five new tests.

Enum layout is minimalistic for 0.1: Just a tag-only u8 representation for now. The complexity of payload variants waits until post-0.1. This deliberate choice holds off adding discriminated unions and generic-induced layout headaches.

Calling convention is locked

Another key leap—a decisive Phase 8 commit locked the calling convention: a single return value with C ABI alignment, while copying parameter semantics remain for later. Our ABI doc swelled with 30 new lines detailing this convention. This was crucial to resolve the last major design question from Phase 8 Round 1, paving the way for seamless backend operations without lingering uncertainties.

Wrapping arithmetic consistency

Noticeable inconsistency plagued runtime arithmetic ops—some used saturating_add/saturating_sub while others opted for wrapping. We fixed this by switching to wrapping_add/wrapping_sub, with safeguards added for i128::MIN / -1 and i128::MIN % -1 to avert potential panics.

Now, all arithmetic consistently wraps at i128 range, with type-width truncation managed at assignment thanks to apply_numeric_cast. It's progress toward resolving the overflow behavior hurdle, though per-type-width arithmetic wrapping remains open. Most programs work fine under this setup, but narrow-type expressions might exhibit quirky intermediate values.

Phase 10: while loop lowering

The architectural leap of the day—the backend gains the ability to represent loops. A 189-line addition in src/ir/lower.rs now supports the header/body/exit CFG pattern for while loops, including SSA through block parameters and backedge generation. Three tests back this new feature.

Prior to this, the backend was bogged down with straight-line code and conditionals. Now, implementing loops unlocks non-trivial program capabilities. Leaping from Phase 8's data layouts to Phase 10's control flow in a day is noteworthy. With data layout locked and calling conventions fixed, backend focus shifts to control flow and advancing code generation.

What's next

Two more submain commits (wrapping arithmetic and while loop lowering) again put us ahead of main, suggesting another merge soon. Next up: tackling if/else lowering in the IR, crucial for bringing backend functionalities for basic 0.1 programs full circle.

Yet, we face delays in areas like the test runner and error model (Result)—now on their fourth day of inactivity, still remaining hard stops on the path to 0.1. While backend gets the spotlight, these issues linger critical.

The matrix holds steady at 78/78.


Follow the Cx language project:

Originally published at https://cx-lang.com/blog/2026-03-28

Top comments (0)