| 1 | ;;;-*- Mode: Lisp; Package: (PPC32 :use CL) -*-
|
|---|
| 2 | ;;;
|
|---|
| 3 | ;;; Copyright 1994-2009 Clozure Associates
|
|---|
| 4 | ;;;
|
|---|
| 5 | ;;; Licensed under the Apache License, Version 2.0 (the "License");
|
|---|
| 6 | ;;; you may not use this file except in compliance with the License.
|
|---|
| 7 | ;;; You may obtain a copy of the License at
|
|---|
| 8 | ;;;
|
|---|
| 9 | ;;; http://www.apache.org/licenses/LICENSE-2.0
|
|---|
| 10 | ;;;
|
|---|
| 11 | ;;; Unless required by applicable law or agreed to in writing, software
|
|---|
| 12 | ;;; distributed under the License is distributed on an "AS IS" BASIS,
|
|---|
| 13 | ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|---|
| 14 | ;;; See the License for the specific language governing permissions and
|
|---|
| 15 | ;;; limitations under the License.
|
|---|
| 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 canonical-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 complex-double-float-vector 30)
|
|---|
| 174 | (define-imm-subtag complex-single-float-vector 29)
|
|---|
| 175 | (define-imm-subtag double-float-vector 28)
|
|---|
| 176 | (define-imm-subtag s16-vector 27)
|
|---|
| 177 | (define-imm-subtag u16-vector 26)
|
|---|
| 178 | (defconstant min-16-bit-ivector-subtag subtag-u16-vector)
|
|---|
| 179 | (defconstant max-16-bit-ivector-subtag subtag-s16-vector)
|
|---|
| 180 |
|
|---|
| 181 | (define-imm-subtag s8-vector 25)
|
|---|
| 182 | (define-imm-subtag u8-vector 24)
|
|---|
| 183 | (defconstant min-8-bit-ivector-subtag subtag-u8-vector)
|
|---|
| 184 | (defconstant max-8-bit-ivector-subtag subtag-s8-vector)
|
|---|
| 185 |
|
|---|
| 186 | (define-imm-subtag simple-base-string 23)
|
|---|
| 187 | (define-imm-subtag fixnum-vector 22)
|
|---|
| 188 | (define-imm-subtag s32-vector 21)
|
|---|
| 189 | (define-imm-subtag u32-vector 20)
|
|---|
| 190 | (define-imm-subtag single-float-vector 19)
|
|---|
| 191 | (defconstant max-32-bit-ivector-subtag subtag-simple-base-string)
|
|---|
| 192 | (defconstant min-cl-ivector-subtag subtag-single-float-vector)
|
|---|
| 193 |
|
|---|
| 194 | (define-node-subtag vectorH 30)
|
|---|
| 195 | (define-node-subtag arrayH 29)
|
|---|
| 196 | (define-node-subtag simple-vector 31) ; Only one such subtag
|
|---|
| 197 | (assert (< subtag-arrayH subtag-vectorH subtag-simple-vector))
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 | ;;; So, we get the remaining subtags (n: (n > max-numeric-subtag) & (n < min-array-subtag))
|
|---|
| 201 | ;;; for various immediate/node object types.
|
|---|
| 202 |
|
|---|
| 203 | (define-imm-subtag macptr 3)
|
|---|
| 204 | (defconstant min-non-numeric-imm-subtag subtag-macptr)
|
|---|
| 205 | (assert (> min-non-numeric-imm-subtag max-numeric-subtag))
|
|---|
| 206 | (define-imm-subtag dead-macptr 4)
|
|---|
| 207 | (define-imm-subtag code-vector 5)
|
|---|
| 208 | (define-imm-subtag creole-object 6)
|
|---|
| 209 | (define-imm-subtag xcode-vector 7) ; code-vector for cross-development
|
|---|
| 210 | (define-imm-subtag complex-single-float 8)
|
|---|
| 211 | (define-imm-subtag complex-double-float 9)
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 | (defconstant max-non-array-imm-subtag (logior (ash 19 ntagbits) fulltag-immheader))
|
|---|
| 215 |
|
|---|
| 216 | (define-node-subtag catch-frame 4)
|
|---|
| 217 | (defconstant min-non-numeric-node-subtag subtag-catch-frame)
|
|---|
| 218 | (assert (> min-non-numeric-node-subtag max-numeric-subtag))
|
|---|
| 219 | (define-node-subtag function 5)
|
|---|
| 220 | (define-node-subtag basic-stream 6)
|
|---|
| 221 | (define-node-subtag symbol 7)
|
|---|
| 222 | (define-node-subtag lock 8)
|
|---|
| 223 | (define-node-subtag hash-vector 9)
|
|---|
| 224 | (define-node-subtag pool 10)
|
|---|
| 225 | (define-node-subtag weak 11)
|
|---|
| 226 | (define-node-subtag package 12)
|
|---|
| 227 | (define-node-subtag slot-vector 13)
|
|---|
| 228 | (define-node-subtag instance 14)
|
|---|
| 229 | (define-node-subtag struct 15)
|
|---|
| 230 | (define-node-subtag istruct 16)
|
|---|
| 231 | (define-node-subtag value-cell 17)
|
|---|
| 232 | (define-node-subtag xfunction 18) ; Function for cross-development
|
|---|
| 233 | (defconstant max-non-array-node-subtag (logior (ash 18 ntagbits) fulltag-nodeheader))
|
|---|
| 234 |
|
|---|
| 235 | (define-subtag character fulltag-imm 9)
|
|---|
| 236 | (define-subtag vsp-protect fulltag-imm 7)
|
|---|
| 237 | (define-subtag slot-unbound fulltag-imm 10)
|
|---|
| 238 | (defconstant slot-unbound-marker subtag-slot-unbound)
|
|---|
| 239 | (define-subtag illegal fulltag-imm 11)
|
|---|
| 240 | (defconstant illegal-marker subtag-illegal)
|
|---|
| 241 | (define-subtag go-tag fulltag-imm 12)
|
|---|
| 242 | (define-subtag block-tag fulltag-imm 24)
|
|---|
| 243 | (define-subtag no-thread-local-binding fulltag-imm 30)
|
|---|
| 244 | (define-subtag unbound fulltag-imm 6)
|
|---|
| 245 | (defconstant unbound-marker subtag-unbound)
|
|---|
| 246 | (defconstant undefined unbound-marker)
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 | (defconstant max-64-bit-constant-index (ash (+ #x7fff ppc32::misc-dfloat-offset) -3))
|
|---|
| 250 | (defconstant max-32-bit-constant-index (ash (+ #x7fff ppc32::misc-data-offset) -2))
|
|---|
| 251 | (defconstant max-16-bit-constant-index (ash (+ #x7fff ppc32::misc-data-offset) -1))
|
|---|
| 252 | (defconstant max-8-bit-constant-index (+ #x7fff ppc32::misc-data-offset))
|
|---|
| 253 | (defconstant max-1-bit-constant-index (ash (+ #x7fff ppc32::misc-data-offset) 5))
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 | ;;; The objects themselves look something like this:
|
|---|
| 257 |
|
|---|
| 258 | ;;; Order of CAR and CDR doesn't seem to matter much - there aren't
|
|---|
| 259 | ;;; too many tricks to be played with predecrement/preincrement addressing.
|
|---|
| 260 | ;;; Keep them in the confusing MCL 3.0 order, to avoid confusion.
|
|---|
| 261 | (define-lisp-object cons tag-list
|
|---|
| 262 | cdr
|
|---|
| 263 | car)
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 | (define-fixedsized-object ratio
|
|---|
| 267 | numer
|
|---|
| 268 | denom)
|
|---|
| 269 |
|
|---|
| 270 | (define-fixedsized-object single-float
|
|---|
| 271 | value)
|
|---|
| 272 |
|
|---|
| 273 | (define-fixedsized-object double-float
|
|---|
| 274 | pad
|
|---|
| 275 | value
|
|---|
| 276 | val-low)
|
|---|
| 277 |
|
|---|
| 278 | (define-fixedsized-object complex-single-float
|
|---|
| 279 | pad
|
|---|
| 280 | realpart
|
|---|
| 281 | imagpart)
|
|---|
| 282 |
|
|---|
| 283 | (define-fixedsized-object complex-double-float
|
|---|
| 284 | pad
|
|---|
| 285 | realpart-high
|
|---|
| 286 | realpart-low
|
|---|
| 287 | imagpart-high
|
|---|
| 288 | imagpart-low)
|
|---|
| 289 |
|
|---|
| 290 | (defconstant complex-double-float.realpart complex-double-float.realpart-high)
|
|---|
| 291 | (defconstant complex-double-float.imagpart complex-double-float.imagpart-high)
|
|---|
| 292 |
|
|---|
| 293 | (define-fixedsized-object complex
|
|---|
| 294 | realpart
|
|---|
| 295 | imagpart
|
|---|
| 296 | )
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 | ;;; There are two kinds of macptr; use the length field of the header if you
|
|---|
| 300 | ;;; need to distinguish between them
|
|---|
| 301 | (define-fixedsized-object macptr
|
|---|
| 302 | address
|
|---|
| 303 | domain
|
|---|
| 304 | type
|
|---|
| 305 | )
|
|---|
| 306 |
|
|---|
| 307 | (define-fixedsized-object xmacptr
|
|---|
| 308 | address
|
|---|
| 309 | domain
|
|---|
| 310 | type
|
|---|
| 311 | flags
|
|---|
| 312 | link
|
|---|
| 313 | )
|
|---|
| 314 |
|
|---|
| 315 | ;;; Catch frames go on the tstack; they point to a minimal lisp-frame
|
|---|
| 316 | ;;; on the cstack. (The catch/unwind-protect PC is on the cstack, where
|
|---|
| 317 | ;;; the GC expects to find it.)
|
|---|
| 318 | (define-fixedsized-object catch-frame
|
|---|
| 319 | catch-tag ; #<unbound> -> unwind-protect, else catch
|
|---|
| 320 | link ; tagged pointer to next older catch frame
|
|---|
| 321 | mvflag ; 0 if single-value, 1 if uwp or multiple-value
|
|---|
| 322 | csp ; pointer to control stack
|
|---|
| 323 | db-link ; value of dynamic-binding link on thread entry.
|
|---|
| 324 | save-save7 ; saved registers
|
|---|
| 325 | save-save6
|
|---|
| 326 | save-save5
|
|---|
| 327 | save-save4
|
|---|
| 328 | save-save3
|
|---|
| 329 | save-save2
|
|---|
| 330 | save-save1
|
|---|
| 331 | save-save0
|
|---|
| 332 | xframe ; exception-frame link
|
|---|
| 333 | nfp
|
|---|
| 334 | )
|
|---|
| 335 |
|
|---|
| 336 | (define-fixedsized-object lock
|
|---|
| 337 | _value ;finalizable pointer to kernel object
|
|---|
| 338 | kind ; '0 = recursive-lock, '1 = rwlock
|
|---|
| 339 | writer ;tcr of owning thread or 0
|
|---|
| 340 | name
|
|---|
| 341 | whostate
|
|---|
| 342 | whostate-2
|
|---|
| 343 | )
|
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 | (define-fixedsized-object symbol
|
|---|
| 348 | pname
|
|---|
| 349 | vcell
|
|---|
| 350 | fcell
|
|---|
| 351 | package-predicate
|
|---|
| 352 | flags
|
|---|
| 353 | plist
|
|---|
| 354 | binding-index
|
|---|
| 355 | )
|
|---|
| 356 |
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 | (defconstant nilsym-offset (+ t-offset symbol.size))
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | (define-fixedsized-object vectorH
|
|---|
| 363 | logsize ; fillpointer if it has one, physsize otherwise
|
|---|
| 364 | physsize ; total size of (possibly displaced) data vector
|
|---|
| 365 | data-vector ; object this header describes
|
|---|
| 366 | displacement ; true displacement or 0
|
|---|
| 367 | flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
|
|---|
| 368 | )
|
|---|
| 369 |
|
|---|
| 370 | (define-lisp-object arrayH fulltag-misc
|
|---|
| 371 | header ; subtag = subtag-arrayH
|
|---|
| 372 | rank ; NEVER 1
|
|---|
| 373 | physsize ; total size of (possibly displaced) data vector
|
|---|
| 374 | data-vector ; object this header describes
|
|---|
| 375 | displacement ; true displacement or 0
|
|---|
| 376 | flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
|
|---|
| 377 | ;; Dimensions follow
|
|---|
| 378 | )
|
|---|
| 379 |
|
|---|
| 380 | (defconstant arrayH.rank-cell 0)
|
|---|
| 381 | (defconstant arrayH.physsize-cell 1)
|
|---|
| 382 | (defconstant arrayH.data-vector-cell 2)
|
|---|
| 383 | (defconstant arrayH.displacement-cell 3)
|
|---|
| 384 | (defconstant arrayH.flags-cell 4)
|
|---|
| 385 | (defconstant arrayH.dim0-cell 5)
|
|---|
| 386 |
|
|---|
| 387 | (defconstant arrayH.flags-cell-bits-byte (byte 8 0))
|
|---|
| 388 | (defconstant arrayH.flags-cell-subtag-byte (byte 8 8))
|
|---|
| 389 |
|
|---|
| 390 |
|
|---|
| 391 | (define-fixedsized-object value-cell
|
|---|
| 392 | value)
|
|---|
| 393 |
|
|---|
| 394 | ;;; The kernel uses these (rather generically named) structures
|
|---|
| 395 | ;;; to keep track of various memory regions it (or the lisp) is
|
|---|
| 396 | ;;; interested in.
|
|---|
| 397 | ;;; The gc-area record definition in "ccl:interfaces;mcl-records.lisp"
|
|---|
| 398 | ;;; matches this.
|
|---|
| 399 |
|
|---|
| 400 | (define-storage-layout area 0
|
|---|
| 401 | pred ; pointer to preceding area in DLL
|
|---|
| 402 | succ ; pointer to next area in DLL
|
|---|
| 403 | low ; low bound on area addresses
|
|---|
| 404 | high ; high bound on area addresses.
|
|---|
| 405 | active ; low limit on stacks, high limit on heaps
|
|---|
| 406 | softlimit ; overflow bound
|
|---|
| 407 | hardlimit ; another one
|
|---|
| 408 | code ; an area-code; see below
|
|---|
| 409 | markbits ; bit vector for GC
|
|---|
| 410 | ndnodes ; "active" size of dynamic area or stack
|
|---|
| 411 | older ; in EGC sense
|
|---|
| 412 | younger ; also for EGC
|
|---|
| 413 | h ; Handle or null pointer
|
|---|
| 414 | softprot ; protected_area structure pointer
|
|---|
| 415 | hardprot ; another one.
|
|---|
| 416 | owner ; fragment (library) which "owns" the area
|
|---|
| 417 | refbits ; bitvector for intergenerational refernces
|
|---|
| 418 | threshold ; for egc
|
|---|
| 419 | gc-count ; generational gc count.
|
|---|
| 420 | static-dnodes ; for honsing, etc.
|
|---|
| 421 | static-used ; bitvector
|
|---|
| 422 | )
|
|---|
| 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 | (defconstant tcr-bias 0)
|
|---|
| 434 |
|
|---|
| 435 | (define-storage-layout tcr (- tcr-bias)
|
|---|
| 436 | prev ; in doubly-linked list
|
|---|
| 437 | next ; in doubly-linked list
|
|---|
| 438 | lisp-fpscr-high
|
|---|
| 439 | lisp-fpscr-low
|
|---|
| 440 | db-link ; special binding chain head
|
|---|
| 441 | catch-top ; top catch frame
|
|---|
| 442 | save-vsp ; VSP when in foreign code
|
|---|
| 443 | save-tsp ; TSP when in foreign code
|
|---|
| 444 | cs-area ; cstack area pointer
|
|---|
| 445 | vs-area ; vstack area pointer
|
|---|
| 446 | ts-area ; tstack area pointer
|
|---|
| 447 | cs-limit ; cstack overflow limit
|
|---|
| 448 | total-bytes-allocated-high
|
|---|
| 449 | total-bytes-allocated-low
|
|---|
| 450 | log2-allocation-quantum ; unboxed
|
|---|
| 451 | interrupt-pending ; fixnum
|
|---|
| 452 | xframe ; exception frame linked list
|
|---|
| 453 | errno-loc ; thread-private, maybe
|
|---|
| 454 | ffi-exception ; fpscr bits from ff-call.
|
|---|
| 455 | osid ; OS thread id
|
|---|
| 456 | valence ; odd when in foreign code
|
|---|
| 457 | foreign-exception-status
|
|---|
| 458 | native-thread-info
|
|---|
| 459 | native-thread-id
|
|---|
| 460 | last-allocptr
|
|---|
| 461 | save-allocptr
|
|---|
| 462 | save-allocbase
|
|---|
| 463 | reset-completion
|
|---|
| 464 | activate
|
|---|
| 465 | suspend-count
|
|---|
| 466 | suspend-context
|
|---|
| 467 | pending-exception-context
|
|---|
| 468 | suspend ; semaphore for suspension notify
|
|---|
| 469 | resume ; sempahore for resumption notify
|
|---|
| 470 | flags ; foreign, being reset, ...
|
|---|
| 471 | gc-context
|
|---|
| 472 | termination-semaphore
|
|---|
| 473 | unwinding
|
|---|
| 474 | tlb-limit
|
|---|
| 475 | tlb-pointer
|
|---|
| 476 | shutdown-count
|
|---|
| 477 | safe-ref-address
|
|---|
| 478 | nfp
|
|---|
| 479 | )
|
|---|
| 480 |
|
|---|
| 481 | (defconstant interrupt-level-binding-index (ash 1 fixnumshift))
|
|---|
| 482 |
|
|---|
| 483 | (define-storage-layout lockptr 0
|
|---|
| 484 | avail
|
|---|
| 485 | owner
|
|---|
| 486 | count
|
|---|
| 487 | signal
|
|---|
| 488 | waiting
|
|---|
| 489 | malloced-ptr
|
|---|
| 490 | spinlock)
|
|---|
| 491 |
|
|---|
| 492 | (define-storage-layout rwlock 0
|
|---|
| 493 | spin
|
|---|
| 494 | state
|
|---|
| 495 | blocked-writers
|
|---|
| 496 | blocked-readers
|
|---|
| 497 | writer
|
|---|
| 498 | reader-signal
|
|---|
| 499 | writer-signal
|
|---|
| 500 | malloced-ptr
|
|---|
| 501 | )
|
|---|
| 502 |
|
|---|
| 503 | ;;; For the eabi port: mark this stack frame as Lisp's (since EABI
|
|---|
| 504 | ;;; foreign frames can be the same size as a lisp frame.)
|
|---|
| 505 |
|
|---|
| 506 |
|
|---|
| 507 | (ppc32::define-storage-layout lisp-frame 0
|
|---|
| 508 | backlink
|
|---|
| 509 | savefn
|
|---|
| 510 | savelr
|
|---|
| 511 | savevsp
|
|---|
| 512 | )
|
|---|
| 513 |
|
|---|
| 514 | (ppc32::define-storage-layout c-frame 0
|
|---|
| 515 | backlink
|
|---|
| 516 | crsave
|
|---|
| 517 | savelr
|
|---|
| 518 | unused-1
|
|---|
| 519 | unused-2
|
|---|
| 520 | savetoc
|
|---|
| 521 | param0
|
|---|
| 522 | param1
|
|---|
| 523 | param2
|
|---|
| 524 | param3
|
|---|
| 525 | param4
|
|---|
| 526 | param5
|
|---|
| 527 | param6
|
|---|
| 528 | param7
|
|---|
| 529 | )
|
|---|
| 530 |
|
|---|
| 531 | (defconstant c-frame.minsize c-frame.size)
|
|---|
| 532 |
|
|---|
| 533 | ;;; .SPeabi-ff-call "shrinks" this frame after loading the GPRs.
|
|---|
| 534 | (ppc32::define-storage-layout eabi-c-frame 0
|
|---|
| 535 | backlink
|
|---|
| 536 | savelr
|
|---|
| 537 | param0
|
|---|
| 538 | param1
|
|---|
| 539 | param2
|
|---|
| 540 | param3
|
|---|
| 541 | param4
|
|---|
| 542 | param5
|
|---|
| 543 | param6
|
|---|
| 544 | param7
|
|---|
| 545 | )
|
|---|
| 546 |
|
|---|
| 547 | (defconstant eabi-c-frame.minsize eabi-c-frame.size)
|
|---|
| 548 |
|
|---|
| 549 | (defmacro define-header (name element-count subtag)
|
|---|
| 550 | `(defconstant ,name (logior (ash ,element-count num-subtag-bits) ,subtag)))
|
|---|
| 551 |
|
|---|
| 552 | (define-header single-float-header single-float.element-count subtag-single-float)
|
|---|
| 553 | (define-header double-float-header double-float.element-count subtag-double-float)
|
|---|
| 554 | (define-header one-digit-bignum-header 1 subtag-bignum)
|
|---|
| 555 | (define-header two-digit-bignum-header 2 subtag-bignum)
|
|---|
| 556 | (define-header three-digit-bignum-header 3 subtag-bignum)
|
|---|
| 557 | (define-header symbol-header symbol.element-count subtag-symbol)
|
|---|
| 558 | (define-header value-cell-header value-cell.element-count subtag-value-cell)
|
|---|
| 559 | (define-header macptr-header macptr.element-count subtag-macptr)
|
|---|
| 560 |
|
|---|
| 561 |
|
|---|
| 562 |
|
|---|
| 563 | )
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 | (defun %kernel-global (sym)
|
|---|
| 569 | (let* ((pos (position sym ppc::*ppc-kernel-globals* :test #'string=)))
|
|---|
| 570 | (if pos
|
|---|
| 571 | (- (+ fulltag-nil (* (1+ pos) 4)))
|
|---|
| 572 | (error "Unknown kernel global : ~s ." sym))))
|
|---|
| 573 |
|
|---|
| 574 | (defmacro kernel-global (sym)
|
|---|
| 575 | (let* ((pos (position sym ppc::*ppc-kernel-globals* :test #'string=)))
|
|---|
| 576 | (if pos
|
|---|
| 577 | (- (+ fulltag-nil (* (1+ pos) 4)))
|
|---|
| 578 | (error "Unknown kernel global : ~s ." sym))))
|
|---|
| 579 |
|
|---|
| 580 | ;;; The kernel imports things that are defined in various other
|
|---|
| 581 | ;;; libraries for us. The objects in question are generally
|
|---|
| 582 | ;;; fixnum-tagged; the entries in the "kernel-imports" vector are 4
|
|---|
| 583 | ;;; bytes apart.
|
|---|
| 584 | (ccl::defenum (:prefix "KERNEL-IMPORT-" :start 0 :step 4)
|
|---|
| 585 | fd-setsize-bytes
|
|---|
| 586 | do-fd-set
|
|---|
| 587 | do-fd-clr
|
|---|
| 588 | do-fd-is-set
|
|---|
| 589 | do-fd-zero
|
|---|
| 590 | MakeDataExecutable
|
|---|
| 591 | GetSharedLibrary
|
|---|
| 592 | FindSymbol
|
|---|
| 593 | malloc
|
|---|
| 594 | free
|
|---|
| 595 | wait-for-signal
|
|---|
| 596 | tcr-frame-ptr
|
|---|
| 597 | register-xmacptr-dispose-function
|
|---|
| 598 | open-debug-output
|
|---|
| 599 | get-r-debug
|
|---|
| 600 | restore-soft-stack-limit
|
|---|
| 601 | egc-control
|
|---|
| 602 | lisp-bug
|
|---|
| 603 | NewThread
|
|---|
| 604 | YieldToThread
|
|---|
| 605 | DisposeThread
|
|---|
| 606 | ThreadCurrentStackSpace
|
|---|
| 607 | usage-exit
|
|---|
| 608 | save-fp-context
|
|---|
| 609 | restore-fp-context
|
|---|
| 610 | put-altivec-registers
|
|---|
| 611 | get-altivec-registers
|
|---|
| 612 | new-semaphore
|
|---|
| 613 | wait-on-semaphore
|
|---|
| 614 | signal-semaphore
|
|---|
| 615 | destroy-semaphore
|
|---|
| 616 | new-recursive-lock
|
|---|
| 617 | lock-recursive-lock
|
|---|
| 618 | unlock-recursive-lock
|
|---|
| 619 | destroy-recursive-lock
|
|---|
| 620 | suspend-other-threads
|
|---|
| 621 | resume-other-threads
|
|---|
| 622 | suspend-tcr
|
|---|
| 623 | resume-tcr
|
|---|
| 624 | rwlock-new
|
|---|
| 625 | rwlock-destroy
|
|---|
| 626 | rwlock-rlock
|
|---|
| 627 | rwlock-wlock
|
|---|
| 628 | rwlock-unlock
|
|---|
| 629 | recursive-lock-trylock
|
|---|
| 630 | foreign-name-and-offset
|
|---|
| 631 | lisp-read
|
|---|
| 632 | lisp-write
|
|---|
| 633 | lisp-open
|
|---|
| 634 | lisp-fchmod
|
|---|
| 635 | lisp-lseek
|
|---|
| 636 | lisp-close
|
|---|
| 637 | lisp-ftruncate
|
|---|
| 638 | lisp-stat
|
|---|
| 639 | lisp-fstat
|
|---|
| 640 | lisp-futex
|
|---|
| 641 | lisp-opendir
|
|---|
| 642 | lisp-readdir
|
|---|
| 643 | lisp-closedir
|
|---|
| 644 | lisp-pipe
|
|---|
| 645 | lisp-gettimeofday
|
|---|
| 646 | lisp-sigexit
|
|---|
| 647 | jvm-init
|
|---|
| 648 | )
|
|---|
| 649 |
|
|---|
| 650 | (defmacro nrs-offset (name)
|
|---|
| 651 | (let* ((pos (position name ppc::*ppc-nilreg-relative-symbols* :test #'eq)))
|
|---|
| 652 | (if pos (+ t-offset (* pos symbol.size)))))
|
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 | (defconstant reservation-discharge #x2004)
|
|---|
| 656 |
|
|---|
| 657 |
|
|---|
| 658 |
|
|---|
| 659 | (defmacro with-stack-short-floats (specs &body body)
|
|---|
| 660 | (ccl::collect ((binds)
|
|---|
| 661 | (inits)
|
|---|
| 662 | (names))
|
|---|
| 663 | (dolist (spec specs)
|
|---|
| 664 | (let ((name (first spec)))
|
|---|
| 665 | (binds `(,name (ccl::%make-sfloat)))
|
|---|
| 666 | (names name)
|
|---|
| 667 | (let ((init (second spec)))
|
|---|
| 668 | (when init
|
|---|
| 669 | (inits `(ccl::%short-float ,init ,name))))))
|
|---|
| 670 | `(let* ,(binds)
|
|---|
| 671 | (declare (dynamic-extent ,@(names))
|
|---|
| 672 | (short-float ,@(names)))
|
|---|
| 673 | ,@(inits)
|
|---|
| 674 | ,@body)))
|
|---|
| 675 |
|
|---|
| 676 | (defparameter *ppc32-target-uvector-subtags*
|
|---|
| 677 | `((:bignum . ,subtag-bignum)
|
|---|
| 678 | (:ratio . ,subtag-ratio)
|
|---|
| 679 | (:single-float . ,subtag-single-float)
|
|---|
| 680 | (:double-float . ,subtag-double-float)
|
|---|
| 681 | (:complex . ,subtag-complex )
|
|---|
| 682 | (:complex-single-float . ,subtag-complex-single-float)
|
|---|
| 683 | (:complex-double-float . ,subtag-complex-double-float)
|
|---|
| 684 | (:symbol . ,subtag-symbol)
|
|---|
| 685 | (:function . ,subtag-function )
|
|---|
| 686 | (:code-vector . ,subtag-code-vector)
|
|---|
| 687 | (:xcode-vector . ,subtag-xcode-vector)
|
|---|
| 688 | (:macptr . ,subtag-macptr )
|
|---|
| 689 | (:catch-frame . ,subtag-catch-frame)
|
|---|
| 690 | (:struct . ,subtag-struct )
|
|---|
| 691 | (:istruct . ,subtag-istruct )
|
|---|
| 692 | (:pool . ,subtag-pool )
|
|---|
| 693 | (:population . ,subtag-weak )
|
|---|
| 694 | (:hash-vector . ,subtag-hash-vector )
|
|---|
| 695 | (:package . ,subtag-package )
|
|---|
| 696 | (:value-cell . ,subtag-value-cell)
|
|---|
| 697 | (:instance . ,subtag-instance )
|
|---|
| 698 | (:lock . ,subtag-lock )
|
|---|
| 699 | (:slot-vector . ,subtag-slot-vector)
|
|---|
| 700 | (:basic-stream . ,subtag-basic-stream)
|
|---|
| 701 | (:simple-string . ,subtag-simple-base-string )
|
|---|
| 702 | (:bit-vector . ,subtag-bit-vector )
|
|---|
| 703 | (:signed-8-bit-vector . ,subtag-s8-vector )
|
|---|
| 704 | (:unsigned-8-bit-vector . ,subtag-u8-vector )
|
|---|
| 705 | (:signed-16-bit-vector . ,subtag-s16-vector )
|
|---|
| 706 | (:unsigned-16-bit-vector . ,subtag-u16-vector )
|
|---|
| 707 | (:signed-32-bit-vector . ,subtag-s32-vector )
|
|---|
| 708 | (:fixnum-vector . ,subtag-fixnum-vector)
|
|---|
| 709 | (:unsigned-32-bit-vector . ,subtag-u32-vector )
|
|---|
| 710 | (:single-float-vector . ,subtag-single-float-vector)
|
|---|
| 711 | (:double-float-vector . ,subtag-double-float-vector )
|
|---|
| 712 | (:complex-single-float-vector . ,subtag-complex-single-float-vector)
|
|---|
| 713 | (:complex-double-float-vector . ,subtag-complex-double-float-vector)
|
|---|
| 714 | (:simple-vector . ,subtag-simple-vector )
|
|---|
| 715 | (:vector-header . ,subtag-vectorH)
|
|---|
| 716 | (:array-header . ,subtag-arrayH)
|
|---|
| 717 | (:min-cl-ivector-subtag ,.min-cl-ivector-subtag)))
|
|---|
| 718 |
|
|---|
| 719 |
|
|---|
| 720 | ;;; This should return NIL unless it's sure of how the indicated
|
|---|
| 721 | ;;; type would be represented (in particular, it should return
|
|---|
| 722 | ;;; NIL if the element type is unknown or unspecified at compile-time.
|
|---|
| 723 | (defun ppc32-array-type-name-from-ctype (ctype)
|
|---|
| 724 | (when (typep ctype 'ccl::array-ctype)
|
|---|
| 725 | (let* ((element-type (ccl::array-ctype-element-type ctype)))
|
|---|
| 726 | (typecase element-type
|
|---|
| 727 | (ccl::class-ctype
|
|---|
| 728 | (let* ((class (ccl::class-ctype-class element-type)))
|
|---|
| 729 | (if (or (eq class ccl::*character-class*)
|
|---|
| 730 | (eq class ccl::*base-char-class*)
|
|---|
| 731 | (eq class ccl::*standard-char-class*))
|
|---|
| 732 | :simple-string
|
|---|
| 733 | :simple-vector)))
|
|---|
| 734 | (ccl::numeric-ctype
|
|---|
| 735 | (if (eq (ccl::numeric-ctype-complexp element-type) :complex)
|
|---|
| 736 | (case (ccl::numeric-ctype-format element-type)
|
|---|
| 737 | (single-float :complex-single-float-vector)
|
|---|
| 738 | (double-float :complex-double-float-vector)
|
|---|
| 739 | (t :simple-vector))
|
|---|
| 740 | (case (ccl::numeric-ctype-class element-type)
|
|---|
| 741 | (integer
|
|---|
| 742 | (let* ((low (ccl::numeric-ctype-low element-type))
|
|---|
| 743 | (high (ccl::numeric-ctype-high element-type)))
|
|---|
| 744 | (cond ((or (null low) (null high)) :simple-vector)
|
|---|
| 745 | ((and (>= low 0) (<= high 1) :bit-vector))
|
|---|
| 746 | ((and (>= low 0) (<= high 255)) :unsigned-8-bit-vector)
|
|---|
| 747 | ((and (>= low 0) (<= high 65535)) :unsigned-16-bit-vector)
|
|---|
| 748 | ((and (>= low 0) (<= high #xffffffff) :unsigned-32-bit-vector))
|
|---|
| 749 | ((and (>= low -128) (<= high 127)) :signed-8-bit-vector)
|
|---|
| 750 | ((and (>= low -32768) (<= high 32767) :signed-16-bit-vector))
|
|---|
| 751 | ((and (>= low target-most-negative-fixnum)
|
|---|
| 752 | (<= high target-most-positive-fixnum))
|
|---|
| 753 | :fixnum-vector)
|
|---|
| 754 | ((and (>= low (ash -1 31)) (<= high (1- (ash 1 31))))
|
|---|
| 755 | :signed-32-bit-vector)
|
|---|
| 756 | (t :simple-vector))))
|
|---|
| 757 | (float
|
|---|
| 758 | (case (ccl::numeric-ctype-format element-type)
|
|---|
| 759 | ((double-float long-float) :double-float-vector)
|
|---|
| 760 | ((single-float short-float) :single-float-vector)
|
|---|
| 761 | (t :simple-vector)))
|
|---|
| 762 | (t :simple-vector))))
|
|---|
| 763 | (ccl::unknown-ctype)
|
|---|
| 764 | (ccl::named-ctype
|
|---|
| 765 | (if (eq element-type ccl::*universal-type*)
|
|---|
| 766 | :simple-vector))
|
|---|
| 767 | (t nil)))))
|
|---|
| 768 |
|
|---|
| 769 | (defun ppc32-misc-byte-count (subtag element-count)
|
|---|
| 770 | (declare (fixnum subtag))
|
|---|
| 771 | (if (or (= fulltag-nodeheader (logand subtag fulltagmask))
|
|---|
| 772 | (<= subtag max-32-bit-ivector-subtag))
|
|---|
| 773 | (ash element-count 2)
|
|---|
| 774 | (if (<= subtag max-8-bit-ivector-subtag)
|
|---|
| 775 | element-count
|
|---|
| 776 | (if (<= subtag max-16-bit-ivector-subtag)
|
|---|
| 777 | (ash element-count 1)
|
|---|
| 778 | (if (= subtag subtag-bit-vector)
|
|---|
| 779 | (ash (+ element-count 7) -3)
|
|---|
| 780 | (if (= subtag subtag-complex-double-float-vector)
|
|---|
| 781 | (+ 4 (ash element-count 4))
|
|---|
| 782 | (+ 4 (ash element-count 3))))))))
|
|---|
| 783 |
|
|---|
| 784 | (defparameter *ppc32-target-arch*
|
|---|
| 785 | (arch::make-target-arch :name :ppc32
|
|---|
| 786 | :lisp-node-size 4
|
|---|
| 787 | :nil-value canonical-nil-value
|
|---|
| 788 | :fixnum-shift fixnumshift
|
|---|
| 789 | :most-positive-fixnum (1- (ash 1 (1- (- 32 fixnumshift))))
|
|---|
| 790 | :most-negative-fixnum (- (ash 1 (1- (- 32 fixnumshift))))
|
|---|
| 791 | :misc-data-offset misc-data-offset
|
|---|
| 792 | :misc-dfloat-offset misc-dfloat-offset
|
|---|
| 793 | :nbits-in-word 32
|
|---|
| 794 | :ntagbits 3
|
|---|
| 795 | :nlisptagbits 2
|
|---|
| 796 | :uvector-subtags *ppc32-target-uvector-subtags*
|
|---|
| 797 | :max-64-bit-constant-index max-64-bit-constant-index
|
|---|
| 798 | :max-32-bit-constant-index max-32-bit-constant-index
|
|---|
| 799 | :max-16-bit-constant-index max-16-bit-constant-index
|
|---|
| 800 | :max-8-bit-constant-index max-8-bit-constant-index
|
|---|
| 801 | :max-1-bit-constant-index max-1-bit-constant-index
|
|---|
| 802 | :word-shift 2
|
|---|
| 803 | :code-vector-prefix ()
|
|---|
| 804 | :gvector-types '(:ratio :complex :symbol :function
|
|---|
| 805 | :catch-frame :struct :istruct
|
|---|
| 806 | :pool :population :hash-vector
|
|---|
| 807 | :package :value-cell :instance
|
|---|
| 808 | :lock :slot-vector
|
|---|
| 809 | :simple-vector)
|
|---|
| 810 | :1-bit-ivector-types '(:bit-vector)
|
|---|
| 811 | :8-bit-ivector-types '(:signed-8-bit-vector
|
|---|
| 812 | :unsigned-8-bit-vector)
|
|---|
| 813 | :16-bit-ivector-types '(:signed-16-bit-vector
|
|---|
| 814 | :unsigned-16-bit-vector)
|
|---|
| 815 | :32-bit-ivector-types '(:signed-32-bit-vector
|
|---|
| 816 | :unsigned-32-bit-vector
|
|---|
| 817 | :single-float-vector
|
|---|
| 818 | :fixnum-vector
|
|---|
| 819 | :single-float
|
|---|
| 820 | :double-float
|
|---|
| 821 | :bignum
|
|---|
| 822 | :simple-string)
|
|---|
| 823 | :64-bit-ivector-types '(:double-float-vector
|
|---|
| 824 | :complex-single-float-vector)
|
|---|
| 825 | :array-type-name-from-ctype-function
|
|---|
| 826 | #'ppc32-array-type-name-from-ctype
|
|---|
| 827 | :package-name "PPC32"
|
|---|
| 828 | :t-offset t-offset
|
|---|
| 829 | :array-data-size-function #'ppc32-misc-byte-count
|
|---|
| 830 | :fpr-mask-function 'ppc::fpr-mask
|
|---|
| 831 | :subprims-base ppc::*ppc-subprims-base*
|
|---|
| 832 | :subprims-shift ppc::*ppc-subprims-shift*
|
|---|
| 833 | :subprims-table ppc::*ppc-subprims*
|
|---|
| 834 | :primitive->subprims `(((0 . 23) . ,(ccl::%subprim-name->offset '.SPbuiltin-plus ppc::*ppc-subprims*)))
|
|---|
| 835 | :unbound-marker-value unbound-marker
|
|---|
| 836 | :slot-unbound-marker-value slot-unbound-marker
|
|---|
| 837 | :fixnum-tag tag-fixnum
|
|---|
| 838 | :single-float-tag subtag-single-float
|
|---|
| 839 | :single-float-tag-is-subtag t
|
|---|
| 840 | :double-float-tag subtag-double-float
|
|---|
| 841 | :cons-tag fulltag-cons
|
|---|
| 842 | :null-tag fulltag-nil
|
|---|
| 843 | :symbol-tag subtag-symbol
|
|---|
| 844 | :symbol-tag-is-subtag t
|
|---|
| 845 | :function-tag subtag-function
|
|---|
| 846 | :function-tag-is-subtag t
|
|---|
| 847 | :big-endian t
|
|---|
| 848 | :misc-subtag-offset misc-subtag-offset
|
|---|
| 849 | :car-offset cons.car
|
|---|
| 850 | :cdr-offset cons.cdr
|
|---|
| 851 | :subtag-char subtag-character
|
|---|
| 852 | :charcode-shift charcode-shift
|
|---|
| 853 | :fulltagmask fulltagmask
|
|---|
| 854 | :fulltag-misc fulltag-misc
|
|---|
| 855 | :char-code-limit #x110000
|
|---|
| 856 | ))
|
|---|
| 857 |
|
|---|
| 858 | ;;; arch macros
|
|---|
| 859 | (defmacro defppc32archmacro (name lambda-list &body body)
|
|---|
| 860 | `(arch::defarchmacro :ppc32 ,name ,lambda-list ,@body))
|
|---|
| 861 |
|
|---|
| 862 | (defppc32archmacro ccl::%make-sfloat ()
|
|---|
| 863 | `(ccl::%alloc-misc ppc32::single-float.element-count ppc32::subtag-single-float))
|
|---|
| 864 |
|
|---|
| 865 | (defppc32archmacro ccl::%make-dfloat ()
|
|---|
| 866 | `(ccl::%alloc-misc ppc32::double-float.element-count ppc32::subtag-double-float))
|
|---|
| 867 |
|
|---|
| 868 | (defppc32archmacro ccl::%numerator (x)
|
|---|
| 869 | `(ccl::%svref ,x ppc32::ratio.numer-cell))
|
|---|
| 870 |
|
|---|
| 871 | (defppc32archmacro ccl::%denominator (x)
|
|---|
| 872 | `(ccl::%svref ,x ppc32::ratio.denom-cell))
|
|---|
| 873 |
|
|---|
| 874 | (defppc32archmacro ccl::%realpart (x)
|
|---|
| 875 | (let* ((thing (gensym)))
|
|---|
| 876 | `(let* ((,thing ,x))
|
|---|
| 877 | (case (ccl::typecode ,thing)
|
|---|
| 878 | (#.ppc32::subtag-complex-single-float (ccl::%complex-single-float-realpart ,thing))
|
|---|
| 879 | (#.ppc32::subtag-complex-double-float (ccl::%complex-double-float-realpart ,thing))
|
|---|
| 880 | (t (ccl::%svref ,thing ppc32::complex.realpart-cell))))))
|
|---|
| 881 |
|
|---|
| 882 | (defppc32archmacro ccl::%imagpart (x)
|
|---|
| 883 | (let* ((thing (gensym)))
|
|---|
| 884 | `(let* ((,thing ,x))
|
|---|
| 885 | (case (ccl::typecode ,thing)
|
|---|
| 886 | (#.ppc32::subtag-complex-single-float (ccl::%complex-single-float-imagpart ,thing))
|
|---|
| 887 | (#.ppc32::subtag-complex-double-float (ccl::%complex-double-float-imagpart ,thing))
|
|---|
| 888 | (t (ccl::%svref ,thing ppc32::complex.realpart-cell))))))
|
|---|
| 889 |
|
|---|
| 890 | ;;;
|
|---|
| 891 | (defppc32archmacro ccl::%get-single-float-from-double-ptr (ptr offset)
|
|---|
| 892 | `(ccl::%double-float->short-float (ccl::%get-double-float ,ptr ,offset)
|
|---|
| 893 | (ccl::%alloc-misc 1 ppc32::subtag-single-float)))
|
|---|
| 894 |
|
|---|
| 895 | (defppc32archmacro ccl::codevec-header-p (word)
|
|---|
| 896 | `(eql ppc32::subtag-code-vector
|
|---|
| 897 | (logand ,word ppc32::subtag-mask)))
|
|---|
| 898 |
|
|---|
| 899 | (defppc32archmacro ccl::immediate-p-macro (thing)
|
|---|
| 900 | (let* ((tag (gensym)))
|
|---|
| 901 | `(let* ((,tag (ccl::lisptag ,thing)))
|
|---|
| 902 | (declare (fixnum ,tag))
|
|---|
| 903 | (or (= ,tag ppc32::tag-fixnum)
|
|---|
| 904 | (= ,tag ppc32::tag-imm)))))
|
|---|
| 905 |
|
|---|
| 906 | (defppc32archmacro ccl::hashed-by-identity (thing)
|
|---|
| 907 | (let* ((typecode (gensym)))
|
|---|
| 908 | `(let* ((,typecode (ccl::typecode ,thing)))
|
|---|
| 909 | (declare (fixnum ,typecode))
|
|---|
| 910 | (or
|
|---|
| 911 | (= ,typecode ppc32::tag-fixnum)
|
|---|
| 912 | (= ,typecode ppc32::tag-imm)
|
|---|
| 913 | (= ,typecode ppc32::subtag-symbol)
|
|---|
| 914 | (= ,typecode ppc32::subtag-instance)))))
|
|---|
| 915 |
|
|---|
| 916 | ;;;
|
|---|
| 917 | (defppc32archmacro ccl::%get-kernel-global (name)
|
|---|
| 918 | `(ccl::%fixnum-ref 0 (+ ,(ccl::target-nil-value)
|
|---|
| 919 | ,(%kernel-global
|
|---|
| 920 | (if (ccl::quoted-form-p name)
|
|---|
| 921 | (cadr name)
|
|---|
| 922 | name)))))
|
|---|
| 923 |
|
|---|
| 924 | (defppc32archmacro ccl::%get-kernel-global-ptr (name dest)
|
|---|
| 925 | `(ccl::%setf-macptr
|
|---|
| 926 | ,dest
|
|---|
| 927 | (ccl::%fixnum-ref-macptr 0 (+ ,(ccl::target-nil-value)
|
|---|
| 928 | ,(%kernel-global
|
|---|
| 929 | (if (ccl::quoted-form-p name)
|
|---|
| 930 | (cadr name)
|
|---|
| 931 | name))))))
|
|---|
| 932 |
|
|---|
| 933 | (defppc32archmacro ccl::%target-kernel-global (name)
|
|---|
| 934 | `(ppc32::%kernel-global ,name))
|
|---|
| 935 |
|
|---|
| 936 | (defppc32archmacro ccl::lfun-vector (fn)
|
|---|
| 937 | fn)
|
|---|
| 938 |
|
|---|
| 939 | (defppc32archmacro ccl::lfun-vector-lfun (lfv)
|
|---|
| 940 | lfv)
|
|---|
| 941 |
|
|---|
| 942 | (defppc32archmacro ccl::area-code ()
|
|---|
| 943 | area.code)
|
|---|
| 944 |
|
|---|
| 945 | (defppc32archmacro ccl::area-succ ()
|
|---|
| 946 | area.succ)
|
|---|
| 947 |
|
|---|
| 948 | (defppc32archmacro ccl::nth-immediate (f i)
|
|---|
| 949 | `(ccl::%svref ,f ,i))
|
|---|
| 950 |
|
|---|
| 951 | (defppc32archmacro ccl::set-nth-immediate (f i new)
|
|---|
| 952 | `(setf (ccl::%svref ,f ,i) ,new))
|
|---|
| 953 |
|
|---|
| 954 | (defppc32archmacro ccl::symptr->symvector (s)
|
|---|
| 955 | s)
|
|---|
| 956 |
|
|---|
| 957 | (defppc32archmacro ccl::symvector->symptr (s)
|
|---|
| 958 | s)
|
|---|
| 959 |
|
|---|
| 960 | (defppc32archmacro ccl::function-to-function-vector (f)
|
|---|
| 961 | f)
|
|---|
| 962 |
|
|---|
| 963 | (defppc32archmacro ccl::function-vector-to-function (v)
|
|---|
| 964 | v)
|
|---|
| 965 |
|
|---|
| 966 | (defppc32archmacro ccl::with-ffcall-results ((buf) &body body)
|
|---|
| 967 | (let* ((size (+ (* 8 4) (* 31 8))))
|
|---|
| 968 | `(%stack-block ((,buf ,size))
|
|---|
| 969 | ,@body)))
|
|---|
| 970 |
|
|---|
| 971 | (defconstant arg-check-trap-pc-limit 8)
|
|---|
| 972 | ;;
|
|---|
| 973 | (defconstant fasl-version #x60)
|
|---|
| 974 | (defconstant fasl-max-version #x60)
|
|---|
| 975 | (defconstant fasl-min-version #x60)
|
|---|
| 976 | (defparameter *image-abi-version* 1040)
|
|---|
| 977 |
|
|---|
| 978 | (provide "PPC32-ARCH")
|
|---|