fork of mes with aarch64 support
Find a file
Ekaitz Zarraga 47cffc5d2a mescc: Fix switch statements' fallthrough
Flattens case structures as nyacc is giving consecutive cases as a
nested block like:

    (case testA
      (case testB
        (case testC BODY)))

We convert to:

    ((case testA (expr-stmt))
     (case testB (expr-stmt))
     (case testC BODY))

And then treat them as independent cases. For the fallthrough we just
add a jump to each case's body right before its clause (each of the case
blocks is responsible of adding its own jump to its body):

        // This doesn't have it because it's the first
    CASE1:
        testA
    CASE1_BODY:

        goto CASE2_BODY
    CASE2:
        testB
    CASE2_BODY:

        goto CASE3_BODY
    CASE3:
        testB
    CASE3_BODY:

This enables complex fallthrough schemes comparing to what was done
before.

* module/mescc/compile.scm (ast->info)[switch]{flatten-cases}: New
variable.
(ast->info)[switch]{statements}: Use flatten-cases on it.
(switch->expr): Remove unneeded matchers and add jumps to body.
* build-aux/check-mescc.sh(xfail-tests): Remove
lib/tests/scaffold/66-local-char-array.c.
2023-11-05 09:45:31 +01:00
build-aux mescc: Fix switch statements' fallthrough 2023-11-05 09:45:31 +01:00
doc DRAFT doc: Update for 0.25. 2023-05-03 08:04:32 +02:00
guix/git guix: m2-planet: Update to 0.10.0-1-c82fb8c353. 2023-11-05 09:40:37 +01:00
include Revert "crt1: Move main declaration to mes/lib-mini.h." 2023-11-05 09:45:31 +01:00
lib lib/tests: 44-switch-body-fallthrough-not-default.c: Add test. 2023-11-05 09:45:31 +01:00
mes/module mescc: RISC-V64 code generation. 2023-11-05 09:40:37 +01:00
module mescc: Fix switch statements' fallthrough 2023-11-05 09:45:31 +01:00
scaffold riscv64: Cater for M2-Planet. 2023-11-05 09:40:37 +01:00
scripts build: Drop support for mescc-tools 0.5.2. 2023-05-03 14:52:25 +02:00
src core: Remove duplicate environment initialization. 2023-11-05 09:40:37 +01:00
tests tests: Make tests/vector.test compatible with Guile. 2023-08-27 10:05:20 +02:00
.dir-locals.el .dir-locals: Add test macro indentation. 2020-12-30 11:47:32 +01:00
.gitignore build: Ignore /m2 build directory. 2023-11-05 09:40:37 +01:00
AUTHORS doc: Update 'AUTHORS'. 2021-01-02 13:45:00 +01:00
BLURB doc: Release update. 2019-11-04 19:59:13 +01:00
BOOTSTRAP doc: Migration to Libera Chat. 2021-06-14 20:05:19 +02:00
ChangeLog Add missing copyright headers and READMEs. 2018-07-26 19:17:12 +02:00
configure configure: Recognize RISC-V architectures. 2023-11-05 09:39:29 +01:00
configure.sh build: Drop support for mescc-tools 0.5.2. 2023-05-03 14:52:25 +02:00
COPYING doc: Use HTTPS. 2022-10-30 09:40:40 +01:00
guix.scm doc: Use guix shell' instead of guix environment'. 2022-04-30 09:44:57 +02:00
HACKING doc: Use HTTPS. 2022-10-30 09:40:40 +01:00
INSTALL doc: Update dependencies, add M2-Planet. 2022-04-30 11:12:48 +02:00
kaem.arm x86_64: build: Cater for M2-Planet. 2023-11-05 09:36:26 +01:00
kaem.riscv64 riscv64: Cater for M2-Planet. 2023-11-05 09:40:37 +01:00
kaem.run riscv64: Cater for M2-Planet. 2023-11-05 09:40:37 +01:00
kaem.x86 x86_64: build: Cater for M2-Planet. 2023-11-05 09:36:26 +01:00
kaem.x86_64 kaem: Pass --64 to blood_elf on 64-bit arches. 2023-11-05 09:36:26 +01:00
NEWS doc: Update `NEWS'. 2023-02-13 07:19:16 +01:00
PORTING doc: Update `PORTING'. 2023-11-05 09:40:37 +01:00
README doc: Use HTTPS. 2022-10-30 09:40:40 +01:00
ROADMAP doc: Update `ROADMAP'. 2023-02-13 09:18:57 +01:00
simple.make lib: linux: Add wait4. 2023-05-03 08:04:32 +02:00
simple.sh lib: linux: Add wait4. 2023-05-03 08:04:32 +02:00

#+COMMENT:                                                            -*- org -*-
#+TITLE: About GNU Mes

#+SUBTITLE: Maxwell Equations of Software

[[https://www.gnu.org/software/mes][GNU Mes]] is a Scheme interpreter and C compiler for bootstrapping the GNU
System.  Since version 0.22 it has again helped to halve the size of
opaque, uninspectable binary seeds that are currently being used in the
[[https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25][Further Reduced Binary Seed bootstrap]] of [[https://www.gnu.org/software/guix][GNU Guix]].  The final goal is to
help create a full-source bootstrap as part of the [[https://bootstrappable.org][bootstrappable builds]]
effort for UNIX-like operating systems.

The Scheme interpreter is written in ~5,000 LOC of simple C, and the C
compiler written in Scheme and these are mutual self-hosting.  Mes can
now be bootstrapped from [[https://github.com/oriansj/m2-planet][M2-Planet]] and [[https://savannah.nongnu.org/projects/mescc-tools][Mescc-Tools]].

Mes has a Garbage Collector, a library of loadable Scheme modules--
notably Dominique Boucher's [[https://github.com/schemeway/lalr-scm][LALR]], Pre-R6RS [[https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html][portable syntax-case]] with
R7RS ellipsis, Matt Wette's [[https://www.nongnu.org/nyacc][Nyacc]] --and test suite, just enough to
support a REPL and a C99 compiler: mescc.

Mes + MesCC + Mes C Library can build a [[https://gitlab.com/janneke/tinycc][bootstrappable TinyCC]] that is
self-hosting.  Using this tcc and the Mes C library we now have a
Reduced Binary Seed bootstrap for the gnutools triplet: glibc-2.2.5,
binutils-2.20.1, gcc-2.95.3.  This is enough to bootstrap Guix for
i686-linux, x86_64-linux, armhf-linux and aarch64-linux.

Mes is inspired by The Maxwell Equations of Software: [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf][LISP-1.5]] -- John
McCarthy page 13, GNU Guix's source/binary packaging transparency and
Jeremiah Orians's [[https://github.com/oriansj/stage0][stage0]] ~500 byte self-hosting hex assembler.

We are very grateful to NLNet for sponsoring the [[https://nlnet.nl/project/GNUMes][Reduced Binary Seed
bootstrap]], the [[https://nlnet.nl/project/GNUMes-arm][ARM port]], and the [[https://nlnet.nl/project/GNUMes-ARM_RISC-V][Full Source Bootstrap.]]

GNU Mes is free software, it is distributed under the terms of the GNU
General Public Licence version 3 or later.  See the file [[file:COPYING][COPYING]].

* Get it

   #+BEGIN_SRC bash
   git clone git://git.savannah.gnu.org/mes.git
   #+END_SRC

* Build it (see [[file:INSTALL][INSTALL]] for full instructions)

   #+BEGIN_SRC bash
   ./configure
   make all
   make check
   #+END_SRC

* REPL it

   #+BEGIN_SRC bash
   ./pre-inst-env mes
   #+END_SRC

* MesCC compiler

   #+BEGIN_SRC bash
   ./pre-inst-env mescc -c scaffold/main.c
   #+END_SRC

* Bugs

    Please send Mes bug reports to [[mailto:bug-mes@gnu.org][bug-mes@gnu.org]].

* Links
  [0] https://www.gnu.org/software/mes
  [1] https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25
  [2] https://www.gnu.org/software/guix
  [3] https://bootstrappable.org
  [4] https://github.com/oriansj/m2-planet
  [5] https://savannah.nongnu.org/projects/mescc-tools
  [6] https://github.com/schemeway/lalr-scm
  [7] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html
  [8] https://www.nongnu.org/nyacc
  [9] https://gitlab.com/janneke/tinycc
  [10] [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf]]
  [11] https://savannah.nongnu.org/projects/stage0
  [12] https://nlnet.nl/project/GNUMes
  [13] https://nlnet.nl/project/GNUMes-arm
  [14] https://nlnet.nl/project/GNUMes-ARM_RISC-V

* Legalese
Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]>

  Copying and distribution of this file, with or without modification,
  are permitted in any medium without royalty provided the copyright
  notice and this notice are preserved.