source: branches/1.1/ccl/compiler/PPC/ppc-arch.lisp

Last change on this file was 6458, checked in by Gary Byers, 18 years ago

New .SPnmkunwind.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.1 KB
Line 
1;;;-*- Mode: Lisp; Package: (PPC :use CL) -*-
2;;;
3;;; Copyright (C) 1994-2001 Digitool, Inc
4;;; This file is part of OpenMCL.
5;;;
6;;; OpenMCL is licensed under the terms of the Lisp Lesser GNU Public
7;;; License , known as the LLGPL and distributed with OpenMCL as the
8;;; file "LICENSE". The LLGPL consists of a preamble and the LGPL,
9;;; which is distributed with OpenMCL as the file "LGPL". Where these
10;;; conflict, the preamble takes precedence.
11;;;
12;;; OpenMCL is referenced in the preamble as the "LIBRARY."
13;;;
14;;; The LLGPL is also available online at
15;;; http://opensource.franz.com/preamble.html
16
17(defpackage "PPC"
18 (:use "CL"))
19
20(require "ARCH")
21
22(in-package "PPC")
23;;; Lisp registers.
24(eval-when (:compile-toplevel :execute)
25 (defmacro defregs (&body regs)
26 `(progn
27 (ccl::defenum () ,@regs)
28 (defparameter *gpr-register-names* ,(coerce (mapcar #'string regs) 'vector))))
29 (defmacro deffpregs (&body regs)
30 `(progn
31 (ccl::defenum () ,@regs)
32 (defparameter *fpr-register-names* ,(coerce (mapcar #'string regs) 'vector))))
33 (defmacro defvregs (&body regs)
34 `(progn
35 (ccl::defenum () ,@regs)
36 (defparameter *vector-register-names* ,(coerce (mapcar #'string regs) 'vector))
37 )))
38
39(defregs
40 rzero ; Always contains 0; not as handy as it sounds.
41 sp ; The control stack. Aligned on 16-byte boundary.
42 target-1 ; volatile reg on Darwin, tp or TOC on Linux.
43 imm0 ; Unboxed, volatile registers.
44 imm1
45 imm2
46 imm3
47 imm4
48 imm5
49 allocptr
50 allocbase
51 nargs ; Volatile. SHOULDN'T be used for tag extraction. (TWI handler confusion.)
52 tsp ; Temp-stack pointer.
53 target-2
54 loc-pc ; for return PC only.
55 vsp ; Value stack pointer; grows towards 0.
56 fn ; Current function (constants vector).
57 temp3 ; Boxed, volatile registers. Some
58 ; may be defined on function entry.
59 temp2
60 temp1
61 temp0
62 arg_x ; Next-to-next-to-last function arg.
63 arg_y ; Next-to-last function argument.
64 arg_z ; Last function argument.
65 save7 ; Boxed, nonvolatile registers.
66 save6
67 save5
68 save4
69 save3
70 save2
71 save1
72 save0
73 )
74
75(deffpregs
76 fp0
77 fp1
78 fp2
79 fp3
80 fp4
81 fp5
82 fp6
83 fp7
84 fp8
85 fp9
86 fp10
87 fp11
88 fp12
89 fp13
90 fp14
91 fp15
92 fp16
93 fp17
94 fp18
95 fp19
96 fp20
97 fp21
98 fp22
99 fp23
100 fp24
101 fp25
102 fp26
103 fp27
104 fp28
105 fp29
106 fp30
107 fp31)
108
109(defvregs
110 vr0 ; General temp vector register
111 vr1 ; Most-significant quadword when word-aligning
112 vr2 ; Least-significant quadword when word-aligning
113 vr3 ; Operand A resulting from word-aligning
114 vr4 ; Operand B resulting from word-aligning
115 vr5 ; Result from operations on A and B
116 vr6
117 vr7
118 vr8
119 vr9
120 vr10
121 vr11
122 vr12
123 vr13
124 vr14
125 vr15
126 vr16
127 vr17
128 vr18
129 vr19
130 ;;By convention, registers after this point are considered non-volatile. Callee should save.
131 vr20
132 vr21
133 vr22
134 vr23
135 vr24
136 vr25
137 vr26
138 vr27 ; Permutation control register A for loads
139 vr28 ; Permutation control register B for stores
140 vr29 ; mask register
141 vr30 ; All zeros
142 vr31 ; All ones
143 )
144
145
146
147;;; Calling sequence may pass additional arguments in temp registers.
148;;; "nfn" (new function) is always passed; it's the new value of "fn".
149(defconstant nfn temp2)
150
151;;; CLOS may pass the context for, e.g.., CALL-NEXT-METHOD in
152;;;; the "next-method-context" register.
153(defconstant next-method-context temp1)
154
155
156;;; It's handy to have 0.0 in an fpr.
157(defconstant fp-zero fp31)
158
159; Also handy to have #x4330000080000000 in an fpr, for s32->float conversion.
160(defconstant fp-s32conv fp30)
161
162(defconstant fname temp3)
163
164;;; Calling sequence may pass additional arguments in temp registers.
165;;; "nfn" (new function) is always passed; it's the new value of "fn".
166(defconstant nfn temp2)
167
168;;; CLOS may pass the context for, e.g.., CALL-NEXT-METHOD in
169;;;; the "next-method-context" register.
170(defconstant next-method-context temp1)
171
172
173;;; It's handy to have 0.0 in an fpr.
174(defconstant fp-zero fp31)
175
176; Also handy to have #x4330000080000000 in an fpr, for s32->float conversion.
177(defconstant fp-s32conv fp30)
178
179(ccl::defenum (:prefix "FPSCR-" :suffix "-BIT")
180 fx
181 fex
182 vx
183 ox
184 ux
185 zx
186 xx
187 vxsnan
188 vxisi
189 vxidi
190 vxzdz
191 vximz
192 vxvc
193 fr
194 fi
195 fprfc
196 fl
197 fg
198 fe
199 fu
200 nil
201 vxsoft
202 vxsqrt
203 vxcvi
204 ve
205 oe
206 ue
207 ze
208 xe
209 ni
210 rn0
211 rn1
212)
213
214(ccl::defenum (:prefix "PPC-" :suffix "-BIT")
215 lt
216 gt
217 eq
218 so
219)
220
221;;; Kernel globals are allocated "below" nil. This list (used to map
222;;; symbolic names to rnil-relative offsets) must (of course) exactly
223;;; match the kernel's notion of where things are.
224;;; The order here matches "ccl:lisp-kernel;lisp_globals.h" & the
225;;; lisp_globals record in "ccl:lisp-kernel;*constants*.s"
226(defparameter *ppc-kernel-globals*
227 '(get-tcr ; callback to obtain (real) tcr
228 tcr-count
229 interrupt-signal ; used by PROCESS-INTERRUPT
230 kernel-imports ; some things we need to have imported for us.
231 tcr-lock
232 emulator-registers ; Where the 68K registers are kept.
233 appmain ; application's (c-runtime) main() function
234 subprims-base ; start of dynamic subprims jump table
235 ret1valaddr ; magic multiple-values return address.
236 tcr-key ; tsd key for thread's tcr
237 area-lock ; serialize access to gc
238 exception-lock ; serialize exception handling
239 deleted-static-pairs ; for hash-consing
240 default-allocation-quantum ; log2_heap_segment_size, as a fixnum.
241 intflag ; interrupt-pending flag
242 gc-inhibit-count ; for gc locking
243 refbits ; oldspace refbits
244 oldspace-dnode-count ; number of dnodes in dynamic space that are older than
245 ; youngest generation
246 altivec-present ; non-zero if cpu supports AltiVec
247 fwdnum ; fixnum: GC "forwarder" call count.
248 gc-count ; fixnum: GC call count.
249 gcable-pointers ; linked-list of weak macptrs.
250 heap-start ; start of lisp heap
251 heap-end ; end of lisp heap
252 statically-linked ; true if the lisp kernel is statically linked
253 stack-size ; value of --stack-size arg
254 bad-current-ts ; current temp-stack area
255 bad-cs-overflow-limit ; limit for control-stack overflow check
256 all-areas ; doubly-linked area list
257 lexpr-return ; multiple-value lexpr return address
258 lexpr-return1v ; single-value lexpr return address
259 in-gc ; non-zero when GC-ish thing active
260 metering-info ; kernel metering structure
261 doh-head ; creole
262 short-float-zero ; low half of 1.0d0
263 double-float-one ; high half of 1.0d0
264 ffi-exception ; ffi fpscr[fex] bit
265 exception-saved-registers ; saved registers from exception frame
266 oldest-ephemeral ; doublenode address of oldest ephemeral object or 0
267 tenured-area ; the tenured_area.
268 errno ; address of C lib errno
269 argv ; address of C lib argv
270 host-platform ; 0 on MacOS, 1 on PPC Linux, 2 on VxWorks ...
271 batch-flag ; non-zero if --batch specified
272 BAD-fpscr-save ; lisp's fpscr when in FFI-land
273 BAD-fpscr-save-high ; high word of FP reg used to save FPSCR
274 image-name ; current image name
275 initial-tcr ; initial thread's context record
276 ))
277
278;;; The order here matches "ccl:lisp-kernel;lisp_globals.h" and the nrs record
279;;; in "ccl:lisp-kernel;constants.s".
280(defparameter *ppc-nil-relative-symbols*
281 '(t
282 nil
283 ccl::%err-disp
284 ccl::cmain
285 eval
286 ccl::apply-evaluated-function
287 error
288 ccl::%defun
289 ccl::%defvar
290 ccl::%defconstant
291 ccl::%macro
292 ccl::%kernel-restart
293 *package*
294 ccl::*total-bytes-freed*
295 :allow-other-keys
296 ccl::%toplevel-catch%
297 ccl::%toplevel-function%
298 ccl::%pascal-functions%
299 ccl::*all-metered-functions*
300 ccl::*total-gc-microseconds*
301 ccl::%builtin-functions%
302 ccl::%unbound-function%
303 ccl::%init-misc
304 ccl::%macro-code%
305 ccl::%closure-code%
306 ccl::%new-gcable-ptr
307 ccl::*gc-event-status-bits*
308 ccl::*post-gc-hook*
309 ccl::%handlers%
310 ccl::%all-packages%
311 ccl::*keyword-package*
312 ccl::%finalization-alist%
313 ccl::%foreign-thread-control
314 ))
315
316;;; Old (and slightly confusing) name; NIL used to be in a register.
317(defparameter *ppc-nilreg-relative-symbols* *ppc-nil-relative-symbols*)
318
319
320
321
322
323(eval-when (:compile-toplevel :load-toplevel :execute)
324(defparameter *ppc-subprims-shift* 2)
325(defparameter *ppc-subprims-base* (ash 5 12) )
326)
327
328;;; For now, nothing's nailed down and we don't say anything about
329;;; registers clobbered.
330;;; These are shared between ppc32 and ppc64.
331(let* ((origin *ppc-subprims-base*)
332 (step (ash 1 *ppc-subprims-shift*)))
333 (flet ((define-ppc-subprim (name)
334 (ccl::make-subprimitive-info :name (string name)
335 :offset (prog1 origin
336 (incf origin step)))))
337 (macrolet ((defppcsubprim (name)
338 `(define-ppc-subprim ',name)))
339 (defparameter *ppc-subprims*
340 (vector
341 (defppcsubprim .SPjmpsym)
342 (defppcsubprim .SPjmpnfn)
343 (defppcsubprim .SPfuncall)
344 (defppcsubprim .SPmkcatch1v)
345 (defppcsubprim .SPmkunwind)
346 (defppcsubprim .SPmkcatchmv)
347 (defppcsubprim .SPthrow)
348 (defppcsubprim .SPnthrowvalues)
349 (defppcsubprim .SPnthrow1value)
350 (defppcsubprim .SPbind)
351 (defppcsubprim .SPbind-self)
352 (defppcsubprim .SPbind-nil)
353 (defppcsubprim .SPbind-self-boundp-check)
354 (defppcsubprim .SPrplaca)
355 (defppcsubprim .SPrplacd)
356 (defppcsubprim .SPconslist)
357 (defppcsubprim .SPconslist-star)
358 (defppcsubprim .SPstkconslist)
359 (defppcsubprim .SPstkconslist-star)
360 (defppcsubprim .SPmkstackv)
361 (defppcsubprim .SPsubtag-misc-ref)
362 (defppcsubprim .SPsetqsym)
363 (defppcsubprim .SPprogvsave)
364 (defppcsubprim .SPstack-misc-alloc)
365 (defppcsubprim .SPgvector)
366 (defppcsubprim .SPnvalret)
367 (defppcsubprim .SPmvpass)
368 (defppcsubprim .SPfitvals)
369 (defppcsubprim .SPnthvalue)
370 (defppcsubprim .SPvalues)
371 (defppcsubprim .SPdefault-optional-args)
372 (defppcsubprim .SPopt-supplied-p)
373 (defppcsubprim .SPheap-rest-arg)
374 (defppcsubprim .SPreq-heap-rest-arg)
375 (defppcsubprim .SPheap-cons-rest-arg)
376 (defppcsubprim .SPsimple-keywords)
377 (defppcsubprim .SPkeyword-args)
378 (defppcsubprim .SPkeyword-bind)
379 (defppcsubprim .SPpoweropen-ffcall)
380 (defppcsubprim .SParef2)
381 (defppcsubprim .SPksignalerr)
382 (defppcsubprim .SPstack-rest-arg)
383 (defppcsubprim .SPreq-stack-rest-arg)
384 (defppcsubprim .SPstack-cons-rest-arg)
385 (defppcsubprim .SPpoweropen-callbackX)
386 (defppcsubprim .SPcall-closure)
387 (defppcsubprim .SPgetXlong)
388 (defppcsubprim .SPspreadargz)
389 (defppcsubprim .SPtfuncallgen)
390 (defppcsubprim .SPtfuncallslide)
391 (defppcsubprim .SPtfuncallvsp)
392 (defppcsubprim .SPtcallsymgen)
393 (defppcsubprim .SPtcallsymslide)
394 (defppcsubprim .SPtcallsymvsp)
395 (defppcsubprim .SPtcallnfngen)
396 (defppcsubprim .SPtcallnfnslide)
397 (defppcsubprim .SPtcallnfnvsp)
398 (defppcsubprim .SPmisc-ref)
399 (defppcsubprim .SPmisc-set)
400 (defppcsubprim .SPstkconsyz)
401 (defppcsubprim .SPstkvcell0)
402 (defppcsubprim .SPstkvcellvsp)
403 (defppcsubprim .SPmakestackblock)
404 (defppcsubprim .SPmakestackblock0)
405 (defppcsubprim .SPmakestacklist)
406 (defppcsubprim .SPstkgvector)
407 (defppcsubprim .SPmisc-alloc)
408 (defppcsubprim .SPpoweropen-ffcallX)
409 (defppcsubprim .SPgvset)
410 (defppcsubprim .SPmacro-bind)
411 (defppcsubprim .SPdestructuring-bind)
412 (defppcsubprim .SPdestructuring-bind-inner)
413 (defppcsubprim .SPrecover-values)
414 (defppcsubprim .SPvpopargregs)
415 (defppcsubprim .SPinteger-sign)
416 (defppcsubprim .SPsubtag-misc-set)
417 (defppcsubprim .SPspread-lexpr-z)
418 (defppcsubprim .SPstore-node-conditional)
419 (defppcsubprim .SPreset)
420 (defppcsubprim .SPmvslide)
421 (defppcsubprim .SPsave-values)
422 (defppcsubprim .SPadd-values)
423 (defppcsubprim .SPpoweropen-callback)
424 (defppcsubprim .SPmisc-alloc-init)
425 (defppcsubprim .SPstack-misc-alloc-init)
426 (defppcsubprim .SPset-hash-key)
427 (defppcsubprim .SPaset2)
428 (defppcsubprim .SPcallbuiltin)
429 (defppcsubprim .SPcallbuiltin0)
430 (defppcsubprim .SPcallbuiltin1)
431 (defppcsubprim .SPcallbuiltin2)
432 (defppcsubprim .SPcallbuiltin3)
433 (defppcsubprim .SPpopj)
434 (defppcsubprim .SPrestorefullcontext)
435 (defppcsubprim .SPsavecontextvsp)
436 (defppcsubprim .SPsavecontext0)
437 (defppcsubprim .SPrestorecontext)
438 (defppcsubprim .SPlexpr-entry)
439 (defppcsubprim .SPpoweropen-syscall)
440 (defppcsubprim .SPbuiltin-plus)
441 (defppcsubprim .SPbuiltin-minus)
442 (defppcsubprim .SPbuiltin-times)
443 (defppcsubprim .SPbuiltin-div)
444 (defppcsubprim .SPbuiltin-eq)
445 (defppcsubprim .SPbuiltin-ne)
446 (defppcsubprim .SPbuiltin-gt)
447 (defppcsubprim .SPbuiltin-ge)
448 (defppcsubprim .SPbuiltin-lt)
449 (defppcsubprim .SPbuiltin-le)
450 (defppcsubprim .SPbuiltin-eql)
451 (defppcsubprim .SPbuiltin-length)
452 (defppcsubprim .SPbuiltin-seqtype)
453 (defppcsubprim .SPbuiltin-assq)
454 (defppcsubprim .SPbuiltin-memq)
455 (defppcsubprim .SPbuiltin-logbitp)
456 (defppcsubprim .SPbuiltin-logior)
457 (defppcsubprim .SPbuiltin-logand)
458 (defppcsubprim .SPbuiltin-ash)
459 (defppcsubprim .SPbuiltin-negate)
460 (defppcsubprim .SPbuiltin-logxor)
461 (defppcsubprim .SPbuiltin-aref1)
462 (defppcsubprim .SPbuiltin-aset1)
463 (defppcsubprim .SPbreakpoint)
464 (defppcsubprim .SPeabi-ff-call)
465 (defppcsubprim .SPeabi-callback)
466 (defppcsubprim .SPeabi-syscall)
467 (defppcsubprim .SPgetu64)
468 (defppcsubprim .SPgets64)
469 (defppcsubprim .SPmakeu64)
470 (defppcsubprim .SPmakes64)
471 (defppcsubprim .SPspecref)
472 (defppcsubprim .SPspecset)
473 (defppcsubprim .SPspecrefcheck)
474 (defppcsubprim .SPrestoreintlevel)
475 (defppcsubprim .SPmakes32)
476 (defppcsubprim .SPmakeu32)
477 (defppcsubprim .SPgets32)
478 (defppcsubprim .SPgetu32)
479 (defppcsubprim .SPfix-overflow)
480 (defppcsubprim .SPmvpasssym)
481 (defppcsubprim .SParef3)
482 (defppcsubprim .SPaset3)
483 (defppcsubprim .SPpoweropen-ffcall-return-registers)
484 (defppcsubprim .SPnmkunwind)
485 (defppcsubprim .SPunused-6)
486 (defppcsubprim .SPunbind-interrupt-level)
487 (defppcsubprim .SPunbind)
488 (defppcsubprim .SPunbind-n)
489 (defppcsubprim .SPunbind-to)
490 (defppcsubprim .SPbind-interrupt-level-m1)
491 (defppcsubprim .SPbind-interrupt-level)
492 (defppcsubprim .SPbind-interrupt-level-0)
493 (defppcsubprim .SPprogvrestore)
494 )))))
495
496
497
498(provide "PPC-ARCH")
Note: See TracBrowser for help on using the repository browser.