mes.git
12 months agomescc: Add missing define.
Jan Nieuwenhuizen [Fri, 9 Nov 2018 15:56:54 +0000 (16:56 +0100)]
mescc: Add missing define.

* lib/x86-mes/x86.M1: Add missing define.

12 months agomescc: Exit if library cannot be found.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 13:46:46 +0000 (14:46 +0100)]
mescc: Exit if library cannot be found.

* module/mescc/mescc.scm (arch-find): Exit upon failure.

12 months agomescc: Accept -O, --std, -x.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 13:07:27 +0000 (14:07 +0100)]
mescc: Accept -O, --std, -x.

* scripts/mescc.in (parse-opts): Accept -O, --std, -x.

12 months agomescc: Support -dumpmachine.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 21:41:20 +0000 (22:41 +0100)]
mescc: Support -dumpmachine.

* scripts/mescc.in (parse-opts): Support -dumpmachine.

12 months agomescc: vsnprintf: Compliant implementation.
Jan Nieuwenhuizen [Mon, 22 Oct 2018 16:33:40 +0000 (18:33 +0200)]
mescc: vsnprintf: Compliant implementation.

* lib/stdio/vsnprintf.c (vsnprintf): New, complient implementation,
replacing vsnprint.
* lib/stdio/vsprintf.c (vsnprint): Forward to vsnprint.
* lib/stdio/snprintf.c (snprintf): Likewise.
* scaffold/tests/9a-snprintf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

12 months agotest: Add performance test.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:04:25 +0000 (12:04 +0200)]
test: Add performance test.

* module/mes/test.scm (pass-if-timeout): New macro.
* tests/perform.test: New test.
* build-aux/check-mes.sh (tests): Run it.

12 months agomes: Add ceil, floor, round, inexact->exact.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:07:06 +0000 (12:07 +0200)]
mes: Add ceil, floor, round, inexact->exact.

* mes/module/mes/scm.mes (ceil, floor, round, inexact->exact,
exact->inexact): New function.

12 months agomes: read-string: Take optional port argument.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:00:00 +0000 (12:00 +0200)]
mes: read-string: Take optional port argument.

* src/posix.c (read_string): Take optional port argument.
* mes/module/mes/guile.mes (read-string): Remove.

12 months agocore: eval_apply: Order gotos according to frequency.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 06:50:45 +0000 (08:50 +0200)]
core: eval_apply: Order gotos according to frequency.

* src/mes.c (eval_apply): Order gotos according to frequency.

12 months agoRevert "core: eval_apply profile."
Jan Nieuwenhuizen [Sun, 21 Oct 2018 06:43:35 +0000 (08:43 +0200)]
Revert "core: eval_apply profile."

This reverts commit d61e6be0b18459a8e3c262eab448b428dc81937a.

12 months agocore: eval_apply profile.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 06:25:07 +0000 (08:25 +0200)]
core: eval_apply profile.

* src/mes.c: Poor man's eval_apply profile.

12 months agocore: Fix displaying of closure.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 18:01:45 +0000 (20:01 +0200)]
core: Fix displaying of closure.

* src/lib.c (display_helper): Fix displaying of closure.

12 months agomes: Print backtrace upon exception.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 16:24:37 +0000 (18:24 +0200)]
mes: Print backtrace upon exception.

* mes/module/mes/catch.mes (display-backtrace,
frame-function): New function.
(%eh): Use them.

12 months agocore: Set procedure in stack frame.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 16:27:13 +0000 (18:27 +0200)]
core: Set procedure in stack frame.

* src/mes.c (eval_apply): Set procedure in stack frame.

12 months agocore: Implement stack and frame.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 16:23:20 +0000 (18:23 +0200)]
core: Implement stack and frame.

* src/lib.c (frame_printer make_frame_type, make_frame,
make_stack_type, make_stack, stack_length, stack_ref): New function.

12 months agocore: Support time functions.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 12:18:04 +0000 (14:18 +0200)]
core: Support time functions.

* lib/linux/clock_gettime.c: New file, move from gnu.c.
* lib/linux/gettimeofday.c: New file, move from tcc.c.
* lib/linux/time.c: New file, move from tcc.c.
* lib/linux/libc.c: Include them.
* lib/linux/gnu.c (clock_gettime): Remove.
* lib/linux/tcc.c (time, gettimeofday): Remove.
* include/time.h (CLOCK_PROCESS_CPUTIME_ID): New define.
* src/posix.c (init_time, current_time, gettimeofday_,
seconds_and_nanoseconds_to_long, get_internal_run_time): New function.
* src/mes.c (scm_symbol_internal_time_units_per_second): New symbol.
(main): Call init_time.

12 months agocore: Use hash table for symbols.
Jan Nieuwenhuizen [Thu, 18 Oct 2018 16:50:09 +0000 (18:50 +0200)]
core: Use hash table for symbols.

* src/mes.c (mes_symbols): Use hash table for symbols.  Update users.

12 months agocore: Use assert before failure exit.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 21:01:59 +0000 (23:01 +0200)]
core: Use assert before failure exit.

* src/mes.c (error): Use assert before failure exit.  Helps debugging.

12 months agocore: Add hashq_get_handle, hash, hash_ref, hash_set_x.
Jan Nieuwenhuizen [Thu, 18 Oct 2018 05:55:28 +0000 (07:55 +0200)]
core: Add hashq_get_handle, hash, hash_ref, hash_set_x.

* src/mes.c (scm_symbol_hashq_table, scm_symbol_record_type,
scm_symbol_module, scm_symbol_buckets, scm_symbol_size): New symbols.
Update users.
* src/hash.c (hash_list_of_char): Rename from hashq_.  Respect size,
update callers.
(hashq_, hash_ hash, hashq_get_handle, hash_ref, hash_set_x_,
hash_set_x): New function.
(hashq_ref): Do not return handle.  Update callers.

12 months agomes: Move pair? to core.
Jan Nieuwenhuizen [Thu, 18 Oct 2018 18:06:10 +0000 (20:06 +0200)]
mes: Move pair? to core.

* src/lib.c (pair_p): New function.  Gains 8% performance on MesCC.

12 months agomes: Move assoc to core.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 20:38:19 +0000 (22:38 +0200)]
mes: Move assoc to core.

* mes/mes.c (assoc_string, assoc): New function.
* mes/module/mes/scm.mes (assoc): Remove.  Gains 12% performance for
MesCC.

12 months agoRevert "core: Add gc-debug for stack array."
Jan Nieuwenhuizen [Sat, 20 Oct 2018 08:58:56 +0000 (10:58 +0200)]
Revert "core: Add gc-debug for stack array."

This reverts commit f35084d1dbea889d107824e7596da1701c6b90ad.

12 months agocore: Add gc-debug for stack array.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 19:23:17 +0000 (21:23 +0200)]
core: Add gc-debug for stack array.

* src/gc.c (gc_debug): New function.

12 months agoscaffold: Resurrect mini-mes.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 18:20:00 +0000 (20:20 +0200)]
scaffold: Resurrect mini-mes.

* src/mini-mes.c: Resurrect.

22 months agocore: Use array-based stack.
Jan Nieuwenhuizen [Thu, 14 Dec 2017 06:05:53 +0000 (07:05 +0100)]
core: Use array-based stack.

* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
(g_stack_array): New variable.
(g_stack): Change type to SCM*.
(gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
(gc_peek_frame): Likewise.
(gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
(gc): Likewise.

12 months agomes: Resurrect Guile-1.8 support.
Jan Nieuwenhuizen [Wed, 17 Oct 2018 07:47:20 +0000 (09:47 +0200)]
mes: Resurrect Guile-1.8 support.

* module/mes/mes-0.scm: Resurrect Guile-1.8 support.

12 months agocore: expand_variable: Remove weird exceptions: begin, if.
Jan Nieuwenhuizen [Tue, 16 Oct 2018 15:13:04 +0000 (17:13 +0200)]
core: expand_variable: Remove weird exceptions: begin, if.

* src/mes.c (expand_variable_): Remove weird exceptions: begin, if.

12 months agomes: Switch to srfi-9 based on structs.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 18:42:10 +0000 (20:42 +0200)]
mes: Switch to srfi-9 based on structs.

* mes/module/srfi/srfi-9.mes: Swap symlink to srfi-9-struct.mes.
* mes/module/srfi/srfi-9/gnu.mes: Swap symlink to gnu-struct.mes.
* src/module.c (make_module_type): Update to match srfi-9-struct
records.  Update users.
* src/hash.c (make_hashq_type): Likewise.

12 months agomes: srfi-9: Add implementation based on struct.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 14:57:00 +0000 (16:57 +0200)]
mes: srfi-9: Add implementation based on struct.

* mes/module/srfi/srfi-9-struct.mes: New file.
* mes/module/srfi/srfi-9-vector.mes: Rename from srfi-9.mes
* mes/module/srfi/srfi-9.mes: Symlink to srfi-9-vector.mes.
* mes/module/srfi/srfi-9/gnu-struct.mes: Add srfi-9-struct
implementation.
* mes/module/srfi/srfi-9/gnu-vector.mes: Rename from gnu.mes.
* mes/module/srfi/srfi-9/gnu.mes: Symlink to gnu-vector.mes.

12 months agocore: hashq-table: Refactor to be a record-like struct.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 13:45:41 +0000 (15:45 +0200)]
core: hashq-table: Refactor to be a record-like struct.

* src/hash.c (hash_table_printer): New function.
(make_hashq_type): New function.
* src/module.c (module_printer): Use it.
(make_module_type): New function.
(make_initial_module): Use them.

12 months agomescc: Mes C Library: oputs: New function.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 13:44:47 +0000 (15:44 +0200)]
mescc: Mes C Library: oputs: New function.

* lib/mes/oputc.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare it.

12 months agocore: Use hashq-table for macros.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 12:13:51 +0000 (14:13 +0200)]
core: Use hashq-table for macros.

* src/mes.c (lookup_macro_): Remove.
(macro_ref, get_macro, macro_set_x): New function.  Update callers.

12 months agocore: Add hashq-table type.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 11:36:19 +0000 (13:36 +0200)]
core: Add hashq-table type.

src/hash.c: New file.
src/module.c (char_hash, module_hash): Remove.
* src/module.c (make_initial_module): Use hash primitives.
(module_define_x): Likewise.
(module_variable): Likewise.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

12 months agocore: Add boot-module.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 08:44:47 +0000 (10:44 +0200)]
core: Add boot-module.

* src/mes.c (scm_symbol_boot_module): New symbol.
(eval_apply): Handle it.
(mes_symbols): Initialize it.

12 months agocore: Add module-define!
Jan Nieuwenhuizen [Sun, 14 Oct 2018 07:10:30 +0000 (09:10 +0200)]
core: Add module-define!

* src/module.c (module_define_x, module_printer): New function.
(make_initial_module): Use them.
* tests/srfi-0.test: Test it.
* src/mes.c (display_m0): Remove.  Update callers.
* mes/module/mes/fluids.mes (make-fluid): Rewrite.
* tests/macro.test: Test it.
* mes/module/mes/boot-0.scm.in (module-define!): Remove.
* mes/module/mes/boot-02.scm: Likewise.
* module/mes/misc.scm (pk, warn): New function.
* build-aux/check-mes.sh (tests): Run tests.

12 months agocore: Add module indirection for variable lookup.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 06:30:18 +0000 (08:30 +0200)]
core: Add module indirection for variable lookup.

* src/module.c (module_ref, module_variable): New function.
* src/mes.c: Thoughout: Use them.
(assq_ref_env): Remove.
* mes/module/mes/boot-0.scm.in (defined?): Use module-variable.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm: Likewise.

12 months agocore: Add module type.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 06:15:22 +0000 (08:15 +0200)]
core: Add module type.

* src/module.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

12 months agocore: Add cstring_to_symbol.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 05:38:51 +0000 (07:38 +0200)]
core: Add cstring_to_symbol.

* src/mes.c (make_symbol): Rename from lookup_symbol_.  Update
callers.
(cstring_to_symbol): New function.
* src/reader.c (reader_read_identifier_or_number): Use it.

12 months agocore: Add struct type.
Jan Nieuwenhuizen [Sat, 13 Oct 2018 15:34:27 +0000 (17:34 +0200)]
core: Add struct type.

* src/struct.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

12 months agobuild: factor-out snarfing.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 11:48:50 +0000 (13:48 +0200)]
build: factor-out snarfing.

* build-aux/snarf.sh: New file.
* build-aux/build-cc.sh: Use it.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-cc64.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/snarf.sh: Likewise.

12 months agocore: core:cdr: Support port type.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 10:28:02 +0000 (12:28 +0200)]
core: core:cdr: Support port type.

* src/mes.c (cdr_): Support port type.
* mes/module/mes/display.mes (display): Add space between fields.

12 months agomes: with-fluids: Fix reset.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 08:39:02 +0000 (10:39 +0200)]
mes: with-fluids: Fix reset.

* mes/module/mes/fluids.mes (with-fluids): Fix reset.
* tests/fluids.test (report): Remove Mes failure expectation.

12 months agomescc: Recognize U integer suffix.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 21:31:30 +0000 (23:31 +0200)]
mescc: Recognize U integer suffix.

* module/mescc/compile.scm (cstring->int): Recognize U integer
suffix.  Thanks, Peter de Wachter!

12 months agomescc: Add INTn_MIN/MAX defines to stdint.h.
Peter De Wachter [Tue, 16 Oct 2018 18:40:41 +0000 (20:40 +0200)]
mescc: Add INTn_MIN/MAX defines to stdint.h.

* include/stdint.h: Add INTn_MIN/MAX defines.  Move integere size
defines from limits.h
* include/limits.h: Include it.

12 months agomescc: Allow superfluous parentheses in function declarations.
Peter De Wachter [Tue, 16 Oct 2018 18:40:40 +0000 (20:40 +0200)]
mescc: Allow superfluous parentheses in function declarations.

E.g.:  int (f)();
This is obscure but valid C.  It occurs in the csmith headers (thanks
to macro shenanigans).

* module/mescc/compile.scm (fctn-defn:get-name,
fctn-defn:get-statement): Allow superfluous parentheses in function declarations.

12 months agomescc: Implement unary plus operator.
Peter De Wachter [Tue, 16 Oct 2018 18:40:38 +0000 (20:40 +0200)]
mescc: Implement unary plus operator.

* module/mescc/compile.scm (ast->type, expr->register,
try-expr->number):): Implement unary plus operator.

12 months agomescc: Add missing assembly defines.
Peter De Wachter [Tue, 16 Oct 2018 18:40:37 +0000 (20:40 +0200)]
mescc: Add missing assembly defines.

* lib/x86-mes/x86.M1: Add missing assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.

12 months agomescc: Delete duplicate assembly defines.
Peter De Wachter [Tue, 16 Oct 2018 18:40:36 +0000 (20:40 +0200)]
mescc: Delete duplicate assembly defines.

* lib/x86-mes/x86.M1: Delete duplicate assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.

12 months agomescc: Exit with non-zero exit code when subprocess fails.
Peter De Wachter [Tue, 16 Oct 2018 18:40:35 +0000 (20:40 +0200)]
mescc: Exit with non-zero exit code when subprocess fails.

system* returns the result of waitpid. So, suppose that a subprocess
fails with exit code 1. Then the waitpid return value will be 256.
And exit(256) is equivalent to exit(0).

Modified-by: Jan Nieuwenhuizen <janneke@gnu.org>
* mes/module/mes/posix.mes (status:exit-val): New function.
* module/mescc/mescc.scm (assert-system*): Use it.

13 months agomescc: Oops typo.
Jan Nieuwenhuizen [Fri, 12 Oct 2018 07:37:10 +0000 (09:37 +0200)]
mescc: Oops typo.

* module/mescc/M1.scm (hex2:immediate8): Typo.

10 months agocore: Support \xNN in reader. Fixes tcc-boot running on Mes. fix
Jan Nieuwenhuizen [Thu, 13 Dec 2018 17:19:19 +0000 (18:19 +0100)]
core: Support \xNN in reader.  Fixes tcc-boot running on Mes.

* src/reader.c (reader_read_string): Support \xNN.  Fixes Guix
bootstrap chain; i.e., compilation of gcc-2.95.3 using tcc-boot.
* tests/base.test ("reader: \\x08"): Test it.
* scaffold/tests/17-compare-char.c: Likewise, for mescc.
* build-aux/check-mescc.sh (tests): Run it.

11 months agobuild: configure: Make dot optional.
Jan Nieuwenhuizen [Sun, 18 Nov 2018 13:30:47 +0000 (14:30 +0100)]
build: configure: Make dot optional.

* configure: Make dot optional.

13 months agobuild: Oops, remove stray lib/linux/x86_64-mes/crt1.
Jan Nieuwenhuizen [Thu, 11 Oct 2018 19:14:14 +0000 (21:14 +0200)]
build: Oops, remove stray lib/linux/x86_64-mes/crt1.

* lib/linux/x86_64-mes/crt1: Remove.

13 months agobuild: x86_64 bootstrap build fixes and workaround.
Jan Nieuwenhuizen [Tue, 9 Oct 2018 17:22:51 +0000 (19:22 +0200)]
build: x86_64 bootstrap build fixes and workaround.

* configure: Substitute @arch@ (WAS: ARCH).  Update users.
* configure.sh: Substitute @arch@.
* build-aux/build-mes.sh: Use $GUILE for x86_64 build.
* build-aux/install.sh.in: Install mes.S, mes.x86_64-mes-S too.
Prune *.E, *.out.

13 months agodoc: Release update.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 15:19:04 +0000 (17:19 +0200)]
doc: Release update.

13 months agomescc: Oops, delete wrong line of assembly.
Jan Nieuwenhuizen [Mon, 8 Oct 2018 05:53:09 +0000 (07:53 +0200)]
mescc: Oops, delete wrong line of assembly.

* lib/x86-mes/x86.M1 (movzbl_%bx,%ebx): Delete wrong line.  Thanks, pdewacht!

13 months agoadmin: Release update.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 13:29:42 +0000 (15:29 +0200)]
admin: Release update.

* doc/announce/ANNOUNCE-0.18: New file.
* guix/git/mes.scm (mes): Update hash.

13 months agoRelease 0.18. v0.18
Jan Nieuwenhuizen [Thu, 4 Oct 2018 21:15:25 +0000 (23:15 +0200)]
Release 0.18.

* configure (VERSION): Update to 0.18.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.
* guix/mescc-tools-boot.patch: New file.

14 months agodoc: Release update.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 05:05:08 +0000 (07:05 +0200)]
doc: Release update.

* BOOTSTRAP: Update.
* HACKING: Update.
* NEWS: Update.
* README: Update.
* doc/mes.texi (Submitting Patches): Fix misquoting, misattribution.

13 months agomescc: Another attempt at divide.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 13:15:45 +0000 (15:15 +0200)]
mescc: Another attempt at divide.

* module/mescc/i386/as.scm (i386:r0/r1): Never be signed.  Use div for unsigned.
(i386:r0%r1): Likewise.
* module/mescc/x86_64/as.scm (x86_64:r0/r1): Likewise.
(x86_64:r0%r1): Likewise.
* lib/x86-mes/x86.M1: Add div.
* lib/x86_64-mes/x86_64.M1: Likewise.

13 months agotests: Expect srfi-13 failure, MesCC more resembles Gcc.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 12:14:50 +0000 (14:14 +0200)]
tests: Expect srfi-13 failure, MesCC more resembles Gcc.

* tests/srfi-13.test (report): Expect INT-MIN failure for x86.

13 months agocore: reader: Support 64 bit.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 22:58:31 +0000 (00:58 +0200)]
core: reader: Support 64 bit.

* src/reader.c (reader_read_identifier_or_number): Support 64 bit.
(reader_read_binary): Likewise.
(reader_read_octal): Likewise.
(reader_read_hex): Likewise.

13 months agomescc: Mes C Library: Fix execve on x86_64.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 20:38:28 +0000 (22:38 +0200)]
mescc: Mes C Library: Fix execve on x86_64.

* include/linux/x86_64/syscall.h (SYS_execve): Typo.  Fixes execve on
x86_64.

13 months agobuild: Support make seed for x86_64.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 20:26:07 +0000 (22:26 +0200)]
build: Support make seed for x86_64.

* build-aux/GNUmakefile.in (seed): Support make seed for x86_64.
* build-aux/build-mes.sh[SEED]: Also build src/mes.S.
* build-aux/build-x86_64-mes.sh[SEED]: Also build src/mes.x86_64-mes.S.

13 months agomes: Support fold-right 3.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 19:05:43 +0000 (21:05 +0200)]
mes: Support fold-right 3.

* mes/module/srfi/srfi-1.mes (fold-right): Support fold-right 3.
* tests/srfi-1.test ("fold-right-3"): Test it.

13 months agomescc: Nyacc comment escapes.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 18:32:49 +0000 (20:32 +0200)]
mescc: Nyacc comment escapes.

* module/mescc/compile.scm (ast->comment): Nyacc comment escapes.

13 months agomescc: Fix clobbering of struct by value assign.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 18:23:43 +0000 (20:23 +0200)]
mescc: Fix clobbering of struct by value assign.

* module/mescc/x86_64/as.scm (long-r0->r1-mem): New instruction.
* module/mescc/i386/as.scm: Likewise.
* lib/x86_64-mes/x86_64.M1: Support it.
* module/mescc/compile.scm (r0->r1-mem*n-): Fix clobbering.

13 months agocore: Add vector test.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 05:13:04 +0000 (07:13 +0200)]
core: Add vector test.

* scaffold/boot/11-vector.scm: New test.
* build-aux/check-boot.sh: Run it.

13 months agomescc: Fix obnoxious assignment ERROR message.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 17:22:16 +0000 (19:22 +0200)]
mescc: Fix obnoxious assignment ERROR message.

* module/mescc/compile.scm (expression->register): Fix assignment
ERROR message.

13 months agocore: Avoid 64bit zero divide.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 22:25:33 +0000 (00:25 +0200)]
core: Avoid 64bit zero divide.

* src/math.c (divide): Avoid (64bit) 0 divide.
(modulo): Likewise.

13 months agomescc: Support negative divide.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 15:28:08 +0000 (17:28 +0200)]
mescc: Support negative divide.

* module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Support
negative divide.
* module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise.
* lib/x86-mes/x86.M1: Likewise.
* lib/x86_64-mes/x86_64.M1: Likewise.
* scaffold/tests/a0-math-divide-signed-negative.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

13 months agomescc: Support --align, off by default.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:56:14 +0000 (15:56 +0200)]
mescc: Support --align, off by default.

* scripts/mescc.in (parse-opts): Add --align.
* module/mescc/mescc.scm (mescc:compile): Support --align, off by
default.
* module/mescc/M1.scm (infos->M1): Add #:align parameter.
(M1:merge-infos): Likewise.  Keep types.
(info->M1): Likewise.  Make alignment switchable.
* module/mescc/compile.scm (r->ident):  Do not clobber.
(ident-add): Likewise.
(clean-info): Keep types.
* module/mescc/i386/as.scm (i386:r->byte-label): New instruction.
* lib/x86-mes/x86.M1: Add instructions.
* lib/x86_64-mes/x86_64.M1: Add instructions.
* module/mescc/x86_64/as.scm (x86_64:r->byte-label,
x86_64:r->word-label, x86_64:r->long-label): New instruction.

13 months agoRevert "mescc: Make globals at least reg-size."
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:57:52 +0000 (15:57 +0200)]
Revert "mescc: Make globals at least reg-size."

This reverts commit 30544316c35ed4a2472f2029beb27e007d913792.

13 months agomescc: Make globals at least reg-size.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:36:32 +0000 (15:36 +0200)]
mescc: Make globals at least reg-size.

* module/mescc/compile.scm (global->info): Make globals at least reg-size.

13 months agomescc: Support 64-bit immediates.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 12:51:57 +0000 (14:51 +0200)]
mescc: Support 64-bit immediates.

* module/mescc/M1.scm (hex2:address8, hex2:immediate8): New function.
(info->M1): Support 64-bit.
* module/mescc/compile.scm (convert-r0): FIXME!
* module/mescc/x86_64/as.scm (x86_64:value->r, x86_64:r->local,
x86_64:label->arg, x86_64:label->r, x86_64:r+value,
x86_64:r-cmp-value, x86_64:r-long-mem-add, x86_64:r-and): Support
64-bit immediates.
* lib/x86_64-mes/x86_64.M1: Likewise.
* scaffold/tests/17-compare-unsigned-char-le.c: Test it.
* scaffold/tests/17-compare-unsigned-short-le.c: Test it.
* build-aux/check-mescc.sh (tests): Run them.

13 months agocore: Use proper name for %compiler.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 06:43:26 +0000 (08:43 +0200)]
core: Use proper name for %compiler.

* src/mes.c (mes_symbols, bload_env): : Use proper name for %compiler.

13 months agocore: Resurrect MES_MINI for non-POSIX.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 05:25:39 +0000 (07:25 +0200)]
core: Resurrect MES_MINI for non-POSIX.

src/mes.c[MES_MINI,!POSIX]: Resurrect.

13 months agomescc: Mes C Library: Add ultoa.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 10:02:16 +0000 (12:02 +0200)]
mescc: Mes C Library: Add ultoa.

* lib/mes/ultoa.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare ultoa.

13 months agomescc: Mes C Library: Add ltoa.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 09:59:20 +0000 (11:59 +0200)]
mescc: Mes C Library: Add ltoa.

* lib/mes/ltoa.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare ltoa.

13 months agomescc: Fix truncation of short.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 09:57:04 +0000 (11:57 +0200)]
mescc: Fix truncation of short.

* module/mescc/compile.scm (convert-r0): Typo.  Fixes truncation of
short.  Thanks, pdewacht!
* scaffold/tests/a0-call-trunc-char.c: New file.
* scaffold/tests/a0-call-trunc-short.c: New file.
* build-aux/check-mescc.sh: Add them.

13 months agobuild: Split-off x86_mes-gcc build.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 05:08:20 +0000 (07:08 +0200)]
build: Split-off x86_mes-gcc build.

* build-aux/build-cc64.sh: New file.
* build-aux/build.sh.in[CC64]: Invoke it.
* build-aux/build-cc.sh: Remove x86_64-mes-gcc build.
* build-aux/GNUmakefile.in (x86_64-mes-gcc): New target.
* build-aux/build-x86_64-mes.sh: Build all scafffold files.

13 months agobuild: Oops, use MES_LIBS.
Jan Nieuwenhuizen [Fri, 5 Oct 2018 20:12:48 +0000 (22:12 +0200)]
build: Oops, use MES_LIBS.

* build-aux/build-x86_64-mes.sh: Use MES_LIBS instead of the unused
MES64_LIBS.  Fixes build.  Thanks, pdewacht!

13 months agobuild: remove bashism.
Jan Nieuwenhuizen [Fri, 5 Oct 2018 19:24:14 +0000 (21:24 +0200)]
build: remove bashism.

* build-aux/trace.sh (trace): Remove bashism.  Thanks pdewacht!

13 months agocore: Support x86_64.
Jan Nieuwenhuizen [Thu, 4 Oct 2018 19:43:45 +0000 (21:43 +0200)]
core: Support x86_64.

* src/lib.c: Support x86_64.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/reader.c: Likewise.
* src/vector.c Likewise.

13 months agobuild: Oops, set VERSION.
Jan Nieuwenhuizen [Thu, 4 Oct 2018 21:10:56 +0000 (23:10 +0200)]
build: Oops, set VERSION.

* build-aux/install.sh.in (VERSION): New substituted variable.

13 months agobuild: Resurrect make seed.
Jan Nieuwenhuizen [Sun, 30 Sep 2018 10:15:11 +0000 (12:15 +0200)]
build: Resurrect make seed.

* build-aux/GNUmakefile.in (seed): Resurrect.
* build-aux/build-x86_64-mes.sh: Build from seed.

14 months agomescc: x86_64 support: Refactor to abstracted assembly, add x86_64.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 16:26:55 +0000 (18:26 +0200)]
mescc: x86_64 support: Refactor to abstracted assembly, add x86_64.

* module/mescc/as.scm: Support abstracted assembly.
* module/mescc/i386/as.scm: Rewrite.
* module/mescc/x86_64/as.scm: Implement.
* module/mescc/compile.scm: Refactor to abstracted assembly.
* module/mescc/M1.scm: Update for partial 64 bit support.
* module/mescc/bytevectors.scm (bytevector-u64-native-set!): New
procedure.
* module/mescc/i386/info.scm (i386:type-alist): Use 4 byte type length
also for faking double, long long, long double.
* module/mescc/info.scm:modified:
* module/mescc/x86_64/info.scm (x86_64:registers): New variable.
* lib/x86-mes/x86.M1: Update for new register scheme.
* lib/x86_64-mes/x86_64.M1: Implement.
* lib/x86-mes/setjmp.c: Implement.
* lib/x86_64-mes-gcc/setjmp.c: Implement.
* build-aux/build-cc.sh: Update for x86_64.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/test64.sh: Likewise.
* include/libmes.h: Likewise.
* include/setjmp.h: Likewise.
* include/signal.h: Likewise.
* include/stdarg.h: Likewise.
* include/sys/stat.h: Likewise.
* include/sys/types.h: Likewise.
* include/sys/wait.h: Likewise.
* include/unistd.h: Likewise.
* lib/libc+gnu.c: Likewise.
* lib/libc+tcc.c: Likewise.
* lib/linux/gnu.c: Likewise.
* lib/linux/libc-mini.c: Likewise.
* lib/linux/libc.c: Likewise.
* lib/linux/tcc.c: Likewise.
* lib/linux/x86_64-mes-gcc/mes.c: Likewise.
* lib/linux/x86_64-mes/crt1.c: Likewise.
* lib/mes/abtol.c: Likewise.
* lib/posix/mktemp.c: Likewise.
* lib/posix/wait.c: Likewise.
* lib/stdio/fopen.c: Likewise.
* lib/stdio/fputc.c: Likewise.
* lib/stdio/fseek.c: Likewise.
* lib/stdio/printf.c: Likewise.
* lib/stdio/sprintf.c: Likewise.
* lib/stdio/vfprintf.c: Likewise.
* lib/stdio/vsprintf.c: Likewise.
* lib/stdio/vsscanf.c: Likewise.
* lib/stdlib/qsort.c: Likewise.
* lib/x86-mes-gcc/setjmp.c: Likewise.
* scaffold/tests/11-if-1.c: Likewise.
* scaffold/tests/15-if-!f.c: Likewise.
* scaffold/tests/16-if-t.c: Likewise.
* scaffold/tests/21-char[].c: Likewise.
* scaffold/tests/23-pointer.c: Likewise.
* scaffold/tests/32-compare.c: Likewise.
* scaffold/tests/33-and-or.c: Likewise.
* scaffold/tests/34-pre-post.c: Likewise.
* scaffold/tests/35-compare-char.c: Likewise.
* scaffold/tests/36-compare-arithmetic.c: Likewise.
* scaffold/tests/37-compare-assign.c: Likewise.
* scaffold/tests/38-compare-call.c: Likewise.
* scaffold/tests/40-if-else.c: Likewise.
* scaffold/tests/41-?.c: Likewise.
* scaffold/tests/42-goto-label.c: Likewise.
* scaffold/tests/43-for-do-while.c: Likewise.
* scaffold/tests/44-switch.c: Likewise.
* scaffold/tests/45-void-call.c: Likewise.
* scaffold/tests/46-function-static.c: Likewise.
* scaffold/tests/51-strcmp.c: Likewise.
* scaffold/tests/51-strncmp.c: Likewise.
* scaffold/tests/53-strcpy.c: Likewise.
* scaffold/tests/54-argv.c: Likewise.
* scaffold/tests/60-math.c: Likewise.
* scaffold/tests/61-array.c: Likewise.
* scaffold/tests/63-struct-cell.c: Likewise.
* scaffold/tests/64-make-cell.c: Likewise.
* scaffold/tests/65-read.c: Likewise.
* scaffold/tests/70-printf.c: Likewise.
* scaffold/tests/71-struct-array.c: Likewise.
* scaffold/tests/72-typedef-struct-def.c: Likewise.
* scaffold/tests/74-multi-line-string.c: Likewise.
* scaffold/tests/76-pointer-arithmetic.c: Likewise.
* scaffold/tests/79-int-array.c: Likewise.
* scaffold/tests/7a-struct-char-array.c: Likewise.
* scaffold/tests/7b-struct-int-array.c: Likewise.
* scaffold/tests/7i-struct-struct.c: Likewise.
* scaffold/tests/7k-for-each-elem.c: Likewise.
* scaffold/tests/7l-struct-any-size-array.c: Likewise.
* scaffold/tests/7o-struct-pre-post.c: Likewise.
* scaffold/tests/7q-bit-field.c: Likewise.
* scaffold/tests/7s-struct-short.c: Likewise.
* scaffold/tests/80-setjmp.c: Likewise.
* scaffold/tests/81-qsort.c: Likewise.
* scaffold/tests/85-sizeof.c: Likewise.
* scaffold/tests/87-sscanf.c: Likewise.
* scaffold/tests/90-strpbrk.c: Likewise.
* scaffold/tests/91-fseek.c: Likewise.
* scaffold/tests/95-signal.c: Likewise.
* scaffold/tests/97-fopen.c: Likewise.
* scaffold/tests/99-readdir.c: Likewise.
* scaffold/tests/t.c: Likewise.
* lib/linux/x86_64-mes/mes.c: New file.
* lib/linux/x86_64-mes/mini.c: New file.
* lib/x86_64-mes/setjmp.c: New file.
* scaffold/tests/06-!call-1.c: New file.
* scaffold/tests/06-call-2.c: New file.
* scaffold/tests/06-call-variable.c: New file.
* scaffold/tests/08-assign-global.c: New file.
* scaffold/tests/08-assign-negative.c: New file.
* scaffold/tests/17-compare-and-or.c: New file.
* scaffold/tests/17-compare-and.c: New file.
* scaffold/tests/17-compare-ge.c: New file.
* scaffold/tests/17-compare-gt.c: New file.
* scaffold/tests/17-compare-le.c: New file.
* scaffold/tests/17-compare-lt.c: New file.
* scaffold/tests/17-compare-or.c: New file.
* scaffold/tests/17-compare-unsigned-ge.c: New file.
* scaffold/tests/17-compare-unsigned-gt.c: New file.
* scaffold/tests/17-compare-unsigned-le.c: New file.
* scaffold/tests/17-compare-unsigned-lt.c: New file.
* scaffold/tests/21-char[]-simple.c: New file.
* scaffold/tests/23-global-pointer-init-null.c: New file.
* scaffold/tests/23-global-pointer-init.c: New file.
* scaffold/tests/23-global-pointer-pointer-ref.c: New file.
* scaffold/tests/23-global-pointer-ref.c: New file.
* scaffold/tests/23-pointer-sub.c: New file.
* scaffold/tests/31-oputs.c: New file.
* scaffold/tests/32-call-wrap.c: New file.
* scaffold/tests/38-compare-call-2.c: New file.
* scaffold/tests/38-compare-call-3.c: New file.
* scaffold/tests/51-pointer-sub.c: New file.
* scaffold/tests/54-argc.c: New file.
* scaffold/tests/63-struct-array-assign.c: New file.
* scaffold/tests/63-struct-array-compare.c: New file.
* scaffold/tests/63-struct-array.c: New file.
* scaffold/tests/63-struct-assign.c: New file.
* scaffold/tests/63-struct-function.c: New file.
* scaffold/tests/63-struct-local.c: New file.
* scaffold/tests/63-struct-pointer.c: New file.
* scaffold/tests/63-struct.c: New file.
* scaffold/tests/70-printf-hello.c: New file.
* scaffold/tests/70-printf-simple.c: New file.
* scaffold/tests/70-stdarg.c: New file.
* scaffold/tests/70-strchr.c: New file.
* scaffold/tests/73-union-hello.c: New file.
* scaffold/tests/76-pointer-arithmetic-pp.c: New file.
* scaffold/tests/79-int-array-simple.c: New file.
* scaffold/tests/7b-struct-int-array-hello.c: New file.
* scaffold/tests/7b-struct-int-array-pointer.c: New file.
* scaffold/tests/7i-struct-struct-simple.c: New file.
* scaffold/tests/7k-for-each-elem-simple.c: New file.
* scaffold/tests/7l-struct-any-size-array-simple.c: New file.
* scaffold/tests/7o-struct-pre-post-simple.c: New file.
* scaffold/tests/7q-bit-field-simple.c: New file.
* scaffold/tests/90-strspn.c: New file.
* scaffold/tests/06-call-string.c.: Rename from 31-eputs.c.
* scaffold/tests/7t-function-destruct.c: Rename from 48-function-destruct.c.
* scaffold/tests/48-global-static.c: Rename from 49-global-static.c.
* scaffold/tests/55-char-array.c:renamed: Rename from 4a-char-array.c.
* scaffold/tests/51-itoa.c:r Rename from 52-itoa.c.
* include/signal.h:(struct sigaction):

14 months agomescc: x86_64 support: Add tests.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 15:19:50 +0000 (17:19 +0200)]
mescc: x86_64 support: Add tests.

14 months agomescc: Initial x86_64 support.
Jan Nieuwenhuizen [Tue, 14 Aug 2018 18:32:56 +0000 (20:32 +0200)]
mescc: Initial x86_64 support.

    make all-go && MES=guile ./pre-inst-env scripts/mescc -m64 -c scaffold/main.c

14 months agomescc: Prepare for x86_64 support.
Jan Nieuwenhuizen [Tue, 14 Aug 2018 10:35:24 +0000 (12:35 +0200)]
mescc: Prepare for x86_64 support.

* module/mescc/info.scm (info): Add allocated, registers.
* module/mescc/i386/info.scm: New file.
* build-aux/build-guile.sh (SCM_FILES): Add it.
* module/mescc/compile.scm (c99-input->info): Add info parameter.
(c99-ast->info): Likewise.
(i386:type-alist): Remove.
(alloc-register, free-register): New function.
(expr->register*): Rename from expr->accu*.  Update callers.
(expr->accu): Rename from expr->accu.  Update callers.
* module/mescc/mescc.scm(%info): New variable.
* module/mescc/mescc.scm (c->ast): Use it.
(mescc:compile): Likewise.
(E->info): Likewise.

13 months agoemacs: Add disassembly helpers.
Jan Nieuwenhuizen [Sun, 16 Sep 2018 09:07:39 +0000 (11:07 +0200)]
emacs: Add disassembly helpers.

* .dir-locals.el (as-32, as-64): Add disassembly helpers.

14 months agoguix: nyacc-for-mes: Update to 0.86.0.
Jan Nieuwenhuizen [Tue, 11 Sep 2018 17:35:24 +0000 (19:35 +0200)]
guix: nyacc-for-mes: Update to 0.86.0.

* guix/git/mes.scm (nyacc-for-mes): Update to 0.86.0 plus fix binary
literals.

14 months agomescc: Support gcc-3.0: Locale header fix.
Jan Nieuwenhuizen [Tue, 11 Sep 2018 05:01:33 +0000 (07:01 +0200)]
mescc: Support gcc-3.0: Locale header fix.

* include/locale.h (LC_ALL, LC_NUMERIC): Numbers, not strings.
(LC_COLLATE, LC_CTYPE): New macro.

14 months agobuild: Oops, fix ./check.sh for bootstrap build.
Jan Nieuwenhuizen [Sun, 9 Sep 2018 05:11:50 +0000 (07:11 +0200)]
build: Oops, fix ./check.sh for bootstrap build.

* build-aux/config.sh (top_builddir): Set default to `.'.

14 months agoguix: nyacc-for-mes: Update to 0.85.3.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 20:13:18 +0000 (22:13 +0200)]
guix: nyacc-for-mes: Update to 0.85.3.

* guix/git/mes.scm (nyacc-for-mes): Update to 0.85.3.

14 months agomes: Support Nyacc 0.85.3: Integrate progress.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 20:14:34 +0000 (22:14 +0200)]
mes: Support Nyacc 0.85.3: Integrate progress.

* mes/module/nyacc/lang/sx-util.mes: New file.
* mes/module/nyacc/version.mes: New file.
* mes/module/nyacc/lang/c99/cpp.mes (nyacc): Include them.
* mes/module/nyacc/lang/c99/parser.mes (nyacc): Include them.
* module/mescc/preprocess.scm (need-progress): New function.
(progress): New function.
(insert-progress-monitors): Use them to Integrate progress.

14 months agomes: Support Nyacc 0.85.3: Add char-set-copy.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 18:28:06 +0000 (20:28 +0200)]
mes: Support Nyacc 0.85.3: Add char-set-copy.

* mes/module/srfi/srfi-14.mes (char-set-copy): New function>

14 months agodoc: Update bootstrap graph.
Jan Nieuwenhuizen [Tue, 4 Sep 2018 05:51:15 +0000 (07:51 +0200)]
doc: Update bootstrap graph.

* doc/images/gcc-mesboot-graph.dot: Regenerate.
* build-aux/GNUmakefile.in (doc/mes.info): Oops change dependency to .png.
* doc/mes.texi (The Mes Bootstrap Process): Update image and wording.

14 months agoguix: Update hash.
Jan Nieuwenhuizen [Tue, 4 Sep 2018 04:40:47 +0000 (06:40 +0200)]
guix: Update hash.

* guix/git/mes.scm (mes): Update hash.

14 months agoRelease 0.17.1. v0.17.1
Jan Nieuwenhuizen [Mon, 3 Sep 2018 17:57:22 +0000 (19:57 +0200)]
Release 0.17.1.

* configure (VERSION): Update to 0.17.1.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* build-aux/GNUmakefile.in (gen-announce): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.