Commit f88a757
authored
feat: add freestanding RISC-V support and improve test runner (#310)
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>1 parent 8063418 commit f88a757
44 files changed
Lines changed: 804 additions & 138 deletions
File tree
- llvm/src
- codegen
- expression/rvalue
- statement
- src
- test
- tools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
375 | 393 | | |
376 | 394 | | |
377 | 395 | | |
| |||
396 | 414 | | |
397 | 415 | | |
398 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
399 | 441 | | |
400 | 442 | | |
401 | 443 | | |
402 | 444 | | |
403 | 445 | | |
404 | 446 | | |
405 | 447 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
412 | 455 | | |
413 | 456 | | |
414 | 457 | | |
| |||
419 | 462 | | |
420 | 463 | | |
421 | 464 | | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
426 | 472 | | |
427 | 473 | | |
428 | 474 | | |
| |||
468 | 514 | | |
469 | 515 | | |
470 | 516 | | |
471 | | - | |
| 517 | + | |
472 | 518 | | |
473 | 519 | | |
474 | 520 | | |
| |||
481 | 527 | | |
482 | 528 | | |
483 | 529 | | |
484 | | - | |
| 530 | + | |
485 | 531 | | |
486 | 532 | | |
487 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
| 634 | + | |
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
129 | 179 | | |
130 | 180 | | |
131 | 181 | | |
132 | 182 | | |
133 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
134 | 186 | | |
135 | 187 | | |
136 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
137 | 192 | | |
138 | 193 | | |
139 | 194 | | |
140 | 195 | | |
141 | 196 | | |
142 | 197 | | |
143 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
144 | 203 | | |
145 | 204 | | |
146 | 205 | | |
| |||
155 | 214 | | |
156 | 215 | | |
157 | 216 | | |
158 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
159 | 220 | | |
160 | 221 | | |
161 | 222 | | |
162 | 223 | | |
163 | 224 | | |
164 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
165 | 228 | | |
166 | 229 | | |
| 230 | + | |
167 | 231 | | |
168 | 232 | | |
169 | 233 | | |
| |||
199 | 263 | | |
200 | 264 | | |
201 | 265 | | |
202 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
203 | 269 | | |
204 | 270 | | |
205 | 271 | | |
| |||
211 | 277 | | |
212 | 278 | | |
213 | 279 | | |
214 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
215 | 283 | | |
216 | 284 | | |
217 | 285 | | |
| |||
222 | 290 | | |
223 | 291 | | |
224 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
225 | 304 | | |
226 | 305 | | |
227 | 306 | | |
| |||
265 | 344 | | |
266 | 345 | | |
267 | 346 | | |
268 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
269 | 350 | | |
270 | 351 | | |
271 | 352 | | |
272 | 353 | | |
273 | 354 | | |
274 | 355 | | |
275 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
276 | 359 | | |
277 | 360 | | |
278 | 361 | | |
279 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
280 | 367 | | |
281 | 368 | | |
282 | 369 | | |
| |||
376 | 463 | | |
377 | 464 | | |
378 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
379 | 473 | | |
380 | 474 | | |
381 | 475 | | |
| |||
404 | 498 | | |
405 | 499 | | |
406 | 500 | | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
407 | 508 | | |
408 | 509 | | |
409 | 510 | | |
| |||
0 commit comments