M1 immediates are limited to 31-bit before they become negative.
* module/mescc/x86_64/as.scm (x86_64:value->r, x86_64:r-cmp-value,
x86_64:r-long-mem-add, x86_64:r-and): Limit M1 immediate to #x80000000.
* lib/tests/scaffold/67-m1-overflow-check.c: New test.
* build-aux/check-mescc.sh (mes_tests): Add it.
This inexplicably fixes a segfault in tcc-boot0.
* module/mescc/armv4/as.scm (armv4:r0/r1): Instead of using "push 0",
use explicit slot for remainder.
* lib/arm-mes/arm.M1 (mov____%esp,%r3): New macro.
* module/mescc/armv4/as.scm (armv4:r0%r1): Use it to avoid overwriting
%r0 before caling __mesabi_uldiv.
Currently, sign-extension (CLTD vs XOR EDX) and signed division (IDIV vs
DIV) selected by setting "signed?". See, module/mescc/x86/as.scm.
Possibly we need a signed? based on numerator and denominator, and
add a extend-sign? based on the signedness of the numerator?
* module/mescc/compile.scm (expr->register): Base "signed?" strictly on
signedness of numerator.
* module/mescc/mescc.scm (M1->hex2): Update to use --little-endian.
(hex2->elf): Likewise, and --base-address.
* module/mescc/mescc.scm (hex2->elf): Likewise, and remove
--exec_enable.
The ARM port added the `-marm' option to mescc, where previously only
-m32' (the default) and `-m64' were supported.
Reported by Vagrant Cascadian <vagrant@reproducible-builds.org>.
* module/mescc/mescc.scm (arch-get-machine): When machine is "arm",
return "32".
* build-aux/build-mes.sh (LIBS)[mescc]: Add -lmescc.
This makes function alignment optional and disables function alignment
when using MesCC-Tools 0.5.2 (numbered architecture).
* module/mescc.scm (parse-opts): Make --align take a value.
* module/mescc/mescc.scm (mescc:compile, infos->hex2): Parse it and pass
it as renamed #:align keyword argument to ...
* module/mescc/M1.scm (infos->M1): ...here. Rename parameter align? to
align, pass it to...
(info->M1): ...here. Likewise. Use it to make function alignment
optional.
* module/mescc/mescc.scm (arch-get-define): Rename
to... (arch-get-defines): ...this. Return a list of defines: Also
adding __SIZEOF_INT__, __SIZEOF_LONG__, and add __SIZEOF_LONG_LONG__ if
it's >=8.
(mescc:preprocess, c->info): Update callers.
* include/stdint.h[!__SIZEOF_LONG_LONG__]: Remove typedefs for int64_t,
uint16_t.
This fixes 36-compare-arithmetic.c
* module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Do not reset
signed?.
* module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Use unique exit
value per failure.
After setting-up a buld environment, running something like
~/src/mes/wip/pre-inst-env mescc -v -v ~/src/mes/wip/scaffold/main.c
works again.
TODO: Make this less complex.
* The mescc-lib (and gcc-lib) build directories do not help;
these were introduced to support `wip-autotools'.
* We used to opt for short *PATH variables: "." rather than
/gnu/store/.... or /home/janneke/src/mes/master to avoid
filling the MES arena. XXX Has this been solved?
* In the Guix bootstrap, we run module/mescc.scm directly
$MES -e '(mescc)' module/mescc.scm
...so that's why these overrides started to appear in multiple
places.
* build-aux/pre-inst-env.in (MES_UNINSTALLED): New variable.
* scripts/mescc.in (includedir,libdir): Use it to override these.
* module/mescc/mescc.scm (arch-find): Use it to add <lib>-messc.
* lib/mes/div.c (__aeabi_idiv): Move for conditional compilation.
(__mesabi_idiv): New procedure.
* module/mescc/armv4/as.scm (armv4:r0/r1): Use __mesabi_idiv.
* module/mescc/armv4/as.scm (optimize-immediate): New macro.
(immediate->r0): Use it.
(armv4:value->r): Use it.
(armv4:local->r): Use it.
(armv4:r->local+n): Use it.
(armv4:r-byte-mem-add): Use it.
(armv4:r-word-mem-add): Use it.
(armv4:local-ptr->r): Use it.
(armv4:r+value): Use it.
(armv4:r-cmp-value): Use it.
(armv4:r0+value): Use it.
(armv4:byte-r->local+n): Use it.
(armv4:word-r->local+n): Use it.
* build-aux/build-guile.sh: Add ARM backend.
* lib/arm-mes/arm.M1: New file.
* module/mescc/armv4/as.scm: New file.
* module/mescc/armv4/info.scm: New file.
* module/mescc/mescc.scm: Use it.
* module/mescc/M1.scm (info->M1): Support ARM symbolic instructions,
including little endian instructions. Align functions.
* module/mescc/compile.scm (mes-or-reproducible?): New variable.
(ast->comment): Use it.
* module/mescc/preprocess.scm (mes-or-reproducible?): New variable.
(c99-input->full-ast): Use it.
* configure: Remove version check for mescc-tools.
Check for stage0 architecture flag type.
* configure.sh: Likewise.
* build-aux/build-scaffold.sh: Add stage0 flag type indirection.
* module/mescc/mescc.scm (arch-get-architecture): Likewise.
* guix/git/mes.scm (mes):
* module/mescc.scm (%includedir, %libdir): New variable.
(mescc:main): Add them to options.
* module/mescc/mescc.scm (mescc:preprocess, c->info): Add %includedir.
(arch-find): Use %libdir instead of
prefix-file.
(prefix-file): Remove.
* scripts/mescc.scm.in (%includedir, %libdir): Initialize from and set
in environment.
xx
* module/mescc/mescc.scm :
* module/mescc/compile.scm (init-declr->info): Do not attempt to
re-calculate function type.
(ftn-declr:get-type): Remove.
* lib/tests/scaffold/70-function-destruct-declare.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.
* lib/tests/scaffold/70-struct-post.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.
* module/mescc/compile.scm (expr->register): Use type size for rank
0 (WAS: 1).
* module/mescc/compile.scm (init->data): Respect type of size.
* lib/tests/scaffold/70-struct-short-enum-init.c: New file.
* lib/tests/scaffold/70-struct-short-enum-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.
* lib/tests/scaffold/70-array-in-struct-init.c: New file.
* lib/tests/scaffold/70-array-in-struct-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.
* module/mescc/compile.scm (array-init-element->data): Recurse for
elements instead of using init->data. Support array fields.