source: branches/acode-rewrite/source/compiler/X86/X8632/x8632-arch.lisp

Last change on this file was 16054, checked in by Gary Byers, 11 years ago

Whew. X86 catches up to ARM.

File size: 45.9 KB
RevLine 
[6986]1;;;-*- Mode: Lisp; Package: (X8632 :use CL) -*-
2
[13067]3;;; Copyright 2009 Clozure Associates
4;;; This file is part of Clozure CL.
5;;;
6;;; Clozure CL is licensed under the terms of the Lisp Lesser GNU
7;;; Public License , known as the LLGPL and distributed with Clozure
8;;; CL as the file "LICENSE". The LLGPL consists of a preamble and
9;;; the LGPL, which is distributed with Clozure CL as the file "LGPL".
10;;; Where these conflict, the preamble takes precedence.
11;;;
12;;; Clozure CL 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
[6986]17;;; This stuff has to match lisp-kernel/x86-constants32.[hs]
18
19(defpackage "X8632"
20 (:use "CL")
21 #+x8632-target
22 (:nicknames "TARGET"))
23
24(in-package "X8632")
25
26(eval-when (:compile-toplevel :load-toplevel :execute)
27 (require "X86-ARCH")
28 (require "X86-LAP")
29
30(defparameter *x8632-symbolic-register-names*
31 (make-hash-table :test #'equal)
32 "For the disassembler, mostly.")
33
34;;; Define integer constants which map to indices in the
35;;; X86::*X8632-REGISTER-ENTRIES* array.
36(ccl::defenum ()
37 ;; 32-bit registers
38 eax
39 ecx
40 edx
41 ebx
42 esp
43 ebp
44 esi
45 edi
46 ;; 16-bit-registers
47 ax
48 cx
49 dx
50 bx
51 sp
52 bp
53 si
54 di
55 ;; 8-bit registers
56 al
57 cl
58 dl
59 bl
[7075]60 ah
61 ch
62 dh
63 bh
[6986]64 ;; xmm registers
65 xmm0
66 xmm1
67 xmm2
68 xmm3
69 xmm4
70 xmm5
71 xmm6
72 xmm7
73 ;; MMX registers
74 mm0
75 mm1
76 mm2
77 mm3
78 mm4
79 mm5
80 mm6
81 mm7
82 ;; x87 FP regs
83 st[0]
84 st[1]
85 st[2]
86 st[3]
87 st[4]
88 st[5]
89 st[6]
90 st[7]
91 ;; Segment registers
92 cs
93 ds
94 ss
95 es
96 fs
97 gs
98 )
99
100(defmacro defx86reg (alias known)
101 (let* ((known-entry (gensym)))
[7042]102 `(let* ((,known-entry (gethash ,(string known) x86::*x8632-registers*)))
[6986]103 (unless ,known-entry
104 (error "register ~a not defined" ',known))
[7037]105 (setf (gethash ,(string alias) x86::*x8632-registers*) ,known-entry)
[6986]106 (unless (gethash ,(string-downcase (string known)) *x8632-symbolic-register-names*)
107 (setf (gethash ,(string-downcase (string known)) *x8632-symbolic-register-names*)
108 (string-downcase ,(string alias))))
109 (defconstant ,alias ,known))))
110
111;;; The limited number of registers that we have may make it
112;;; impossible to statically partition the register file into
113;;; immediate and tagged sets.
114;;;
115;;; As a baseline, we will use the scheme defined below. This
116;;; partitioning will be in effect any time a function is entered
117;;; (and therefore at the time of a function call).
118;;;
119;;; This partitioning can be altered by setting or clearing bits in
120;;; thread-private memory which indicate whether a register is an
121;;; immmediate or a node. The GC will look at these flag bits to
122;;; decide how to treat the registers.
123;;;
124;;; "Lispy" register names might be therefore be confusing at times.
125;;;
126
127(defx86reg imm0 eax)
128(defx86reg imm0.w ax)
129(defx86reg imm0.b al)
[9374]130(defx86reg imm0.bh ah)
[6986]131
132(defx86reg temp0 ecx)
133(defx86reg temp0.w cx)
134(defx86reg temp0.b cl)
[9374]135(defx86reg temp0.bh ch)
[6986]136(defx86reg shift cl)
137
138(defx86reg temp1 edx)
139(defx86reg temp1.w dx)
140(defx86reg temp1.b dl)
[9374]141(defx86reg temp1.bh dh)
[8426]142(defx86reg nargs edx)
[6986]143
[7115]144(defx86reg arg_z ebx)
145(defx86reg arg_z.w bx)
146(defx86reg arg_z.b bl)
[9374]147(defx86reg arg_z.bh bh)
[6986]148
[7115]149(defx86reg arg_y esi)
150(defx86reg arg_y.w si)
[6986]151
[7115]152(defx86reg fn edi)
[6986]153
[7262]154;; Callee-saved non-volatile registers are probably a non-starter on
155;; IA-32.
[6986]156
157;;; Use xmm regs for floating-point. (They can also hold integer values.)
158(defx86reg fp0 xmm0)
159(defx86reg fp1 xmm1)
160(defx86reg fp2 xmm2)
161(defx86reg fp3 xmm3)
162(defx86reg fp4 xmm4)
163(defx86reg fp5 xmm5)
164(defx86reg fp6 xmm6)
165(defx86reg fp7 xmm7)
166
[7286]167(defx86reg fpzero fp7)
168
[6986]169;;; The 8 MMX registers overlap the x87 FPU.
170;;; (so when/if we use the x87 FPU, we need to be careful with this)
171(defx86reg stack-temp mm7)
172
173(defx86reg fname temp0)
174
[7115]175(defx86reg allocptr temp0)
176
[7426]177(defx86reg ra0 temp0)
[7262]178
[7286]179;;; We rely one at least one of %ra0/%fn pointing to the current function
180;;; (or to a TRA that references the function) at all times. When we
181;;; tail call something, we want %RA0 to point to our caller's TRA and
182;;; %FN to point to the new function. Unless we go out of line to
183;;; do tail calls, we need some register not involved in the calling
184;;; sequence to hold the current function, since it might get GCed otherwise.
185;;; (The odds of this happening are low, but non-zero.)
186;;; xxx
187(defx86reg xfn temp1)
188
[7962]189(defx86reg next-method-context temp0)
190
[6986]191;;; This follows the ppc32 scheme pretty closely.
192
193(defconstant nbits-in-word 32)
194(defconstant nbits-in-byte 8)
195(defconstant ntagbits 3)
196(defconstant nlisptagbits 2)
197(defconstant nfixnumtagbits 2)
198(defconstant num-subtag-bits 8)
[8357]199(defconstant subtagmask 255)
[6986]200(defconstant fixnumshift 2)
201(defconstant fixnum-shift 2)
202(defconstant fulltagmask 7)
203(defconstant tagmask 3)
204(defconstant fixnummask 3)
205(defconstant ncharcodebits 8)
206(defconstant charcode-shift 8)
207(defconstant word-shift 2)
208(defconstant word-size-in-bytes 4)
209(defconstant node-size word-size-in-bytes)
210(defconstant dnode-size 8)
211(defconstant dnode-align-bits 3)
212(defconstant dnode-shift dnode-align-bits)
213(defconstant bitmap-shift 5)
214
215(defconstant fixnumone (ash 1 fixnumshift))
216(defconstant fixnum-one fixnumone)
217(defconstant fixnum1 fixnumone)
218
219(defconstant target-most-negative-fixnum (ash -1 (1- (- nbits-in-word nfixnumtagbits))))
220(defconstant target-most-positive-fixnum (1- (ash 1 (1- (- nbits-in-word nfixnumtagbits)))))
221
[8357]222;;; bits correspond to reg encoding used in instructions
223;;; 7 6 5 4 3 2 1 0
224;;; edi esi ebp esp ebx edx ecx eax
225
226(defconstant default-node-regs-mask #b11001110)
227
[6986]228;;; 2-bit "lisptag" values
229(defconstant tag-fixnum 0)
230(defconstant tag-list 1) ;a misnomer now
231(defconstant tag-misc 2)
232(defconstant tag-imm 3)
233
234;;; 3-bit "fulltag" values
235(defconstant fulltag-even-fixnum 0)
236(defconstant fulltag-cons 1)
237(defconstant fulltag-nodeheader 2)
238(defconstant fulltag-imm 3)
239(defconstant fulltag-odd-fixnum 4)
240(defconstant fulltag-tra 5) ;was for nil on PPC32
241(defconstant fulltag-misc 6)
242(defconstant fulltag-immheader 7)
243
244(defmacro define-subtag (name tag subtag)
245 `(defconstant ,(ccl::form-symbol "SUBTAG-" name) (logior ,tag (ash ,subtag ntagbits))))
246
247(defmacro define-imm-subtag (name subtag)
248 `(define-subtag ,name fulltag-immheader ,subtag))
249
250(defmacro define-node-subtag (name subtag)
251 `(define-subtag ,name fulltag-nodeheader ,subtag))
252
253;;; The order in which various header values are defined is
254;;; significant in several ways:
255;;; 1) Numeric subtags precede non-numeric ones; there are further
256;;; orderings among numeric subtags.
257;;; 2) All subtags which denote CL arrays are preceded by those that
258;;; don't, with a further ordering which requires that
259;;; (< header-arrayH header-vectorH ,@all-other-CL-vector-types)
260;;; 3) The element-size of ivectors is determined by the ordering of
261;;; ivector subtags.
262;;; 4) All subtags are >= fulltag-immheader.
263
264;;; Numeric subtags
265(define-imm-subtag bignum 0)
266(defconstant min-numeric-subtag subtag-bignum)
267(define-node-subtag ratio 1)
268(defconstant max-rational-subtag subtag-ratio)
269
270(define-imm-subtag single-float 1)
271(define-imm-subtag double-float 2)
272(defconstant min-float-subtag subtag-single-float)
273(defconstant max-float-subtag subtag-double-float)
274(defconstant max-real-subtag subtag-double-float)
275
276(define-node-subtag complex 3)
277(defconstant max-numeric-subtag subtag-complex)
278
279;;; CL array types. There are more immediate types than node types;
280;;; all CL array subtags must be > than all non-CL-array subtags. So
281;;; we start by defining the immediate subtags in decreasing order,
282;;; starting with that subtag whose element size isn't an integral
283;;; number of bits and ending with those whose element size - like all
284;;; non-CL-array fulltag-immheader types - is 32 bits.
285
286(define-imm-subtag bit-vector 31)
[16000]287(define-imm-subtag complex-double-float-vector 30)
288(define-imm-subtag complex-single-float-vector 29)
289(define-imm-subtag double-float-vector 28)
290(define-imm-subtag s16-vector 27)
291(define-imm-subtag u16-vector 26)
[6986]292(defconstant min-16-bit-ivector-subtag subtag-u16-vector)
293(defconstant max-16-bit-ivector-subtag subtag-s16-vector)
294
295
[16000]296(define-imm-subtag s8-vector 25)
297(define-imm-subtag u8-vector 24)
[6986]298(defconstant min-8-bit-ivector-subtag subtag-u8-vector)
[16000]299(defconstant max-8-bit-ivector-subtag subtag-s8-vector)
[6986]300
[16000]301(define-imm-subtag simple-base-string 23)
302(define-imm-subtag fixnum-vector 22)
303(define-imm-subtag s32-vector 21)
304(define-imm-subtag u32-vector 20)
305(define-imm-subtag single-float-vector 19)
306(defconstant max-32-bit-ivector-subtag subtag-simple-base-string)
[6986]307(defconstant min-cl-ivector-subtag subtag-single-float-vector)
308
[16000]309(define-node-subtag arrayH 29)
310(define-node-subtag vectorH 30)
311(define-node-subtag simple-vector 31) ; Only one such subtag
[6986]312(assert (< subtag-arrayH subtag-vectorH subtag-simple-vector))
313
314(define-imm-subtag macptr 3)
315(defconstant min-non-numeric-imm-subtag subtag-macptr)
316(assert (> min-non-numeric-imm-subtag max-numeric-subtag))
317(define-imm-subtag dead-macptr 4)
[8255]318;;(define-imm-subtag unused 5) ;was creole-object
319;;(define-imm-subtag unused 6) ;was code-vector
320(define-imm-subtag xcode-vector 7)
[15985]321(define-imm-subtag complex-single-float 8)
322(define-imm-subtag complex-double-float 9)
[8225]323
324;;; immediate subtags
325(define-subtag unbound fulltag-imm 6)
[6986]326(defconstant unbound-marker subtag-unbound)
327(defconstant undefined unbound-marker)
[8225]328(define-subtag character fulltag-imm 9)
329(define-subtag slot-unbound fulltag-imm 10)
[6986]330(defconstant slot-unbound-marker subtag-slot-unbound)
[8225]331(define-subtag illegal fulltag-imm 11)
[6986]332(defconstant illegal-marker subtag-illegal)
[9374]333(define-subtag forward-marker fulltag-imm 28)
[8225]334(define-subtag reserved-frame fulltag-imm 29)
[7217]335(defconstant reserved-frame-marker subtag-reserved-frame)
[8225]336(define-subtag no-thread-local-binding fulltag-imm 30)
[7217]337
[6986]338;;; This has two functions: it tells the link-inverting marker where
339;;; the code ends and the self-reference table and constants start, and it
340;;; ensures that the 0th constant will never be in the same memozized
341;;; dnode as some (unboxed) word of machine code. I'm not sure if
342;;; there's a better way to do either of those things.
343;;;
344;;; Depending on how you look at it, we either lose 8 bytes per
345;;; function, or gain 7 bytes of otherwise unused space for debugging
346;;; info.
[8225]347;;; xxx -- comments above not right for x8632
348(define-subtag function-boundary-marker fulltag-imm 31)
[7037]349(defconstant function-boundary-marker subtag-function-boundary-marker)
[6986]350(defconstant max-non-array-imm-subtag (logior (ash 19 ntagbits) fulltag-immheader))
351
352(define-node-subtag catch-frame 4)
353(defconstant min-non-numeric-node-subtag subtag-catch-frame)
354(assert (> min-non-numeric-node-subtag max-numeric-subtag))
355(define-node-subtag function 5)
356(define-node-subtag basic-stream 6)
357(define-node-subtag symbol 7)
358(define-node-subtag lock 8)
359(define-node-subtag hash-vector 9)
360(define-node-subtag pool 10)
361(define-node-subtag weak 11)
362(define-node-subtag package 12)
363(define-node-subtag slot-vector 13)
364(define-node-subtag instance 14)
365(define-node-subtag struct 15)
366(define-node-subtag istruct 16)
367(define-node-subtag value-cell 17)
368(define-node-subtag xfunction 18) ; Function for cross-development
369
370(defconstant max-non-array-node-subtag (logior (ash 18 ntagbits) fulltag-nodeheader))
371
372(defconstant misc-header-offset (- fulltag-misc))
373(defconstant misc-subtag-offset misc-header-offset)
374(defconstant misc-data-offset (+ misc-header-offset node-size))
[8075]375(defconstant misc-dfloat-offset ( + misc-header-offset 8))
[6986]376
[11295]377(defconstant max-64-bit-constant-index (ash 1 24))
378(defconstant max-32-bit-constant-index (ash 1 24))
379(defconstant max-16-bit-constant-index (ash 1 24))
380(defconstant max-8-bit-constant-index (ash 1 24))
381(defconstant max-1-bit-constant-index (ash 1 24))
[6986]382
383) ;eval-when
384
[7286]385;;; On IA-32, the tag which was used for nil on ppc32 is now used for
386;;; tagged return addresses. We therefore make nil a distinguished
387;;; CONS. This way, CAR and CDR can just check the tag, and
388;;; CONSP/RPLACA/RPLACD can check the tag and complain if the argument
389;;; is NIL.
[10959]390(defconstant canonical-nil-value (+ #x13000 fulltag-cons))
391(defconstant canonical-t-value (+ #x13008 fulltag-misc))
392(defconstant t-offset (- canonical-t-value canonical-nil-value))
[7286]393
394(defconstant misc-bias fulltag-misc)
395(defconstant cons-bias fulltag-cons)
396
397
[6986]398(defmacro define-storage-layout (name origin &rest cells)
399 `(progn
400 (ccl::defenum (:start ,origin :step 4)
401 ,@(mapcar #'(lambda (cell) (ccl::form-symbol name "." cell)) cells))
402 (defconstant ,(ccl::form-symbol name ".SIZE") ,(* (length cells) 4))))
403
404(defmacro define-lisp-object (name tagname &rest cells)
405 `(define-storage-layout ,name ,(- (symbol-value tagname)) ,@cells))
406
407(defmacro define-fixedsized-object (name &rest non-header-cells)
408 `(progn
409 (define-lisp-object ,name fulltag-misc header ,@non-header-cells)
410 (ccl::defenum ()
411 ,@(mapcar #'(lambda (cell) (ccl::form-symbol name "." cell "-CELL")) non-header-cells))
412 (defconstant ,(ccl::form-symbol name ".ELEMENT-COUNT") ,(length non-header-cells))))
413
414(define-lisp-object cons tag-list
415 cdr
416 car)
417
418(define-fixedsized-object ratio
419 numer
420 denom)
421
422(define-fixedsized-object single-float
423 value)
424
425(define-fixedsized-object double-float
426 pad
427 value
428 val-high)
429
[15985]430(define-fixedsized-object complex-single-float
431 pad
432 realpart
433 imagpart)
434
435(define-fixedsized-object complex-double-float
436 pad
437 realpart-low
438 realpart-high
439 imagpart-low
440 imagpart-high)
441
442(defconstant complex-double-float.realpart complex-double-float.realpart-low)
443(defconstant complex-double-float.imagpart complex-double-float.imagpart-low)
444
445
[6986]446(define-fixedsized-object complex
447 realpart
448 imagpart)
449
450;;; There are two kinds of macptr; use the length field of the header if you
451;;; need to distinguish between them
452(define-fixedsized-object macptr
453 address
454 domain
455 type
456)
457
458(define-fixedsized-object xmacptr
459 address
460 domain
461 type
462 flags
463 link
464)
465
466;;; Need to think about catch frames on x8632, too.
[9646]467(define-fixedsized-object catch-frame
[6986]468 catch-tag ; #<unbound> -> unwind-protect, else catch
469 link ; tagged pointer to next older catch frame
470 mvflag ; 0 if single-value, 1 if uwp or multiple-value
471 esp ;
472 ebp
473 foreign-sp
474 db-link ; value of dynamic-binding link on thread entry.
475 xframe ; exception-frame link
476 pc ; tra of catch exit/unwind cleanup
[16043]477 nfp
478 pad
[6986]479)
480
481(define-fixedsized-object lock
482 _value ;finalizable pointer to kernel object
483 kind ; '0 = recursive-lock, '1 = rwlock
484 writer ;tcr of owning thread or 0
485 name
[10206]486 whostate
487 whostate-2
[6986]488 )
489
490
491
492(define-fixedsized-object symbol
493 pname
494 vcell
495 fcell
496 package-predicate
497 flags
498 plist
499 binding-index
500)
501
[7339]502(defconstant nilsym-offset (+ t-offset symbol.size))
503
[6986]504(define-fixedsized-object vectorH
505 logsize ; fillpointer if it has one, physsize otherwise
506 physsize ; total size of (possibly displaced) data vector
507 data-vector ; object this header describes
508 displacement ; true displacement or 0
509 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
510)
511
512(define-lisp-object arrayH fulltag-misc
513 header ; subtag = subtag-arrayH
514 rank ; NEVER 1
515 physsize ; total size of (possibly displaced) data vector
516 data-vector ; object this header describes
517 displacement ; true displacement or 0
518 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
519 ;; Dimensions follow
520)
521
522(defconstant arrayH.rank-cell 0)
523(defconstant arrayH.physsize-cell 1)
524(defconstant arrayH.data-vector-cell 2)
525(defconstant arrayH.displacement-cell 3)
526(defconstant arrayH.flags-cell 4)
527(defconstant arrayH.dim0-cell 5)
528
529(defconstant arrayH.flags-cell-bits-byte (byte 8 0))
530(defconstant arrayH.flags-cell-subtag-byte (byte 8 8))
531
532
533(define-fixedsized-object value-cell
534 value)
535
[7962]536(define-storage-layout lisp-frame 0
537 backptr
538 return-address
539 xtra)
540
[10332]541(define-storage-layout tsp-frame 0
542 backptr
543 ebp)
544
545(define-storage-layout csp-frame 0
546 backptr
547 ebp)
548
[7962]549(define-storage-layout xcf 0 ;"exception callback frame"
550 backptr
551 return-address ; always 0
552 nominal-function
553 relative-pc
554 containing-object
555 xp
556 ra0
[10332]557 foreign-sp ;value of tcr.foreign_sp
558 prev-xframe ;tcr.xframe before exception
[15000]559 ;(last 2 needed by apply-in-frame)
560 pc-low ;fixnum low half of absolute pc
561 pc-high ;and the high half
562 )
[7962]563
[6986]564;;; The kernel uses these (rather generically named) structures
565;;; to keep track of various memory regions it (or the lisp) is
566;;; interested in.
567
568(define-storage-layout area 0
569 pred ; pointer to preceding area in DLL
570 succ ; pointer to next area in DLL
571 low ; low bound on area addresses
572 high ; high bound on area addresses.
573 active ; low limit on stacks, high limit on heaps
574 softlimit ; overflow bound
575 hardlimit ; another one
576 code ; an area-code; see below
577 markbits ; bit vector for GC
578 ndnodes ; "active" size of dynamic area or stack
579 older ; in EGC sense
580 younger ; also for EGC
581 h ; Handle or null pointer
582 softprot ; protected_area structure pointer
583 hardprot ; another one.
584 owner ; fragment (library) which "owns" the area
585 refbits ; bitvector for intergenerational refernces
586 threshold ; for egc
587 gc-count ; generational gc count.
588 static-dnodes ; for honsing, etc.
589 static-used ; bitvector
590)
591
592(define-storage-layout protected-area 0
593 next
594 start ; first byte (page-aligned) that might be protected
595 end ; last byte (page-aligned) that could be protected
596 nprot ; Might be 0
597 protsize ; number of bytes to protect
598 why)
599
[14619]600#+windows-target
601(progn
[6986]602(eval-when (:compile-toplevel :load-toplevel :execute)
[14619]603 (defconstant tcr-bias #xe88))
[6986]604
[14619]605(define-storage-layout tcr tcr-bias
606 linear
607 aux
608 valence
609 node-regs-mask ; bit set means corresponding reg contains node
610 save-allocbase
611 save-allocptr
612 last-allocptr
613 catch-top
614 db-link
615 tlb-limit
616 tlb-pointer
617 ffi-exception
618 foreign-sp
619 interrupt-pending
620 next-method-context
621 next-tsp
[16043]622 nfp
[14619]623 save-tsp
624 save-vsp
625 save-ebp
626 ts-area
627 vs-area
628 xframe
629 unwinding
630 flags
631 foreign-mxcsr
632 lisp-mxcsr
633 pending-exception-context
634 unboxed0
635 unboxed1
636 save0
637 save1
638 save2
[16043]639 save3
640 safe-ref-address)
[14619]641
642(define-storage-layout tcr-aux 0
643 total-bytes-allocated-low
644 total-bytes-allocated-high
645 cs-area
646 cs-limit
647 log2-allocation-quantum
648 errno-loc
649 osid
650 foreign-exception-status
651 native-thread-info
652 native-thread-id
653 reset-completion
654 activate
655 gc-context
656 termination-semaphore
657 shutdown-count
658 suspend-count
659 suspend-context
660 suspend
661 resume
662 allocated
663 pending-io-info
664 io-datum
665 next
666 prev)
667
668)
669
670#-windows-target
671(progn
672
673(eval-when (:compile-toplevel :load-toplevel :execute)
[14621]674 (defconstant tcr-bias 0))
[14619]675
[6986]676(define-storage-layout tcr (- tcr-bias)
[7023]677 next ; in doubly-linked list
[6986]678 prev ; in doubly-linked list
679 node-regs-mask ; bit set means corresponding reg contains node
680 linear
[7962]681 ;; save0 *must* be aligned on a 16-byte boundary!
682 save0 ;spill area for node registers
683 save1 ; (caller saved)
684 save2 ; probably saved/restored in
685 save3 ; callout/trap handlers
[6986]686 save-ebp ; lisp frame ptr for foreign code
[7262]687 lisp-mxcsr
688 foreign-mxcsr
[6986]689 db-link ; special binding chain head
690 catch-top ; top catch frame
691 save-vsp ; SP when in foreign code
692 save-tsp ; TSP, at all times
693 foreign-sp ; SP when in lisp code
694 cs-area ; cstack area pointer
695 vs-area ; vstack area pointer
696 ts-area ; tstack area pointer
697 cs-limit ; cstack overflow limit
[7262]698 total-bytes-allocated-low
699 total-bytes-allocated-high
[6986]700 log2-allocation-quantum ; unboxed
701 interrupt-pending ; fixnum
702 xframe ; exception frame linked list
703 errno-loc ; thread-private, maybe
704 ffi-exception ; fpscr bits from ff-call.
705 osid ; OS thread id
706 valence ; odd when in foreign code
707 foreign-exception-status
708 native-thread-info
709 native-thread-id
710 last-allocptr
711 save-allocptr
712 save-allocbase
713 reset-completion
714 activate
715 suspend-count
716 suspend-context
717 pending-exception-context
718 suspend ; semaphore for suspension notify
719 resume ; sempahore for resumption notify
720 flags ; foreign, being reset, ...
721 gc-context
722 termination-semaphore
723 unwinding
724 tlb-limit
725 tlb-pointer
726 shutdown-count
727 next-tsp
728 safe-ref-address
[7037]729 ldt-selector
[8075]730 scratch-mxcsr ;used for reading/writing mxcsr
[9000]731 unboxed0 ;unboxed scratch locations
732 unboxed1
[9039]733 next-method-context ;used in lieu of register
[10251]734 save-eflags
[10936]735 allocated ;maybe unaligned TCR pointer
[11093]736 pending-io-info
737 io-datum ;for windows overlapped I/O
[16043]738 nfp)
[6986]739)
740
741(defconstant interrupt-level-binding-index (ash 1 fixnumshift))
742
743(define-storage-layout lockptr 0
744 avail
745 owner
746 count
747 signal
748 waiting
749 malloced-ptr
750 spinlock)
751
[10251]752(define-storage-layout rwlock 0
753 spin
754 state
755 blocked-writers
756 blocked-readers
757 writer
758 reader-signal
759 writer-signal
760 malloced-ptr
761 )
762
[6986]763(defmacro define-header (name element-count subtag)
764 `(defconstant ,name (logior (ash ,element-count num-subtag-bits) ,subtag)))
765
766(define-header single-float-header single-float.element-count subtag-single-float)
767(define-header double-float-header double-float.element-count subtag-double-float)
768
769;;; We could possibly have a one-digit bignum header when dealing
770;;; with "small bignums" in some bignum code. Like other cases of
771;;; non-normalized bignums, they should never escape from the lab.
772(define-header one-digit-bignum-header 1 subtag-bignum)
773(define-header two-digit-bignum-header 2 subtag-bignum)
774(define-header three-digit-bignum-header 3 subtag-bignum)
775(define-header symbol-header symbol.element-count subtag-symbol)
776(define-header value-cell-header value-cell.element-count subtag-value-cell)
777(define-header macptr-header macptr.element-count subtag-macptr)
778
779;;; see x86-clos.lisp
[9000]780(defconstant gf-code-size 30)
[6986]781
782(defun %kernel-global (sym)
783 (let* ((pos (position sym x86::*x86-kernel-globals* :test #'string=)))
784 (if pos
[8426]785 (- (+ fulltag-cons (* (1+ pos) node-size)))
[6986]786 (error "Unknown kernel global : ~s ." sym))))
787
788(defmacro kernel-global (sym)
789 (let* ((pos (position sym x86::*x86-kernel-globals* :test #'string=)))
790 (if pos
[8426]791 (- (+ fulltag-cons (* (1+ pos) node-size)))
[6986]792 (error "Unknown kernel global : ~s ." sym))))
793
794(ccl::defenum (:prefix "KERNEL-IMPORT-" :start 0 :step node-size)
795 fd-setsize-bytes
796 do-fd-set
797 do-fd-clr
798 do-fd-is-set
799 do-fd-zero
800 MakeDataExecutable
801 GetSharedLibrary
802 FindSymbol
803 malloc
804 free
[13971]805 wait-for-signal
[11659]806 tcr-frame-ptr
[11676]807 register-xmacptr-dispose-function
[11631]808 open-debug-output
[6986]809 get-r-debug
810 restore-soft-stack-limit
811 egc-control
812 lisp-bug
813 NewThread
[11749]814 cooperative-thread-startup
[6986]815 DisposeThread
816 ThreadCurrentStackSpace
817 usage-exit
818 save-fp-context
819 restore-fp-context
820 put-altivec-registers ;is there any
821 get-altivec-registers ;point to these on x86?
822 new-semaphore
823 wait-on-semaphore
824 signal-semaphore
825 destroy-semaphore
826 new-recursive-lock
827 lock-recursive-lock
828 unlock-recursive-lock
829 destroy-recursive-lock
830 suspend-other-threads
831 resume-other-threads
832 suspend-tcr
833 resume-tcr
834 rwlock-new
835 rwlock-destroy
836 rwlock-rlock
837 rwlock-wlock
838 rwlock-unlock
839 recursive-lock-trylock
840 foreign-name-and-offset
[10659]841 lisp-read
842 lisp-write
843 lisp-open
844 lisp-fchmod
845 lisp-lseek
846 lisp-close
847 lisp-ftruncate
848 lisp-stat
849 lisp-fstat
850 lisp-futex
851 lisp-opendir
852 lisp-readdir
853 lisp-closedir
[10677]854 lisp-pipe
[10816]855 lisp-gettimeofday
[12196]856 lisp-sigexit
[15191]857 jvm-init
[6986]858)
859
860(defmacro nrs-offset (name)
861 (let* ((pos (position name x86::*x86-nilreg-relative-symbols* :test #'eq)))
862 (if pos (* (1- pos) symbol.size))))
863
[7878]864(defmacro with-stack-short-floats (specs &body body)
865 (ccl::collect ((binds)
866 (inits)
867 (names))
868 (dolist (spec specs)
869 (let ((name (first spec)))
870 (binds `(,name (ccl::%make-sfloat)))
871 (names name)
872 (let ((init (second spec)))
873 (when init
874 (inits `(ccl::%short-float ,init ,name))))))
875 `(let* ,(binds)
876 (declare (dynamic-extent ,@(names))
877 (short-float ,@(names)))
878 ,@(inits)
879 ,@body)))
880
[15985]881
[6986]882(defparameter *x8632-target-uvector-subtags*
883 `((:bignum . ,subtag-bignum)
884 (:ratio . ,subtag-ratio)
885 (:single-float . ,subtag-single-float)
886 (:double-float . ,subtag-double-float)
887 (:complex . ,subtag-complex )
[15985]888 (:complex-single-float . ,subtag-complex-single-float)
889 (:complex-double-float . ,subtag-complex-double-float)
[6986]890 (:symbol . ,subtag-symbol)
891 (:function . ,subtag-function )
892 (:xcode-vector . ,subtag-xcode-vector)
893 (:macptr . ,subtag-macptr )
894 (:catch-frame . ,subtag-catch-frame)
895 (:struct . ,subtag-struct )
896 (:istruct . ,subtag-istruct )
897 (:pool . ,subtag-pool )
898 (:population . ,subtag-weak )
899 (:hash-vector . ,subtag-hash-vector )
900 (:package . ,subtag-package )
901 (:value-cell . ,subtag-value-cell)
902 (:instance . ,subtag-instance )
903 (:lock . ,subtag-lock )
904 (:slot-vector . ,subtag-slot-vector)
905 (:basic-stream . ,subtag-basic-stream)
906 (:simple-string . ,subtag-simple-base-string )
907 (:bit-vector . ,subtag-bit-vector )
908 (:signed-8-bit-vector . ,subtag-s8-vector )
909 (:unsigned-8-bit-vector . ,subtag-u8-vector )
910 (:signed-16-bit-vector . ,subtag-s16-vector )
911 (:unsigned-16-bit-vector . ,subtag-u16-vector )
912 (:signed-32-bit-vector . ,subtag-s32-vector )
913 (:fixnum-vector . ,subtag-fixnum-vector)
914 (:unsigned-32-bit-vector . ,subtag-u32-vector )
915 (:single-float-vector . ,subtag-single-float-vector)
916 (:double-float-vector . ,subtag-double-float-vector )
917 (:simple-vector . ,subtag-simple-vector )
[16000]918 (:complex-single-float-vector . ,subtag-complex-single-float-vector)
919 (:complex-double-float-vector . ,subtag-complex-double-float-vector)
[6986]920 (:vector-header . ,subtag-vectorH)
[15979]921 (:array-header . ,subtag-arrayH)
922 ;;; A pseudo vector type keyword
923 (:min-cl-ivector-subtag . ,min-cl-ivector-subtag)
924 ))
[6986]925
926;;; This should return NIL unless it's sure of how the indicated
927;;; type would be represented (in particular, it should return
928;;; NIL if the element type is unknown or unspecified at compile-time.
929(defun x8632-array-type-name-from-ctype (ctype)
930 (when (typep ctype 'ccl::array-ctype)
931 (let* ((element-type (ccl::array-ctype-element-type ctype)))
932 (typecase element-type
933 (ccl::class-ctype
934 (let* ((class (ccl::class-ctype-class element-type)))
935 (if (or (eq class ccl::*character-class*)
936 (eq class ccl::*base-char-class*)
937 (eq class ccl::*standard-char-class*))
938 :simple-string
939 :simple-vector)))
940 (ccl::numeric-ctype
941 (if (eq (ccl::numeric-ctype-complexp element-type) :complex)
[16000]942 (case (ccl::numeric-ctype-format element-type)
943 (single-float :complex-single-float-vector)
944 (double-float :complex-double-float-vector)
945 (t :simple-vector))
[6986]946 (case (ccl::numeric-ctype-class element-type)
947 (integer
948 (let* ((low (ccl::numeric-ctype-low element-type))
949 (high (ccl::numeric-ctype-high element-type)))
950 (cond ((or (null low) (null high)) :simple-vector)
951 ((and (>= low 0) (<= high 1) :bit-vector))
952 ((and (>= low 0) (<= high 255)) :unsigned-8-bit-vector)
953 ((and (>= low 0) (<= high 65535)) :unsigned-16-bit-vector)
954 ((and (>= low 0) (<= high #xffffffff) :unsigned-32-bit-vector))
955 ((and (>= low -128) (<= high 127)) :signed-8-bit-vector)
956 ((and (>= low -32768) (<= high 32767) :signed-16-bit-vector))
957 ((and (>= low target-most-negative-fixnum)
958 (<= high target-most-positive-fixnum))
959 :fixnum-vector)
960 ((and (>= low (ash -1 31)) (<= high (1- (ash 1 31))))
961 :signed-32-bit-vector)
962 (t :simple-vector))))
963 (float
964 (case (ccl::numeric-ctype-format element-type)
965 ((double-float long-float) :double-float-vector)
966 ((single-float short-float) :single-float-vector)
967 (t :simple-vector)))
968 (t :simple-vector))))
969 (ccl::unknown-ctype)
970 (ccl::named-ctype
971 (if (eq element-type ccl::*universal-type*)
972 :simple-vector))
973 (t nil)))))
974
975(defun x8632-misc-byte-count (subtag element-count)
976 (declare (fixnum subtag))
977 (if (or (= fulltag-nodeheader (logand subtag fulltagmask))
978 (<= subtag max-32-bit-ivector-subtag))
979 (ash element-count 2)
980 (if (<= subtag max-8-bit-ivector-subtag)
981 element-count
982 (if (<= subtag max-16-bit-ivector-subtag)
983 (ash element-count 1)
984 (if (= subtag subtag-bit-vector)
985 (ash (+ element-count 7) -3)
[16000]986 (if (= subtag subtag-complex-double-float-vector)
987 (+ 4 (ash element-count 4))
988 (+ 4 (ash element-count 3))))))))
[6986]989
[16000]990
[6986]991(defparameter *x8632-subprims-shift* 2)
[10251]992(defconstant x8632-subprims-base #x15000)
[6986]993
994(declaim (special *x8632-subprims*))
995
996(let* ((origin x8632-subprims-base)
997 (step (ash 1 *x8632-subprims-shift*)))
998 (flet ((define-x8632-subprim (name)
999 (ccl::make-subprimitive-info :name (string name)
1000 :offset (prog1 origin
1001 (incf origin step)))))
1002 (macrolet ((defx8632subprim (name)
1003 `(define-x8632-subprim ',name)))
1004 (defparameter *x8632-subprims*
1005 (vector
1006 (defx8632subprim .SPjmpsym)
1007 (defx8632subprim .SPjmpnfn)
1008 (defx8632subprim .SPfuncall)
1009 (defx8632subprim .SPmkcatch1v)
1010 (defx8632subprim .SPmkunwind)
1011 (defx8632subprim .SPmkcatchmv)
1012 (defx8632subprim .SPthrow)
1013 (defx8632subprim .SPnthrowvalues)
1014 (defx8632subprim .SPnthrow1value)
1015 (defx8632subprim .SPbind)
1016 (defx8632subprim .SPbind-self)
1017 (defx8632subprim .SPbind-nil)
1018 (defx8632subprim .SPbind-self-boundp-check)
1019 (defx8632subprim .SPrplaca)
1020 (defx8632subprim .SPrplacd)
1021 (defx8632subprim .SPconslist)
1022 (defx8632subprim .SPconslist-star)
1023 (defx8632subprim .SPstkconslist)
1024 (defx8632subprim .SPstkconslist-star)
1025 (defx8632subprim .SPmkstackv)
1026 (defx8632subprim .SPsubtag-misc-ref)
1027 (defx8632subprim .SPsetqsym)
1028 (defx8632subprim .SPprogvsave)
1029 (defx8632subprim .SPstack-misc-alloc)
1030 (defx8632subprim .SPgvector)
1031 (defx8632subprim .SPnvalret)
1032 (defx8632subprim .SPmvpass)
1033 (defx8632subprim .SPrecover-values-for-mvcall)
1034 (defx8632subprim .SPnthvalue)
1035 (defx8632subprim .SPvalues)
1036 (defx8632subprim .SPdefault-optional-args)
1037 (defx8632subprim .SPopt-supplied-p)
1038 (defx8632subprim .SPheap-rest-arg)
1039 (defx8632subprim .SPreq-heap-rest-arg)
1040 (defx8632subprim .SPheap-cons-rest-arg)
1041 (defx8632subprim .SPsimple-keywords)
1042 (defx8632subprim .SPkeyword-args)
1043 (defx8632subprim .SPkeyword-bind)
1044 (defx8632subprim .SPffcall)
1045 (defx8632subprim .SParef2)
1046 (defx8632subprim .SPksignalerr)
1047 (defx8632subprim .SPstack-rest-arg)
1048 (defx8632subprim .SPreq-stack-rest-arg)
1049 (defx8632subprim .SPstack-cons-rest-arg)
1050 (defx8632subprim .SPpoweropen-callbackX) ;needed on x86?
1051 (defx8632subprim .SPcall-closure)
1052 (defx8632subprim .SPgetXlong)
1053 (defx8632subprim .SPspreadargz)
1054 (defx8632subprim .SPtfuncallgen)
1055 (defx8632subprim .SPtfuncallslide)
1056 (defx8632subprim .SPtfuncallvsp)
1057 (defx8632subprim .SPtcallsymgen)
1058 (defx8632subprim .SPtcallsymslide)
1059 (defx8632subprim .SPtcallsymvsp)
1060 (defx8632subprim .SPtcallnfngen)
1061 (defx8632subprim .SPtcallnfnslide)
1062 (defx8632subprim .SPtcallnfnvsp)
1063 (defx8632subprim .SPmisc-ref)
1064 (defx8632subprim .SPmisc-set)
1065 (defx8632subprim .SPstkconsyz)
1066 (defx8632subprim .SPstkvcell0)
1067 (defx8632subprim .SPstkvcellvsp)
1068 (defx8632subprim .SPmakestackblock)
1069 (defx8632subprim .SPmakestackblock0)
1070 (defx8632subprim .SPmakestacklist)
1071 (defx8632subprim .SPstkgvector)
1072 (defx8632subprim .SPmisc-alloc)
1073 (defx8632subprim .SPpoweropen-ffcallX) ;needed on x86?
1074 (defx8632subprim .SPgvset)
1075 (defx8632subprim .SPmacro-bind)
1076 (defx8632subprim .SPdestructuring-bind)
1077 (defx8632subprim .SPdestructuring-bind-inner)
1078 (defx8632subprim .SPrecover-values)
1079 (defx8632subprim .SPvpopargregs)
1080 (defx8632subprim .SPinteger-sign)
1081 (defx8632subprim .SPsubtag-misc-set)
1082 (defx8632subprim .SPspread-lexpr-z)
1083 (defx8632subprim .SPstore-node-conditional)
1084 (defx8632subprim .SPreset)
1085 (defx8632subprim .SPmvslide)
1086 (defx8632subprim .SPsave-values)
1087 (defx8632subprim .SPadd-values)
[7816]1088 (defx8632subprim .SPcallback)
[6986]1089 (defx8632subprim .SPmisc-alloc-init)
1090 (defx8632subprim .SPstack-misc-alloc-init)
1091 (defx8632subprim .SPset-hash-key)
1092 (defx8632subprim .SPaset2)
1093 (defx8632subprim .SPcallbuiltin)
1094 (defx8632subprim .SPcallbuiltin0)
1095 (defx8632subprim .SPcallbuiltin1)
1096 (defx8632subprim .SPcallbuiltin2)
1097 (defx8632subprim .SPcallbuiltin3)
1098 (defx8632subprim .SPpopj)
1099 (defx8632subprim .SPrestorefullcontext)
1100 (defx8632subprim .SPsavecontextvsp)
1101 (defx8632subprim .SPsavecontext0)
1102 (defx8632subprim .SPrestorecontext)
1103 (defx8632subprim .SPlexpr-entry)
[8834]1104 (defx8632subprim .SPsyscall2)
[6986]1105 (defx8632subprim .SPbuiltin-plus)
1106 (defx8632subprim .SPbuiltin-minus)
1107 (defx8632subprim .SPbuiltin-times)
1108 (defx8632subprim .SPbuiltin-div)
1109 (defx8632subprim .SPbuiltin-eq)
1110 (defx8632subprim .SPbuiltin-ne)
1111 (defx8632subprim .SPbuiltin-gt)
1112 (defx8632subprim .SPbuiltin-ge)
1113 (defx8632subprim .SPbuiltin-lt)
1114 (defx8632subprim .SPbuiltin-le)
1115 (defx8632subprim .SPbuiltin-eql)
1116 (defx8632subprim .SPbuiltin-length)
1117 (defx8632subprim .SPbuiltin-seqtype)
1118 (defx8632subprim .SPbuiltin-assq)
1119 (defx8632subprim .SPbuiltin-memq)
1120 (defx8632subprim .SPbuiltin-logbitp)
1121 (defx8632subprim .SPbuiltin-logior)
1122 (defx8632subprim .SPbuiltin-logand)
1123 (defx8632subprim .SPbuiltin-ash)
1124 (defx8632subprim .SPbuiltin-negate)
1125 (defx8632subprim .SPbuiltin-logxor)
1126 (defx8632subprim .SPbuiltin-aref1)
1127 (defx8632subprim .SPbuiltin-aset1)
1128 (defx8632subprim .SPbreakpoint)
1129 (defx8632subprim .SPeabi-ff-call)
1130 (defx8632subprim .SPeabi-callback)
1131 (defx8632subprim .SPsyscall)
1132 (defx8632subprim .SPgetu64)
1133 (defx8632subprim .SPgets64)
1134 (defx8632subprim .SPmakeu64)
1135 (defx8632subprim .SPmakes64)
1136 (defx8632subprim .SPspecref)
1137 (defx8632subprim .SPspecset)
1138 (defx8632subprim .SPspecrefcheck)
1139 (defx8632subprim .SPrestoreintlevel)
1140 (defx8632subprim .SPmakes32)
1141 (defx8632subprim .SPmakeu32)
1142 (defx8632subprim .SPgets32)
1143 (defx8632subprim .SPgetu32)
1144 (defx8632subprim .SPfix-overflow)
1145 (defx8632subprim .SPmvpasssym)
1146 (defx8632subprim .SParef3)
1147 (defx8632subprim .SPaset3)
1148 (defx8632subprim .SPffcall-return-registers)
[9768]1149 (defx8632subprim .SPaset1)
[10731]1150 (defx8632subprim .SPset-hash-key-conditional)
[6986]1151 (defx8632subprim .SPunbind-interrupt-level)
1152 (defx8632subprim .SPunbind)
1153 (defx8632subprim .SPunbind-n)
1154 (defx8632subprim .SPunbind-to)
1155 (defx8632subprim .SPbind-interrupt-level-m1)
1156 (defx8632subprim .SPbind-interrupt-level)
1157 (defx8632subprim .SPbind-interrupt-level-0)
1158 (defx8632subprim .SPprogvrestore)
[7426]1159 (defx8632subprim .SPnmkunwind)
[6986]1160 )))))
1161
1162
1163
1164(defparameter *x8632-target-arch*
1165 (arch::make-target-arch :name :x8632
1166 :lisp-node-size node-size
[10959]1167 :nil-value canonical-nil-value
[6986]1168 :fixnum-shift fixnumshift
1169 :most-positive-fixnum target-most-positive-fixnum
1170 :most-negative-fixnum target-most-negative-fixnum
1171 :misc-data-offset misc-data-offset
1172 :misc-dfloat-offset misc-dfloat-offset
1173 :nbits-in-word nbits-in-word
1174 :ntagbits ntagbits
1175 :nlisptagbits nlisptagbits
1176 :uvector-subtags *x8632-target-uvector-subtags*
1177 :max-64-bit-constant-index max-64-bit-constant-index
1178 :max-32-bit-constant-index max-32-bit-constant-index
1179 :max-16-bit-constant-index max-16-bit-constant-index
1180 :max-8-bit-constant-index max-8-bit-constant-index
1181 :max-1-bit-constant-index max-1-bit-constant-index
1182 :word-shift word-shift
1183 :code-vector-prefix ()
1184 :gvector-types '(:ratio :complex :symbol :function
1185 :catch-frame :struct :istruct
1186 :pool :population :hash-vector
1187 :package :value-cell :instance
1188 :lock :slot-vector
1189 :simple-vector)
1190 :1-bit-ivector-types '(:bit-vector)
1191 :8-bit-ivector-types '(:signed-8-bit-vector
1192 :unsigned-8-bit-vector)
1193 :16-bit-ivector-types '(:signed-16-bit-vector
1194 :unsigned-16-bit-vector)
1195 :32-bit-ivector-types '(:signed-32-bit-vector
1196 :unsigned-32-bit-vector
1197 :single-float-vector
1198 :fixnum-vector
1199 :single-float
1200 :double-float
1201 :bignum
1202 :simple-string)
[16054]1203 :64-bit-ivector-types '(:double-float-vector :complex-single-float-vector)
[6986]1204 :array-type-name-from-ctype-function
1205 #'x8632-array-type-name-from-ctype
1206 :package-name "X8632"
1207 :t-offset t-offset
1208 :array-data-size-function #'x8632-misc-byte-count
[16014]1209 :fpr-mask-function 'x86::fpr-mask
1210
[6986]1211 :subprims-base x8632-subprims-base
1212 :subprims-shift x8632::*x8632-subprims-shift*
1213 :subprims-table x8632::*x8632-subprims*
1214 :primitive->subprims `(((0 . 23) . ,(ccl::%subprim-name->offset '.SPbuiltin-plus x8632::*x8632-subprims*)))
1215 :unbound-marker-value unbound-marker
1216 :slot-unbound-marker-value slot-unbound-marker
1217 :fixnum-tag tag-fixnum
1218 :single-float-tag subtag-single-float
1219 :single-float-tag-is-subtag t
1220 :double-float-tag subtag-double-float
1221 :cons-tag fulltag-cons
1222 :null-tag fulltag-cons
1223 :symbol-tag subtag-symbol
1224 :symbol-tag-is-subtag t
1225 :function-tag subtag-function
1226 :function-tag-is-subtag t
1227 :big-endian nil
1228 :misc-subtag-offset misc-subtag-offset
1229 :car-offset cons.car
1230 :cdr-offset cons.cdr
1231 :subtag-char subtag-character
1232 :charcode-shift charcode-shift
1233 :fulltagmask fulltagmask
1234 :fulltag-misc fulltag-misc
1235 :char-code-limit #x110000
1236 ))
1237
1238;; arch macros
1239
1240(defmacro defx8632archmacro (name lambda-list &body body)
1241 `(arch::defarchmacro :x8632 ,name ,lambda-list ,@body))
1242
1243(defx8632archmacro ccl::%make-sfloat ()
1244 `(ccl::%alloc-misc x8632::single-float.element-count x8632::subtag-single-float))
1245
1246(defx8632archmacro ccl::%make-dfloat ()
1247 `(ccl::%alloc-misc x8632::double-float.element-count x8632::subtag-double-float))
1248
1249(defx8632archmacro ccl::%numerator (x)
1250 `(ccl::%svref ,x x8632::ratio.numer-cell))
1251
1252(defx8632archmacro ccl::%denominator (x)
1253 `(ccl::%svref ,x x8632::ratio.denom-cell))
1254
1255(defx8632archmacro ccl::%realpart (x)
[15985]1256 (let* ((thing (gensym)))
1257 `(let* ((,thing ,x))
1258 (case (ccl::typecode ,thing)
1259 (#.x8632::subtag-complex-single-float (ccl::%complex-single-float-realpart ,thing))
1260 (#.x8632::subtag-complex-double-float (ccl::%complex-double-float-realpart ,thing))
1261 (t (ccl::%svref ,thing x8632::complex.realpart-cell))))))
[6986]1262
1263(defx8632archmacro ccl::%imagpart (x)
[15985]1264 (let* ((thing (gensym)))
1265 `(let* ((,thing ,x))
1266 (case (ccl::typecode ,thing)
1267 (#.x8632::subtag-complex-single-float (ccl::%complex-single-float-imagpart ,thing))
1268 (#.x8632::subtag-complex-double-float (ccl::%complex-double-float-imagpart ,thing))
1269 (t (ccl::%svref ,thing x8632::complex.realpart-cell))))))
[6986]1270
1271;;;
1272(defx8632archmacro ccl::%get-single-float-from-double-ptr (ptr offset)
1273 `(ccl::%double-float->short-float (ccl::%get-double-float ,ptr ,offset)
1274 (ccl::%alloc-misc 1 x8632::subtag-single-float)))
1275
1276(defx8632archmacro ccl::codevec-header-p (word)
1277 (declare (ignore word))
1278 (error "~s makes no sense on :X8632" 'ccl::codevec-header-p))
1279
1280(defx8632archmacro ccl::immediate-p-macro (thing)
1281 (let* ((tag (gensym)))
1282 `(let* ((,tag (ccl::lisptag ,thing)))
1283 (declare (fixnum ,tag))
1284 (or (= ,tag x8632::tag-fixnum)
1285 (= ,tag x8632::tag-imm)))))
1286
1287(defx8632archmacro ccl::hashed-by-identity (thing)
1288 (let* ((typecode (gensym)))
1289 `(let* ((,typecode (ccl::typecode ,thing)))
1290 (declare (fixnum ,typecode))
1291 (or
1292 (= ,typecode x8632::tag-fixnum)
1293 (= ,typecode x8632::tag-imm)
1294 (= ,typecode x8632::subtag-symbol)
1295 (= ,typecode x8632::subtag-instance)))))
1296
1297;;;
1298(defx8632archmacro ccl::%get-kernel-global (name)
[10959]1299 `(ccl::%fixnum-ref 0 (+ ,(ccl::target-nil-value)
[6986]1300 ,(%kernel-global
1301 (if (ccl::quoted-form-p name)
1302 (cadr name)
1303 name)))))
1304
[7771]1305(defx8632archmacro ccl::%get-kernel-global-ptr (name dest)
1306 `(ccl::%setf-macptr
1307 ,dest
[10959]1308 (ccl::%fixnum-ref-macptr 0 (+ ,(ccl::target-nil-value)
[7771]1309 ,(%kernel-global
1310 (if (ccl::quoted-form-p name)
1311 (cadr name)
1312 name))))))
1313
[6986]1314(defx8632archmacro ccl::%target-kernel-global (name)
1315 `(x8632::%kernel-global ,name))
1316
1317(defx8632archmacro ccl::lfun-vector (fun)
[9190]1318 fun)
[6986]1319
1320(defx8632archmacro ccl::lfun-vector-lfun (lfv)
[9190]1321 lfv)
[6986]1322
1323(defx8632archmacro ccl::area-code ()
1324 area.code)
1325
1326(defx8632archmacro ccl::area-succ ()
1327 area.succ)
1328
1329(defx8632archmacro ccl::nth-immediate (f i)
1330 `(ccl::%nth-immediate ,f (the fixnum (- (the fixnum ,i) 1))))
1331
1332(defx8632archmacro ccl::set-nth-immediate (f i new)
1333 `(ccl::%set-nth-immediate ,f (the fixnum (- (the fixnum ,i) 1)) ,new))
1334
1335(defx8632archmacro ccl::symptr->symvector (s)
[7262]1336 s)
[6986]1337
1338(defx8632archmacro ccl::symvector->symptr (s)
[7262]1339 s)
[6986]1340
1341(defx8632archmacro ccl::function-to-function-vector (f)
[7262]1342 f)
[6986]1343
1344(defx8632archmacro ccl::function-vector-to-function (v)
[7262]1345 v)
[6986]1346
1347(defx8632archmacro ccl::with-ffcall-results ((buf) &body body)
1348 ;; Reserve space for eax,edx,st0 only.
1349 (let* ((size (+ (* 2 4) (* 1 8))))
1350 `(ccl::%stack-block ((,buf ,size :clear t))
1351 ,@body)))
1352
[7962]1353;;; When found at a tagged return address, the instruction
1354;;; (movl ($ imm32) (% fn))
1355;;; lets the runtime easily map a return address to the containing
1356;;; function.
1357;;;
1358;;; The notation ($ :self) is used in the assembler to mean "a 32-bit
1359;;; immediate whose offset will be remembered in a table at the end of
1360;;; the function object."
1361;;;
1362;;; Before the function is made executable (or when the GC moves the
1363;;; function), these :self immediates are filled in with the actual
1364;;; address of the function.
1365
1366(defconstant recover-fn-opcode-byte #b10111111) ;when %fn is %edi
1367(defconstant recover-fn-address-offset 1)
1368
[10251]1369;;; For backtrace: the relative PC of an argument-check trap
1370;;; must be less than or equal to this value. (Because of
1371;;; the way that we do "anchored" UUOs, it should always be =.)
1372;;; (maybe not = on x8632)
1373(defconstant arg-check-trap-pc-limit 7)
1374
[15582]1375(defconstant fasl-version #x60)
1376(defconstant fasl-max-version #x60)
1377(defconstant fasl-min-version #x60)
[16000]1378(defparameter *image-abi-version* 1040)
[15093]1379
[6986]1380(provide "X8632-ARCH")
Note: See TracBrowser for help on using the repository browser.