revive STAGE2 RISCV64 backend
@kubkon only took me a month of work to feel this is enough to upstream.
- fixed a ton of incorrect stuff.
- struct / array access when they are on the stack, (still need to figure out the shifting stuff for registers).
- globals loading through the
load_symbol. -
@abs()for some cases. -
@byteSwap()for 16-bit. - loading 64-bit immediate (although in a bad way, really should not being allocating a register to do it).
- multiple args work correctly now, even though multiple levels of functions.
- pass by reference (aka pointer args) work now, and can be assigned to and stuff.
- lots of boilerplate added for addition and comparing and shifting.
- actual overflow checks for
airAddWithOverflowusing the struct parsing stuff. - slices work now, and we have panic messages with messages.
- added
R_ZIG_GOT_HI20andR_ZIG_GOT_LO12for loading symbols from.got.zig. - we actually follow the RISC-V calling convention correctly now.
- lots and lots more
all of these small little bug fixes will add up to create a nice stable environment for other contributors who are interested in RISC-V to find it more fun. not saying we're there yet, i'm rewriting stuff every hour.
PS. up to you guys if you wanna keep the panic function i made for stage2_riscv64. i'd like to keep it because it's a nice indication of when im panicking in a controlled fashion rather than segfaulting. but i can always add it back manually in my local set. just drop it if you dont want it, i've split it into it's own commit.
Tests
The test runner works now! Here is the current pass rate:
860 passed, 1064 failed - 44.70% passing
(so much boilerplate to write :P)
this is a good PR and all, but some of the strategies ive used aren't really clean and i dont like them. ill make this a draft while i redo some stuff.
it really shouldn't have been that difficult to merge in a couple more commits 😄
anyways, i've rewritten a large part of the pointer management, i'm happy enough for this to land.
marked as draft because these points are still left before this can land / be reviewed:
- [x] Rewrite stack frame abstraction.
- [x] Finish simplified test runner and get it running.
- [x] Enable
stage2_riscv64in the test matrix and disable all failing tests.
After you resolve conflicts, we're good to go!
Done!
Hmm, I still see conflicts.
Yeah, my fault. Github had a bit of a moment and decided to mark the entire merge commit as belonging to this PR. I don't think we need a 132k PR :sweat: . Gimme a couple minutes I'll figure it out.