-;;;; miscellaneous VM definition noise for the x86
+;;;; miscellaneous VM definition noise for the Alpha
;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;; files for more information.
(in-package "SB!VM")
-
-
\f
-;;;; Define the registers
+;;;; defining the registers
(eval-when (:compile-toplevel :load-toplevel :execute)
(defvar *register-names* (make-array 32 :initial-element nil)))
(macrolet ((defreg (name offset)
(let ((offset-sym (symbolicate name "-OFFSET")))
`(eval-when (:compile-toplevel :load-toplevel :execute)
- (defconstant ,offset-sym ,offset)
- (setf (svref *register-names* ,offset-sym) ,(symbol-name name)))))
+ (def!constant ,offset-sym ,offset)
+ (setf (svref *register-names* ,offset-sym)
+ ,(symbol-name name)))))
(defregset (name &rest regs)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter ,name
- (list ,@(mapcar #'(lambda (name)
- (symbolicate name "-OFFSET"))
+ (list ,@(mapcar (lambda (name)
+ (symbolicate name "-OFFSET"))
regs))))))
;; c.f. src/runtime/alpha-lispregs.h
(define-storage-base constant :non-packed)
(define-storage-base immediate-constant :non-packed)
-;;;
-;;; Handy macro so we don't have to keep changing all the numbers whenever
-;;; we insert a new storage class.
-;;; FIXME: This macro is not needed in the runtime target.
+;;; a handy macro so we don't have to keep changing all the numbers
+;;; whenever we insert a new storage class.
-(defmacro define-storage-classes (&rest classes)
+(defmacro !define-storage-classes (&rest classes)
(do ((forms (list 'progn)
(let* ((class (car classes))
(sc-name (car class))
"-SC-NUMBER"))))
(list* `(define-storage-class ,sc-name ,index
,@(cdr class))
- `(defconstant ,constant-name ,index)
- `(export ',constant-name)
+ `(def!constant ,constant-name ,index)
+ ;; (The CMU CL version of this macro did
+ ;; `(EXPORT ',CONSTANT-NAME)
+ ;; here, but in SBCL we try to have package
+ ;; structure described statically in one
+ ;; master source file, instead of building it
+ ;; dynamically by letting all the system code
+ ;; modify it as the system boots.)
forms)))
(index 0 (1+ index))
(classes classes (cdr classes)))
((null classes)
(nreverse forms))))
-;;; see comment in ../x86/vm.lisp. The value of 7 was taken from
-;;; vm:catch-block-size in a cmucl that I happened to have around
-;;; and seems to be working so far -dan
-(defconstant sb!vm::kludge-nondeterministic-catch-block-size 7)
-
+(def!constant kludge-nondeterministic-catch-block-size 7)
-(define-storage-classes
+(!define-storage-classes
- ;; Non-immediate contstants in the constant pool
+ ;; non-immediate constants in the constant pool
(constant constant)
;; ZERO and NULL are in registers.
:element-size 2 :alignment 2) ; (signed-byte 64)
(unsigned-stack non-descriptor-stack
:element-size 2 :alignment 2) ; (unsigned-byte 64)
- (base-char-stack non-descriptor-stack) ; non-descriptor characters.
+ (character-stack non-descriptor-stack) ; non-descriptor characters.
(sap-stack non-descriptor-stack
:element-size 2 :alignment 2) ; System area pointers.
(single-stack non-descriptor-stack) ; single-floats
:alternate-scs (control-stack))
;; Non-Descriptor characters
- (base-char-reg registers
+ (character-reg registers
:locations #.non-descriptor-regs
:constant-scs (immediate)
:save-p t
- :alternate-scs (base-char-stack))
+ :alternate-scs (character-stack))
;; Non-Descriptor SAP's (arbitrary pointers into address space)
(sap-reg registers
;; A catch or unwind block.
(catch-block control-stack
- :element-size sb!vm::kludge-nondeterministic-catch-block-size))
-
+ :element-size kludge-nondeterministic-catch-block-size))
\f
-;;;; Make some random tns for important registers.
-
+;;; Make some random tns for important registers.
(macrolet ((defregtn (name sc)
(let ((offset-sym (symbolicate name "-OFFSET"))
(tn-sym (symbolicate name "-TN")))
(defregtn ocfp any-reg)
(defregtn lip interior-reg))
-;; And some floating point values.
+;; and some floating point values..
(defparameter fp-single-zero-tn
(make-random-tn :kind :normal
:sc (sc-or-lose 'single-reg)
(make-random-tn :kind :normal
:sc (sc-or-lose 'double-reg)
:offset 31))
-
\f
-;;; Immediate-Constant-SC -- Interface
-;;;
-;;; If value can be represented as an immediate constant, then return the
-;;; appropriate SC number, otherwise return NIL.
-;;;
+;;; If value can be represented as an immediate constant, then return
+;;; the appropriate SC number, otherwise return NIL.
(!def-vm-support-routine immediate-constant-sc (value)
(typecase value
((integer 0 0)
(sc-number-or-lose 'fp-double-zero )
nil))))
\f
-;;;; Function Call Parameters
+;;;; function call parameters
-;;; The SC numbers for register and stack arguments/return values.
-;;;
-(defconstant register-arg-scn (meta-sc-number-or-lose 'descriptor-reg))
-(defconstant immediate-arg-scn (meta-sc-number-or-lose 'any-reg))
-(defconstant control-stack-arg-scn (meta-sc-number-or-lose 'control-stack))
+;;; the SC numbers for register and stack arguments/return values
+(def!constant register-arg-scn (meta-sc-number-or-lose 'descriptor-reg))
+(def!constant immediate-arg-scn (meta-sc-number-or-lose 'any-reg))
+(def!constant control-stack-arg-scn (meta-sc-number-or-lose 'control-stack))
(eval-when (:compile-toplevel :load-toplevel :execute)
-;;; Offsets of special stack frame locations
-(defconstant ocfp-save-offset 0)
-(defconstant lra-save-offset 1)
-(defconstant nfp-save-offset 2)
-
-;;; The number of arguments/return values passed in registers.
-;;;
-(defconstant register-arg-count 6)
-
-;;; Names to use for the argument registers.
-;;;
+;;; offsets of special stack frame locations
+(def!constant ocfp-save-offset 0)
+(def!constant lra-save-offset 1)
+(def!constant nfp-save-offset 2)
+;;; the number of arguments/return values passed in registers
+(def!constant register-arg-count 6)
-); Eval-When (Compile Load Eval)
+;;; (Names to use for the argument registers would go here, but there
+;;; are none.)
+); EVAL-WHEN
-;;; A list of TN's describing the register arguments.
-;;;
+;;; a list of TN's describing the register arguments
(defparameter *register-arg-tns*
- (mapcar #'(lambda (n)
- (make-random-tn :kind :normal
- :sc (sc-or-lose 'descriptor-reg)
- :offset n))
+ (mapcar (lambda (n)
+ (make-random-tn :kind :normal
+ :sc (sc-or-lose 'descriptor-reg)
+ :offset n))
*register-arg-offsets*))
-;;; SINGLE-VALUE-RETURN-BYTE-OFFSET
-;;;
;;; This is used by the debugger.
-;;;
-(export 'single-value-return-byte-offset)
-(defconstant single-value-return-byte-offset 4)
-
+(def!constant single-value-return-byte-offset 4)
\f
-;;; LOCATION-PRINT-NAME -- Interface
-;;;
-;;; This function is called by debug output routines that want a pretty name
-;;; for a TN's location. It returns a thing that can be printed with PRINC.
-;;;
+;;; This function is called by debug output routines that want a
+;;; pretty name for a TN's location. It returns a thing that can be
+;;; printed with PRINC.
(!def-vm-support-routine location-print-name (tn)
; (declare (type tn tn))
(let ((sb (sb-name (sc-sb (tn-sc tn))))
(non-descriptor-stack (format nil "NS~D" offset))
(constant (format nil "Const~D" offset))
(immediate-constant "Immed"))))
+\f
+;;; The loader uses this to convert alien names to the form they
+;;; occure in the symbol table (for example, prepending an
+;;; underscore).
+(defun extern-alien-name (name)
+ (declare (type string name))
+ ;; ELF ports currently don't need any prefix
+ (typecase name
+ (simple-base-string name)
+ (base-string (coerce name 'simple-base-string))
+ (t (handler-case (coerce name 'simple-base-string)
+ (type-error () (error "invalid external alien name: ~S" name))))))