source: release/1.7/source/compiler/X86/X8632/x8632-arch.lisp

Last change on this file was 15099, checked in by R. Matthew Emerson, 13 years ago

Revert r15026.

File size: 44.6 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)
287(define-imm-subtag double-float-vector 30)
288(define-imm-subtag s16-vector 29)
289(define-imm-subtag u16-vector 28)
290(defconstant min-16-bit-ivector-subtag subtag-u16-vector)
291(defconstant max-16-bit-ivector-subtag subtag-s16-vector)
292
293;imm-subtag 27 unused
294
295(define-imm-subtag s8-vector 26)
296(define-imm-subtag u8-vector 25)
297(defconstant min-8-bit-ivector-subtag subtag-u8-vector)
298(defconstant max-8-bit-ivector-subtag (logior fulltag-immheader (ash 27 ntagbits)))
299
300(define-imm-subtag simple-base-string 24)
301(define-imm-subtag fixnum-vector 23)
302(define-imm-subtag s32-vector 22)
303(define-imm-subtag u32-vector 21)
304(define-imm-subtag single-float-vector 20)
305(defconstant max-32-bit-ivector-subtag (logior fulltag-immheader (ash 24 ntagbits)))
306(defconstant min-cl-ivector-subtag subtag-single-float-vector)
307
308(define-node-subtag arrayH 19)
309(define-node-subtag vectorH 20)
310(assert (< subtag-arrayH subtag-vectorH min-cl-ivector-subtag))
311(define-node-subtag simple-vector 21) ; Only one such subtag
312(assert (< subtag-arrayH subtag-vectorH subtag-simple-vector))
313(defconstant min-vector-subtag subtag-vectorH)
314(defconstant min-array-subtag subtag-arrayH)
315
316(define-imm-subtag macptr 3)
317(defconstant min-non-numeric-imm-subtag subtag-macptr)
318(assert (> min-non-numeric-imm-subtag max-numeric-subtag))
319(define-imm-subtag dead-macptr 4)
[8255]320;;(define-imm-subtag unused 5) ;was creole-object
321;;(define-imm-subtag unused 6) ;was code-vector
322(define-imm-subtag xcode-vector 7)
[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
430(define-fixedsized-object complex
431 realpart
432 imagpart)
433
434;;; There are two kinds of macptr; use the length field of the header if you
435;;; need to distinguish between them
436(define-fixedsized-object macptr
437 address
438 domain
439 type
440)
441
442(define-fixedsized-object xmacptr
443 address
444 domain
445 type
446 flags
447 link
448)
449
450;;; Need to think about catch frames on x8632, too.
[9646]451(define-fixedsized-object catch-frame
[6986]452 catch-tag ; #<unbound> -> unwind-protect, else catch
453 link ; tagged pointer to next older catch frame
454 mvflag ; 0 if single-value, 1 if uwp or multiple-value
455 esp ;
456 ebp
457 foreign-sp
458 db-link ; value of dynamic-binding link on thread entry.
459 xframe ; exception-frame link
460 pc ; tra of catch exit/unwind cleanup
461)
462
463(define-fixedsized-object lock
464 _value ;finalizable pointer to kernel object
465 kind ; '0 = recursive-lock, '1 = rwlock
466 writer ;tcr of owning thread or 0
467 name
[10206]468 whostate
469 whostate-2
[6986]470 )
471
472
473
474(define-fixedsized-object symbol
475 pname
476 vcell
477 fcell
478 package-predicate
479 flags
480 plist
481 binding-index
482)
483
[7339]484(defconstant nilsym-offset (+ t-offset symbol.size))
485
[6986]486(define-fixedsized-object vectorH
487 logsize ; fillpointer if it has one, physsize otherwise
488 physsize ; total size of (possibly displaced) data vector
489 data-vector ; object this header describes
490 displacement ; true displacement or 0
491 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
492)
493
494(define-lisp-object arrayH fulltag-misc
495 header ; subtag = subtag-arrayH
496 rank ; NEVER 1
497 physsize ; total size of (possibly displaced) data vector
498 data-vector ; object this header describes
499 displacement ; true displacement or 0
500 flags ; has-fill-pointer,displaced-to,adjustable bits; subtype of underlying simple vector.
501 ;; Dimensions follow
502)
503
504(defconstant arrayH.rank-cell 0)
505(defconstant arrayH.physsize-cell 1)
506(defconstant arrayH.data-vector-cell 2)
507(defconstant arrayH.displacement-cell 3)
508(defconstant arrayH.flags-cell 4)
509(defconstant arrayH.dim0-cell 5)
510
511(defconstant arrayH.flags-cell-bits-byte (byte 8 0))
512(defconstant arrayH.flags-cell-subtag-byte (byte 8 8))
513
514
515(define-fixedsized-object value-cell
516 value)
517
[7962]518(define-storage-layout lisp-frame 0
519 backptr
520 return-address
521 xtra)
522
[10332]523(define-storage-layout tsp-frame 0
524 backptr
525 ebp)
526
527(define-storage-layout csp-frame 0
528 backptr
529 ebp)
530
[7962]531(define-storage-layout xcf 0 ;"exception callback frame"
532 backptr
533 return-address ; always 0
534 nominal-function
535 relative-pc
536 containing-object
537 xp
538 ra0
[10332]539 foreign-sp ;value of tcr.foreign_sp
540 prev-xframe ;tcr.xframe before exception
[15099]541 ) ;(last 2 needed by apply-in-frame)
[7962]542
[6986]543;;; The kernel uses these (rather generically named) structures
544;;; to keep track of various memory regions it (or the lisp) is
545;;; interested in.
546
547(define-storage-layout area 0
548 pred ; pointer to preceding area in DLL
549 succ ; pointer to next area in DLL
550 low ; low bound on area addresses
551 high ; high bound on area addresses.
552 active ; low limit on stacks, high limit on heaps
553 softlimit ; overflow bound
554 hardlimit ; another one
555 code ; an area-code; see below
556 markbits ; bit vector for GC
557 ndnodes ; "active" size of dynamic area or stack
558 older ; in EGC sense
559 younger ; also for EGC
560 h ; Handle or null pointer
561 softprot ; protected_area structure pointer
562 hardprot ; another one.
563 owner ; fragment (library) which "owns" the area
564 refbits ; bitvector for intergenerational refernces
565 threshold ; for egc
566 gc-count ; generational gc count.
567 static-dnodes ; for honsing, etc.
568 static-used ; bitvector
569)
570
571(define-storage-layout protected-area 0
572 next
573 start ; first byte (page-aligned) that might be protected
574 end ; last byte (page-aligned) that could be protected
575 nprot ; Might be 0
576 protsize ; number of bytes to protect
577 why)
578
[14619]579#+windows-target
580(progn
[6986]581(eval-when (:compile-toplevel :load-toplevel :execute)
[14619]582 (defconstant tcr-bias #xe88))
[6986]583
[14619]584(define-storage-layout tcr tcr-bias
585 linear
586 aux
587 valence
588 node-regs-mask ; bit set means corresponding reg contains node
589 save-allocbase
590 save-allocptr
591 last-allocptr
592 catch-top
593 db-link
594 tlb-limit
595 tlb-pointer
596 ffi-exception
597 foreign-sp
598 interrupt-pending
599 next-method-context
600 next-tsp
601 safe-ref-address
602 save-tsp
603 save-vsp
604 save-ebp
605 ts-area
606 vs-area
607 xframe
608 unwinding
609 flags
610 foreign-mxcsr
611 lisp-mxcsr
612 pending-exception-context
613 unboxed0
614 unboxed1
615 save0
616 save1
617 save2
618 save3)
619
620(define-storage-layout tcr-aux 0
621 total-bytes-allocated-low
622 total-bytes-allocated-high
623 cs-area
624 cs-limit
625 log2-allocation-quantum
626 errno-loc
627 osid
628 foreign-exception-status
629 native-thread-info
630 native-thread-id
631 reset-completion
632 activate
633 gc-context
634 termination-semaphore
635 shutdown-count
636 suspend-count
637 suspend-context
638 suspend
639 resume
640 allocated
641 pending-io-info
642 io-datum
643 next
644 prev)
645
646)
647
648#-windows-target
649(progn
650
651(eval-when (:compile-toplevel :load-toplevel :execute)
[14621]652 (defconstant tcr-bias 0))
[14619]653
[6986]654(define-storage-layout tcr (- tcr-bias)
[7023]655 next ; in doubly-linked list
[6986]656 prev ; in doubly-linked list
657 node-regs-mask ; bit set means corresponding reg contains node
658 linear
[7962]659 ;; save0 *must* be aligned on a 16-byte boundary!
660 save0 ;spill area for node registers
661 save1 ; (caller saved)
662 save2 ; probably saved/restored in
663 save3 ; callout/trap handlers
[6986]664 save-ebp ; lisp frame ptr for foreign code
[7262]665 lisp-mxcsr
666 foreign-mxcsr
[6986]667 db-link ; special binding chain head
668 catch-top ; top catch frame
669 save-vsp ; SP when in foreign code
670 save-tsp ; TSP, at all times
671 foreign-sp ; SP when in lisp code
672 cs-area ; cstack area pointer
673 vs-area ; vstack area pointer
674 ts-area ; tstack area pointer
675 cs-limit ; cstack overflow limit
[7262]676 total-bytes-allocated-low
677 total-bytes-allocated-high
[6986]678 log2-allocation-quantum ; unboxed
679 interrupt-pending ; fixnum
680 xframe ; exception frame linked list
681 errno-loc ; thread-private, maybe
682 ffi-exception ; fpscr bits from ff-call.
683 osid ; OS thread id
684 valence ; odd when in foreign code
685 foreign-exception-status
686 native-thread-info
687 native-thread-id
688 last-allocptr
689 save-allocptr
690 save-allocbase
691 reset-completion
692 activate
693 suspend-count
694 suspend-context
695 pending-exception-context
696 suspend ; semaphore for suspension notify
697 resume ; sempahore for resumption notify
698 flags ; foreign, being reset, ...
699 gc-context
700 termination-semaphore
701 unwinding
702 tlb-limit
703 tlb-pointer
704 shutdown-count
705 next-tsp
706 safe-ref-address
[7037]707 ldt-selector
[8075]708 scratch-mxcsr ;used for reading/writing mxcsr
[9000]709 unboxed0 ;unboxed scratch locations
710 unboxed1
[9039]711 next-method-context ;used in lieu of register
[10251]712 save-eflags
[10936]713 allocated ;maybe unaligned TCR pointer
[11093]714 pending-io-info
715 io-datum ;for windows overlapped I/O
[6986]716)
[14619]717)
[6986]718
719(defconstant interrupt-level-binding-index (ash 1 fixnumshift))
720
721(define-storage-layout lockptr 0
722 avail
723 owner
724 count
725 signal
726 waiting
727 malloced-ptr
728 spinlock)
729
[10251]730(define-storage-layout rwlock 0
731 spin
732 state
733 blocked-writers
734 blocked-readers
735 writer
736 reader-signal
737 writer-signal
738 malloced-ptr
739 )
740
[6986]741(defmacro define-header (name element-count subtag)
742 `(defconstant ,name (logior (ash ,element-count num-subtag-bits) ,subtag)))
743
744(define-header single-float-header single-float.element-count subtag-single-float)
745(define-header double-float-header double-float.element-count subtag-double-float)
746
747;;; We could possibly have a one-digit bignum header when dealing
748;;; with "small bignums" in some bignum code. Like other cases of
749;;; non-normalized bignums, they should never escape from the lab.
750(define-header one-digit-bignum-header 1 subtag-bignum)
751(define-header two-digit-bignum-header 2 subtag-bignum)
752(define-header three-digit-bignum-header 3 subtag-bignum)
753(define-header symbol-header symbol.element-count subtag-symbol)
754(define-header value-cell-header value-cell.element-count subtag-value-cell)
755(define-header macptr-header macptr.element-count subtag-macptr)
756
757;;; see x86-clos.lisp
[9000]758(defconstant gf-code-size 30)
[6986]759
760(defun %kernel-global (sym)
761 (let* ((pos (position sym x86::*x86-kernel-globals* :test #'string=)))
762 (if pos
[8426]763 (- (+ fulltag-cons (* (1+ pos) node-size)))
[6986]764 (error "Unknown kernel global : ~s ." sym))))
765
766(defmacro kernel-global (sym)
767 (let* ((pos (position sym x86::*x86-kernel-globals* :test #'string=)))
768 (if pos
[8426]769 (- (+ fulltag-cons (* (1+ pos) node-size)))
[6986]770 (error "Unknown kernel global : ~s ." sym))))
771
772(ccl::defenum (:prefix "KERNEL-IMPORT-" :start 0 :step node-size)
773 fd-setsize-bytes
774 do-fd-set
775 do-fd-clr
776 do-fd-is-set
777 do-fd-zero
778 MakeDataExecutable
779 GetSharedLibrary
780 FindSymbol
781 malloc
782 free
[13971]783 wait-for-signal
[11659]784 tcr-frame-ptr
[11676]785 register-xmacptr-dispose-function
[11631]786 open-debug-output
[6986]787 get-r-debug
788 restore-soft-stack-limit
789 egc-control
790 lisp-bug
791 NewThread
[11749]792 cooperative-thread-startup
[6986]793 DisposeThread
794 ThreadCurrentStackSpace
795 usage-exit
796 save-fp-context
797 restore-fp-context
798 put-altivec-registers ;is there any
799 get-altivec-registers ;point to these on x86?
800 new-semaphore
801 wait-on-semaphore
802 signal-semaphore
803 destroy-semaphore
804 new-recursive-lock
805 lock-recursive-lock
806 unlock-recursive-lock
807 destroy-recursive-lock
808 suspend-other-threads
809 resume-other-threads
810 suspend-tcr
811 resume-tcr
812 rwlock-new
813 rwlock-destroy
814 rwlock-rlock
815 rwlock-wlock
816 rwlock-unlock
817 recursive-lock-trylock
818 foreign-name-and-offset
[10659]819 lisp-read
820 lisp-write
821 lisp-open
822 lisp-fchmod
823 lisp-lseek
824 lisp-close
825 lisp-ftruncate
826 lisp-stat
827 lisp-fstat
828 lisp-futex
829 lisp-opendir
830 lisp-readdir
831 lisp-closedir
[10677]832 lisp-pipe
[10816]833 lisp-gettimeofday
[12196]834 lisp-sigexit
[6986]835)
836
837(defmacro nrs-offset (name)
838 (let* ((pos (position name x86::*x86-nilreg-relative-symbols* :test #'eq)))
839 (if pos (* (1- pos) symbol.size))))
840
[7878]841(defmacro with-stack-short-floats (specs &body body)
842 (ccl::collect ((binds)
843 (inits)
844 (names))
845 (dolist (spec specs)
846 (let ((name (first spec)))
847 (binds `(,name (ccl::%make-sfloat)))
848 (names name)
849 (let ((init (second spec)))
850 (when init
851 (inits `(ccl::%short-float ,init ,name))))))
852 `(let* ,(binds)
853 (declare (dynamic-extent ,@(names))
854 (short-float ,@(names)))
855 ,@(inits)
856 ,@body)))
857
[6986]858(defparameter *x8632-target-uvector-subtags*
859 `((:bignum . ,subtag-bignum)
860 (:ratio . ,subtag-ratio)
861 (:single-float . ,subtag-single-float)
862 (:double-float . ,subtag-double-float)
863 (:complex . ,subtag-complex )
864 (:symbol . ,subtag-symbol)
865 (:function . ,subtag-function )
866 (:xcode-vector . ,subtag-xcode-vector)
867 (:macptr . ,subtag-macptr )
868 (:catch-frame . ,subtag-catch-frame)
869 (:struct . ,subtag-struct )
870 (:istruct . ,subtag-istruct )
871 (:pool . ,subtag-pool )
872 (:population . ,subtag-weak )
873 (:hash-vector . ,subtag-hash-vector )
874 (:package . ,subtag-package )
875 (:value-cell . ,subtag-value-cell)
876 (:instance . ,subtag-instance )
877 (:lock . ,subtag-lock )
878 (:slot-vector . ,subtag-slot-vector)
879 (:basic-stream . ,subtag-basic-stream)
880 (:simple-string . ,subtag-simple-base-string )
881 (:bit-vector . ,subtag-bit-vector )
882 (:signed-8-bit-vector . ,subtag-s8-vector )
883 (:unsigned-8-bit-vector . ,subtag-u8-vector )
884 (:signed-16-bit-vector . ,subtag-s16-vector )
885 (:unsigned-16-bit-vector . ,subtag-u16-vector )
886 (:signed-32-bit-vector . ,subtag-s32-vector )
887 (:fixnum-vector . ,subtag-fixnum-vector)
888 (:unsigned-32-bit-vector . ,subtag-u32-vector )
889 (:single-float-vector . ,subtag-single-float-vector)
890 (:double-float-vector . ,subtag-double-float-vector )
891 (:simple-vector . ,subtag-simple-vector )
892 (:vector-header . ,subtag-vectorH)
893 (:array-header . ,subtag-arrayH)))
894
895;;; This should return NIL unless it's sure of how the indicated
896;;; type would be represented (in particular, it should return
897;;; NIL if the element type is unknown or unspecified at compile-time.
898(defun x8632-array-type-name-from-ctype (ctype)
899 (when (typep ctype 'ccl::array-ctype)
900 (let* ((element-type (ccl::array-ctype-element-type ctype)))
901 (typecase element-type
902 (ccl::class-ctype
903 (let* ((class (ccl::class-ctype-class element-type)))
904 (if (or (eq class ccl::*character-class*)
905 (eq class ccl::*base-char-class*)
906 (eq class ccl::*standard-char-class*))
907 :simple-string
908 :simple-vector)))
909 (ccl::numeric-ctype
910 (if (eq (ccl::numeric-ctype-complexp element-type) :complex)
911 :simple-vector
912 (case (ccl::numeric-ctype-class element-type)
913 (integer
914 (let* ((low (ccl::numeric-ctype-low element-type))
915 (high (ccl::numeric-ctype-high element-type)))
916 (cond ((or (null low) (null high)) :simple-vector)
917 ((and (>= low 0) (<= high 1) :bit-vector))
918 ((and (>= low 0) (<= high 255)) :unsigned-8-bit-vector)
919 ((and (>= low 0) (<= high 65535)) :unsigned-16-bit-vector)
920 ((and (>= low 0) (<= high #xffffffff) :unsigned-32-bit-vector))
921 ((and (>= low -128) (<= high 127)) :signed-8-bit-vector)
922 ((and (>= low -32768) (<= high 32767) :signed-16-bit-vector))
923 ((and (>= low target-most-negative-fixnum)
924 (<= high target-most-positive-fixnum))
925 :fixnum-vector)
926 ((and (>= low (ash -1 31)) (<= high (1- (ash 1 31))))
927 :signed-32-bit-vector)
928 (t :simple-vector))))
929 (float
930 (case (ccl::numeric-ctype-format element-type)
931 ((double-float long-float) :double-float-vector)
932 ((single-float short-float) :single-float-vector)
933 (t :simple-vector)))
934 (t :simple-vector))))
935 (ccl::unknown-ctype)
936 (ccl::named-ctype
937 (if (eq element-type ccl::*universal-type*)
938 :simple-vector))
939 (t nil)))))
940
941(defun x8632-misc-byte-count (subtag element-count)
942 (declare (fixnum subtag))
943 (if (or (= fulltag-nodeheader (logand subtag fulltagmask))
944 (<= subtag max-32-bit-ivector-subtag))
945 (ash element-count 2)
946 (if (<= subtag max-8-bit-ivector-subtag)
947 element-count
948 (if (<= subtag max-16-bit-ivector-subtag)
949 (ash element-count 1)
950 (if (= subtag subtag-bit-vector)
951 (ash (+ element-count 7) -3)
952 (+ 4 (ash element-count 3)))))))
953
954(defparameter *x8632-subprims-shift* 2)
[10251]955(defconstant x8632-subprims-base #x15000)
[6986]956
957(declaim (special *x8632-subprims*))
958
959(let* ((origin x8632-subprims-base)
960 (step (ash 1 *x8632-subprims-shift*)))
961 (flet ((define-x8632-subprim (name)
962 (ccl::make-subprimitive-info :name (string name)
963 :offset (prog1 origin
964 (incf origin step)))))
965 (macrolet ((defx8632subprim (name)
966 `(define-x8632-subprim ',name)))
967 (defparameter *x8632-subprims*
968 (vector
969 (defx8632subprim .SPjmpsym)
970 (defx8632subprim .SPjmpnfn)
971 (defx8632subprim .SPfuncall)
972 (defx8632subprim .SPmkcatch1v)
973 (defx8632subprim .SPmkunwind)
974 (defx8632subprim .SPmkcatchmv)
975 (defx8632subprim .SPthrow)
976 (defx8632subprim .SPnthrowvalues)
977 (defx8632subprim .SPnthrow1value)
978 (defx8632subprim .SPbind)
979 (defx8632subprim .SPbind-self)
980 (defx8632subprim .SPbind-nil)
981 (defx8632subprim .SPbind-self-boundp-check)
982 (defx8632subprim .SPrplaca)
983 (defx8632subprim .SPrplacd)
984 (defx8632subprim .SPconslist)
985 (defx8632subprim .SPconslist-star)
986 (defx8632subprim .SPstkconslist)
987 (defx8632subprim .SPstkconslist-star)
988 (defx8632subprim .SPmkstackv)
989 (defx8632subprim .SPsubtag-misc-ref)
990 (defx8632subprim .SPsetqsym)
991 (defx8632subprim .SPprogvsave)
992 (defx8632subprim .SPstack-misc-alloc)
993 (defx8632subprim .SPgvector)
994 (defx8632subprim .SPnvalret)
995 (defx8632subprim .SPmvpass)
996 (defx8632subprim .SPrecover-values-for-mvcall)
997 (defx8632subprim .SPnthvalue)
998 (defx8632subprim .SPvalues)
999 (defx8632subprim .SPdefault-optional-args)
1000 (defx8632subprim .SPopt-supplied-p)
1001 (defx8632subprim .SPheap-rest-arg)
1002 (defx8632subprim .SPreq-heap-rest-arg)
1003 (defx8632subprim .SPheap-cons-rest-arg)
1004 (defx8632subprim .SPsimple-keywords)
1005 (defx8632subprim .SPkeyword-args)
1006 (defx8632subprim .SPkeyword-bind)
1007 (defx8632subprim .SPffcall)
1008 (defx8632subprim .SParef2)
1009 (defx8632subprim .SPksignalerr)
1010 (defx8632subprim .SPstack-rest-arg)
1011 (defx8632subprim .SPreq-stack-rest-arg)
1012 (defx8632subprim .SPstack-cons-rest-arg)
1013 (defx8632subprim .SPpoweropen-callbackX) ;needed on x86?
1014 (defx8632subprim .SPcall-closure)
1015 (defx8632subprim .SPgetXlong)
1016 (defx8632subprim .SPspreadargz)
1017 (defx8632subprim .SPtfuncallgen)
1018 (defx8632subprim .SPtfuncallslide)
1019 (defx8632subprim .SPtfuncallvsp)
1020 (defx8632subprim .SPtcallsymgen)
1021 (defx8632subprim .SPtcallsymslide)
1022 (defx8632subprim .SPtcallsymvsp)
1023 (defx8632subprim .SPtcallnfngen)
1024 (defx8632subprim .SPtcallnfnslide)
1025 (defx8632subprim .SPtcallnfnvsp)
1026 (defx8632subprim .SPmisc-ref)
1027 (defx8632subprim .SPmisc-set)
1028 (defx8632subprim .SPstkconsyz)
1029 (defx8632subprim .SPstkvcell0)
1030 (defx8632subprim .SPstkvcellvsp)
1031 (defx8632subprim .SPmakestackblock)
1032 (defx8632subprim .SPmakestackblock0)
1033 (defx8632subprim .SPmakestacklist)
1034 (defx8632subprim .SPstkgvector)
1035 (defx8632subprim .SPmisc-alloc)
1036 (defx8632subprim .SPpoweropen-ffcallX) ;needed on x86?
1037 (defx8632subprim .SPgvset)
1038 (defx8632subprim .SPmacro-bind)
1039 (defx8632subprim .SPdestructuring-bind)
1040 (defx8632subprim .SPdestructuring-bind-inner)
1041 (defx8632subprim .SPrecover-values)
1042 (defx8632subprim .SPvpopargregs)
1043 (defx8632subprim .SPinteger-sign)
1044 (defx8632subprim .SPsubtag-misc-set)
1045 (defx8632subprim .SPspread-lexpr-z)
1046 (defx8632subprim .SPstore-node-conditional)
1047 (defx8632subprim .SPreset)
1048 (defx8632subprim .SPmvslide)
1049 (defx8632subprim .SPsave-values)
1050 (defx8632subprim .SPadd-values)
[7816]1051 (defx8632subprim .SPcallback)
[6986]1052 (defx8632subprim .SPmisc-alloc-init)
1053 (defx8632subprim .SPstack-misc-alloc-init)
1054 (defx8632subprim .SPset-hash-key)
1055 (defx8632subprim .SPaset2)
1056 (defx8632subprim .SPcallbuiltin)
1057 (defx8632subprim .SPcallbuiltin0)
1058 (defx8632subprim .SPcallbuiltin1)
1059 (defx8632subprim .SPcallbuiltin2)
1060 (defx8632subprim .SPcallbuiltin3)
1061 (defx8632subprim .SPpopj)
1062 (defx8632subprim .SPrestorefullcontext)
1063 (defx8632subprim .SPsavecontextvsp)
1064 (defx8632subprim .SPsavecontext0)
1065 (defx8632subprim .SPrestorecontext)
1066 (defx8632subprim .SPlexpr-entry)
[8834]1067 (defx8632subprim .SPsyscall2)
[6986]1068 (defx8632subprim .SPbuiltin-plus)
1069 (defx8632subprim .SPbuiltin-minus)
1070 (defx8632subprim .SPbuiltin-times)
1071 (defx8632subprim .SPbuiltin-div)
1072 (defx8632subprim .SPbuiltin-eq)
1073 (defx8632subprim .SPbuiltin-ne)
1074 (defx8632subprim .SPbuiltin-gt)
1075 (defx8632subprim .SPbuiltin-ge)
1076 (defx8632subprim .SPbuiltin-lt)
1077 (defx8632subprim .SPbuiltin-le)
1078 (defx8632subprim .SPbuiltin-eql)
1079 (defx8632subprim .SPbuiltin-length)
1080 (defx8632subprim .SPbuiltin-seqtype)
1081 (defx8632subprim .SPbuiltin-assq)
1082 (defx8632subprim .SPbuiltin-memq)
1083 (defx8632subprim .SPbuiltin-logbitp)
1084 (defx8632subprim .SPbuiltin-logior)
1085 (defx8632subprim .SPbuiltin-logand)
1086 (defx8632subprim .SPbuiltin-ash)
1087 (defx8632subprim .SPbuiltin-negate)
1088 (defx8632subprim .SPbuiltin-logxor)
1089 (defx8632subprim .SPbuiltin-aref1)
1090 (defx8632subprim .SPbuiltin-aset1)
1091 (defx8632subprim .SPbreakpoint)
1092 (defx8632subprim .SPeabi-ff-call)
1093 (defx8632subprim .SPeabi-callback)
1094 (defx8632subprim .SPsyscall)
1095 (defx8632subprim .SPgetu64)
1096 (defx8632subprim .SPgets64)
1097 (defx8632subprim .SPmakeu64)
1098 (defx8632subprim .SPmakes64)
1099 (defx8632subprim .SPspecref)
1100 (defx8632subprim .SPspecset)
1101 (defx8632subprim .SPspecrefcheck)
1102 (defx8632subprim .SPrestoreintlevel)
1103 (defx8632subprim .SPmakes32)
1104 (defx8632subprim .SPmakeu32)
1105 (defx8632subprim .SPgets32)
1106 (defx8632subprim .SPgetu32)
1107 (defx8632subprim .SPfix-overflow)
1108 (defx8632subprim .SPmvpasssym)
1109 (defx8632subprim .SParef3)
1110 (defx8632subprim .SPaset3)
1111 (defx8632subprim .SPffcall-return-registers)
[9768]1112 (defx8632subprim .SPaset1)
[10731]1113 (defx8632subprim .SPset-hash-key-conditional)
[6986]1114 (defx8632subprim .SPunbind-interrupt-level)
1115 (defx8632subprim .SPunbind)
1116 (defx8632subprim .SPunbind-n)
1117 (defx8632subprim .SPunbind-to)
1118 (defx8632subprim .SPbind-interrupt-level-m1)
1119 (defx8632subprim .SPbind-interrupt-level)
1120 (defx8632subprim .SPbind-interrupt-level-0)
1121 (defx8632subprim .SPprogvrestore)
[7426]1122 (defx8632subprim .SPnmkunwind)
[6986]1123 )))))
1124
1125
1126
1127(defparameter *x8632-target-arch*
1128 (arch::make-target-arch :name :x8632
1129 :lisp-node-size node-size
[10959]1130 :nil-value canonical-nil-value
[6986]1131 :fixnum-shift fixnumshift
1132 :most-positive-fixnum target-most-positive-fixnum
1133 :most-negative-fixnum target-most-negative-fixnum
1134 :misc-data-offset misc-data-offset
1135 :misc-dfloat-offset misc-dfloat-offset
1136 :nbits-in-word nbits-in-word
1137 :ntagbits ntagbits
1138 :nlisptagbits nlisptagbits
1139 :uvector-subtags *x8632-target-uvector-subtags*
1140 :max-64-bit-constant-index max-64-bit-constant-index
1141 :max-32-bit-constant-index max-32-bit-constant-index
1142 :max-16-bit-constant-index max-16-bit-constant-index
1143 :max-8-bit-constant-index max-8-bit-constant-index
1144 :max-1-bit-constant-index max-1-bit-constant-index
1145 :word-shift word-shift
1146 :code-vector-prefix ()
1147 :gvector-types '(:ratio :complex :symbol :function
1148 :catch-frame :struct :istruct
1149 :pool :population :hash-vector
1150 :package :value-cell :instance
1151 :lock :slot-vector
1152 :simple-vector)
1153 :1-bit-ivector-types '(:bit-vector)
1154 :8-bit-ivector-types '(:signed-8-bit-vector
1155 :unsigned-8-bit-vector)
1156 :16-bit-ivector-types '(:signed-16-bit-vector
1157 :unsigned-16-bit-vector)
1158 :32-bit-ivector-types '(:signed-32-bit-vector
1159 :unsigned-32-bit-vector
1160 :single-float-vector
1161 :fixnum-vector
1162 :single-float
1163 :double-float
1164 :bignum
1165 :simple-string)
1166 :64-bit-ivector-types '(:double-float-vector)
1167 :array-type-name-from-ctype-function
1168 #'x8632-array-type-name-from-ctype
1169 :package-name "X8632"
1170 :t-offset t-offset
1171 :array-data-size-function #'x8632-misc-byte-count
1172 :numeric-type-name-to-typecode-function
1173 #'(lambda (type-name)
1174 (ecase type-name
1175 (fixnum tag-fixnum)
1176 (bignum subtag-bignum)
1177 ((short-float single-float) subtag-single-float)
1178 ((long-float double-float) subtag-double-float)
1179 (ratio subtag-ratio)
1180 (complex subtag-complex)))
1181 :subprims-base x8632-subprims-base
1182 :subprims-shift x8632::*x8632-subprims-shift*
1183 :subprims-table x8632::*x8632-subprims*
1184 :primitive->subprims `(((0 . 23) . ,(ccl::%subprim-name->offset '.SPbuiltin-plus x8632::*x8632-subprims*)))
1185 :unbound-marker-value unbound-marker
1186 :slot-unbound-marker-value slot-unbound-marker
1187 :fixnum-tag tag-fixnum
1188 :single-float-tag subtag-single-float
1189 :single-float-tag-is-subtag t
1190 :double-float-tag subtag-double-float
1191 :cons-tag fulltag-cons
1192 :null-tag fulltag-cons
1193 :symbol-tag subtag-symbol
1194 :symbol-tag-is-subtag t
1195 :function-tag subtag-function
1196 :function-tag-is-subtag t
1197 :big-endian nil
1198 :misc-subtag-offset misc-subtag-offset
1199 :car-offset cons.car
1200 :cdr-offset cons.cdr
1201 :subtag-char subtag-character
1202 :charcode-shift charcode-shift
1203 :fulltagmask fulltagmask
1204 :fulltag-misc fulltag-misc
1205 :char-code-limit #x110000
1206 ))
1207
1208;; arch macros
1209
1210(defmacro defx8632archmacro (name lambda-list &body body)
1211 `(arch::defarchmacro :x8632 ,name ,lambda-list ,@body))
1212
1213(defx8632archmacro ccl::%make-sfloat ()
1214 `(ccl::%alloc-misc x8632::single-float.element-count x8632::subtag-single-float))
1215
1216(defx8632archmacro ccl::%make-dfloat ()
1217 `(ccl::%alloc-misc x8632::double-float.element-count x8632::subtag-double-float))
1218
1219(defx8632archmacro ccl::%numerator (x)
1220 `(ccl::%svref ,x x8632::ratio.numer-cell))
1221
1222(defx8632archmacro ccl::%denominator (x)
1223 `(ccl::%svref ,x x8632::ratio.denom-cell))
1224
1225(defx8632archmacro ccl::%realpart (x)
1226 `(ccl::%svref ,x x8632::complex.realpart-cell))
1227
1228(defx8632archmacro ccl::%imagpart (x)
1229 `(ccl::%svref ,x x8632::complex.imagpart-cell))
1230
1231;;;
1232(defx8632archmacro ccl::%get-single-float-from-double-ptr (ptr offset)
1233 `(ccl::%double-float->short-float (ccl::%get-double-float ,ptr ,offset)
1234 (ccl::%alloc-misc 1 x8632::subtag-single-float)))
1235
1236(defx8632archmacro ccl::codevec-header-p (word)
1237 (declare (ignore word))
1238 (error "~s makes no sense on :X8632" 'ccl::codevec-header-p))
1239
1240(defx8632archmacro ccl::immediate-p-macro (thing)
1241 (let* ((tag (gensym)))
1242 `(let* ((,tag (ccl::lisptag ,thing)))
1243 (declare (fixnum ,tag))
1244 (or (= ,tag x8632::tag-fixnum)
1245 (= ,tag x8632::tag-imm)))))
1246
1247(defx8632archmacro ccl::hashed-by-identity (thing)
1248 (let* ((typecode (gensym)))
1249 `(let* ((,typecode (ccl::typecode ,thing)))
1250 (declare (fixnum ,typecode))
1251 (or
1252 (= ,typecode x8632::tag-fixnum)
1253 (= ,typecode x8632::tag-imm)
1254 (= ,typecode x8632::subtag-symbol)
1255 (= ,typecode x8632::subtag-instance)))))
1256
1257;;;
1258(defx8632archmacro ccl::%get-kernel-global (name)
[10959]1259 `(ccl::%fixnum-ref 0 (+ ,(ccl::target-nil-value)
[6986]1260 ,(%kernel-global
1261 (if (ccl::quoted-form-p name)
1262 (cadr name)
1263 name)))))
1264
[7771]1265(defx8632archmacro ccl::%get-kernel-global-ptr (name dest)
1266 `(ccl::%setf-macptr
1267 ,dest
[10959]1268 (ccl::%fixnum-ref-macptr 0 (+ ,(ccl::target-nil-value)
[7771]1269 ,(%kernel-global
1270 (if (ccl::quoted-form-p name)
1271 (cadr name)
1272 name))))))
1273
[6986]1274(defx8632archmacro ccl::%target-kernel-global (name)
1275 `(x8632::%kernel-global ,name))
1276
1277(defx8632archmacro ccl::lfun-vector (fun)
[9190]1278 fun)
[6986]1279
1280(defx8632archmacro ccl::lfun-vector-lfun (lfv)
[9190]1281 lfv)
[6986]1282
1283(defx8632archmacro ccl::area-code ()
1284 area.code)
1285
1286(defx8632archmacro ccl::area-succ ()
1287 area.succ)
1288
1289(defx8632archmacro ccl::nth-immediate (f i)
1290 `(ccl::%nth-immediate ,f (the fixnum (- (the fixnum ,i) 1))))
1291
1292(defx8632archmacro ccl::set-nth-immediate (f i new)
1293 `(ccl::%set-nth-immediate ,f (the fixnum (- (the fixnum ,i) 1)) ,new))
1294
1295(defx8632archmacro ccl::symptr->symvector (s)
[7262]1296 s)
[6986]1297
1298(defx8632archmacro ccl::symvector->symptr (s)
[7262]1299 s)
[6986]1300
1301(defx8632archmacro ccl::function-to-function-vector (f)
[7262]1302 f)
[6986]1303
1304(defx8632archmacro ccl::function-vector-to-function (v)
[7262]1305 v)
[6986]1306
1307(defx8632archmacro ccl::with-ffcall-results ((buf) &body body)
1308 ;; Reserve space for eax,edx,st0 only.
1309 (let* ((size (+ (* 2 4) (* 1 8))))
1310 `(ccl::%stack-block ((,buf ,size :clear t))
1311 ,@body)))
1312
[7962]1313;;; When found at a tagged return address, the instruction
1314;;; (movl ($ imm32) (% fn))
1315;;; lets the runtime easily map a return address to the containing
1316;;; function.
1317;;;
1318;;; The notation ($ :self) is used in the assembler to mean "a 32-bit
1319;;; immediate whose offset will be remembered in a table at the end of
1320;;; the function object."
1321;;;
1322;;; Before the function is made executable (or when the GC moves the
1323;;; function), these :self immediates are filled in with the actual
1324;;; address of the function.
1325
1326(defconstant recover-fn-opcode-byte #b10111111) ;when %fn is %edi
1327(defconstant recover-fn-address-offset 1)
1328
[10251]1329;;; For backtrace: the relative PC of an argument-check trap
1330;;; must be less than or equal to this value. (Because of
1331;;; the way that we do "anchored" UUOs, it should always be =.)
1332;;; (maybe not = on x8632)
1333(defconstant arg-check-trap-pc-limit 7)
1334
[6986]1335(provide "X8632-ARCH")
Note: See TracBrowser for help on using the repository browser.