Closed woodrush closed 3 years ago
Thanks for merging the 8cc branch, I added a commit to update the 8cc submodule reference.
You're welcome! Yes, I'm working on the Lisp-in-life project now, such as writing compiler optimizations, improving data structures, etc. Originally, only super-short programs such as (print (* 3 14))
worked, but the ROM and RAM sizes now shrank to 1/2 and 1/3, and large programs such as the prime number finder lisp program is working on the Life simulator now. I thought it was more exciting if larger programs worked. I'll be updating the repo once I write up the results.
The goto feature was particularly useful for reducing function calls, leading to optimization, by the way.
This pull request depends on this pull request from the 8cc submodule, so another commit to renew the submodule pointer should be made.
The computed goto feature (and the "Labels as Values" feature) allows the address of
goto
labels to be stored invoid*
pointers, and allows jumping to them by writing code such asgoto *ptr;
, as described here.Although this is a non-standard feature, the original 8cc implements this through
emit_label_addr
andemit_computed_goto
. However, these functions were left as is from the original 8cc code and also didn't have any tests, being left as unimplemented. Although 8cc finishes without errors when using this syntax, the compiled EIR causes an error when compiled by ELC.I have made a separate pull request in the 8cc repository that adds this feature. This pull request here in the ELVM repository adds a test for the computed goto feature.
I ran the tests on Ubuntu (
gcc 9.3.0
) and on a Mac (Apple clang version 12.0.0
), withmake && make build-py && make test-py
.