1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
12 (eval-when (:compile-toplevel :load-toplevel :execute)
14 (defconstant n-word-bits 32
16 "Number of bits per word where a word holds one lisp descriptor.")
18 (defconstant n-byte-bits 8
20 "Number of bits per byte where a byte is the smallest addressable object.")
22 (defconstant word-shift (1- (integer-length (/ n-word-bits n-byte-bits)))
24 "Number of bits to shift between word addresses and byte addresses.")
26 (defconstant n-word-bytes (/ n-word-bits n-byte-bits)
28 "Number of bytes in a word.")
30 (defconstant float-sign-shift 31)
32 (defconstant single-float-bias 126)
33 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
34 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
35 (defconstant single-float-normal-exponent-min 1)
36 (defconstant single-float-normal-exponent-max 254)
37 (defconstant single-float-hidden-bit (ash 1 23))
38 (defconstant single-float-trapping-nan-bit (ash 1 22))
40 (defconstant double-float-bias 1022)
41 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
42 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
43 (defconstant double-float-normal-exponent-min 1)
44 (defconstant double-float-normal-exponent-max #x7FE)
45 (defconstant double-float-hidden-bit (ash 1 20))
46 (defconstant double-float-trapping-nan-bit (ash 1 19))
48 (defconstant single-float-digits
49 (+ (byte-size single-float-significand-byte) 1))
51 (defconstant double-float-digits
52 (+ (byte-size double-float-significand-byte) n-word-bits 1))
54 ;;; These values are originally from the DEC Assembly Language
55 ;;; Programmers guide. Where possible we read/write the software
56 ;;; fp_control word, which apparently is necessary for the OS FPU
57 ;;; completion (OS handler which fixes up non-IEEE answers that the
58 ;;; hardware occasionally gives us) to work properly. The rounding
59 ;;; mode, however, can't be set that way, so we have to deal with that
60 ;;; directly. (FIXME: we actually don't suport setting the rounding mode
61 ;;; at the moment anyway)
63 ;;; Short guide to floating point trap terminology: an "exception" is
64 ;;; cheap and can happen at almost any time. An exception will only
65 ;;; generate a trap if that trap is enabled, otherwise a default value
66 ;;; will be substituted. A "trap" will end up somewhere in the
67 ;;; kernel, which may play by its own rules, (on Alpha it allegedly
68 ;;; actually fixes up some non-IEEE compliant results to get the
69 ;;; _right_ answer) but if something is really wrong will eventually
70 ;;; signal SIGFPE and let us sort it out.
72 ;;; Old comment follows: The active bits are actually in (byte 12 52)
73 ;;; of the fpcr. (byte 6 52) contain the exception flags. Bit 63 is the
74 ;;; bitwise logor of all exceptions. The enable and exception bytes
75 ;;; are in a software control word manipulated via OS functions and the
76 ;;; bits in the SCP match those defs. This mapping follows
79 ;;; trap enables are set in software (fp_control)
80 (defconstant float-inexact-trap-bit (ash 1 4)) ; rw
81 (defconstant float-underflow-trap-bit (ash 1 3)) ; rw
82 (defconstant float-overflow-trap-bit (ash 1 2)) ; ro
83 (defconstant float-divide-by-zero-trap-bit (ash 1 1)) ; ro
84 (defconstant float-invalid-trap-bit (ash 1 0)) ; ro
85 (defconstant-eqx float-traps-byte (byte 6 1) #'equalp)
87 ;;; exceptions are also read/written in software (by syscalls, no less).
88 ;;; This is kind of dumb, but has to be done
89 (defconstant-eqx float-sticky-bits (byte 6 17) #'equalp) ; fp_control
91 ;;; (We don't actually _have_ "current exceptions" on Alpha; the
92 ;;; hardware only ever sets bits. So, set this the same as accrued
94 (defconstant-eqx float-exceptions-byte (byte 6 17) #'equalp)
96 ;;; Rounding modes can only be set by frobbing the hardware fpcr directly
97 (defconstant float-round-to-zero 0)
98 (defconstant float-round-to-negative 1)
99 (defconstant float-round-to-nearest 2)
100 (defconstant float-round-to-positive 3)
101 (defconstant-eqx float-rounding-mode (byte 2 58) #'equalp)
103 ;;; Miscellaneous stuff - I think it's far to say that you deserve
104 ;;; what you get if you ask for fast mode.
105 (defconstant float-fast-bit 0)
111 ;;;; Description of the target address space.
113 ;;; Where to put the different spaces.
118 (defconstant read-only-space-start #x20000000)
119 (defconstant read-only-space-end #x24000000)
121 (defconstant static-space-start #x28000000)
122 (defconstant static-space-end #x2c000000)
124 ;; this is used in PURIFY as part of a sloppy check to see if a pointer
125 ;; is in dynamic space. Chocolate brownie for the first person to fix it
127 (defconstant dynamic-space-start #x30000000)
128 (defconstant dynamic-space-end #x3fff0000)
130 (defconstant dynamic-0-space-start #x30000000)
131 (defconstant dynamic-0-space-end #x3fff0000)
133 (defconstant dynamic-1-space-start #x40000000)
134 (defconstant dynamic-1-space-end #x4fff0000)
136 (defconstant control-stack-start #x50000000)
137 (defconstant control-stack-end #x51000000)
139 (defconstant binding-stack-start #x70000000)
140 (defconstant binding-stack-end #x71000000))
144 (defparameter read-only-space-start #x10000000)
145 (defparameter static-space-start #x28000000)
146 (defparameter dynamic-space-start #x30000000))
149 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
150 ;;; backend, so they could probably be removed.
152 ;; The space-register holding the lisp heap.
153 (defconstant lisp-heap-space 4)
155 ;; The space-register holding the C text segment.
156 (defconstant c-text-space 4)
158 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
159 ;;; here, but it seems to be the only port that needs to know the
160 ;;; location of NIL from lisp.
162 ;;;; other miscellaneous constants
164 (defenum (:suffix -trap :start 8)
171 single-step-breakpoint)
173 (defenum (:prefix trace-table-)
181 ;;; These symbols are loaded into static space directly after NIL so
182 ;;; that the system can compute their address by adding a constant
185 ;;; The fdefn objects for the static functions are loaded into static
186 ;;; space directly after the static symbols. That way, the raw-addr
187 ;;; can be loaded directly out of them by indirecting relative to NIL.
189 (defparameter *static-symbols*
192 ;; The C startup code must fill these in.
194 ;;lisp::lisp-environment-list
195 ;;lisp::lisp-command-line-list
196 sb!impl::*!initial-fdefn-objects*
198 ;; Functions that the C code needs to call
200 sb!kernel::internal-error
201 sb!di::handle-breakpoint
202 sb!di::handle-fun-end-breakpoint
205 *read-only-space-free-pointer*
206 *static-space-free-pointer*
207 *initial-dynamic-space-free-pointer*
209 ;; things needed for non-local exit
210 *current-catch-block*
211 *current-unwind-protect-block*
213 ;; interrupt handling
214 *free-interrupt-context-index*
215 sb!unix::*interrupts-enabled*
216 sb!unix::*interrupt-pending*))
218 (defparameter *static-funs*
228 ;; probably need the following as they are defined in
229 ;; arith.lisp: two-arg-<= two-arg->= two-arg-/=
230 ;; a comment from old CMU CL or old old CMU CL or
231 ;; the SBCL alpha port or what? Do we need to worry about it,
232 ;; or can we delete it?
235 sb!kernel:two-arg-and
236 sb!kernel:two-arg-ior
237 sb!kernel:two-arg-xor
238 sb!kernel:two-arg-gcd
239 sb!kernel:two-arg-lcm))