1 ;;;; miscellaneous VM definition noise for the ARM
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
17 (eval-when (:compile-toplevel
:load-toplevel
:execute
)
18 (defvar *register-names
* (make-array 16 :initial-element nil
)))
20 (macrolet ((defreg (name offset
)
21 (let ((offset-sym (symbolicate name
"-OFFSET")))
22 `(eval-when (:compile-toplevel
:load-toplevel
:execute
)
23 (def!constant
,offset-sym
,offset
)
24 (setf (svref *register-names
* ,offset-sym
) ,(symbol-name name
)))))
26 (defregset (name &rest regs
)
27 `(eval-when (:compile-toplevel
:load-toplevel
:execute
)
29 (list ,@(mapcar #'(lambda (name)
30 (symbolicate name
"-OFFSET")) regs
))))))
47 (defreg pc
15) ;; Yes, the program counter.
49 (defregset system-regs
50 null cfp csp lr pc code
)
52 (defregset descriptor-regs
55 (defregset non-descriptor-regs
56 ocfp nfp nargs nl2 nl3
)
58 ;; registers used to pass arguments
60 ;; the number of arguments/return values passed in registers
61 (def!constant register-arg-count
3)
62 ;; names and offsets for registers used to pass arguments
63 (defregset *register-arg-offsets
* r0 r1 r2
)
64 (defparameter *register-arg-names
* '(r0 r1 r2
)))
67 ;;;; SB and SC definition:
69 (define-storage-base registers
:finite
:size
16)
70 (define-storage-base control-stack
:unbounded
:size
8)
71 (define-storage-base non-descriptor-stack
:unbounded
:size
0)
72 (define-storage-base constant
:non-packed
)
73 (define-storage-base immediate-constant
:non-packed
)
75 (define-storage-base float-registers
:finite
:size
32)
76 ;; NOTE: If you fix the following, please to so with its own feature
77 ;; conditional, and also adjust the definitions of the
78 ;; {,COMPLEX-}{SINGLE,DOUBLE}-REG SCs below.
80 (error "Don't know how many float registers for non-VFP systems")
83 ;;; Handy macro so we don't have to keep changing all the numbers whenever
84 ;;; we insert a new storage class.
86 (defmacro define-storage-classes
(&rest classes
)
87 (do ((forms (list 'progn
)
88 (let* ((class (car classes
))
90 (constant-name (intern (concatenate 'simple-string
93 (list* `(define-storage-class ,sc-name
,index
95 `(def!constant
,constant-name
,index
)
98 (classes classes
(cdr classes
)))
102 (def!constant kludge-nondeterministic-catch-block-size
6)
104 (define-storage-classes
106 ;; Non-immediate contstants in the constant pool
109 ;; NULL is in a register.
110 (null immediate-constant
)
112 ;; Anything else that can be an immediate.
113 (immediate immediate-constant
)
118 ;; The control stack. (Scanned by GC)
119 (control-stack control-stack
)
121 ;; We put ANY-REG and DESCRIPTOR-REG early so that their SC-NUMBER
122 ;; is small and therefore the error trap information is smaller.
123 ;; Moving them up here from their previous place down below saves
124 ;; ~250K in core file size. --njf, 2006-01-27
126 ;; Immediate descriptor objects. Don't have to be seen by GC, but nothing
127 ;; bad will happen if they are. (fixnums, characters, header values, etc).
130 :locations
#.
(append non-descriptor-regs descriptor-regs
)
131 :constant-scs
(immediate)
133 :alternate-scs
(control-stack))
135 ;; Pointer descriptor objects. Must be seen by GC.
136 (descriptor-reg registers
137 :locations
#.descriptor-regs
138 :constant-scs
(constant null immediate
)
140 :alternate-scs
(control-stack))
142 ;; The non-descriptor stacks.
143 (signed-stack non-descriptor-stack
) ; (signed-byte 32)
144 (unsigned-stack non-descriptor-stack
) ; (unsigned-byte 32)
145 (character-stack non-descriptor-stack
) ; non-descriptor characters.
146 (sap-stack non-descriptor-stack
) ; System area pointers.
147 (single-stack non-descriptor-stack
) ; single-floats
148 (double-stack non-descriptor-stack
149 :element-size
2 :alignment
2) ; double floats.
150 (complex-single-stack non-descriptor-stack
:element-size
2)
151 (complex-double-stack non-descriptor-stack
:element-size
4 :alignment
2)
153 ;; **** Things that can go in the integer registers.
155 ;; Non-Descriptor characters
156 (character-reg registers
157 :locations
#.non-descriptor-regs
158 :constant-scs
(immediate)
160 :alternate-scs
(character-stack))
162 ;; Non-Descriptor SAP's (arbitrary pointers into address space)
164 :locations
#.non-descriptor-regs
165 :constant-scs
(immediate)
167 :alternate-scs
(sap-stack))
169 ;; Non-Descriptor (signed or unsigned) numbers.
170 (signed-reg registers
171 :locations
#.non-descriptor-regs
172 :constant-scs
(immediate)
174 :alternate-scs
(signed-stack))
175 (unsigned-reg registers
176 :locations
#.non-descriptor-regs
177 :constant-scs
(immediate)
179 :alternate-scs
(unsigned-stack))
181 ;; Random objects that must not be seen by GC. Used only as temporaries.
182 (non-descriptor-reg registers
183 :locations
#.non-descriptor-regs
)
185 ;; Pointers to the interior of objects. Used only as a temporary.
186 (interior-reg registers
187 :locations
(#.lr-offset
))
189 ;; **** Things that can go in the floating point registers.
191 ;; Non-Descriptor single-floats.
192 (single-reg float-registers
193 :locations
#.
(loop for i below
32 collect i
)
196 :alternate-scs
(single-stack))
198 ;; Non-Descriptor double-floats.
199 (double-reg float-registers
200 :locations
#.
(loop for i below
32 by
2 collect i
)
204 :alternate-scs
(double-stack))
206 (complex-single-reg float-registers
207 :locations
#.
(loop for i from
0 below
32 by
2 collect i
)
211 :alternate-scs
(complex-single-stack))
213 (complex-double-reg float-registers
214 :locations
#.
(loop for i from
0 below
32 by
4 collect i
)
218 :alternate-scs
(complex-double-stack))
220 ;; A catch or unwind block.
221 (catch-block control-stack
222 :element-size kludge-nondeterministic-catch-block-size
))
224 ;;;; Make some random tns for important registers.
226 (macrolet ((defregtn (name sc
)
227 (let ((offset-sym (symbolicate name
"-OFFSET"))
228 (tn-sym (symbolicate name
"-TN")))
229 `(defparameter ,tn-sym
230 (make-random-tn :kind
:normal
231 :sc
(sc-or-lose ',sc
)
232 :offset
,offset-sym
)))))
234 (defregtn null descriptor-reg
)
235 (defregtn code descriptor-reg
)
237 (defregtn nargs any-reg
)
238 (defregtn ocfp any-reg
)
239 (defregtn csp any-reg
)
240 (defregtn cfp any-reg
)
241 (defregtn lr interior-reg
)
242 (defregtn pc any-reg
))
244 ;;; If VALUE can be represented as an immediate constant, then return the
245 ;;; appropriate SC number, otherwise return NIL.
246 (defun immediate-constant-sc (value)
249 (sc-number-or-lose 'null
))
250 ((or (integer #.sb
!xc
:most-negative-fixnum
#.sb
!xc
:most-positive-fixnum
)
252 (sc-number-or-lose 'immediate
))
254 (if (static-symbol-p value
)
255 (sc-number-or-lose 'immediate
)
258 (defun boxed-immediate-sc-p (sc)
259 (or (eql sc
(sc-number-or-lose 'null
))
260 (eql sc
(sc-number-or-lose 'immediate
))))
262 ;;;; function call parameters
264 ;;; the SC numbers for register and stack arguments/return values
265 (def!constant register-arg-scn
(meta-sc-number-or-lose 'descriptor-reg
))
266 (def!constant immediate-arg-scn
(meta-sc-number-or-lose 'any-reg
))
267 (def!constant control-stack-arg-scn
(meta-sc-number-or-lose 'control-stack
))
269 ;;; offsets of special stack frame locations
270 (def!constant ocfp-save-offset
0)
271 (def!constant lra-save-offset
1)
272 (def!constant nfp-save-offset
2)
274 ;;; This is used by the debugger.
275 ;;; < nyef> Ah, right. So, SINGLE-VALUE-RETURN-BYTE-OFFSET doesn't apply to x86oids or ARM.
276 (def!constant single-value-return-byte-offset
0)
279 ;;; A list of TN's describing the register arguments.
281 (defparameter *register-arg-tns
*
282 (mapcar #'(lambda (n)
283 (make-random-tn :kind
:normal
284 :sc
(sc-or-lose 'descriptor-reg
)
286 *register-arg-offsets
*))
288 ;;; This function is called by debug output routines that want a pretty name
289 ;;; for a TN's location. It returns a thing that can be printed with PRINC.
290 (defun location-print-name (tn)
291 (declare (type tn tn
))
292 (let ((sb (sb-name (sc-sb (tn-sc tn
))))
293 (offset (tn-offset tn
)))
295 (registers (or (svref *register-names
* offset
)
296 (format nil
"R~D" offset
)))
297 (control-stack (format nil
"CS~D" offset
))
298 (non-descriptor-stack (format nil
"NS~D" offset
))
299 (constant (format nil
"Const~D" offset
))
300 (immediate-constant "Immed")
301 (float-registers (format nil
"F~D" offset
)))))
303 (defun combination-implementation-style (node)
304 (declare (type sb
!c
::combination node
) (ignore node
))
305 (values :default nil
))
307 (defun primitive-type-indirect-cell-type (ptype)
308 (declare (ignore ptype
))