-(in-package "SB!VM")
+;;;; the MIPS VM definition of SAP operations
+
+;;;; 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")
\f
;;;; Moves and coercions:
;;; Move a tagged SAP to an untagged representation.
-;;;
(define-vop (move-to-sap)
(:args (x :scs (descriptor-reg)))
(:results (y :scs (sap-reg)))
(:generator 1
(loadw y x sap-pointer-slot other-pointer-lowtag)))
-;;;
(define-move-vop move-to-sap :move
(descriptor-reg) (sap-reg))
;;; Move an untagged SAP to a tagged representation.
-;;;
(define-vop (move-from-sap)
(:args (x :scs (sap-reg) :to (:eval 1)))
(:temporary (:scs (non-descriptor-reg)) ndescr)
(:generator 20
(with-fixed-allocation (y ndescr sap-widetag sap-size)
(storew x y sap-pointer-slot other-pointer-lowtag))))
-;;;
+
(define-move-vop move-from-sap :move
(sap-reg) (descriptor-reg))
-
;;; Move untagged sap values.
-;;;
(define-vop (sap-move)
(:args (x :target y
:scs (sap-reg)
(:affected)
(:generator 0
(move x y)))
-;;;
+
(define-move-vop sap-move :move
(sap-reg) (sap-reg))
-
;;; Move untagged sap arguments/return-values.
-;;;
(define-vop (move-sap-argument)
(:args (x :target y
:scs (sap-reg))
(move x y))
(sap-stack
(storew x fp (tn-offset y))))))
-;;;
+
(define-move-vop move-sap-argument :move-arg
(descriptor-reg sap-reg) (sap-reg))
-
-;;; Use standard MOVE-ARGUMENT + coercion to move an untagged sap to a
+;;; Use standard MOVE-ARG + coercion to move an untagged sap to a
;;; descriptor passing location.
-;;;
(define-move-vop move-argument :move-arg
(sap-reg) (descriptor-reg))
-
-
\f
;;;; SAP-INT and INT-SAP
-
(define-vop (sap-int)
(:args (sap :scs (sap-reg) :target int))
(:arg-types system-area-pointer)
(:policy :fast-safe)
(:generator 1
(move int sap)))
-
-
\f
;;;; POINTER+ and POINTER-
-
(define-vop (pointer+)
(:translate sap+)
(:args (ptr :scs (sap-reg) :target res)
(:result-types signed-num)
(:generator 1
(inst sub ptr1 ptr2 res)))
-
-
\f
;;;; mumble-SYSTEM-REF and mumble-SYSTEM-SET
-
(macrolet ((def-system-ref-and-set
(ref-name set-name sc type size &optional signed)
(let ((ref-name-c (symbolicate ref-name "-C"))
single-reg single-float :float)
(def-system-ref-and-set sap-ref-double %set-sap-ref-double
double-reg double-float :float))
-
\f
;;; Noise to convert normal lisp data objects into SAPs.
-
(define-vop (vector-sap)
(:translate vector-sap)
(:policy :fast-safe)
(- (* vector-data-offset n-word-bytes) other-pointer-lowtag)
vector
sap)))
-
\f
;;; Transforms for 64-bit SAP accessors.
-;;; FIXME: So these are now commented out on the SPARC, PPC and HPPA
-;;; backends. Did they ever serve a purpose? Could they in future? --
-;;; CSR, 2002-08-10
-#|
(deftransform sap-ref-64 ((sap offset) (* *))
'(logior (ash (sap-ref-32 sap offset) 32)
(sap-ref-32 sap (+ offset 4))))
'(progn
(%set-signed-sap-ref-32 sap offset (ash value -32))
(%set-sap-ref-32 sap (+ 4 offset) (logand value #xffffffff))))
-|#
-(in-package "SB!VM")
+;;;; the MIPS VM definition of SAP operations
+
+;;;; 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")
\f
;;;; Moves and coercions:
;;; Move a tagged SAP to an untagged representation.
-;;;
(define-vop (move-to-sap)
(:args (x :scs (descriptor-reg)))
(:results (y :scs (sap-reg)))
(:generator 1
(loadw y x sap-pointer-slot other-pointer-lowtag)))
-;;;
(define-move-vop move-to-sap :move
(descriptor-reg) (sap-reg))
-
;;; Move an untagged SAP to a tagged representation.
-;;;
(define-vop (move-from-sap)
(:args (x :scs (sap-reg) :target sap))
(:temporary (:scs (sap-reg) :from (:argument 0)) sap)
(move sap x)
(with-fixed-allocation (y pa-flag ndescr sap-widetag sap-size)
(storew sap y sap-pointer-slot other-pointer-lowtag))))
-;;;
+
(define-move-vop move-from-sap :move
(sap-reg) (descriptor-reg))
-
;;; Move untagged sap values.
-;;;
(define-vop (sap-move)
(:args (x :target y
:scs (sap-reg)
(:affected)
(:generator 0
(move y x)))
-;;;
+
(define-move-vop sap-move :move
(sap-reg) (sap-reg))
-
;;; Move untagged sap arguments/return-values.
-;;;
(define-vop (move-sap-arg)
(:args (x :target y
:scs (sap-reg))
(move y x))
(sap-stack
(storew x fp (tn-offset y))))))
-;;;
+
(define-move-vop move-sap-arg :move-arg
(descriptor-reg sap-reg) (sap-reg))
-
-;;; Use standard MOVE-ARGUMENT + coercion to move an untagged sap to a
+;;; Use standard MOVE-ARG + coercion to move an untagged sap to a
;;; descriptor passing location.
-;;;
(define-move-vop move-arg :move-arg
(sap-reg) (descriptor-reg))
-
-
\f
;;;; SAP-INT and INT-SAP
-
(define-vop (sap-int)
(:args (sap :scs (sap-reg) :target int))
(:arg-types system-area-pointer)
(:policy :fast-safe)
(:generator 1
(move sap int)))
-
-
\f
;;;; POINTER+ and POINTER-
-
(define-vop (pointer+)
(:translate sap+)
(:args (ptr :scs (sap-reg))
(:result-types signed-num)
(:generator 1
(inst subu res ptr1 ptr2)))
-
-
\f
;;;; mumble-SYSTEM-REF and mumble-SYSTEM-SET
-
(macrolet ((def-system-ref-and-set
(ref-name set-name sc type size &optional signed)
(let ((ref-name-c (symbolicate ref-name "-C"))
single-reg single-float :single)
(def-system-ref-and-set sap-ref-double %set-sap-ref-double
double-reg double-float :double))
-
\f
;;; Noise to convert normal lisp data objects into SAPs.
-
(define-vop (vector-sap)
(:translate vector-sap)
(:policy :fast-safe)
(:generator 2
(inst addu sap vector
(- (* vector-data-offset n-word-bytes) other-pointer-lowtag))))
+\f
+;;; Transforms for 64-bit SAP accessors.
+#!+little-endian
+(progn
+ (deftransform sap-ref-64 ((sap offset) (* *))
+ '(logior (sap-ref-32 sap offset)
+ (ash (sap-ref-32 sap (+ offset 4)) 32)))
+ (deftransform signed-sap-ref-64 ((sap offset) (* *))
+ '(logior (sap-ref-32 sap offset)
+ (ash (signed-sap-ref-32 sap (+ offset 4)) 32)))
+ (deftransform %set-sap-ref-64 ((sap offset value) (* * *))
+ '(progn
+ (%set-sap-ref-32 sap offset (logand value #xffffffff))
+ (%set-sap-ref-32 sap (+ offset 4) (ash value -32))))
+ (deftransform %set-signed-sap-ref-64 ((sap offset value) (* * *))
+ '(progn
+ (%set-sap-ref-32 sap offset (logand value #xffffffff))
+ (%set-signed-sap-ref-32 sap (+ offset 4) (ash value -32)))))
+#!-little-endian
+(progn
+ (deftransform sap-ref-64 ((sap offset) (* *))
+ '(logior (ash (sap-ref-32 sap offset) 32)
+ (sap-ref-32 sap (+ offset 4))))
+ (deftransform signed-sap-ref-64 ((sap offset) (* *))
+ '(logior (ash (signed-sap-ref-32 sap offset) 32)
+ (sap-ref-32 sap (+ 4 offset))))
+ (deftransform %set-sap-ref-64 ((sap offset value) (* * *))
+ '(progn
+ (%set-sap-ref-32 sap offset (ash value -32))
+ (%set-sap-ref-32 sap (+ offset 4) (logand value #xffffffff))))
+ (deftransform %set-signed-sap-ref-64 ((sap offset value) (* * *))
+ '(progn
+ (%set-signed-sap-ref-32 sap offset (ash value -32))
+ (%set-sap-ref-32 sap (+ 4 offset) (logand value #xffffffff)))))