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

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

Merge trunk changes r13066 through r13067.
(copyright notices)

File size: 43.5 KB
RevLine 
[6986]1;;;-*- Mode: Lisp; Package: (X8632 :use CL) -*-
2
[13075]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
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
579(eval-when (:compile-toplevel :load-toplevel :execute)
580 (defconstant tcr-bias 0))
581
582(define-storage-layout tcr (- tcr-bias)
[7023]583 next ; in doubly-linked list
[6986]584 prev ; in doubly-linked list
585 node-regs-mask ; bit set means corresponding reg contains node
586 linear
[7962]587 ;; save0 *must* be aligned on a 16-byte boundary!
588 save0 ;spill area for node registers
589 save1 ; (caller saved)
590 save2 ; probably saved/restored in
591 save3 ; callout/trap handlers
[6986]592 save-ebp ; lisp frame ptr for foreign code
[7262]593 lisp-mxcsr
594 foreign-mxcsr
[6986]595 db-link ; special binding chain head
596 catch-top ; top catch frame
597 save-vsp ; SP when in foreign code
598 save-tsp ; TSP, at all times
599 foreign-sp ; SP when in lisp code
600 cs-area ; cstack area pointer
601 vs-area ; vstack area pointer
602 ts-area ; tstack area pointer
603 cs-limit ; cstack overflow limit
[7262]604 total-bytes-allocated-low
605 total-bytes-allocated-high
[6986]606 log2-allocation-quantum ; unboxed
607 interrupt-pending ; fixnum
608 xframe ; exception frame linked list
609 errno-loc ; thread-private, maybe
610 ffi-exception ; fpscr bits from ff-call.
611 osid ; OS thread id
612 valence ; odd when in foreign code
613 foreign-exception-status
614 native-thread-info
615 native-thread-id
616 last-allocptr
617 save-allocptr
618 save-allocbase
619 reset-completion
620 activate
621 suspend-count
622 suspend-context
623 pending-exception-context
624 suspend ; semaphore for suspension notify
625 resume ; sempahore for resumption notify
626 flags ; foreign, being reset, ...
627 gc-context
628 termination-semaphore
629 unwinding
630 tlb-limit
631 tlb-pointer
632 shutdown-count
633 next-tsp
634 safe-ref-address
[7037]635 ldt-selector
[8075]636 scratch-mxcsr ;used for reading/writing mxcsr
[9000]637 unboxed0 ;unboxed scratch locations
638 unboxed1
[9039]639 next-method-context ;used in lieu of register
[10251]640 save-eflags
[10936]641 allocated ;maybe unaligned TCR pointer
[11093]642 pending-io-info
643 io-datum ;for windows overlapped I/O
[6986]644)
645
646(defconstant interrupt-level-binding-index (ash 1 fixnumshift))
647
648(define-storage-layout lockptr 0
649 avail
650 owner
651 count
652 signal
653 waiting
654 malloced-ptr
655 spinlock)
656
[10251]657(define-storage-layout rwlock 0
658 spin
659 state
660 blocked-writers
661 blocked-readers
662 writer
663 reader-signal
664 writer-signal
665 malloced-ptr
666 )
667
[6986]668(defmacro define-header (name element-count subtag)
669 `(defconstant ,name (logior (ash ,element-count num-subtag-bits) ,subtag)))
670
671(define-header single-float-header single-float.element-count subtag-single-float)
672(define-header double-float-header double-float.element-count subtag-double-float)
673
674;;; We could possibly have a one-digit bignum header when dealing
675;;; with "small bignums" in some bignum code. Like other cases of
676;;; non-normalized bignums, they should never escape from the lab.
677(define-header one-digit-bignum-header 1 subtag-bignum)
678(define-header two-digit-bignum-header 2 subtag-bignum)
679(define-header three-digit-bignum-header 3 subtag-bignum)
680(define-header symbol-header symbol.element-count subtag-symbol)
681(define-header value-cell-header value-cell.element-count subtag-value-cell)
682(define-header macptr-header macptr.element-count subtag-macptr)
683
684;;; see x86-clos.lisp
[9000]685(defconstant gf-code-size 30)
[6986]686
687(defun %kernel-global (sym)
688 (let* ((pos (position sym x86::*x86-kernel-globals* :test #'string=)))
689 (if pos
[8426]690 (- (+ fulltag-cons (* (1+ pos) node-size)))
[6986]691 (error "Unknown kernel global : ~s ." sym))))
692
693(defmacro kernel-global (sym)
694 (let* ((pos (position sym x86::*x86-kernel-globals* :test #'string=)))
695 (if pos
[8426]696 (- (+ fulltag-cons (* (1+ pos) node-size)))
[6986]697 (error "Unknown kernel global : ~s ." sym))))
698
699(ccl::defenum (:prefix "KERNEL-IMPORT-" :start 0 :step node-size)
700 fd-setsize-bytes
701 do-fd-set
702 do-fd-clr
703 do-fd-is-set
704 do-fd-zero
705 MakeDataExecutable
706 GetSharedLibrary
707 FindSymbol
708 malloc
709 free
[11379]710 jvm-init
[11659]711 tcr-frame-ptr
[11676]712 register-xmacptr-dispose-function
[11631]713 open-debug-output
[6986]714 get-r-debug
715 restore-soft-stack-limit
716 egc-control
717 lisp-bug
718 NewThread
[11749]719 cooperative-thread-startup
[6986]720 DisposeThread
721 ThreadCurrentStackSpace
722 usage-exit
723 save-fp-context
724 restore-fp-context
725 put-altivec-registers ;is there any
726 get-altivec-registers ;point to these on x86?
727 new-semaphore
728 wait-on-semaphore
729 signal-semaphore
730 destroy-semaphore
731 new-recursive-lock
732 lock-recursive-lock
733 unlock-recursive-lock
734 destroy-recursive-lock
735 suspend-other-threads
736 resume-other-threads
737 suspend-tcr
738 resume-tcr
739 rwlock-new
740 rwlock-destroy
741 rwlock-rlock
742 rwlock-wlock
743 rwlock-unlock
744 recursive-lock-trylock
745 foreign-name-and-offset
[10659]746 lisp-read
747 lisp-write
748 lisp-open
749 lisp-fchmod
750 lisp-lseek
751 lisp-close
752 lisp-ftruncate
753 lisp-stat
754 lisp-fstat
755 lisp-futex
756 lisp-opendir
757 lisp-readdir
758 lisp-closedir
[10677]759 lisp-pipe
[10816]760 lisp-gettimeofday
[12196]761 lisp-sigexit
[6986]762)
763
764(defmacro nrs-offset (name)
765 (let* ((pos (position name x86::*x86-nilreg-relative-symbols* :test #'eq)))
766 (if pos (* (1- pos) symbol.size))))
767
[7878]768(defmacro with-stack-short-floats (specs &body body)
769 (ccl::collect ((binds)
770 (inits)
771 (names))
772 (dolist (spec specs)
773 (let ((name (first spec)))
774 (binds `(,name (ccl::%make-sfloat)))
775 (names name)
776 (let ((init (second spec)))
777 (when init
778 (inits `(ccl::%short-float ,init ,name))))))
779 `(let* ,(binds)
780 (declare (dynamic-extent ,@(names))
781 (short-float ,@(names)))
782 ,@(inits)
783 ,@body)))
784
[6986]785(defparameter *x8632-target-uvector-subtags*
786 `((:bignum . ,subtag-bignum)
787 (:ratio . ,subtag-ratio)
788 (:single-float . ,subtag-single-float)
789 (:double-float . ,subtag-double-float)
790 (:complex . ,subtag-complex )
791 (:symbol . ,subtag-symbol)
792 (:function . ,subtag-function )
793 (:xcode-vector . ,subtag-xcode-vector)
794 (:macptr . ,subtag-macptr )
795 (:catch-frame . ,subtag-catch-frame)
796 (:struct . ,subtag-struct )
797 (:istruct . ,subtag-istruct )
798 (:pool . ,subtag-pool )
799 (:population . ,subtag-weak )
800 (:hash-vector . ,subtag-hash-vector )
801 (:package . ,subtag-package )
802 (:value-cell . ,subtag-value-cell)
803 (:instance . ,subtag-instance )
804 (:lock . ,subtag-lock )
805 (:slot-vector . ,subtag-slot-vector)
806 (:basic-stream . ,subtag-basic-stream)
807 (:simple-string . ,subtag-simple-base-string )
808 (:bit-vector . ,subtag-bit-vector )
809 (:signed-8-bit-vector . ,subtag-s8-vector )
810 (:unsigned-8-bit-vector . ,subtag-u8-vector )
811 (:signed-16-bit-vector . ,subtag-s16-vector )
812 (:unsigned-16-bit-vector . ,subtag-u16-vector )
813 (:signed-32-bit-vector . ,subtag-s32-vector )
814 (:fixnum-vector . ,subtag-fixnum-vector)
815 (:unsigned-32-bit-vector . ,subtag-u32-vector )
816 (:single-float-vector . ,subtag-single-float-vector)
817 (:double-float-vector . ,subtag-double-float-vector )
818 (:simple-vector . ,subtag-simple-vector )
819 (:vector-header . ,subtag-vectorH)
820 (:array-header . ,subtag-arrayH)))
821
822;;; This should return NIL unless it's sure of how the indicated
823;;; type would be represented (in particular, it should return
824;;; NIL if the element type is unknown or unspecified at compile-time.
825(defun x8632-array-type-name-from-ctype (ctype)
826 (when (typep ctype 'ccl::array-ctype)
827 (let* ((element-type (ccl::array-ctype-element-type ctype)))
828 (typecase element-type
829 (ccl::class-ctype
830 (let* ((class (ccl::class-ctype-class element-type)))
831 (if (or (eq class ccl::*character-class*)
832 (eq class ccl::*base-char-class*)
833 (eq class ccl::*standard-char-class*))
834 :simple-string
835 :simple-vector)))
836 (ccl::numeric-ctype
837 (if (eq (ccl::numeric-ctype-complexp element-type) :complex)
838 :simple-vector
839 (case (ccl::numeric-ctype-class element-type)
840 (integer
841 (let* ((low (ccl::numeric-ctype-low element-type))
842 (high (ccl::numeric-ctype-high element-type)))
843 (cond ((or (null low) (null high)) :simple-vector)
844 ((and (>= low 0) (<= high 1) :bit-vector))
845 ((and (>= low 0) (<= high 255)) :unsigned-8-bit-vector)
846 ((and (>= low 0) (<= high 65535)) :unsigned-16-bit-vector)
847 ((and (>= low 0) (<= high #xffffffff) :unsigned-32-bit-vector))
848 ((and (>= low -128) (<= high 127)) :signed-8-bit-vector)
849 ((and (>= low -32768) (<= high 32767) :signed-16-bit-vector))
850 ((and (>= low target-most-negative-fixnum)
851 (<= high target-most-positive-fixnum))
852 :fixnum-vector)
853 ((and (>= low (ash -1 31)) (<= high (1- (ash 1 31))))
854 :signed-32-bit-vector)
855 (t :simple-vector))))
856 (float
857 (case (ccl::numeric-ctype-format element-type)
858 ((double-float long-float) :double-float-vector)
859 ((single-float short-float) :single-float-vector)
860 (t :simple-vector)))
861 (t :simple-vector))))
862 (ccl::unknown-ctype)
863 (ccl::named-ctype
864 (if (eq element-type ccl::*universal-type*)
865 :simple-vector))
866 (t nil)))))
867
868(defun x8632-misc-byte-count (subtag element-count)
869 (declare (fixnum subtag))
870 (if (or (= fulltag-nodeheader (logand subtag fulltagmask))
871 (<= subtag max-32-bit-ivector-subtag))
872 (ash element-count 2)
873 (if (<= subtag max-8-bit-ivector-subtag)
874 element-count
875 (if (<= subtag max-16-bit-ivector-subtag)
876 (ash element-count 1)
877 (if (= subtag subtag-bit-vector)
878 (ash (+ element-count 7) -3)
879 (+ 4 (ash element-count 3)))))))
880
881(defparameter *x8632-subprims-shift* 2)
[10251]882(defconstant x8632-subprims-base #x15000)
[6986]883
884(declaim (special *x8632-subprims*))
885
886(let* ((origin x8632-subprims-base)
887 (step (ash 1 *x8632-subprims-shift*)))
888 (flet ((define-x8632-subprim (name)
889 (ccl::make-subprimitive-info :name (string name)
890 :offset (prog1 origin
891 (incf origin step)))))
892 (macrolet ((defx8632subprim (name)
893 `(define-x8632-subprim ',name)))
894 (defparameter *x8632-subprims*
895 (vector
896 (defx8632subprim .SPjmpsym)
897 (defx8632subprim .SPjmpnfn)
898 (defx8632subprim .SPfuncall)
899 (defx8632subprim .SPmkcatch1v)
900 (defx8632subprim .SPmkunwind)
901 (defx8632subprim .SPmkcatchmv)
902 (defx8632subprim .SPthrow)
903 (defx8632subprim .SPnthrowvalues)
904 (defx8632subprim .SPnthrow1value)
905 (defx8632subprim .SPbind)
906 (defx8632subprim .SPbind-self)
907 (defx8632subprim .SPbind-nil)
908 (defx8632subprim .SPbind-self-boundp-check)
909 (defx8632subprim .SPrplaca)
910 (defx8632subprim .SPrplacd)
911 (defx8632subprim .SPconslist)
912 (defx8632subprim .SPconslist-star)
913 (defx8632subprim .SPstkconslist)
914 (defx8632subprim .SPstkconslist-star)
915 (defx8632subprim .SPmkstackv)
916 (defx8632subprim .SPsubtag-misc-ref)
917 (defx8632subprim .SPsetqsym)
918 (defx8632subprim .SPprogvsave)
919 (defx8632subprim .SPstack-misc-alloc)
920 (defx8632subprim .SPgvector)
921 (defx8632subprim .SPnvalret)
922 (defx8632subprim .SPmvpass)
923 (defx8632subprim .SPrecover-values-for-mvcall)
924 (defx8632subprim .SPnthvalue)
925 (defx8632subprim .SPvalues)
926 (defx8632subprim .SPdefault-optional-args)
927 (defx8632subprim .SPopt-supplied-p)
928 (defx8632subprim .SPheap-rest-arg)
929 (defx8632subprim .SPreq-heap-rest-arg)
930 (defx8632subprim .SPheap-cons-rest-arg)
931 (defx8632subprim .SPsimple-keywords)
932 (defx8632subprim .SPkeyword-args)
933 (defx8632subprim .SPkeyword-bind)
934 (defx8632subprim .SPffcall)
935 (defx8632subprim .SParef2)
936 (defx8632subprim .SPksignalerr)
937 (defx8632subprim .SPstack-rest-arg)
938 (defx8632subprim .SPreq-stack-rest-arg)
939 (defx8632subprim .SPstack-cons-rest-arg)
940 (defx8632subprim .SPpoweropen-callbackX) ;needed on x86?
941 (defx8632subprim .SPcall-closure)
942 (defx8632subprim .SPgetXlong)
943 (defx8632subprim .SPspreadargz)
944 (defx8632subprim .SPtfuncallgen)
945 (defx8632subprim .SPtfuncallslide)
946 (defx8632subprim .SPtfuncallvsp)
947 (defx8632subprim .SPtcallsymgen)
948 (defx8632subprim .SPtcallsymslide)
949 (defx8632subprim .SPtcallsymvsp)
950 (defx8632subprim .SPtcallnfngen)
951 (defx8632subprim .SPtcallnfnslide)
952 (defx8632subprim .SPtcallnfnvsp)
953 (defx8632subprim .SPmisc-ref)
954 (defx8632subprim .SPmisc-set)
955 (defx8632subprim .SPstkconsyz)
956 (defx8632subprim .SPstkvcell0)
957 (defx8632subprim .SPstkvcellvsp)
958 (defx8632subprim .SPmakestackblock)
959 (defx8632subprim .SPmakestackblock0)
960 (defx8632subprim .SPmakestacklist)
961 (defx8632subprim .SPstkgvector)
962 (defx8632subprim .SPmisc-alloc)
963 (defx8632subprim .SPpoweropen-ffcallX) ;needed on x86?
964 (defx8632subprim .SPgvset)
965 (defx8632subprim .SPmacro-bind)
966 (defx8632subprim .SPdestructuring-bind)
967 (defx8632subprim .SPdestructuring-bind-inner)
968 (defx8632subprim .SPrecover-values)
969 (defx8632subprim .SPvpopargregs)
970 (defx8632subprim .SPinteger-sign)
971 (defx8632subprim .SPsubtag-misc-set)
972 (defx8632subprim .SPspread-lexpr-z)
973 (defx8632subprim .SPstore-node-conditional)
974 (defx8632subprim .SPreset)
975 (defx8632subprim .SPmvslide)
976 (defx8632subprim .SPsave-values)
977 (defx8632subprim .SPadd-values)
[7816]978 (defx8632subprim .SPcallback)
[6986]979 (defx8632subprim .SPmisc-alloc-init)
980 (defx8632subprim .SPstack-misc-alloc-init)
981 (defx8632subprim .SPset-hash-key)
982 (defx8632subprim .SPaset2)
983 (defx8632subprim .SPcallbuiltin)
984 (defx8632subprim .SPcallbuiltin0)
985 (defx8632subprim .SPcallbuiltin1)
986 (defx8632subprim .SPcallbuiltin2)
987 (defx8632subprim .SPcallbuiltin3)
988 (defx8632subprim .SPpopj)
989 (defx8632subprim .SPrestorefullcontext)
990 (defx8632subprim .SPsavecontextvsp)
991 (defx8632subprim .SPsavecontext0)
992 (defx8632subprim .SPrestorecontext)
993 (defx8632subprim .SPlexpr-entry)
[8834]994 (defx8632subprim .SPsyscall2)
[6986]995 (defx8632subprim .SPbuiltin-plus)
996 (defx8632subprim .SPbuiltin-minus)
997 (defx8632subprim .SPbuiltin-times)
998 (defx8632subprim .SPbuiltin-div)
999 (defx8632subprim .SPbuiltin-eq)
1000 (defx8632subprim .SPbuiltin-ne)
1001 (defx8632subprim .SPbuiltin-gt)
1002 (defx8632subprim .SPbuiltin-ge)
1003 (defx8632subprim .SPbuiltin-lt)
1004 (defx8632subprim .SPbuiltin-le)
1005 (defx8632subprim .SPbuiltin-eql)
1006 (defx8632subprim .SPbuiltin-length)
1007 (defx8632subprim .SPbuiltin-seqtype)
1008 (defx8632subprim .SPbuiltin-assq)
1009 (defx8632subprim .SPbuiltin-memq)
1010 (defx8632subprim .SPbuiltin-logbitp)
1011 (defx8632subprim .SPbuiltin-logior)
1012 (defx8632subprim .SPbuiltin-logand)
1013 (defx8632subprim .SPbuiltin-ash)
1014 (defx8632subprim .SPbuiltin-negate)
1015 (defx8632subprim .SPbuiltin-logxor)
1016 (defx8632subprim .SPbuiltin-aref1)
1017 (defx8632subprim .SPbuiltin-aset1)
1018 (defx8632subprim .SPbreakpoint)
1019 (defx8632subprim .SPeabi-ff-call)
1020 (defx8632subprim .SPeabi-callback)
1021 (defx8632subprim .SPsyscall)
1022 (defx8632subprim .SPgetu64)
1023 (defx8632subprim .SPgets64)
1024 (defx8632subprim .SPmakeu64)
1025 (defx8632subprim .SPmakes64)
1026 (defx8632subprim .SPspecref)
1027 (defx8632subprim .SPspecset)
1028 (defx8632subprim .SPspecrefcheck)
1029 (defx8632subprim .SPrestoreintlevel)
1030 (defx8632subprim .SPmakes32)
1031 (defx8632subprim .SPmakeu32)
1032 (defx8632subprim .SPgets32)
1033 (defx8632subprim .SPgetu32)
1034 (defx8632subprim .SPfix-overflow)
1035 (defx8632subprim .SPmvpasssym)
1036 (defx8632subprim .SParef3)
1037 (defx8632subprim .SPaset3)
1038 (defx8632subprim .SPffcall-return-registers)
[9768]1039 (defx8632subprim .SPaset1)
[10731]1040 (defx8632subprim .SPset-hash-key-conditional)
[6986]1041 (defx8632subprim .SPunbind-interrupt-level)
1042 (defx8632subprim .SPunbind)
1043 (defx8632subprim .SPunbind-n)
1044 (defx8632subprim .SPunbind-to)
1045 (defx8632subprim .SPbind-interrupt-level-m1)
1046 (defx8632subprim .SPbind-interrupt-level)
1047 (defx8632subprim .SPbind-interrupt-level-0)
1048 (defx8632subprim .SPprogvrestore)
[7426]1049 (defx8632subprim .SPnmkunwind)
[6986]1050 )))))
1051
1052
1053
1054(defparameter *x8632-target-arch*
1055 (arch::make-target-arch :name :x8632
1056 :lisp-node-size node-size
[10959]1057 :nil-value canonical-nil-value
[6986]1058 :fixnum-shift fixnumshift
1059 :most-positive-fixnum target-most-positive-fixnum
1060 :most-negative-fixnum target-most-negative-fixnum
1061 :misc-data-offset misc-data-offset
1062 :misc-dfloat-offset misc-dfloat-offset
1063 :nbits-in-word nbits-in-word
1064 :ntagbits ntagbits
1065 :nlisptagbits nlisptagbits
1066 :uvector-subtags *x8632-target-uvector-subtags*
1067 :max-64-bit-constant-index max-64-bit-constant-index
1068 :max-32-bit-constant-index max-32-bit-constant-index
1069 :max-16-bit-constant-index max-16-bit-constant-index
1070 :max-8-bit-constant-index max-8-bit-constant-index
1071 :max-1-bit-constant-index max-1-bit-constant-index
1072 :word-shift word-shift
1073 :code-vector-prefix ()
1074 :gvector-types '(:ratio :complex :symbol :function
1075 :catch-frame :struct :istruct
1076 :pool :population :hash-vector
1077 :package :value-cell :instance
1078 :lock :slot-vector
1079 :simple-vector)
1080 :1-bit-ivector-types '(:bit-vector)
1081 :8-bit-ivector-types '(:signed-8-bit-vector
1082 :unsigned-8-bit-vector)
1083 :16-bit-ivector-types '(:signed-16-bit-vector
1084 :unsigned-16-bit-vector)
1085 :32-bit-ivector-types '(:signed-32-bit-vector
1086 :unsigned-32-bit-vector
1087 :single-float-vector
1088 :fixnum-vector
1089 :single-float
1090 :double-float
1091 :bignum
1092 :simple-string)
1093 :64-bit-ivector-types '(:double-float-vector)
1094 :array-type-name-from-ctype-function
1095 #'x8632-array-type-name-from-ctype
1096 :package-name "X8632"
1097 :t-offset t-offset
1098 :array-data-size-function #'x8632-misc-byte-count
1099 :numeric-type-name-to-typecode-function
1100 #'(lambda (type-name)
1101 (ecase type-name
1102 (fixnum tag-fixnum)
1103 (bignum subtag-bignum)
1104 ((short-float single-float) subtag-single-float)
1105 ((long-float double-float) subtag-double-float)
1106 (ratio subtag-ratio)
1107 (complex subtag-complex)))
1108 :subprims-base x8632-subprims-base
1109 :subprims-shift x8632::*x8632-subprims-shift*
1110 :subprims-table x8632::*x8632-subprims*
1111 :primitive->subprims `(((0 . 23) . ,(ccl::%subprim-name->offset '.SPbuiltin-plus x8632::*x8632-subprims*)))
1112 :unbound-marker-value unbound-marker
1113 :slot-unbound-marker-value slot-unbound-marker
1114 :fixnum-tag tag-fixnum
1115 :single-float-tag subtag-single-float
1116 :single-float-tag-is-subtag t
1117 :double-float-tag subtag-double-float
1118 :cons-tag fulltag-cons
1119 :null-tag fulltag-cons
1120 :symbol-tag subtag-symbol
1121 :symbol-tag-is-subtag t
1122 :function-tag subtag-function
1123 :function-tag-is-subtag t
1124 :big-endian nil
1125 :misc-subtag-offset misc-subtag-offset
1126 :car-offset cons.car
1127 :cdr-offset cons.cdr
1128 :subtag-char subtag-character
1129 :charcode-shift charcode-shift
1130 :fulltagmask fulltagmask
1131 :fulltag-misc fulltag-misc
1132 :char-code-limit #x110000
1133 ))
1134
1135;; arch macros
1136
1137(defmacro defx8632archmacro (name lambda-list &body body)
1138 `(arch::defarchmacro :x8632 ,name ,lambda-list ,@body))
1139
1140(defx8632archmacro ccl::%make-sfloat ()
1141 `(ccl::%alloc-misc x8632::single-float.element-count x8632::subtag-single-float))
1142
1143(defx8632archmacro ccl::%make-dfloat ()
1144 `(ccl::%alloc-misc x8632::double-float.element-count x8632::subtag-double-float))
1145
1146(defx8632archmacro ccl::%numerator (x)
1147 `(ccl::%svref ,x x8632::ratio.numer-cell))
1148
1149(defx8632archmacro ccl::%denominator (x)
1150 `(ccl::%svref ,x x8632::ratio.denom-cell))
1151
1152(defx8632archmacro ccl::%realpart (x)
1153 `(ccl::%svref ,x x8632::complex.realpart-cell))
1154
1155(defx8632archmacro ccl::%imagpart (x)
1156 `(ccl::%svref ,x x8632::complex.imagpart-cell))
1157
1158;;;
1159(defx8632archmacro ccl::%get-single-float-from-double-ptr (ptr offset)
1160 `(ccl::%double-float->short-float (ccl::%get-double-float ,ptr ,offset)
1161 (ccl::%alloc-misc 1 x8632::subtag-single-float)))
1162
1163(defx8632archmacro ccl::codevec-header-p (word)
1164 (declare (ignore word))
1165 (error "~s makes no sense on :X8632" 'ccl::codevec-header-p))
1166
1167(defx8632archmacro ccl::immediate-p-macro (thing)
1168 (let* ((tag (gensym)))
1169 `(let* ((,tag (ccl::lisptag ,thing)))
1170 (declare (fixnum ,tag))
1171 (or (= ,tag x8632::tag-fixnum)
1172 (= ,tag x8632::tag-imm)))))
1173
1174(defx8632archmacro ccl::hashed-by-identity (thing)
1175 (let* ((typecode (gensym)))
1176 `(let* ((,typecode (ccl::typecode ,thing)))
1177 (declare (fixnum ,typecode))
1178 (or
1179 (= ,typecode x8632::tag-fixnum)
1180 (= ,typecode x8632::tag-imm)
1181 (= ,typecode x8632::subtag-symbol)
1182 (= ,typecode x8632::subtag-instance)))))
1183
1184;;;
1185(defx8632archmacro ccl::%get-kernel-global (name)
[10959]1186 `(ccl::%fixnum-ref 0 (+ ,(ccl::target-nil-value)
[6986]1187 ,(%kernel-global
1188 (if (ccl::quoted-form-p name)
1189 (cadr name)
1190 name)))))
1191
[7771]1192(defx8632archmacro ccl::%get-kernel-global-ptr (name dest)
1193 `(ccl::%setf-macptr
1194 ,dest
[10959]1195 (ccl::%fixnum-ref-macptr 0 (+ ,(ccl::target-nil-value)
[7771]1196 ,(%kernel-global
1197 (if (ccl::quoted-form-p name)
1198 (cadr name)
1199 name))))))
1200
[6986]1201(defx8632archmacro ccl::%target-kernel-global (name)
1202 `(x8632::%kernel-global ,name))
1203
1204(defx8632archmacro ccl::lfun-vector (fun)
[9190]1205 fun)
[6986]1206
1207(defx8632archmacro ccl::lfun-vector-lfun (lfv)
[9190]1208 lfv)
[6986]1209
1210(defx8632archmacro ccl::area-code ()
1211 area.code)
1212
1213(defx8632archmacro ccl::area-succ ()
1214 area.succ)
1215
1216(defx8632archmacro ccl::nth-immediate (f i)
1217 `(ccl::%nth-immediate ,f (the fixnum (- (the fixnum ,i) 1))))
1218
1219(defx8632archmacro ccl::set-nth-immediate (f i new)
1220 `(ccl::%set-nth-immediate ,f (the fixnum (- (the fixnum ,i) 1)) ,new))
1221
1222(defx8632archmacro ccl::symptr->symvector (s)
[7262]1223 s)
[6986]1224
1225(defx8632archmacro ccl::symvector->symptr (s)
[7262]1226 s)
[6986]1227
1228(defx8632archmacro ccl::function-to-function-vector (f)
[7262]1229 f)
[6986]1230
1231(defx8632archmacro ccl::function-vector-to-function (v)
[7262]1232 v)
[6986]1233
1234(defx8632archmacro ccl::with-ffcall-results ((buf) &body body)
1235 ;; Reserve space for eax,edx,st0 only.
1236 (let* ((size (+ (* 2 4) (* 1 8))))
1237 `(ccl::%stack-block ((,buf ,size :clear t))
1238 ,@body)))
1239
[7962]1240;;; When found at a tagged return address, the instruction
1241;;; (movl ($ imm32) (% fn))
1242;;; lets the runtime easily map a return address to the containing
1243;;; function.
1244;;;
1245;;; The notation ($ :self) is used in the assembler to mean "a 32-bit
1246;;; immediate whose offset will be remembered in a table at the end of
1247;;; the function object."
1248;;;
1249;;; Before the function is made executable (or when the GC moves the
1250;;; function), these :self immediates are filled in with the actual
1251;;; address of the function.
1252
1253(defconstant recover-fn-opcode-byte #b10111111) ;when %fn is %edi
1254(defconstant recover-fn-address-offset 1)
1255
[10251]1256;;; For backtrace: the relative PC of an argument-check trap
1257;;; must be less than or equal to this value. (Because of
1258;;; the way that we do "anchored" UUOs, it should always be =.)
1259;;; (maybe not = on x8632)
1260(defconstant arg-check-trap-pc-limit 7)
1261
[6986]1262(provide "X8632-ARCH")
Note: See TracBrowser for help on using the repository browser.