feat: add freestanding RISC-V support, migrate to opaque pointers, and enhance test runner#310
Merged
LunaStev merged 1 commit intoMar 29, 2026
Conversation
This commit introduces backend support for freestanding targets, including a complete initial implementation for RISC-V (rv64), migrates LLVM APIs to use opaque pointers, and drastically improves the Python test runner to support architecture-specific tests. [Details] 1. RISC-V and Freestanding Targets Support - Added new target configurations: `FreestandingX86_64`, `FreestandingArm64`, and `FreestandingRISCV64` (`riscv64-unknown-none-elf`). - Implemented C-ABI lowering rules (ByVal/SRet handling) for RISC-V 64-bit (`classify_param_riscv64`, `classify_ret_riscv64`). - Added inline assembly support for RISC-V, including physical register mapping (`x0`-`x31`, `a0`-`a7`, etc.), width calculations, default clobbers, and constraint validation (`r`, `m`, `i`, etc.). - Added RISC-V CPUs and target features to the CLI `print` commands. 2. LLVM Opaque Pointer Migration - Updated `abi_c.rs`, `legacy.rs`, and standard I/O generation (`printf`, `scanf`) to use modern LLVM opaque pointers (`context.ptr_type()`) instead of typed pointers (`i8_type().ptr_type()`), fixing API deprecation issues. 3. Test Runner & Metadata Improvements - Enhanced `tools/run_tests.py` to parse `// wave-test: host-os=<os>, host-arch=<arch>` metadata at the top of test files. - The test runner now automatically skips tests that do not match the host's OS or Architecture (e.g., skipping Linux syscall tests on macOS). - Applied metadata headers to existing hardware/OS-dependent tests (e.g., inline assembly and syscall tests). - Test runner now gracefully falls back to the `debug` build if the `release` binary is missing, and exits with code `1` if any tests fail. 4. Code Cleanup and Warning Fixes - Cleaned up unused variables, imports, and functions (e.g., removed `is_zero_decimal`, fixed `ASTNode::Enum` resolution). - Fixed an OS-specific unused import warning in `version.rs` (`std::fs`). - Removed an unnecessary `unsafe` block from the LLVM version fetcher. - Added `#[allow(dead_code)]` to currently unused runner functions. Signed-off-by: LunaStev <youngjae681@gmail.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.
1. RISC-V & Freestanding Target Support
Wave is now capable of targeting bare-metal/freestanding environments, specifically for RISC-V 64-bit systems.
FreestandingX86_64,FreestandingArm64, andFreestandingRISCV64(riscv64-unknown-none-elf).ByVal/SRet) to ensure compatibility with existing C-based firmware and kernels.x0-x31,a0-a7,t0-t6, etc.).r,m,i) and width calculations.printcommand to list RISC-V specific CPUs and target features.2. LLVM Opaque Pointer Migration
To align with modern LLVM standards (LLVM 15+), the backend has been migrated to use Opaque Pointers.
abi_c.rs,legacy.rs, and standard I/O generation (printf/scanf) to usecontext.ptr_type()instead of specific typed pointers (likei8*).3. Advanced Test Runner (
tools/run_tests.py)The Python test suite is now much more "aware" of the host environment, preventing false failures on incompatible platforms.
// wave-test: host-os=<os>, host-arch=<arch>headers at the top of.wavefiles.debugbuild if thereleasebinary is missing.1if any test fails, making it suitable for CI/CD pipelines.4. Code Hygiene & Maintenance
#[allow(dead_code)]to internal runner functions that are reserved for future debugger/REPL features.unsafeblock from the LLVM version fetcher.Benefits