Skip to content

add support for ppc64le

Kimplul requested to merge Kimplul/lightening:ppc-dev into main

Hi, I've been porting lightening to ppc64le. The testsuite passes and I'm able to compile GNU Guile in Qemu. The testsuite doesn't pass, but the tests fail at the same point regardless of whether I'm using JIT or not. Not to say that this is bug free, but seems to be at least usable. Real hardware would be great to test on, but I don't have access to any at the moment.

Addresses (at least to an extent) #9.

Caveats:

This builds on top of my MIPS branch, sharing some common code with it. Currently only ppc64le on Linux has been tested, as that is apparently the only flavor of ppc that Debian currently supports. Gentoo is one distro that seems to support all flavors of ppc, but I haven't really looked into how easy it would be to integrate into the CI. Unfortunately porting ppc turned out to not be quite as straightforward as MIPS, and there's a fair number of changes to the internals in this patch that makes it a bit extra. While working on this stuff, I ported some of the more useful-looking tests from Lightning, which found a number of bugs in existing ports. I'll open up a separate PR with the tests and details about them, but a lot of changes that may seem out of place in this PR are to work with the new tests.

I don't expect 32bit systems or operating systems other than Linux to work out of the box, as there was a fair bit of extra cruft to handle AIX and the SysV calling convention that I removed to keep things more clear for me. Eventually they could be patched back in, with required modifications of course.

Modifications to the internals

Besides what is presented in the MIPS PR, not really anything too significant. There is a new macro, JIT_ASYMMETRIC_STACK, which calls a function before a procedure call and another one after. This is used in ppc because the elf calling convention requires that all arguments passed on the stack be inside the current stack frame, i.e. the size of the frame has to be known beforehand. Efficient for compilers, but since we can't know how large a frame we will need, the approach I took was to generate a 'fake' stack frame at every procedure call, which requires some asymmetric building and destroying that the current system didn't support.

In the same vein, JIT_NEEDS_PROLOG is a macro that calls a prolog function in jit_enter_jit_abiand an epilog function in jit_leave_jit_abi. This is required because ppc has a separate link register that can't be accessed through any regular means, but is caller-save, so I use these functions to move the link register into a normal register that is then saved to the stack.

There are a number of changes made to accommodate for the ported tests that show up here and there, most obvious probably being JIT_EXTRA_SPACE and JIT_PLATFORM_CALLEE_SAVE_FPRS. I'll go over them in the other PR.

Over in my main branch is an amalgamation of all changes, both the ppc porting and bugfixing stuff.

Feedback and testing is welcome.

Edited by Kimplul

Merge request reports