cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.97k stars 984 forks source link

LoongArch64 Support #754

Closed maoif closed 10 months ago

maoif commented 10 months ago

This pull request adds support for LoongArch64, which is an ISA similar to RISC-V. The machine type as returned by (machine-type) is [t]la64le, the internal architecture name is loongarch64.

This PR is basically an adaptation of this old PR toward those new features like unboxed floating points and vfasl.

mflatt commented 10 months ago

This is very nicely done! I built (in a qemu-hosted Arch Linux installation) and ran make test-one with no issues. I would like to test a little more, but this looks ready to go. Assuming it's ok, I would rebase, drop the merge commit, and fix the conflict in configure that I recently introduced before trying to merge the PR.

maoif commented 10 months ago

This is very nicely done! I built (in a qemu-hosted Arch Linux installation) and ran make test-one with no issues. I would like to test a little more, but this looks ready to go. Assuming it's ok, I would rebase, drop the merge commit, and fix the conflict in configure that I recently introduced before trying to merge the PR.

Thanks.

BTW, I ran the VM using the image here (in my case only 20.3 and 20.4 can boot) and the EFI file here:

qemu-system-loongarch64 \
          -m 8G -M virt -smp 4 \
          -cpu la464-loongarch-cpu \
          -serial stdio \
          -bios QEMU_EFI_8.1.fd \
          -device virtio-gpu-pci \
          -device nec-usb-xhci,id=xhci,addr=0x1b \
          -device usb-tablet,id=tablet,bus=xhci.0,port=1 \
          -device usb-kbd,id=keyboard,bus=xhci.0,port=2 \
          -net nic -net user \
          -nic user,hostfwd=tcp::33334-:22 \
          -hda Loongnix-20.4.cartoon.mini.loongarch64.cn.qcow2

Initial user:password: loongson:Loongson20

Aside from that, maybe we can add some github actions using this project to automate test for non-x86 architectures. It doesn't support loongarch now so more work needs to be done.

However, I tried using this project on my local branch a while ago and had some test failures that did not appear when run on qemu and the test time was several times longer.

mflatt commented 10 months ago

As an extra check, I built on hardware provided by Loongson at https://portal.cfarm.net/, which is about twice as fast a qemu on my machine, and ran more tests there. I found a failure that happens when running 5_6.ms with cp0=t, which is easiest to see this way:

cd tla64le/mats
../../bin/zuo . 5_6.mo cp0=t
grep compiler-internal 5_6.mo

shows

Expected error in mat vector-cas!: "compiler-internal: cas: no match found for (#{t d9q40fxqwbl62hchjs8tny84i-0} zero #[#{L15c:Triv:immediate jczowy6yjfz400ntojb6av7y0-15c-36} 36 536870921] #[#{L15c:Triv:immediate jczowy6yjfz400ntojb6av7y0-15c-36} 36 16] #[#{L15c:Triv:immediate jczowy6yjfz400ntojb6av7y0-15c-36} 36 24])".
Expected error in mat vector-cas!: "compiler-internal: cas: no match found for (#{t d9q40fxqwbl62hchjs8tny84i-1} zero #[#{L15c:Triv:immediate jczowy6yjfz400ntojb6av7y0-15c-36} 36 8796093022217] #[#{L15c:Triv:immediate jczowy6yjfz400ntojb6av7y0-15c-36} 36 16] #[#{L15c:Triv:immediate jczowy6yjfz400ntojb6av7y0-15c-36} 36 24])".

where the expected errors are

Expected error in mat vector-cas!: "vector-cas!: 67108864 is not a valid index for #(4 5 3)".
Expected error in mat vector-cas!: "vector-cas!: 1099511627776 is not a valid index for #(4 5 3)".
mflatt commented 10 months ago

Interestingly, but maybe not surprisingly, trv64le fails on the same way with that test+configuration.

maoif commented 10 months ago

The "compiler-internal" error is fixed in the new commit.

mflatt commented 10 months ago

Thanks!