close Warning: Can't use blame annotator:
No changeset 1586 in the repository

source: branches/working-0710/ccl/compiler/PPC/PPC32/ppc32-arch.lisp

Last change on this file was 7385, checked in by Gary Byers, 17 years ago

Storage layout for new rwlock.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 33.3 KB
RevLine 
1;;;-*- Mode: Lisp; Package: (PPC32 :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
18;; This file matches "ccl:pmcl;constants.h" & "ccl:pmcl;constants.s"
19
20(defpackage "PPC32"
21 (:use "CL")
22 #+ppc32-target
23 (:nicknames "TARGET"))
24
25(in-package "PPC32")
26
27(eval-when (:compile-toplevel :load-toplevel :execute)
28 (require "PPC-ARCH")
29
30
31(defmacro define-storage-layout (name origin &rest cells)
32 `(progn
33 (ccl::defenum (:start ,origin :step 4)
34 ,@(mapcar #'(lambda (cell) (ccl::form-symbol name "." cell)) cells))
35 (defconstant ,(ccl::form-symbol name ".SIZE") ,(* (length cells) 4))))
36
37(defmacro define-lisp-object (name tagname &rest cells)
38 `(define-storage-layout ,name ,(- (symbol-value tagname)) ,@cells))
39
40(defmacro define-subtag (name tag subtag)
41 `(defconstant ,(ccl::form-symbol "SUBTAG-" name) (logior ,tag (ash ,subtag ntagbits))))
42
43
44(defmacro define-imm-subtag (name subtag)
45 `(define-subtag ,name fulltag-immheader ,subtag))
46
47(defmacro define-node-subtag (name subtag)
48 `(define-subtag ,name fulltag-nodeheader ,subtag))
49
50(defmacro define-fixedsized-object (name &rest non-header-cells)
51 `(progn
52 (define-lisp-object ,name fulltag-misc header ,@non-header-cells)
53 (ccl::defenum ()
54 ,@(mapcar #'(lambda (cell) (ccl::form-symbol name "." cell "-CELL")) non-header-cells))
55 (defconstant ,(ccl::form-symbol name ".ELEMENT-COUNT") ,(length non-header-cells))))
56
57
58)
59
60(eval-when (:compile-toplevel :load-toplevel :execute)
61(defconstant rcontext 13)
62(defconstant nbits-in-word 32)
63(defconstant least-significant-bit 31)
64(defconstant nbits-in-byte 8)
65(defconstant ntagbits 3) ; But non-header objects only use 2
66(defconstant nlisptagbits 2)
67(defconstant nfixnumtagbits 2) ; See ?
68(defconstant num-subtag-bits 8) ; tag part of header is 8 bits wide
69(defconstant fixnumshift nfixnumtagbits)
70(defconstant fixnum-shift fixnumshift) ; A pet name for it.
71(defconstant fulltagmask (1- (ash 1 ntagbits))) ; Only needed by GC/very low-level code
72(defconstant full-tag-mask fulltagmask)
73(defconstant tagmask (1- (ash 1 nlisptagbits)))
74(defconstant tag-mask tagmask)
75(defconstant fixnummask (1- (ash 1 nfixnumtagbits)))
76(defconstant fixnum-mask fixnummask)
77(defconstant subtag-mask (1- (ash 1 num-subtag-bits)))
78(defconstant ncharcodebits 24) ; only the low 8 bits are used, currently
79(defconstant charcode-shift (- nbits-in-word ncharcodebits))
80(defconstant word-shift 2)
81(defconstant word-size-in-bytes 4)
82(defconstant node-size 4)
83(defconstant dnode-size 8)
84(defconstant dnode-align-bits 3)
85(defconstant dnode-shift dnode-align-bits)
86(defconstant bitmap-shift 5)
87
88(defconstant target-most-negative-fixnum (ash -1 (1- (- nbits-in-word nfixnumtagbits))))
89(defconstant target-most-positive-fixnum (1- (ash 1 (1- (- nbits-in-word nfixnumtagbits)))))
90
91;; PPC-32 stuff and tags.
92
93;; Tags.
94;; There are two-bit tags and three-bit tags.
95;; A FULLTAG is the value of the low three bits of a tagged object.
96;; A TAG is the value of the low two bits of a tagged object.
97;; A TYPECODE is either a TAG or the value of a "tag-misc" object's header-byte.
98
99;; There are 4 primary TAG values. Any object which lisp can "see" can be classified
100;; by its TAG. (Some headers have FULLTAGS that are congruent modulo 4 with the
101;; TAGS of other objects, but lisp can't "see" headers.)
102(ccl::defenum ()
103 tag-fixnum ; All fixnums, whether odd or even
104 tag-list ; Conses and NIL
105 tag-misc ; Heap-consed objects other than lists: vectors, symbols, functions, floats ...
106 tag-imm ; Immediate-objects: characters, UNBOUND, other markers.
107)
108
109;;; And there are 8 FULLTAG values. Note that NIL has its own FULLTAG (congruent mod 4 to tag-list),
110;;; that FULLTAG-MISC is > 4 (so that code-vector entry-points can be branched to, since the low
111;;; two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags
112;;; that share the same TAG.
113;;; Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each
114;;; object that they see.
115(ccl::defenum ()
116 fulltag-even-fixnum ; I suppose EVENP/ODDP might care; nothing else does.
117 fulltag-cons ; a real (non-null) cons. Shares TAG with fulltag-nil.
118 fulltag-nodeheader ; Header of heap-allocated object that contains lisp-object pointers
119 fulltag-imm ; a "real" immediate object. Shares TAG with fulltag-immheader.
120 fulltag-odd-fixnum ;
121 fulltag-nil ; NIL and nothing but. (Note that there's still a hidden NILSYM.)
122 fulltag-misc ; Pointer "real" tag-misc object. Shares TAG with fulltag-nodeheader.
123 fulltag-immheader ; Header of heap-allocated object that contains unboxed data.
124)
125
126(defconstant misc-header-offset (- fulltag-misc))
127(defconstant misc-subtag-offset (+ misc-header-offset 3))
128(defconstant misc-data-offset (+ misc-header-offset 4))
129(defconstant misc-dfloat-offset (+ misc-header-offset 8))
130
131
132
133
134
135
136(defconstant nil-value #x00003015)
137;;; T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans
138;;; two doublewords. The arithmetic difference between T and NIL is
139;;; such that the least-significant bit and exactly one other bit is
140;;; set in the result.
141
142(defconstant t-offset (+ 8 (- 8 fulltag-nil) fulltag-misc))
143(assert (and (logbitp 0 t-offset) (= (logcount t-offset) 2)))
144
145;;; The order in which various header values are defined is significant in several ways:
146;;; 1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags.
147;;; 2) All subtags which denote CL arrays are preceded by those that don't,
148;;; with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types)
149;;; 3) The element-size of ivectors is determined by the ordering of ivector subtags.
150;;; 4) All subtags are >= fulltag-immheader .
151
152
153;;; Numeric subtags.
154(define-imm-subtag bignum 0)
155(defconstant min-numeric-subtag subtag-bignum)
156(define-node-subtag ratio 1)
157(defconstant max-rational-subtag subtag-ratio)
158
159(define-imm-subtag single-float 1) ; "SINGLE" float, aka short-float in the new order.
160(define-imm-subtag double-float 2)
161(defconstant min-float-subtag subtag-single-float)
162(defconstant max-float-subtag subtag-double-float)
163(defconstant max-real-subtag subtag-double-float)
164
165(define-node-subtag complex 3)
166(defconstant max-numeric-subtag subtag-complex)
167
168;;; CL array types. There are more immediate types than node types; all CL array subtags must be > than
169;;; all non-CL-array subtags. So we start by defining the immediate subtags in decreasing order, starting
170;;; with that subtag whose element size isn't an integral number of bits and ending with those whose
171;;; element size - like all non-CL-array fulltag-immheader types - is 32 bits.
172(define-imm-subtag bit-vector 31)
173(define-imm-subtag double-float-vector 30)
174(define-imm-subtag s16-vector 29)
175(define-imm-subtag u16-vector 28)
176(defconstant min-16-bit-ivector-subtag subtag-u16-vector)
177(defconstant max-16-bit-ivector-subtag subtag-s16-vector)
178
179
180;;(define-imm-subtag simple-base-string 27)
181(define-imm-subtag s8-vector 26)
182(define-imm-subtag u8-vector 25)
183(defconstant min-8-bit-ivector-subtag subtag-u8-vector)
184(defconstant max-8-bit-ivector-subtag (logior fulltag-immheader (ash 27 ntagbits)))
185
186(define-imm-subtag simple-base-string 24)
187(define-imm-subtag fixnum-vector 23)
188(define-imm-subtag s32-vector 22)
189(define-imm-subtag u32-vector 21)
190(define-imm-subtag single-float-vector 20)
191(defconstant max-32-bit-ivector-subtag (logior fulltag-immheader (ash 24 ntagbits)))
192(defconstant min-cl-ivector-subtag subtag-single-float-vector)
193
194(define-node-subtag vectorH 20)
195(define-node-subtag arrayH 19)
196(assert (< subtag-arrayH subtag-vectorH min-cl-ivector-subtag))
197(define-node-subtag simple-vector 21) ; Only one such subtag
198(assert (< subtag-arrayH subtag-vectorH subtag-simple-vector))
199(defconstant min-vector-subtag subtag-vectorH)
200(defconstant min-array-subtag subtag-arrayH)
201
202;;; So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag))
203;;; for various immediate/node object types.
204
205(define-imm-subtag macptr 3)
206(defconstant min-non-numeric-imm-subtag subtag-macptr)
207(assert (> min-non-numeric-imm-subtag max-numeric-subtag))
208(define-imm-subtag dead-macptr 4)
209(define-imm-subtag code-vector 5)
210(define-imm-subtag creole-object 6)
211(define-imm-subtag xcode-vector 7) ; code-vector for cross-development
212
213(defconstant max-non-array-imm-subtag (logior (ash 19 ntagbits) fulltag-immheader))
214
215(define-node-subtag catch-frame 4)
216(defconstant min-non-numeric-node-subtag subtag-catch-frame)
217(assert (> min-non-numeric-node-subtag max-numeric-subtag))
218(define-node-subtag function 5)
219(define-node-subtag basic-stream 6)
220(define-node-subtag symbol 7)
221(define-node-subtag lock 8)
222(define-node-subtag hash-vector 9)
223(define-node-subtag pool 10)
224(define-node-subtag weak 11)
225(define-node-subtag package 12)
226(define-node-subtag slot-vector 13)
227(define-node-subtag instance 14)
228(define-node-subtag struct 15)
229(define-node-subtag istruct 16)
230(define-node-subtag value-cell 17)
231(define-node-subtag xfunction 18) ; Function for cross-development
232(defconstant max-non-array-node-subtag (logior (ash 18 ntagbits) fulltag-nodeheader))
233
234(define-subtag character fulltag-imm 9)
235(define-subtag vsp-protect fulltag-imm 7)
236(define-subtag slot-unbound fulltag-imm 10)
237(defconstant slot-unbound-marker subtag-slot-unbound)
238(define-subtag illegal fulltag-imm 11)
239(defconstant illegal-marker subtag-illegal)
240(define-subtag go-tag fulltag-imm 12)
241(define-subtag block-tag fulltag-imm 24)
242(define-subtag no-thread-local-binding fulltag-imm 30)
243(define-subtag unbound fulltag-imm 6)
244(defconstant unbound-marker subtag-unbound)
245(defconstant undefined unbound-marker)
246
247
248(defconstant max-64-bit-constant-index (ash (+ #x7fff ppc32::misc-dfloat-offset) -3))
249(defconstant max-32-bit-constant-index (ash (+ #x7fff ppc32::misc-data-offset) -2))
250(defconstant max-16-bit-constant-index (ash (+ #x7fff ppc32::misc-data-offset) -1))
251(defconstant max-8-bit-constant-index (+ #x7fff ppc32::misc-data-offset))
252(defconstant max-1-bit-constant-index (ash (+ #x7fff ppc32::misc-data-offset) 5))
253
254
255;;; The objects themselves look something like this:
256
257;;; Order of CAR and CDR doesn't seem to matter much - there aren't
258;;; too many tricks to be played with predecrement/preincrement addressing.
259;;; Keep them in the confusing MCL 3.0 order, to avoid confusion.
260(define-lisp-object cons tag-list
261 cdr
262 car)
263
264
265(define-fixedsized-object ratio
266 numer
267 denom)
268
269(define-fixedsized-object single-float
270 value)
271
272(define-fixedsized-object double-float
273 pad
274 value
275 val-low)
276
277(define-fixedsized-object complex
278 realpart
279 imagpart
280)
281
282
283;;; There are two kinds of macptr; use the length field of the header if you
284;;; need to distinguish between them
285(define-fixedsized-object macptr
286 address
287 domain
288 type
289)
290
291(define-fixedsized-object xmacptr
292 address
293 domain
294 type
295 flags
296 link
297)
298
299;;; Catch frames go on the tstack; they point to a minimal lisp-frame
300;;; on the cstack. (The catch/unwind-protect PC is on the cstack, where
301;;; the GC expects to find it.)
302(define-fixedsized-object catch-frame
303 catch-tag ; #<unbound> -> unwind-protect, else catch
304 link ; tagged pointer to next older catch frame
305 mvflag ; 0 if single-value, 1 if uwp or multiple-value
306 csp ; pointer to control stack
307 db-link ; value of dynamic-binding link on thread entry.
308 save-save7 ; saved registers
309 save-save6
310 save-save5
311 save-save4
312 save-save3
313 save-save2
314 save-save1
315 save-save0
316 xframe ; exception-frame link
317 tsp-segment ; mostly padding, for now.
318)
319
320(define-fixedsized-object lock
321 _value ;finalizable pointer to kernel object
322 kind ; '0 = recursive-lock, '1 = rwlock
323 writer ;tcr of owning thread or 0
324 name
325 )
326
327
328
329(define-fixedsized-object symbol
330 pname
331 vcell
332 fcell
333 package-predicate
334 flags
335 plist
336 binding-index
337)
338
339
340
341(defconstant nilsym-offset (+ t-offset symbol.size))
342
343
344(define-fixedsized-object vectorH
345 logsize ; fillpointer if it has one, physsize otherwise
346 physsize ; total size of (possibly displaced) data vector
347 data-vector ; object this header describes
348 displacement ; true displacement or 0
349 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
350)
351
352(define-lisp-object arrayH fulltag-misc
353 header ; subtag = subtag-arrayH
354 rank ; NEVER 1
355 physsize ; total size of (possibly displaced) data vector
356 data-vector ; object this header describes
357 displacement ; true displacement or 0
358 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
359 ;; Dimensions follow
360)
361
362(defconstant arrayH.rank-cell 0)
363(defconstant arrayH.physsize-cell 1)
364(defconstant arrayH.data-vector-cell 2)
365(defconstant arrayH.displacement-cell 3)
366(defconstant arrayH.flags-cell 4)
367(defconstant arrayH.dim0-cell 5)
368
369(defconstant arrayH.flags-cell-bits-byte (byte 8 0))
370(defconstant arrayH.flags-cell-subtag-byte (byte 8 8))
371
372
373(define-fixedsized-object value-cell
374 value)
375
376;;; The kernel uses these (rather generically named) structures
377;;; to keep track of various memory regions it (or the lisp) is
378;;; interested in.
379;;; The gc-area record definition in "ccl:interfaces;mcl-records.lisp"
380;;; matches this.
381
382(define-storage-layout area 0
383 pred ; pointer to preceding area in DLL
384 succ ; pointer to next area in DLL
385 low ; low bound on area addresses
386 high ; high bound on area addresses.
387 active ; low limit on stacks, high limit on heaps
388 softlimit ; overflow bound
389 hardlimit ; another one
390 code ; an area-code; see below
391 markbits ; bit vector for GC
392 ndnodes ; "active" size of dynamic area or stack
393 older ; in EGC sense
394 younger ; also for EGC
395 h ; Handle or null pointer
396 softprot ; protected_area structure pointer
397 hardprot ; another one.
398 owner ; fragment (library) which "owns" the area
399 refbits ; bitvector for intergenerational refernces
400 threshold ; for egc
401 gc-count ; generational gc count.
402 static-dnodes ; for honsing, etc.
403 static-used ; bitvector
404)
405
406
407(define-storage-layout protected-area 0
408 next
409 start ; first byte (page-aligned) that might be protected
410 end ; last byte (page-aligned) that could be protected
411 nprot ; Might be 0
412 protsize ; number of bytes to protect
413 why)
414
415(defconstant tcr-bias 0)
416
417(define-storage-layout tcr (- tcr-bias)
418 prev ; in doubly-linked list
419 next ; in doubly-linked list
420 lisp-fpscr-high
421 lisp-fpscr-low
422 db-link ; special binding chain head
423 catch-top ; top catch frame
424 save-vsp ; VSP when in foreign code
425 save-tsp ; TSP when in foreign code
426 cs-area ; cstack area pointer
427 vs-area ; vstack area pointer
428 ts-area ; tstack area pointer
429 cs-limit ; cstack overflow limit
430 total-bytes-allocated-high
431 total-bytes-allocated-low
432 log2-allocation-quantum ; unboxed
433 interrupt-pending ; fixnum
434 xframe ; exception frame linked list
435 errno-loc ; thread-private, maybe
436 ffi-exception ; fpscr bits from ff-call.
437 osid ; OS thread id
438 valence ; odd when in foreign code
439 foreign-exception-status
440 native-thread-info
441 native-thread-id
442 last-allocptr
443 save-allocptr
444 save-allocbase
445 reset-completion
446 activate
447 suspend-count
448 suspend-context
449 pending-exception-context
450 suspend ; semaphore for suspension notify
451 resume ; sempahore for resumption notify
452 flags ; foreign, being reset, ...
453 gc-context
454 termination-semaphore
455 unwinding
456 tlb-limit
457 tlb-pointer
458 shutdown-count
459 safe-ref-address
460)
461
462(defconstant interrupt-level-binding-index (ash 1 fixnumshift))
463
464(define-storage-layout lockptr 0
465 avail
466 owner
467 count
468 signal
469 waiting
470 malloced-ptr
471 spinlock)
472
473(define-storage-layout rwlock 0
474 spin
475 state
476 blocked-writers
477 blocked-readers
478 writer
479 reader-signal
480 writer-signal
481 malloced-ptr
482 )
483
484;;; For the eabi port: mark this stack frame as Lisp's (since EABI
485;;; foreign frames can be the same size as a lisp frame.)
486
487
488(ppc32::define-storage-layout lisp-frame 0
489 backlink
490 savefn
491 savelr
492 savevsp
493)
494
495(ppc32::define-storage-layout c-frame 0
496 backlink
497 crsave
498 savelr
499 unused-1
500 unused-2
501 savetoc
502 param0
503 param1
504 param2
505 param3
506 param4
507 param5
508 param6
509 param7
510)
511
512(defconstant c-frame.minsize c-frame.size)
513
514;;; .SPeabi-ff-call "shrinks" this frame after loading the GPRs.
515(ppc32::define-storage-layout eabi-c-frame 0
516 backlink
517 savelr
518 param0
519 param1
520 param2
521 param3
522 param4
523 param5
524 param6
525 param7
526)
527
528(defconstant eabi-c-frame.minsize eabi-c-frame.size)
529
530(defmacro define-header (name element-count subtag)
531 `(defconstant ,name (logior (ash ,element-count num-subtag-bits) ,subtag)))
532
533(define-header single-float-header single-float.element-count subtag-single-float)
534(define-header double-float-header double-float.element-count subtag-double-float)
535(define-header one-digit-bignum-header 1 subtag-bignum)
536(define-header two-digit-bignum-header 2 subtag-bignum)
537(define-header three-digit-bignum-header 3 subtag-bignum)
538(define-header symbol-header symbol.element-count subtag-symbol)
539(define-header value-cell-header value-cell.element-count subtag-value-cell)
540(define-header macptr-header macptr.element-count subtag-macptr)
541
542(defconstant yield-syscall
543 #+darwinppc-target -60
544 #+linuxppc-target #$__NR_sched_yield)
545)
546
547
548
549
550(defun %kernel-global (sym)
551 (let* ((pos (position sym ppc::*ppc-kernel-globals* :test #'string=)))
552 (if pos
553 (- (+ fulltag-nil (* (1+ pos) 4)))
554 (error "Unknown kernel global : ~s ." sym))))
555
556(defmacro kernel-global (sym)
557 (let* ((pos (position sym ppc::*ppc-kernel-globals* :test #'string=)))
558 (if pos
559 (- (+ fulltag-nil (* (1+ pos) 4)))
560 (error "Unknown kernel global : ~s ." sym))))
561
562;;; The kernel imports things that are defined in various other
563;;; libraries for us. The objects in question are generally
564;;; fixnum-tagged; the entries in the "kernel-imports" vector are 4
565;;; bytes apart.
566(ccl::defenum (:prefix "KERNEL-IMPORT-" :start 0 :step 4)
567 fd-setsize-bytes
568 do-fd-set
569 do-fd-clr
570 do-fd-is-set
571 do-fd-zero
572 MakeDataExecutable
573 GetSharedLibrary
574 FindSymbol
575 malloc
576 free
577 allocate_tstack
578 allocate_vstack
579 register_cstack
580 raise-thread-interrupt
581 get-r-debug
582 restore-soft-stack-limit
583 egc-control
584 lisp-bug
585 NewThread
586 YieldToThread
587 DisposeThread
588 ThreadCurrentStackSpace
589 usage-exit
590 save-fp-context
591 restore-fp-context
592 put-altivec-registers
593 get-altivec-registers
594 new-semaphore
595 wait-on-semaphore
596 signal-semaphore
597 destroy-semaphore
598 new-recursive-lock
599 lock-recursive-lock
600 unlock-recursive-lock
601 destroy-recursive-lock
602 suspend-other-threads
603 resume-other-threads
604 suspend-tcr
605 resume-tcr
606 rwlock-new
607 rwlock-destroy
608 rwlock-rlock
609 rwlock-wlock
610 rwlock-unlock
611 recursive-lock-trylock
612 foreign-name-and-offset
613)
614
615(defmacro nrs-offset (name)
616 (let* ((pos (position name ppc::*ppc-nilreg-relative-symbols* :test #'eq)))
617 (if pos (+ t-offset (* pos symbol.size)))))
618
619
620(defconstant reservation-discharge #x2004)
621
622
623
624(defmacro with-stack-short-floats (specs &body body)
625 (ccl::collect ((binds)
626 (inits)
627 (names))
628 (dolist (spec specs)
629 (let ((name (first spec)))
630 (binds `(,name (ccl::%make-sfloat)))
631 (names name)
632 (let ((init (second spec)))
633 (when init
634 (inits `(ccl::%short-float ,init ,name))))))
635 `(let* ,(binds)
636 (declare (dynamic-extent ,@(names))
637 (short-float ,@(names)))
638 ,@(inits)
639 ,@body)))
640
641(defparameter *ppc32-target-uvector-subtags*
642 `((:bignum . ,subtag-bignum)
643 (:ratio . ,subtag-ratio)
644 (:single-float . ,subtag-single-float)
645 (:double-float . ,subtag-double-float)
646 (:complex . ,subtag-complex )
647 (:symbol . ,subtag-symbol)
648 (:function . ,subtag-function )
649 (:code-vector . ,subtag-code-vector)
650 (:xcode-vector . ,subtag-xcode-vector)
651 (:macptr . ,subtag-macptr )
652 (:catch-frame . ,subtag-catch-frame)
653 (:struct . ,subtag-struct )
654 (:istruct . ,subtag-istruct )
655 (:pool . ,subtag-pool )
656 (:population . ,subtag-weak )
657 (:hash-vector . ,subtag-hash-vector )
658 (:package . ,subtag-package )
659 (:value-cell . ,subtag-value-cell)
660 (:instance . ,subtag-instance )
661 (:lock . ,subtag-lock )
662 (:slot-vector . ,subtag-slot-vector)
663 (:basic-stream . ,subtag-basic-stream)
664 (:simple-string . ,subtag-simple-base-string )
665 (:bit-vector . ,subtag-bit-vector )
666 (:signed-8-bit-vector . ,subtag-s8-vector )
667 (:unsigned-8-bit-vector . ,subtag-u8-vector )
668 (:signed-16-bit-vector . ,subtag-s16-vector )
669 (:unsigned-16-bit-vector . ,subtag-u16-vector )
670 (:signed-32-bit-vector . ,subtag-s32-vector )
671 (:fixnum-vector . ,subtag-fixnum-vector)
672 (:unsigned-32-bit-vector . ,subtag-u32-vector )
673 (:single-float-vector . ,subtag-single-float-vector)
674 (:double-float-vector . ,subtag-double-float-vector )
675 (:simple-vector . ,subtag-simple-vector )
676 (:vector-header . ,subtag-vectorH)
677 (:array-header . ,subtag-arrayH)))
678
679
680;;; This should return NIL unless it's sure of how the indicated
681;;; type would be represented (in particular, it should return
682;;; NIL if the element type is unknown or unspecified at compile-time.
683(defun ppc32-array-type-name-from-ctype (ctype)
684 (when (typep ctype 'ccl::array-ctype)
685 (let* ((element-type (ccl::array-ctype-element-type ctype)))
686 (typecase element-type
687 (ccl::class-ctype
688 (let* ((class (ccl::class-ctype-class element-type)))
689 (if (or (eq class ccl::*character-class*)
690 (eq class ccl::*base-char-class*)
691 (eq class ccl::*standard-char-class*))
692 :simple-string
693 :simple-vector)))
694 (ccl::numeric-ctype
695 (if (eq (ccl::numeric-ctype-complexp element-type) :complex)
696 :simple-vector
697 (case (ccl::numeric-ctype-class element-type)
698 (integer
699 (let* ((low (ccl::numeric-ctype-low element-type))
700 (high (ccl::numeric-ctype-high element-type)))
701 (cond ((or (null low) (null high)) :simple-vector)
702 ((and (>= low 0) (<= high 1) :bit-vector))
703 ((and (>= low 0) (<= high 255)) :unsigned-8-bit-vector)
704 ((and (>= low 0) (<= high 65535)) :unsigned-16-bit-vector)
705 ((and (>= low 0) (<= high #xffffffff) :unsigned-32-bit-vector))
706 ((and (>= low -128) (<= high 127)) :signed-8-bit-vector)
707 ((and (>= low -32768) (<= high 32767) :signed-16-bit-vector))
708 ((and (>= low target-most-negative-fixnum)
709 (<= high target-most-positive-fixnum))
710 :fixnum-vector)
711 ((and (>= low (ash -1 31)) (<= high (1- (ash 1 31))))
712 :signed-32-bit-vector)
713 (t :simple-vector))))
714 (float
715 (case (ccl::numeric-ctype-format element-type)
716 ((double-float long-float) :double-float-vector)
717 ((single-float short-float) :single-float-vector)
718 (t :simple-vector)))
719 (t :simple-vector))))
720 (ccl::unknown-ctype)
721 (ccl::named-ctype
722 (if (eq element-type ccl::*universal-type*)
723 :simple-vector))
724 (t nil)))))
725
726(defun ppc32-misc-byte-count (subtag element-count)
727 (declare (fixnum subtag))
728 (if (or (= fulltag-nodeheader (logand subtag fulltagmask))
729 (<= subtag max-32-bit-ivector-subtag))
730 (ash element-count 2)
731 (if (<= subtag max-8-bit-ivector-subtag)
732 element-count
733 (if (<= subtag max-16-bit-ivector-subtag)
734 (ash element-count 1)
735 (if (= subtag subtag-bit-vector)
736 (ash (+ element-count 7) -3)
737 (+ 4 (ash element-count 3)))))))
738
739(defparameter *ppc32-target-arch*
740 (arch::make-target-arch :name :ppc32
741 :lisp-node-size 4
742 :nil-value nil-value
743 :fixnum-shift fixnumshift
744 :most-positive-fixnum (1- (ash 1 (1- (- 32 fixnumshift))))
745 :most-negative-fixnum (- (ash 1 (1- (- 32 fixnumshift))))
746 :misc-data-offset misc-data-offset
747 :misc-dfloat-offset misc-dfloat-offset
748 :nbits-in-word 32
749 :ntagbits 3
750 :nlisptagbits 2
751 :uvector-subtags *ppc32-target-uvector-subtags*
752 :max-64-bit-constant-index max-64-bit-constant-index
753 :max-32-bit-constant-index max-32-bit-constant-index
754 :max-16-bit-constant-index max-16-bit-constant-index
755 :max-8-bit-constant-index max-8-bit-constant-index
756 :max-1-bit-constant-index max-1-bit-constant-index
757 :word-shift 2
758 :code-vector-prefix ()
759 :gvector-types '(:ratio :complex :symbol :function
760 :catch-frame :struct :istruct
761 :pool :population :hash-vector
762 :package :value-cell :instance
763 :lock :slot-vector
764 :simple-vector)
765 :1-bit-ivector-types '(:bit-vector)
766 :8-bit-ivector-types '(:signed-8-bit-vector
767 :unsigned-8-bit-vector)
768 :16-bit-ivector-types '(:signed-16-bit-vector
769 :unsigned-16-bit-vector)
770 :32-bit-ivector-types '(:signed-32-bit-vector
771 :unsigned-32-bit-vector
772 :single-float-vector
773 :fixnum-vector
774 :single-float
775 :double-float
776 :bignum
777 :simple-string)
778 :64-bit-ivector-types '(:double-float-vector)
779 :array-type-name-from-ctype-function
780 #'ppc32-array-type-name-from-ctype
781 :package-name "PPC32"
782 :t-offset t-offset
783 :array-data-size-function #'ppc32-misc-byte-count
784 :numeric-type-name-to-typecode-function
785 #'(lambda (type-name)
786 (ecase type-name
787 (fixnum tag-fixnum)
788 (bignum subtag-bignum)
789 ((short-float single-float) subtag-single-float)
790 ((long-float double-float) subtag-double-float)
791 (ratio subtag-ratio)
792 (complex subtag-complex)))
793 :subprims-base ppc::*ppc-subprims-base*
794 :subprims-shift ppc::*ppc-subprims-shift*
795 :subprims-table ppc::*ppc-subprims*
796 :primitive->subprims `(((0 . 23) . ,(ccl::%subprim-name->offset '.SPbuiltin-plus ppc::*ppc-subprims*)))
797 :unbound-marker-value unbound-marker
798 :slot-unbound-marker-value slot-unbound-marker
799 :fixnum-tag tag-fixnum
800 :single-float-tag subtag-single-float
801 :single-float-tag-is-subtag t
802 :double-float-tag subtag-double-float
803 :cons-tag fulltag-cons
804 :null-tag fulltag-nil
805 :symbol-tag subtag-symbol
806 :symbol-tag-is-subtag t
807 :function-tag subtag-function
808 :function-tag-is-subtag t
809 :big-endian t
810 :misc-subtag-offset misc-subtag-offset
811 :car-offset cons.car
812 :cdr-offset cons.cdr
813 :subtag-char subtag-character
814 :charcode-shift charcode-shift
815 :fulltagmask fulltagmask
816 :fulltag-misc fulltag-misc
817 :char-code-limit #x110000
818 ))
819
820;;; arch macros
821(defmacro defppc32archmacro (name lambda-list &body body)
822 `(arch::defarchmacro :ppc32 ,name ,lambda-list ,@body))
823
824(defppc32archmacro ccl::%make-sfloat ()
825 `(ccl::%alloc-misc ppc32::single-float.element-count ppc32::subtag-single-float))
826
827(defppc32archmacro ccl::%make-dfloat ()
828 `(ccl::%alloc-misc ppc32::double-float.element-count ppc32::subtag-double-float))
829
830(defppc32archmacro ccl::%numerator (x)
831 `(ccl::%svref ,x ppc32::ratio.numer-cell))
832
833(defppc32archmacro ccl::%denominator (x)
834 `(ccl::%svref ,x ppc32::ratio.denom-cell))
835
836(defppc32archmacro ccl::%realpart (x)
837 `(ccl::%svref ,x ppc32::complex.realpart-cell))
838
839(defppc32archmacro ccl::%imagpart (x)
840 `(ccl::%svref ,x ppc32::complex.imagpart-cell))
841
842;;;
843(defppc32archmacro ccl::%get-single-float-from-double-ptr (ptr offset)
844 `(ccl::%double-float->short-float (ccl::%get-double-float ,ptr ,offset)
845 (ccl::%alloc-misc 1 ppc32::subtag-single-float)))
846
847(defppc32archmacro ccl::codevec-header-p (word)
848 `(eql ppc32::subtag-code-vector
849 (logand ,word ppc32::subtag-mask)))
850
851(defppc32archmacro ccl::immediate-p-macro (thing)
852 (let* ((tag (gensym)))
853 `(let* ((,tag (ccl::lisptag ,thing)))
854 (declare (fixnum ,tag))
855 (or (= ,tag ppc32::tag-fixnum)
856 (= ,tag ppc32::tag-imm)))))
857
858(defppc32archmacro ccl::hashed-by-identity (thing)
859 (let* ((typecode (gensym)))
860 `(let* ((,typecode (ccl::typecode ,thing)))
861 (declare (fixnum ,typecode))
862 (or
863 (= ,typecode ppc32::tag-fixnum)
864 (= ,typecode ppc32::tag-imm)
865 (= ,typecode ppc32::subtag-symbol)
866 (= ,typecode ppc32::subtag-instance)))))
867
868;;;
869(defppc32archmacro ccl::%get-kernel-global (name)
870 `(ccl::%fixnum-ref 0 (+ ppc32::nil-value
871 ,(%kernel-global
872 (if (ccl::quoted-form-p name)
873 (cadr name)
874 name)))))
875
876(defppc32archmacro ccl::%get-kernel-global-ptr (name dest)
877 `(ccl::%setf-macptr
878 ,dest
879 (ccl::%fixnum-ref-macptr 0 (+ ppc32::nil-value
880 ,(%kernel-global
881 (if (ccl::quoted-form-p name)
882 (cadr name)
883 name))))))
884
885(defppc32archmacro ccl::%target-kernel-global (name)
886 `(ppc32::%kernel-global ,name))
887
888(defppc32archmacro ccl::lfun-vector (fn)
889 fn)
890
891(defppc32archmacro ccl::lfun-vector-lfun (lfv)
892 lfv)
893
894(defppc32archmacro ccl::area-code ()
895 area.code)
896
897(defppc32archmacro ccl::area-succ ()
898 area.succ)
899
900(defppc32archmacro ccl::nth-immediate (f i)
901 `(ccl::%svref ,f ,i))
902
903(defppc32archmacro ccl::set-nth-immediate (f i new)
904 `(setf (ccl::%svref ,f ,i) ,new))
905
906(defppc32archmacro ccl::symptr->symvector (s)
907 s)
908
909(defppc32archmacro ccl::symvector->symptr (s)
910 s)
911
912(defppc32archmacro ccl::function-to-function-vector (f)
913 f)
914
915(defppc32archmacro ccl::function-vector-to-function (v)
916 v)
917
918(defppc32archmacro ccl::with-ffcall-results ((buf) &body body)
919 (let* ((size (+ (* 8 4) (* 31 8))))
920 `(%stack-block ((,buf ,size))
921 ,@body)))
922
923(provide "PPC32-ARCH")
Note: See TracBrowser for help on using the repository browser.