Setup frontend.janet to show the basics of what is going on. Currently
emitting "fake" instructions just to hash out the idea.
One apparent issue is how we handle register spilling during variable
argument IR instructions (function calls). Arguments should come
_before_ the function call not after.
Allows for builting with cosmopolitan, both with meson
and Makefile. Use:
CC=comsocc meson setup -Dipv6=false -Ddynamic_modules=false
-Dshared=false -Dos_name=cosmopolitan
to configure for cosmopolitan build.
This removes unnecessary movn, movf, lds, and a few other instructions.
Any instructions that has not side effects and writes to a slot that
isn't used can be removed. A number of other optimizations can follow
from this:
- Implement the def-aliasing-var optimization better
- This function can be iterated as a fix point until no more
instructions are removed.
- If we implement slot renaming, then we no longer need to free slots
and can simplify the initial code generation a lot.
Building janet requires janet_boot to be run on the host at build time;
- $(UNAME) can now be overridden from the make cmdline
- Added $(RUN) variable to allow a emulator to be specified
- Added ".exe" extension to binaries when using MINGW
Examples:
Cross compiling for win32 and running under wine:
```
make test \
CC=i686-w64-mingw32-gcc \
LD=i686-w64-mingw32-gcc \
UNAME=MINGW \
RUN=wine
Janet 1.27.0-ad7c3bed mingw/x86/gcc - '(doc)' for help
```
Cross compiling for aarch64 and running under qemu:
```
make repl \
CC=aarch64-none-linux-gnu-gcc \
LD=aarch64-none-linux-gnu-gcc \
RUN="qemu-aarch64 -L /tmp/aarch64/"
Janet 1.27.0-ad7c3bed linux/aarch64/gcc - '(doc)' for help
```
This allows a configuration workflow that is a bit simpler than before
and doesn't requiring applying patches. Instead, add a config.mk to
source dir with JANETCONF_HEADER=myconfig.h and compile as usual.
The patching workflow will of course still work exactly as before.