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 ;;; number of bits per word where a word holds one lisp descriptor
15 (def!constant n-word-bits 32)
17 ;;; the natural width of a machine word (as seen in e.g. register width,
19 (def!constant n-machine-word-bits 64)
21 ;;; number of bits per byte where a byte is the smallest addressable
23 (def!constant n-byte-bits 8)
25 (def!constant float-sign-shift 31)
27 (def!constant single-float-bias 126)
28 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
29 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
30 (def!constant single-float-normal-exponent-min 1)
31 (def!constant single-float-normal-exponent-max 254)
32 (def!constant single-float-hidden-bit (ash 1 23))
33 (def!constant single-float-trapping-nan-bit (ash 1 22))
35 (def!constant double-float-bias 1022)
36 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
37 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
38 (def!constant double-float-normal-exponent-min 1)
39 (def!constant double-float-normal-exponent-max #x7FE)
40 (def!constant double-float-hidden-bit (ash 1 20))
41 (def!constant double-float-trapping-nan-bit (ash 1 19))
43 (def!constant single-float-digits
44 (+ (byte-size single-float-significand-byte) 1))
46 (def!constant double-float-digits
47 (+ (byte-size double-float-significand-byte) n-word-bits 1))
49 ;;; These values are originally from the DEC Assembly Language
50 ;;; Programmers guide. Where possible we read/write the software
51 ;;; fp_control word, which apparently is necessary for the OS FPU
52 ;;; completion (OS handler which fixes up non-IEEE answers that the
53 ;;; hardware occasionally gives us) to work properly. The rounding
54 ;;; mode, however, can't be set that way, so we have to deal with that
55 ;;; directly. (FIXME: we actually don't suport setting the rounding mode
56 ;;; at the moment anyway)
58 ;;; Short guide to floating point trap terminology: an "exception" is
59 ;;; cheap and can happen at almost any time. An exception will only
60 ;;; generate a trap if that trap is enabled, otherwise a default value
61 ;;; will be substituted. A "trap" will end up somewhere in the
62 ;;; kernel, which may play by its own rules, (on Alpha it allegedly
63 ;;; actually fixes up some non-IEEE compliant results to get the
64 ;;; _right_ answer) but if something is really wrong will eventually
65 ;;; signal SIGFPE and let us sort it out.
67 ;;; Old comment follows: The active bits are actually in (byte 12 52)
68 ;;; of the fpcr. (byte 6 52) contain the exception flags. Bit 63 is the
69 ;;; bitwise logor of all exceptions. The enable and exception bytes
70 ;;; are in a software control word manipulated via OS functions and the
71 ;;; bits in the SCP match those defs. This mapping follows
74 ;;; trap enables are set in software (fp_control)
75 (def!constant float-inexact-trap-bit (ash 1 4)) ; rw
76 (def!constant float-underflow-trap-bit (ash 1 3)) ; rw
77 (def!constant float-overflow-trap-bit (ash 1 2)) ; ro
78 (def!constant float-divide-by-zero-trap-bit (ash 1 1)) ; ro
79 (def!constant float-invalid-trap-bit (ash 1 0)) ; ro
80 (defconstant-eqx float-traps-byte (byte 6 1) #'equalp)
82 ;;; exceptions are also read/written in software (by syscalls, no less).
83 ;;; This is kind of dumb, but has to be done
84 (defconstant-eqx float-sticky-bits (byte 6 17) #'equalp) ; fp_control
86 ;;; (We don't actually _have_ "current exceptions" on Alpha; the
87 ;;; hardware only ever sets bits. So, set this the same as accrued
89 (defconstant-eqx float-exceptions-byte (byte 6 17) #'equalp)
91 ;;; Rounding modes can only be set by frobbing the hardware fpcr directly
92 (def!constant float-round-to-zero 0)
93 (def!constant float-round-to-negative 1)
94 (def!constant float-round-to-nearest 2)
95 (def!constant float-round-to-positive 3)
96 (defconstant-eqx float-rounding-mode (byte 2 58) #'equalp)
98 ;;; Miscellaneous stuff - I think it's far to say that you deserve
99 ;;; what you get if you ask for fast mode.
100 (def!constant float-fast-bit 0)
106 ;;;; Description of the target address space.
108 ;;; Where to put the different spaces.
113 (def!constant read-only-space-start #x20000000)
114 (def!constant read-only-space-end #x24000000))
118 (defconstant read-only-space-start #x10000000)
119 (defconstant read-only-space-end #x25000000))
122 (def!constant static-space-start #x28000000)
123 (def!constant static-space-end #x2c000000)
125 (def!constant dynamic-0-space-start #x30000000)
126 (def!constant dynamic-0-space-end #x3fff0000)
128 (def!constant dynamic-1-space-start #x40000000)
129 (def!constant dynamic-1-space-end #x4fff0000)
131 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
132 ;;; backend, so they could probably be removed.
134 ;; The space-register holding the lisp heap.
135 (def!constant lisp-heap-space 4)
137 ;; The space-register holding the C text segment.
138 (def!constant c-text-space 4)
140 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
141 ;;; here, but it seems to be the only port that needs to know the
142 ;;; location of NIL from lisp.
144 ;;;; other miscellaneous constants
146 (defenum (:suffix -trap :start 8)
153 single-step-breakpoint
154 ;; Stepper actually not implemented on Alpha, but these constants
155 ;; are still needed to avoid undefined variable warnings during sbcl
160 (defenum (:prefix trace-table-)
168 ;;; These symbols are loaded into static space directly after NIL so
169 ;;; that the system can compute their address by adding a constant
172 ;;; The fdefn objects for the static functions are loaded into static
173 ;;; space directly after the static symbols. That way, the raw-addr
174 ;;; can be loaded directly out of them by indirecting relative to NIL.
176 (defparameter *static-symbols*
178 *common-static-symbols*
179 *c-callable-static-symbols*
182 (defparameter *static-funs*
192 ;; probably need the following as they are defined in
193 ;; arith.lisp: two-arg-<= two-arg->= two-arg-/=
194 ;; a comment from old CMU CL or old old CMU CL or
195 ;; the SBCL alpha port or what? Do we need to worry about it,
196 ;; or can we delete it?
200 sb!kernel:two-arg-and
201 sb!kernel:two-arg-ior
202 sb!kernel:two-arg-xor
203 sb!kernel:two-arg-eqv
204 sb!kernel:two-arg-gcd
205 sb!kernel:two-arg-lcm))