Changeset 188
- Timestamp:
- Jan 3, 2004, 11:49:34 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/ccl/compiler/PPC/PPC32/ppc32-arch.lisp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/compiler/PPC/PPC32/ppc32-arch.lisp
r83 r188 18 18 ;; This file matches "ccl:pmcl;constants.h" & "ccl:pmcl;constants.s" 19 19 20 (in-package "PPC32") 21 20 22 (eval-when (:compile-toplevel :load-toplevel :execute) 21 (require " ARCH"))23 (require "PPC-ARCH")) 22 24 23 25 … … 25 27 26 28 29 (defmacro define-storage-layout (name origin &rest cells) 30 `(progn 31 (ccl::defenum (:start ,origin :step (ash 1 ppc32::word-shift)) 32 ,@(mapcar #'(lambda (cell) (ccl::form-symbol name "." cell)) cells)) 33 (defconstant ,(ccl::form-symbol name ".SIZE") ,(* (length cells) 34 (ash 1 ppc32::word-shift))))) 35 36 (defmacro define-lisp-object (name tagname &rest cells) 37 `(define-storage-layout ,name ,(- (symbol-value tagname)) ,@cells)) 38 39 (defmacro define-subtag (name tag subtag) 40 `(defconstant ,(ccl::form-symbol "SUBTAG-" name) (logior ,tag (ash ,subtag ntagbits)))) 41 42 43 (defmacro define-imm-subtag (name subtag) 44 `(define-subtag ,name fulltag-immheader ,subtag)) 45 46 (defmacro define-node-subtag (name subtag) 47 `(define-subtag ,name fulltag-nodeheader ,subtag)) 48 49 (defmacro define-fixedsized-object (name &rest non-header-cells) 50 `(progn 51 (define-lisp-object ,name fulltag-misc header ,@non-header-cells) 52 (ccl::defenum () 53 ,@(mapcar #'(lambda (cell) (ccl::form-symbol name "." cell "-CELL")) non-header-cells)) 54 (defconstant ,(ccl::form-symbol name ".ELEMENT-COUNT") ,(length non-header-cells)))) 55 56 57 (eval-when (:compile-toplevel :load-toplevel :execute) 58 (defconstant nbits-in-word 32) 59 (defconstant least-significant-bit 31) 60 (defconstant nbits-in-byte 8) 61 (defconstant ntagbits 3) ; But non-header objects only use 2 62 (defconstant nlisptagbits 2) 63 (defconstant nfixnumtagbits 2) ; See ? 64 (defconstant num-subtag-bits 8) ; tag part of header is 8 bits wide 65 (defconstant fixnumshift nfixnumtagbits) 66 (defconstant fixnum-shift fixnumshift) ; A pet name for it. 67 (defconstant fulltagmask (1- (ash 1 ntagbits))) ; Only needed by GC/very low-level code 68 (defconstant full-tag-mask fulltagmask) 69 (defconstant tagmask (1- (ash 1 nlisptagbits))) 70 (defconstant tag-mask tagmask) 71 (defconstant fixnummask (1- (ash 1 nfixnumtagbits))) 72 (defconstant fixnum-mask fixnummask) 73 (defconstant subtag-mask (1- (ash 1 num-subtag-bits))) 74 (defconstant ncharcodebits 16) 75 (defconstant charcode-shift (- nbits-in-word ncharcodebits)) 76 (defconstant word-shift 2) 77 27 78 28 79 ;; PPC-32 stuff and tags. 29 (eval-when (:compile-toplevel :load-toplevel :execute) 30 31 32 ;;; Lisp registers. 33 (eval-when (:compile-toplevel :execute) 34 (defmacro defregs (&body regs) 35 `(progn 36 (ccl::defenum () ,@regs) 37 (defparameter *gpr-register-names* ,(coerce (mapcar #'string regs) 'vector)))) 38 (defmacro deffpregs (&body regs) 39 `(progn 40 (ccl::defenum () ,@regs) 41 (defparameter *fpr-register-names* ,(coerce (mapcar #'string regs) 'vector)))) 42 (defmacro defvregs (&body regs) 43 `(progn 44 (ccl::defenum () ,@regs) 45 (defparameter *vector-register-names* ,(coerce (mapcar #'string regs) 'vector)) 46 ))) 47 48 (defregs 49 rzero ; Always contains 0; not as handy as it sounds. 50 sp ; The control stack. Aligned on 16-byte boundary. 51 rcontext ; thread context 52 imm0 ; Unboxed, volatile registers. 53 imm1 54 imm2 55 imm3 56 imm4 57 imm5 58 allocptr 59 allocbase 60 nargs ; Volatile. SHOULDN'T be used for tag extraction. (TWI handler confusion.) 61 tsp ; Temp-stack pointer. 62 vsp ; Value stack pointer; grows towards 0. 63 loc-pc ; for return PC only. 64 fn ; Current function (constants vector). 65 temp4 ; Boxed, volatile registers. Some 66 ; may be defined on function entry. 67 temp3 68 temp2 69 temp1 70 temp0 71 arg_x ; Next-to-next-to-last function arg. 72 arg_y ; Next-to-last function argument. 73 arg_z ; Last function argument. 74 save7 ; Boxed, nonvolatile registers. 75 save6 76 save5 77 save4 78 save3 79 save2 80 save1 81 save0 82 ) 80 81 ;; Tags. 82 ;; There are two-bit tags and three-bit tags. 83 ;; A FULLTAG is the value of the low three bits of a tagged object. 84 ;; A TAG is the value of the low two bits of a tagged object. 85 ;; A TYPECODE is either a TAG or the value of a "tag-misc" object's header-byte. 86 87 ;; There are 4 primary TAG values. Any object which lisp can "see" can be classified 88 ;; by its TAG. (Some headers have FULLTAGS that are congruent modulo 4 with the 89 ;; TAGS of other objects, but lisp can't "see" headers.) 90 (ccl::defenum () 91 tag-fixnum ; All fixnums, whether odd or even 92 tag-list ; Conses and NIL 93 tag-misc ; Heap-consed objects other than lists: vectors, symbols, functions, floats ... 94 tag-imm ; Immediate-objects: characters, UNBOUND, other markers. 95 ) 96 97 ;; And there are 8 FULLTAG values. Note that NIL has its own FULLTAG (congruent mod 4 to tag-list), 98 ;; that FULLTAG-MISC is > 4 (so that code-vector entry-points can be branched to, since the low 99 ;; two bits of the PC are ignored) and that both FULLTAG-MISC and FULLTAG-IMM have header fulltags 100 ;; that share the same TAG. 101 ;; Things that walk memory (and the stack) have to be careful to look at the FULLTAG of each 102 ;; object that they see. 103 (ccl::defenum () 104 fulltag-even-fixnum ; I suppose EVENP/ODDP might care; nothing else does. 105 fulltag-cons ; a real (non-null) cons. Shares TAG with fulltag-nil. 106 fulltag-nodeheader ; Header of heap-allocated object that contains lisp-object pointers 107 fulltag-imm ; a "real" immediate object. Shares TAG with fulltag-immheader. 108 fulltag-odd-fixnum ; 109 fulltag-nil ; NIL and nothing but. (Note that there's still a hidden NILSYM.) 110 fulltag-misc ; Pointer "real" tag-misc object. Shares TAG with fulltag-nodeheader. 111 fulltag-immheader ; Header of heap-allocated object that contains unboxed data. 112 ) 113 114 (defconstant misc-header-offset (- fulltag-misc)) 115 (defconstant misc-subtag-offset (+ misc-header-offset 3)) 116 (defconstant misc-data-offset (+ misc-header-offset 4)) 117 (defconstant misc-dfloat-offset (+ misc-header-offset 8)) 118 119 120 121 122 83 123 84 124 (defconstant nil-value #x00002015) 85 86 (deffpregs 87 fp0 88 fp1 89 fp2 90 fp3 91 fp4 92 fp5 93 fp6 94 fp7 95 fp8 96 fp9 97 fp10 98 fp11 99 fp12 100 fp13 101 fp14 102 fp15 103 fp16 104 fp17 105 fp18 106 fp19 107 fp20 108 fp21 109 fp22 110 fp23 111 fp24 112 fp25 113 fp26 114 fp27 115 fp28 116 fp29 117 fp30 118 fp31) 119 120 (defvregs 121 vr0 ; General temp vector register 122 vr1 ; Most-significant quadword when word-aligning 123 vr2 ; Least-significant quadword when word-aligning 124 vr3 ; Operand A resulting from word-aligning 125 vr4 ; Operand B resulting from word-aligning 126 vr5 ; Result from operations on A and B 127 vr6 128 vr7 129 vr8 130 vr9 131 vr10 132 vr11 133 vr12 134 vr13 135 vr14 136 vr15 137 vr16 138 vr17 139 vr18 140 vr19 141 ;;By convention, registers after this point are considered non-volatile. Callee should save. 142 vr20 143 vr21 144 vr22 145 vr23 146 vr24 147 vr25 148 vr26 149 vr27 ; Permutation control register A for loads 150 vr28 ; Permutation control register B for stores 151 vr29 ; mask register 152 vr30 ; All zeros 153 vr31 ; All ones 154 ) 155 156 157 (defconstant fname temp3) 158 159 ;;; Calling sequence may pass additional arguments in temp registers. 160 ;;; "nfn" (new function) is always passed; it's the new value of "fn". 161 (defconstant nfn temp2) 162 163 ;;; CLOS may pass the context for, e.g.., CALL-NEXT-METHOD in 164 ;;;; the "next-method-context" register. 165 (defconstant next-method-context temp1) 166 167 168 ;;; It's handy to have 0.0 in an fpr. 169 (defconstant fp-zero fp31) 170 171 ; Also handy to have #x4330000080000000 in an fpr, for s32->float conversion. 172 (defconstant fp-s32conv fp30) 173 174 125 ; T is almost adjacent to NIL: since NIL is a misaligned CONS, it spans 126 ; two doublewords. The arithmetic difference between T and NIL is 127 ; such that the least-significant bit and exactly one other bit is 128 ; set in the result. 129 130 (defconstant t-offset (+ 8 (- 8 fulltag-nil) fulltag-misc)) 131 (assert (and (logbitp 0 t-offset) (= (logcount t-offset) 2))) 132 133 ; The order in which various header values are defined is significant in several ways: 134 ; 1) Numeric subtags precede non-numeric ones; there are further orderings among numeric subtags. 135 ; 2) All subtags which denote CL arrays are preceded by those that don't, 136 ; with a further ordering which requires that (< header-arrayH header-vectorH ,@all-other-CL-vector-types) 137 ; 3) The element-size of ivectors is determined by the ordering of ivector subtags. 138 ; 4) All subtags are >= fulltag-immheader . 139 140 141 ; Numeric subtags. 142 (define-imm-subtag bignum 0) 143 (defconstant min-numeric-subtag subtag-bignum) 144 (define-node-subtag ratio 1) 145 (defconstant max-rational-subtag subtag-ratio) 146 147 (define-imm-subtag single-float 1) ; "SINGLE" float, aka short-float in the new order. 148 (define-imm-subtag double-float 2) 149 (defconstant min-float-subtag subtag-single-float) 150 (defconstant max-float-subtag subtag-double-float) 151 (defconstant max-real-subtag subtag-double-float) 152 153 (define-node-subtag complex 3) 154 (defconstant max-numeric-subtag subtag-complex) 155 156 ; CL array types. There are more immediate types than node types; all CL array subtags must be > than 157 ; all non-CL-array subtags. So we start by defining the immediate subtags in decreasing order, starting 158 ; with that subtag whose element size isn't an integral number of bits and ending with those whose 159 ; element size - like all non-CL-array fulltag-immheader types - is 32 bits. 160 (define-imm-subtag bit-vector 31) 161 (define-imm-subtag double-float-vector 30) 162 (define-imm-subtag s16-vector 29) 163 (define-imm-subtag u16-vector 28) 164 (define-imm-subtag simple-general-string 27) 165 (defconstant min-16-bit-ivector-subtag subtag-simple-general-string) 166 (defconstant max-16-bit-ivector-subtag subtag-s16-vector) 167 (defconstant max-string-subtag subtag-simple-general-string) 168 169 (define-imm-subtag simple-base-string 26) 170 (define-imm-subtag s8-vector 25) 171 (define-imm-subtag u8-vector 24) 172 (defconstant min-8-bit-ivector-subtag subtag-u8-vector) 173 (defconstant max-8-bit-ivector-subtag subtag-simple-base-string) 174 (defconstant min-string-subtag subtag-simple-base-string) 175 176 (define-imm-subtag s32-vector 23) 177 (define-imm-subtag u32-vector 22) 178 (define-imm-subtag single-float-vector 21) 179 (defconstant max-32-bit-ivector-subtag subtag-s32-vector) 180 (defconstant min-cl-ivector-subtag subtag-single-float-vector) 181 182 (define-node-subtag vectorH 21) 183 (define-node-subtag arrayH 20) 184 (assert (< subtag-arrayH subtag-vectorH min-cl-ivector-subtag)) 185 (define-node-subtag simple-vector 22) ; Only one such subtag 186 (assert (< subtag-arrayH subtag-vectorH subtag-simple-vector)) 187 (defconstant min-vector-subtag subtag-vectorH) 188 (defconstant min-array-subtag subtag-arrayH) 189 190 ; So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag)) 191 ; for various immediate/node object types. 192 193 (define-imm-subtag macptr 3) 194 (defconstant min-non-numeric-imm-subtag subtag-macptr) 195 (assert (> min-non-numeric-imm-subtag max-numeric-subtag)) 196 (define-imm-subtag dead-macptr 4) 197 (define-imm-subtag code-vector 5) 198 (define-imm-subtag creole-object 6) 199 (define-imm-subtag xcode-vector 7) ; code-vector for cross-development 200 201 (defconstant max-non-array-imm-subtag (logior (ash 19 ntagbits) fulltag-immheader)) 202 203 (define-node-subtag catch-frame 4) 204 (defconstant min-non-numeric-node-subtag subtag-catch-frame) 205 (assert (> min-non-numeric-node-subtag max-numeric-subtag)) 206 (define-node-subtag function 5) 207 (define-node-subtag lisp-thread 6) 208 (define-node-subtag symbol 7) 209 (define-node-subtag lock 8) 210 (define-node-subtag hash-vector 9) 211 (define-node-subtag pool 10) 212 (define-node-subtag weak 11) 213 (define-node-subtag package 12) 214 (define-node-subtag slot-vector 13) 215 (define-node-subtag instance 14) 216 (define-node-subtag struct 15) 217 (define-node-subtag istruct 16) 218 (define-node-subtag value-cell 17) 219 (define-node-subtag xfunction 18) ; Function for cross-development 220 (define-node-subtag svar 19) 221 (defconstant max-non-array-node-subtag (logior (ash 19 ntagbits) fulltag-nodeheader)) 222 223 (define-subtag character fulltag-imm 9) 224 (define-subtag vsp-protect fulltag-imm 7) 225 (define-subtag slot-unbound fulltag-imm 10) 226 (defconstant slot-unbound-marker subtag-slot-unbound) 227 (define-subtag illegal fulltag-imm 11) 228 (defconstant illegal-marker subtag-illegal) 229 (define-subtag go-tag fulltag-imm 12) 230 (define-subtag block-tag fulltag-imm 24) 231 (define-subtag no-thread-local-binding fulltag-imm 30) 232 (define-subtag unbound fulltag-imm 6) 233 (defconstant unbound-marker subtag-unbound) 234 (defconstant undefined unbound-marker) 175 235 176 236 … … 184 244 ; The objects themselves look something like this: 185 245 246 ; Order of CAR and CDR doesn't seem to matter much - there aren't 247 ; too many tricks to be played with predecrement/preincrement addressing. 248 ; Keep them in the confusing MCL 3.0 order, to avoid confusion. 249 (define-lisp-object cons tag-list 250 cdr 251 car) 252 253 254 (define-fixedsized-object ratio 255 numer 256 denom) 257 258 (define-fixedsized-object single-float 259 value) 260 261 (define-fixedsized-object double-float 262 pad 263 value 264 val-low) 265 266 (define-fixedsized-object complex 267 realpart 268 imagpart 269 ) 270 271 272 ; There are two kinds of macptr; use the length field of the header if you 273 ; need to distinguish between them 274 (define-fixedsized-object macptr 275 address 276 domain 277 type 278 ) 279 280 (define-fixedsized-object xmacptr 281 address 282 domain 283 type 284 flags 285 link 286 ) 287 288 ; Catch frames go on the tstack; they point to a minimal lisp-frame 289 ; on the cstack. (The catch/unwind-protect PC is on the cstack, where 290 ; the GC expects to find it.) 291 (define-fixedsized-object catch-frame 292 catch-tag ; #<unbound> -> unwind-protect, else catch 293 link ; tagged pointer to next older catch frame 294 mvflag ; 0 if single-value, 1 if uwp or multiple-value 295 csp ; pointer to control stack 296 db-link ; value of dynamic-binding link on thread entry. 297 save-save7 ; saved registers 298 save-save6 299 save-save5 300 save-save4 301 save-save3 302 save-save2 303 save-save1 304 save-save0 305 xframe ; exception-frame link 306 tsp-segment ; mostly padding, for now. 307 ) 308 309 (define-fixedsized-object lock 310 _value ;finalizable pointer to kernel object 311 kind ; '0 = recursive-lock, '1 = rwlock 312 writer ;tcr of owning thread or 0 313 name 314 ) 315 316 (define-fixedsized-object lisp-thread 317 tcr 318 name 319 cs-size 320 vs-size 321 ts-size 322 initial-function.args 323 interrupt-functions 324 interrupt-lock 325 startup-function 326 state 327 state-change-lock 328 ) 329 330 (define-fixedsized-object symbol 331 pname 332 vcell 333 fcell 334 package-plist 335 flags 336 ) 337 338 339 (defconstant nilsym-offset (+ t-offset symbol.size)) 340 341 342 (define-fixedsized-object vectorH 343 logsize ; fillpointer if it has one, physsize otherwise 344 physsize ; total size of (possibly displaced) data vector 345 data-vector ; object this header describes 346 displacement ; true displacement or 0 347 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector. 348 ) 349 350 (define-lisp-object arrayH fulltag-misc 351 header ; subtag = subtag-arrayH 352 rank ; NEVER 1 353 physsize ; total size of (possibly displaced) data vector 354 data-vector ; object this header describes 355 displacement ; true displacement or 0 356 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector. 357 ;; Dimensions follow 358 ) 359 360 (defconstant arrayH.rank-cell 0) 361 (defconstant arrayH.physsize-cell 1) 362 (defconstant arrayH.data-vector-cell 2) 363 (defconstant arrayH.displacement-cell 3) 364 (defconstant arrayH.flags-cell 4) 365 (defconstant arrayH.dim0-cell 5) 366 367 (defconstant arrayH.flags-cell-bits-byte (byte 8 0)) 368 (defconstant arrayH.flags-cell-subtag-byte (byte 8 8)) 369 370 371 (define-fixedsized-object value-cell 372 value) 373 374 (define-fixedsized-object svar 375 symbol 376 idx) 377 378 ;;; The kernel uses these (rather generically named) structures 379 ;;; to keep track of various memory regions it (or the lisp) is 380 ;;; interested in. 381 ;;; The gc-area record definition in "ccl:interfaces;mcl-records.lisp" 382 ;;; matches this. 383 384 (define-storage-layout area 0 385 pred ; pointer to preceding area in DLL 386 succ ; pointer to next area in DLL 387 low ; low bound on area addresses 388 high ; high bound on area addresses. 389 active ; low limit on stacks, high limit on heaps 390 softlimit ; overflow bound 391 hardlimit ; another one 392 code ; an area-code; see below 393 markbits ; bit vector for GC 394 ndwords ; "active" size of dynamic area or stack 395 older ; in EGC sense 396 younger ; also for EGC 397 h ; Handle or null pointer 398 softprot ; protected_area structure pointer 399 hardprot ; another one. 400 owner ; fragment (library) which "owns" the area 401 refbits ; bitvector for intergenerational refernces 402 threshold ; for egc 403 gc-count ; generational gc count. 404 ) 405 406 (ccl::defenum (:prefix "AREA-") 407 void ; list header 408 cstack ; a control stack 409 vstack ; a value stack 410 tstack ; (dynamic-extent) temp stack 411 readonly ; readonly section 412 staticlib ; static data in library 413 static ; static data in application 414 dynamic ; dynmaic (heap) data in application 415 ) 416 417 418 ; areas are sorted such that (in the "succ" direction) codes are >=. 419 ; If you think that you're looking for a stack (instead of a heap), look 420 ; in the "pred" direction from the all-areas header. 421 (defconstant max-stack-area-code area-tstack) 422 (defconstant min-heap-area-code area-readonly) 423 424 425 (define-storage-layout protected-area 0 426 next 427 start ; first byte (page-aligned) that might be protected 428 end ; last byte (page-aligned) that could be protected 429 nprot ; Might be 0 430 protsize ; number of bytes to protect 431 why) 432 433 (define-storage-layout tcr 0 434 prev ; in doubly-linked list 435 next ; in doubly-linked list 436 lisp-fpscr-high 437 lisp-fpscr-low 438 db-link ; special binding chain head 439 catch-top ; top catch frame 440 save-vsp ; VSP when in foreign code 441 save-tsp ; TSP when in foreign code 442 cs-area ; cstack area pointer 443 vs-area ; vstack area pointer 444 ts-area ; tstack area pointer 445 cs-limit ; cstack overflow limit 446 total-bytes-allocated-high 447 total-bytes-allocated-low 448 interrupt-level ; fixnum 449 interrupt-pending ; fixnum 450 xframe ; exception frame linked list 451 errno-loc ; thread-private, maybe 452 ffi-exception ; fpscr bits from ff-call. 453 osid ; OS thread id 454 valence ; odd when in foreign code 455 foreign-exception-status 456 native-thread-info 457 native-thread-id 458 last-allocptr 459 save-allocptr 460 save-allocbase 461 reset-completion 462 activate 463 suspend-count 464 suspend-context 465 pending-exception-context 466 suspend ; semaphore for suspension notify 467 resume ; sempahore for resumption notify 468 flags ; foreign, being reset, ... 469 gc-context 470 suspend-total 471 suspend-total-on-exception-entry 472 tlb-limit 473 tlb-pointer 474 ) 475 476 (define-storage-layout lockptr 0 477 avail 478 owner 479 count 480 signal 481 waiting 482 malloced-ptr) 186 483 187 484 ;; For the eabi port: mark this stack frame as Lisp's (since EABI … … 233 530 234 531 235 236 237 238 (ccl::defenum (:prefix "PPC-" :suffix "-BIT")239 lt240 gt241 eq242 so243 )244 245 246 (ccl::defenum (:prefix "FPSCR-" :suffix "-BIT")247 fx248 fex249 vx250 ox251 ux252 zx253 xx254 vxsnan255 vxisi256 vxidi257 vxzdz258 vximz259 vxvc260 fr261 fi262 fprfc263 fl264 fg265 fe266 fu267 nil268 vxsoft269 vxsqrt270 vxcvi271 ve272 oe273 ue274 ze275 xe276 ni277 rn0278 rn1279 )280 281 532 (defconstant yield-syscall 282 533 #+darwinppc-target -60 … … 284 535 ) 285 536 537 286 538 (provide "PPC32-ARCH")
Note:
See TracChangeset
for help on using the changeset viewer.
