Split svm1 into four architectures: svm1 x {32,64} x {be,le}.
authorTaylor R Campbell <campbell@mumble.net>
Tue, 11 Dec 2018 15:44:19 +0000 (15:44 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Tue, 11 Dec 2018 15:44:19 +0000 (15:44 +0000)
--with-cross-target must specify exactly which one to use for now.

--enable-native-code=svm1 or svm1-le or svm1-64 will fill in the
remaining parameters (word size, byte order) from the host system
characteristics.

22 files changed:
src/compiler/base/fasdump.scm
src/compiler/choose-machine.sh
src/compiler/configure
src/compiler/machines/C/compiler.pkg
src/compiler/machines/i386/compiler.pkg
src/compiler/machines/svm/.gitignore
src/compiler/machines/svm/big-endian.scm [new file with mode: 0644]
src/compiler/machines/svm/compile-assembler.scm
src/compiler/machines/svm/compiler.pkg
src/compiler/machines/svm/compiler.sf
src/compiler/machines/svm/decls.scm
src/compiler/machines/svm/little-endian.scm [new file with mode: 0644]
src/compiler/machines/svm/machine.scm
src/compiler/machines/svm/wordsize-32.scm [new file with mode: 0644]
src/compiler/machines/svm/wordsize-64.scm [new file with mode: 0644]
src/compiler/machines/x86-64/compiler.pkg
src/configure.ac
src/microcode/aclocal.m4
src/microcode/cmpintmd/svm1-config.h
src/microcode/configure.ac
src/microcode/confshared.h
src/microcode/svm1-interp.c

index e4228902d64b2636b6373aa4a175f272d0964d4b..700c49d4bf9a5abbf0300aaeaf5ba406de8128b6 100644 (file)
@@ -223,6 +223,11 @@ USA.
 (define fasl-format:aarch64le (make-std64le-fasl-format 25))
 (define fasl-format:aarch64be (make-std64be-fasl-format 25))
 
+(define fasl-format:svm1-32be (make-std32be-fasl-format 26))
+(define fasl-format:svm1-32le (make-std32le-fasl-format 27))
+(define fasl-format:svm1-64be (make-std64be-fasl-format 28))
+(define fasl-format:svm1-64le (make-std64le-fasl-format 29))
+
 #;
 (define fasl-format:pdp10
   (make-fasl-format
index 051886040f04fadc3f9c64dd0abb5f5514dc0c4e..b2c372786ce87e7ae3f01e4557ccef1faac1b73a 100755 (executable)
@@ -36,10 +36,11 @@ if test x"${TARGET_ARCH}" = xc; then
     exit 0
 fi
 
-if test x"${TARGET_ARCH}" = xsvm1; then
+case ${TARGET_ARCH} in
+svm1-32be|svm1-32le|svm1-64be|svm1-64le)
     echo svm
     exit 0
-fi
+esac
 
 if test -d "${HERE}/machines/${TARGET_ARCH}"; then
     echo "${TARGET_ARCH}"
index 169bc1a6ec19d80c791decd7fadb61ce2ea998dc..2bb7037550797cc6928eeb5ef642d5a221333508 100755 (executable)
@@ -55,3 +55,22 @@ for FN in ${LINKS}; do
     CMDS="rm -f ${FN} && ln -s machine/${FN} ${FN}"
     echo "${CMDS}"; eval "${CMDS}"
 done
+
+case ${TARGET_ARCH} in
+svm1-32be|svm1-32le)
+    ln -sf wordsize-32.scm machine/wordsize.scm
+    ;;
+svm1-64be|svm1-64le)
+    ln -sf wordsize-64.scm machine/wordsize.scm
+    ;;
+esac
+
+case ${TARGET_ARCH} in
+svm1-32be|svm1-64be)
+    ln -sf big-endian.scm machine/endian.scm
+    ;;
+svm1-32le|svm1-64le)
+    ln -sf little-endian.scm machine/endian.scm
+    ;;
+esac
+
index a77dd7baa4397411819c7852b807bb64998460af..bfa97abfaa0013249c796b4d37fb660c1dcb543b 100644 (file)
@@ -408,6 +408,10 @@ USA.
          fasl-format:mips32le
          fasl-format:ppc32
          fasl-format:sparc32
+         fasl-format:svm1-32be
+         fasl-format:svm1-32le
+         fasl-format:svm1-64be
+         fasl-format:svm1-64le
          portable-fasdump))
 
 (define-package (compiler constraints)
index f1fd35bcdf8a4a7d9f1a86969d4ca2384ff85ff9..fb11b624e0b56685b0ef147434dff21459c5804d 100644 (file)
@@ -394,6 +394,10 @@ USA.
          fasl-format:mips32le
          fasl-format:ppc32
          fasl-format:sparc32
+         fasl-format:svm1-32be
+         fasl-format:svm1-32le
+         fasl-format:svm1-64be
+         fasl-format:svm1-64le
          portable-fasdump))
 
 (define-package (compiler constraints)
index 26b0acef8888878c715b1ace82dc250593a2ccc7..6b5a626a7774e41052d462e2e8a085809f158c7d 100644 (file)
@@ -1,4 +1,6 @@
 assembler-db.scm
 assembler-rules.exp
+endian.scm
 svm1-defns.h
 svm1-opcodes.scm
+wordsize.scm
diff --git a/src/compiler/machines/svm/big-endian.scm b/src/compiler/machines/svm/big-endian.scm
new file mode 100644 (file)
index 0000000..6ca26b8
--- /dev/null
@@ -0,0 +1,32 @@
+#| -*-Scheme-*-
+
+Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
+    2017, 2018 Massachusetts Institute of Technology
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+|#
+
+;;;; Machine Model for SVM: Byte Order
+;;; package: (compiler)
+
+(declare (usual-integrations))
+\f
+(define-integrable endianness 'BIG)
\ No newline at end of file
index bdfaa12e13e81a346511e48d24e6a2b30fc93e15..cc97256914010011d0266d8021152f001e72bc1b 100644 (file)
@@ -28,6 +28,8 @@ USA.
   (lambda ()
     (let ((environment (make-top-level-environment)))
       (load "../../base/macros" environment)
+      (load "endian" environment)
+      (load "wordsize" environment)
       (load "machine" environment)
       ;; Load assembler-compiler before -runtime.
       ;; It needs to create RULE-MATCHER anti-syntax.
index 939e5b5bb883fd37d25a70fe7a4411a3dc403381..4762af8c3f358ced6a960568f5c085ead8474437 100644 (file)
@@ -36,6 +36,8 @@ USA.
         "base/sets"                    ;set abstraction
         "base/mvalue"                  ;multiple-value support
         "base/scode"                   ;SCode abstraction
+        "machines/svm/endian"          ;byte order
+        "machines/svm/wordsize"        ;word size
         "machines/svm/machine"         ;machine dependent stuff
         "back/asutl"                   ;back-end odds and ends
         "base/utils"                   ;odds and ends
@@ -394,6 +396,10 @@ USA.
          fasl-format:mips32le
          fasl-format:ppc32
          fasl-format:sparc32
+         fasl-format:svm1-32be
+         fasl-format:svm1-32le
+         fasl-format:svm1-64be
+         fasl-format:svm1-64le
          portable-fasdump))
 
 (define-package (compiler constraints)
index 0dc3d58e62f129048f30b63619f129e8202d414d..4c5db39af74a25d9800a577b9cc77ac0fdb84525 100644 (file)
@@ -75,6 +75,8 @@ USA.
        ((access initialize-package! environment)))
       (sf-and-load "base/pmlook")
       (sf-and-load "base/pmpars")
+      (sf-and-load "machines/svm/endian")
+      (sf-and-load "machines/svm/wordsize")
       (sf-and-load "machines/svm/machine")
       (sf-and-load "back/syntax")
       (sf-and-load "base/scode")
index 67ef02e76383b9ab471721bea8813d7940c270f6..df6c9f5d17ab5e9a9f669df108a719d39652522d 100644 (file)
@@ -349,7 +349,8 @@ USA.
                           "object" "proced" "rvalue"
                           "scode" "subprb" "utils"))
         (machine-base
-         (append (filename/append "machines/svm" "machine")
+         (append (filename/append "machines/svm" "endian" "wordsize"
+                                  "machine")
                  (filename/append "back" "asutl")))
         (rtl-base
          (filename/append "rtlbase"
diff --git a/src/compiler/machines/svm/little-endian.scm b/src/compiler/machines/svm/little-endian.scm
new file mode 100644 (file)
index 0000000..4e9de57
--- /dev/null
@@ -0,0 +1,32 @@
+#| -*-Scheme-*-
+
+Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
+    2017, 2018 Massachusetts Institute of Technology
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+|#
+
+;;;; Machine Model for SVM: Byte Order
+;;; package: (compiler)
+
+(declare (usual-integrations))
+\f
+(define-integrable endianness 'LITTLE)
\ No newline at end of file
index 83fe59022f59c577b381465d83955f0eb3ad3e8d..bc8d626407ebf7e2d9e3684ac04f5b72f867cbb5 100644 (file)
@@ -31,15 +31,24 @@ USA.
 \f
 ;;;; Architecture Parameters
 
-;; XXX Invent an svm1 fasdump format.
-(define (target-fasl-format) fasl-format:amd64) ;XXX
+(define (target-fasl-format)
+  (cond ((and (eq? endianness 'BIG) (= scheme-object-width 32))
+        fasl-format:svm1-32be)
+       ((and (eq? endianness 'LITTLE) (= scheme-object-width 32))
+        fasl-format:svm1-32le)
+       ((and (eq? endianness 'BIG) (= scheme-object-width 64))
+        fasl-format:svm1-64be)
+       ((and (eq? endianness 'LITTLE) (= scheme-object-width 64))
+        fasl-format:svm1-64le)
+       (else
+        (error "Unknown byte order and object width:"
+               `(,endianness ENDIAN)
+               `(,scheme-object-width BITS)))))
 
 (define use-pre/post-increment? #t)
-(define-integrable endianness 'LITTLE)
 (define-integrable addressing-granularity 8)
 (define-integrable scheme-type-width 6)
 (define-integrable scheme-type-limit #x40)
-(define-integrable scheme-object-width (if (fix:fixnum? #x100000000) 64 32))
 
 (define-integrable scheme-datum-width
   (- scheme-object-width scheme-type-width))
diff --git a/src/compiler/machines/svm/wordsize-32.scm b/src/compiler/machines/svm/wordsize-32.scm
new file mode 100644 (file)
index 0000000..d0de6f9
--- /dev/null
@@ -0,0 +1,32 @@
+#| -*-Scheme-*-
+
+Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
+    2017, 2018 Massachusetts Institute of Technology
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+|#
+
+;;;; Machine Model for SVM: Word Size
+;;; package: (compiler)
+
+(declare (usual-integrations))
+\f
+(define-integrable scheme-object-width 32)
\ No newline at end of file
diff --git a/src/compiler/machines/svm/wordsize-64.scm b/src/compiler/machines/svm/wordsize-64.scm
new file mode 100644 (file)
index 0000000..d1ca83b
--- /dev/null
@@ -0,0 +1,32 @@
+#| -*-Scheme-*-
+
+Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
+    1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
+    2017, 2018 Massachusetts Institute of Technology
+
+This file is part of MIT/GNU Scheme.
+
+MIT/GNU Scheme is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+MIT/GNU Scheme is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with MIT/GNU Scheme; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
+USA.
+
+|#
+
+;;;; Machine Model for SVM: Word Size
+;;; package: (compiler)
+
+(declare (usual-integrations))
+\f
+(define-integrable scheme-object-width 64)
\ No newline at end of file
index c06a21a579aa8b66143b38663602e9b70f16282d..f8b09924dd0421ce2fc3aee83fc7deea4e2c5303 100644 (file)
@@ -394,6 +394,10 @@ USA.
          fasl-format:mips32le
          fasl-format:ppc32
          fasl-format:sparc32
+         fasl-format:svm1-32be
+         fasl-format:svm1-32le
+         fasl-format:svm1-64be
+         fasl-format:svm1-64le
          portable-fasdump))
 
 (define-package (compiler constraints)
index abcc2b015bd62714b0168000a7ef8131c76474d6..c2cdb77e3abac634aed87f6eac4cbb54694972c2 100644 (file)
@@ -150,17 +150,20 @@ c)
     INSTALL_LIARC_BUNDLES=install-liarc-bundles
     IF_LIARC=
     ;;
-svm1)
+svm1-32be|svm1-32le|svm1-64be|svm1-64le)
     IF_SVM=
     ;;
 esac
 
 MIT_SCHEME_COMPILER_TARGET([${with_compiler_target}])
-if test x"${mit_scheme_compiler_target}" = xsvm1; then
+case ${mit_scheme_compiler_target} in
+svm1-32be|svm1-32le|svm1-64be|svm1-64le)
     IF_SVM_COMPILER=
-else
+    ;;
+*)
     IF_SVM_COMPILER='#!svm compiler: '
-fi
+    ;;
+esac
 
 AUXDIR_NAME=mit-scheme-${mit_scheme_native_code}
 AUXDIR='$(libdir)'/${AUXDIR_NAME}
@@ -264,12 +267,11 @@ directory, which is usually \`/usr/local/lib/mit-scheme-${mit_scheme_native_code
 fi
 
 # A 32bit host running LIAR/svm needs a large heap.
-if test x"${mit_scheme_native_code}" = xsvm1; then
-    AC_CHECK_SIZEOF([unsigned long])
-    if test ${ac_cv_sizeof_unsigned_long} -eq 4; then
-       HOST_COMPILER_HEAP="--heap 10000"
-    fi
-fi
+case ${mit_scheme_native_code} in
+svm1-32be|svm1-32le)
+    HOST_COMPILER_HEAP="--heap 10000"
+    ;;
+esac
 
 if test x"${enable_x11}" = x && test x"${enable_default_plugins}" = xyes; then
     AC_PATH_X
index 990eacd72a97b358265e57e41f1b18ae73fc7cd7..54361014de457af605512b3e3372bb8de674e0c2 100644 (file)
@@ -4,6 +4,12 @@ AC_DEFUN([MIT_SCHEME_NATIVE_CODE],[
 _mit_scheme_native_code_spec=$1
 _mit_scheme_native_code_host_cpu=$2
 
+AC_CHECK_SIZEOF([unsigned long])
+AC_C_BIGENDIAN(
+    [mit_scheme_host_byteorder=be],
+    [mit_scheme_host_byteorder=le],
+    [AC_MSG_ERROR([unknown host byte order])])
+
 AC_MSG_CHECKING([for native-code support])
 MIT_SCHEME_ARCHITECTURE([${_mit_scheme_native_code_spec}])
 
@@ -45,7 +51,40 @@ none)
 c)
     AC_MSG_RESULT([yes, using portable C code])
     ;;
-svm1)
+svm1|svm1-32|svm1-64|svm1-be|svm1-le|svm1-32be|svm1-32le|svm1-64be|svm1-64le)
+    case ${mit_scheme_native_code} in
+    svm1|svm1-be|svm1-le)
+       case ${ac_cv_sizeof_unsigned_long} in
+       4)
+           mit_scheme_svm_wordsize=32
+           ;;
+       8)
+           mit_scheme_svm_wordsize=64
+           ;;
+       *)
+           AC_MSG_ERROR([Unknown host word size])
+           ;;
+       esac
+       ;;
+    svm1-32le|svm1-32be)
+       mit_scheme_svm_wordsize=32
+       ;;
+    svm1-64le|svm1-64be)
+       mit_scheme_svm_wordsize=64
+       ;;
+    esac
+    case ${mit_scheme_native_code} in
+    svm1|svm1-32|svm1-64)
+       mit_scheme_svm_byteorder="${mit_scheme_host_byteorder}"
+       ;;
+    svm1-32be|svm1-64be)
+       mit_scheme_svm_byteorder=be
+       ;;
+    svm1-32le|svm1-64le)
+       mit_scheme_svm_byteorder=le
+       ;;
+    esac
+    mit_scheme_native_code=svm1-${mit_scheme_svm_wordsize}${mit_scheme_svm_byteorder}
     AC_MSG_RESULT([yes, using portable SVM code])
     ;;
 *)
@@ -99,8 +138,8 @@ yes|YES|y|Y)
 c|C)
     mit_scheme_architecture=c
     ;;
-svm|svm1)
-    mit_scheme_architecture=svm1
+svm1-32be|svm1-32le|svm1-64be|svm1-64le)
+    mit_scheme_architecture=${_mit_scheme_architecture_spec}
     ;;
 no|NO|none|NONE|n|N)
     mit_scheme_architecture=none
index 178b03a2c7c6be426719986e618b618f69306285..b89ea3182386be48878209d81806ae638057173c 100644 (file)
@@ -31,4 +31,6 @@ USA.
 #define CC_IS_SVM 1
 #define CC_IS_GENERIC 1
 
+extern const fasl_arch_t svm_fasl_arch;
+
 #endif /* !SCM_CMPINTMD_CONFIG_H_INCLUDED */
index 076a2a31b32e71cafe0b01b54257213066df6219..136691c6480aba40080c096248a94cd2b980d887 100644 (file)
@@ -861,7 +861,7 @@ c)
     AUX_PROGRAMS="gen-nonce extract-liarc-decls"
     INSTALL_INCLUDE=install-include
     ;;
-svm1)
+svm1-32be|svm1-32le|svm1-64be|svm1-64le)
     OPTIONAL_BASES="${OPTIONAL_BASES} svm1-interp"
     ;;
 *)
@@ -880,10 +880,18 @@ if test x"${mit_scheme_compiler_target}" = xc; then
     AC_CONFIG_FILES([liarc-ld], [chmod +x liarc-ld])
 fi
 
+case ${mit_scheme_native_code} in
+svm1-32be|svm1-32le|svm1-64be|svm1-64le)
+    cmpintmd=svm1
+    ;;
+*)
+    cmpintmd=${mit_scheme_native_code}
+    ;;
+esac
 AC_CONFIG_LINKS([
-    cmpintmd.h:cmpintmd/${mit_scheme_native_code}.h
-    cmpintmd.c:cmpintmd/${mit_scheme_native_code}.c
-    cmpintmd-config.h:cmpintmd/${mit_scheme_native_code}-config.h
+    cmpintmd.h:cmpintmd/${cmpintmd}.h
+    cmpintmd.c:cmpintmd/${cmpintmd}.c
+    cmpintmd-config.h:cmpintmd/${cmpintmd}-config.h
     ])
 
 for base in ${OPTIONAL_BASES}; do
index bcbadf5d222640d4e6124ebd6e30725ee276ab50..13ce4c3ea39b833efc0badc250d90f39d10d0d50 100644 (file)
@@ -222,6 +222,10 @@ typedef enum
   FASL_IA64,
   FASL_ARM,
   FASL_AARCH64,
+  FASL_SVM1_32BE,
+  FASL_SVM1_32LE,
+  FASL_SVM1_64BE,
+  FASL_SVM1_64LE,
 } fasl_arch_t;
 
 /* Possible values for COMPILER_PROCESSOR_TYPE.  This identifies the
@@ -657,4 +661,9 @@ extern void win32_stack_reset (void);
 #  define HEAP_FREE(address)
 #endif
 
+#ifdef CC_IS_SVM
+#  undef CURRENT_FASL_ARCH
+#  define CURRENT_FASL_ARCH svm_fasl_arch
+#endif
+
 #endif /* SCM_CONFSHARED_H */
index 9ee92f5eaea0f94a5c673a371dc364b1f3141a6a..96d2a72250c1d1921067a2783f4b88ad2d3ade36 100644 (file)
@@ -51,6 +51,22 @@ USA.
 \f
 typedef SCHEME_OBJECT word_t;  /* convenience abbreviation */
 
+#if (SIZEOF_UNSIGNED_LONG == 4)
+#  ifdef WORDS_BIGENDIAN
+const fasl_arch_t svm_fasl_arch = FASL_SVM1_32BE;
+#  else
+const fasl_arch_t svm_fasl_arch = FASL_SVM1_32LE;
+#  endif
+#elif (SIZEOF_UNSIGNED_LONG == 8)
+#  ifdef WORDS_BIGENDIAN
+const fasl_arch_t svm_fasl_arch = FASL_SVM1_64BE;
+#  else
+const fasl_arch_t svm_fasl_arch = FASL_SVM1_64LE;
+#  endif
+#else
+#error Neither 32-bit nor 64-bit, what is this, a PDP-10?
+#endif
+
 #define N_WORD_REGISTERS 0x100
 #define N_FLOAT_REGISTERS 0x100