Skip to content
Permalink
Browse files

rv32: initial, basic stuff (ii)

stub files for compiler/rv32 and assembly/rv32

files generated essentially by starting off with empty files, and
playing whack-a-mole with compile errors.  Those errors are *mostly*
from VOPs called by name from compiler/ir2tran and
compiler/generic/vm-ir2tran, but there are some support functions and
constant definitions needed, and we also need to provide move
functions to trick the compiler into thinking that we know how to move
things between memory and registers.  (And we need to define memory,
or at least stack, and registers, too)
  • Loading branch information...
csrhodes committed Aug 1, 2018
1 parent 20e4117 commit d2536034a7338cc3937e98eb76b3f12f387caf9f
@@ -335,6 +335,7 @@
#!+mips ("src/code/mips-vm")
#!+arm ("src/code/arm-vm")
#!+arm64 ("src/code/arm64-vm")
#!+rv32 ("src/code/rv32-vm")

;; RANDOM-LAYOUT-CLOS-HASH (in 'class') uses RANDOM, the transform for which
;; uses GENERATE-RANDOM-EXPR-FOR-POWER-OF-2 which becomes BIG-RANDOM-CHUNK,
@@ -0,0 +1,12 @@
;;;; allocating simple objects

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")
@@ -0,0 +1,12 @@
;;;; simple cases for generic arithmetic

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")
@@ -0,0 +1,13 @@
;;;; various array operations that are too expensive (in space) to do
;;;; inline

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")
@@ -0,0 +1,24 @@
;;;; the machine specific support routines needed by the file assembler

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")

(define-assembly-routine (throw (:return-style :none))
((:arg target (descriptor-reg any-reg) 0)
(:arg start (descriptor-reg any-reg) 0)
(:arg count (descriptor-reg any-reg) 0))
(declare (ignore target start count)))

(define-assembly-routine (unwind (:return-style :none))
((:arg block (descriptor-reg any-reg) 0)
(:arg start (descriptor-reg any-reg) 0)
(:arg count (descriptor-reg any-reg) 0))
(declare (ignore block start count)))
@@ -0,0 +1,18 @@
;;;; the machine-specific support routines needed by the file assembler

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")

(defun generate-call-sequence (name style vop options)
(declare (ignore name style vop options)))

(defun generate-return-sequence (style)
(declare (ignore style)))
@@ -0,0 +1,66 @@
;;; This file contains the RV32-specific runtime stuff.

(in-package "SB!VM")

#-sb-xc-host
(defun machine-type ()
"Return a string describing the type of the local machine."
"RV32")

;;; FIXUP-CODE-OBJECT

(defconstant-eqx +fixup-kinds+ #(:dummy) #'equalp)

(!with-bigvec-or-sap
(defun fixup-code-object (code offset fixup kind flavor)
(declare (ignore code offset fixup kind flavor))
nil))

;;; CONTEXT-FLOAT-REGISTER
#-sb-xc-host (progn
(define-alien-routine ("os_context_float_register_addr" context-float-register-addr)
(* unsigned) (context (* os-context-t)) (index int))

(defun context-float-register (context index format)
(let ((sap (alien-sap (context-float-register-addr context index))))
(ecase format
(single-float
(sap-ref-single sap 0))
(double-float
(sap-ref-double sap 0))
(complex-single-float
(complex (sap-ref-single sap 0)
(sap-ref-single sap 4)))
(complex-double-float
(complex (sap-ref-double sap 0)
(sap-ref-double sap 8))))))

(defun %set-context-float-register (context index format value)
(let ((sap (alien-sap (context-float-register-addr context index))))
(ecase format
(single-float
(setf (sap-ref-single sap 0) value))
(double-float
(setf (sap-ref-double sap 0) value))
(complex-single-float
(locally
(declare (type (complex single-float) value))
(setf (sap-ref-single sap 0) (realpart value)
(sap-ref-single sap 4) (imagpart value))))
(complex-double-float
(locally
(declare (type (complex double-float) value))
(setf (sap-ref-double sap 0) (realpart value)
(sap-ref-double sap 8) (imagpart value))))))))

;;; INTERNAL-ERROR-ARGS
#-sb-xc-host
(defun internal-error-args (context)
(declare (type (alien (* os-context-t)) context))
(declare (ignore context))
nil)

;;; CONTEXT-CALL-FUNCTION
#-sb-xc-host
(defun context-call-function (context function &optional arg-count)
(declare (ignore context function arg-count)))
@@ -0,0 +1,61 @@
;;;; allocation VOPs for the RV32

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")

(define-vop (list-or-list*)
(:args (things :more t))
(:info num)
(:results (result :scs (descriptor-reg)))
(:variant-vars star)
(:generator 0))

(define-vop (list list-or-list*)
(:variant t))
(define-vop (list* list-or-list*)
(:variant t))

(define-vop (make-closure)
(:args (function :scs (descriptor-reg)))
(:info label length stack-allocate-p)
(:ignore label)
(:results (result :scs (descriptor-reg)))
(:generator 10))

(define-vop (make-value-cell)
(:args (value :scs (descriptor-reg any-reg)))
(:results (result :scs (descriptor-reg)))
(:info stack-allocate-p)
(:generator 10))

(define-vop (make-unbound-marker)
(:args)
(:results (result :scs (descriptor-reg any-reg)))
(:generator 1))

(define-vop (make-funcallable-instance-tramp)
(:args)
(:results (result :scs (any-reg)))
(:generator 1))

(define-vop (fixed-alloc)
(:args)
(:info name words type lowtag stack-allocate-p)
(:results (result :scs (descriptor-reg)))
(:generator 4))

(define-vop (var-alloc)
(:args (extra :scs (any-reg)))
(:arg-types positive-fixnum)
(:info name words type lowtag)
(:ignore name)
(:results (result :scs (descriptor-reg)))
(:generator 6))
@@ -0,0 +1,12 @@
;;;; the VM definition of arithmetic VOPs for the RV32

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")
@@ -0,0 +1,98 @@
;;;; array operations for the RV32 VM

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")

(macrolet
((def-full-data-vector-frobs (type element-type &rest scs)
(let ((setname (symbolicate "DATA-VECTOR-SET/" type)))
`(progn
(define-full-setter ,setname ,type
vector-data-offset other-pointer-lowtag ,scs ,element-type data-vector-set))))
(def-partial-data-vector-frobs (type element-type size signed &rest scs)
(let ((setname (symbolicate "DATA-VECTOR-SET/" type)))
`(progn
(define-partial-setter ,setname ,type
,size vector-data-offset other-pointer-lowtag ,scs
,element-type data-vector-set)))))
(def-full-data-vector-frobs simple-vector * descriptor-reg any-reg)

(def-partial-data-vector-frobs simple-base-string character 1 nil character-reg)
(def-full-data-vector-frobs simple-character-string character character-reg)

(def-partial-data-vector-frobs simple-array-unsigned-byte-7 positive-fixnum 1 nil unsigned-reg signed-reg)
(def-partial-data-vector-frobs simple-array-signed-byte-8 tagged-num 1 t signed-reg)
(def-partial-data-vector-frobs simple-array-unsigned-byte-8 positive-fixnum 1 nil unsigned-reg signed-reg)
(def-partial-data-vector-frobs simple-array-unsigned-byte-15 positive-fixnum 2 nil unsigned-reg signed-reg)
(def-partial-data-vector-frobs simple-array-signed-byte-16 tagged-num 2 t signed-reg)
(def-partial-data-vector-frobs simple-array-unsigned-byte-16 positive-fixnum 2 nil unsigned-reg signed-reg)
(def-full-data-vector-frobs simple-array-unsigned-fixnum positive-fixnum any-reg)
(def-full-data-vector-frobs simple-array-fixnum tagged-num any-reg)
(def-full-data-vector-frobs simple-array-unsigned-byte-31 unsigned-num unsigned-reg)
(def-full-data-vector-frobs simple-array-signed-byte-32 signed-num signed-reg)
(def-full-data-vector-frobs simple-array-unsigned-byte-32 unsigned-num unsigned-reg))

(macrolet
((def-small-data-vector-frobs (type bits)
(let ((setname (symbolicate "DATA-VECTOR-SET/" type)))
`(progn
(define-vop (,setname)
(:translate data-vector-set)
(:args (object :scs (descriptor-reg))
(index :scs (unsigned-reg))
(value :scs (unsigned-reg)))
(:arg-types ,type positive-fixnum positive-fixnum)
(:results (result :scs (unsigned-reg)))
(:result-types positive-fixnum)
(:generator 25))))))
(def-small-data-vector-frobs simple-bit-vector 1)
(def-small-data-vector-frobs simple-array-unsigned-byte-2 2)
(def-small-data-vector-frobs simple-array-unsigned-byte-4 4))

(define-vop (data-vector-set/simple-array-single-float)
(:translate data-vector-set)
(:args (object :scs (descriptor-reg))
(index :scs (unsigned-reg))
(value :scs (single-reg)))
(:arg-types simple-array-single-float positive-fixnum single-float)
(:results (result :scs (single-reg)))
(:result-types single-float)
(:generator 5))

(define-vop (data-vector-set/simple-array-double-float)
(:translate data-vector-set)
(:args (object :scs (descriptor-reg))
(index :scs (unsigned-reg))
(value :scs (double-reg)))
(:arg-types simple-array-double-float positive-fixnum double-float)
(:results (result :scs (double-reg)))
(:result-types double-float)
(:generator 5))

(define-vop (data-vector-set/simple-array-complex-single-float)
(:translate data-vector-set)
(:args (object :scs (descriptor-reg))
(index :scs (unsigned-reg))
(value :scs (complex-single-reg)))
(:arg-types simple-array-complex-single-float positive-fixnum complex-single-float)
(:results (result :scs (complex-single-reg)))
(:result-types complex-single-float)
(:generator 5))

(define-vop (data-vector-set/simple-array-complex-double-float)
(:translate data-vector-set)
(:args (object :scs (descriptor-reg))
(index :scs (unsigned-reg))
(value :scs (complex-double-reg)))
(:arg-types simple-array-complex-double-float positive-fixnum complex-double-float)
(:results (result :scs (complex-double-reg)))
(:result-types complex-double-float)
(:generator 5))
@@ -0,0 +1,29 @@
;;;; function call for the RV32 VM

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB!VM")

(define-vop (call-out)
(:args (function :scs (sap-reg)) (args :more t))
(:results (results :more t))
(:ignore args results)
(:save-p t)
(:generator 0))

(define-vop (alloc-number-stack-space)
(:info amount)
(:result-types system-area-pointer)
(:results (result :scs (sap-reg any-reg)))
(:generator 0))

(define-vop (dealloc-number-stack-space)
(:info amount)
(:generator 0))
Oops, something went wrong.

0 comments on commit d253603

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.