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
feat: enhance C ABI compatibility, type inference, and JSON serialization (#293)
This commit improves the robustness of the LLVM backend regarding type
resolution under opaque pointers, refines C ABI lowering for aggregates,
and introduces JSON serialization utilities.
Changes:
- **LLVM Codegen & ABI**:
- **C ABI Refinement**: Updated `abi_c.rs` to pass small "mixed"
aggregates as direct values, allowing LLVM to handle register
assignment (INTEGER vs. SSE) more effectively for the C calling
convention.
- **Implicit Main Return**: Implemented implicit `return 0` for the
`main` function. If `main` is defined as void-like in Wave, it is
now lowered to an `i32` return in LLVM to satisfy standard
execution environments.
- **Symbol Resolution**: Fixed a bug in `gen_function_call` where
extern C functions were being looked up by their Wave name instead
of their redirected LLVM symbol name.
- **Address Generation**: Introduced `generate_address_and_type_ir`
to provide both the memory address and its corresponding LLVM type,
simplifying indexing and field access logic.
- **Type System & Pointers**:
- **Enhanced Inference**: Implemented `infer_wave_type_of_expr` and
`basic_ty_to_wave_ty` to improve Wave-to-LLVM type mapping,
especially for complex lvalues.
- **Legacy Compatibility**: Updated `deref` handling to allow redundant
dereferences on already-addressable lvalues (e.g., `deref array[i]`),
maintaining compatibility with existing code.
- **Parser & Verification**:
- **ABI Validation**: Added a verification pass to ensure only
`extern(c)` is used, as other ABIs are not yet supported.
- **JSON Utilities**:
- Added `write_pretty_to` and `write_compact_to` to the `Json` enum.
- Implemented full JSON string escaping (handles newlines, quotes,
slashes, and control characters).
- **CLI & Flags**:
- Added support for `-Os` (optimize for size) and `-Ofast`
(aggressive optimization) flags in the CLI and LLVM pass builder.
These updates stabilize the transition to opaque pointers and provide
a more predictable interface for system-level FFI and serialization.
Signed-off-by: LunaStev <luna@lunastev.org>
0 commit comments