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: improve inline asm parsing and type safety (#265)
Enhance inline assembly block parsing and type handling for greater
robustness and expressiveness.
Changes:
- **ASM Parsing**:
- `parse_asm_block` now supports generic `Expression` for inputs/outputs,
allowing variable references, literals (decimal, hex, binary),
pointers (`&x`), and dereferences (`deref x`).
- Added `parse_asm_operand` to handle various operand types.
- Implemented `parse_asm_inout_clause` for cleaner `in`/`out` parsing.
- Enforced `is_assignable` check for `out` operands.
- **LLVM Codegen**:
- `gen_asm_stmt_ir` refactored to support multiple outputs via struct
return values.
- `asm_operand_to_value` converts AST expressions to LLVM values,
handling literals (with correct radix) and address-of operations.
- `store_asm_output` handles writing assembly results back to variables,
including pointer casts.
- Added `coerce_basic_value` for explicit type conversions (e.g., int to
pointer for syscalls) and implicit widening.
- **Type Safety**:
- Implemented `coerce_to_expected` in function calls to automatically
widen integers (e.g., `i32` -> `i64`) and cast pointers where safe.
- `gen_variable_ir` now uses `coerce_basic_value` for initializers.
- **Tests**:
- Updated `test56.wave` (syscalls) to use new asm features and type-safe wrappers (`syscall4i`, `syscall4p`).
- Fixed array size in `test66.wave`.
- Added explicit type for overflow test in `test69.wave`.
- Marked `test56.wave` as a known timeout in test runner (server test).
- **Error Reporting**:
- Integrated `colorex` crate for colored error messages in `front/error`.
- Lexer now produces `IntLiteral` token type, storing the raw string
representation for later parsing (preserving radix info).
This update makes inline assembly more versatile and integrates it better
with the type system.
Signed-off-by: LunaStev <luna@lunastev.org>
0 commit comments