Move definition of N-BYTE-BITS.
[sbcl.git] / src / compiler / alpha / parms.lisp
blobe498b82ccd35617c983cee651b8ba2ac7687c976
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
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.
10 (in-package "SB!VM")
12 (eval-when (:compile-toplevel :load-toplevel :execute)
14 ;;; number of bits per word where a word holds one lisp descriptor
15 (defconstant n-word-bits 32)
17 ;;; the natural width of a machine word (as seen in e.g. register width,
18 ;;; address space)
19 (defconstant n-machine-word-bits 64)
21 (defconstant float-sign-shift 31)
23 (defconstant single-float-bias 126)
24 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
25 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
26 (defconstant single-float-normal-exponent-min 1)
27 (defconstant single-float-normal-exponent-max 254)
28 (defconstant single-float-hidden-bit (ash 1 23))
29 (defconstant single-float-trapping-nan-bit (ash 1 22))
31 (defconstant double-float-bias 1022)
32 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
33 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
34 (defconstant double-float-normal-exponent-min 1)
35 (defconstant double-float-normal-exponent-max #x7FE)
36 (defconstant double-float-hidden-bit (ash 1 20))
37 (defconstant double-float-trapping-nan-bit (ash 1 19))
39 (defconstant single-float-digits
40 (+ (byte-size single-float-significand-byte) 1))
42 (defconstant double-float-digits
43 (+ (byte-size double-float-significand-byte) n-word-bits 1))
45 ;;; These values are originally from the DEC Assembly Language
46 ;;; Programmers guide. Where possible we read/write the software
47 ;;; fp_control word, which apparently is necessary for the OS FPU
48 ;;; completion (OS handler which fixes up non-IEEE answers that the
49 ;;; hardware occasionally gives us) to work properly. The rounding
50 ;;; mode, however, can't be set that way, so we have to deal with that
51 ;;; directly. (FIXME: we actually don't suport setting the rounding mode
52 ;;; at the moment anyway)
54 ;;; Short guide to floating point trap terminology: an "exception" is
55 ;;; cheap and can happen at almost any time. An exception will only
56 ;;; generate a trap if that trap is enabled, otherwise a default value
57 ;;; will be substituted. A "trap" will end up somewhere in the
58 ;;; kernel, which may play by its own rules, (on Alpha it allegedly
59 ;;; actually fixes up some non-IEEE compliant results to get the
60 ;;; _right_ answer) but if something is really wrong will eventually
61 ;;; signal SIGFPE and let us sort it out.
63 ;;; Old comment follows: The active bits are actually in (byte 12 52)
64 ;;; of the fpcr. (byte 6 52) contain the exception flags. Bit 63 is the
65 ;;; bitwise logor of all exceptions. The enable and exception bytes
66 ;;; are in a software control word manipulated via OS functions and the
67 ;;; bits in the SCP match those defs. This mapping follows
68 ;;; <machine/fpu.h>
70 ;;; trap enables are set in software (fp_control)
71 (defconstant float-inexact-trap-bit (ash 1 4)) ; rw
72 (defconstant float-underflow-trap-bit (ash 1 3)) ; rw
73 (defconstant float-overflow-trap-bit (ash 1 2)) ; ro
74 (defconstant float-divide-by-zero-trap-bit (ash 1 1)) ; ro
75 (defconstant float-invalid-trap-bit (ash 1 0)) ; ro
76 (defconstant-eqx float-traps-byte (byte 6 1) #'equalp)
78 ;;; exceptions are also read/written in software (by syscalls, no less).
79 ;;; This is kind of dumb, but has to be done
80 (defconstant-eqx float-sticky-bits (byte 6 17) #'equalp) ; fp_control
82 ;;; (We don't actually _have_ "current exceptions" on Alpha; the
83 ;;; hardware only ever sets bits. So, set this the same as accrued
84 ;;; exceptions)
85 (defconstant-eqx float-exceptions-byte (byte 6 17) #'equalp)
87 ;;; Rounding modes can only be set by frobbing the hardware fpcr directly
88 (defconstant float-round-to-zero 0)
89 (defconstant float-round-to-negative 1)
90 (defconstant float-round-to-nearest 2)
91 (defconstant float-round-to-positive 3)
92 (defconstant-eqx float-rounding-mode (byte 2 58) #'equalp)
94 ;;; Miscellaneous stuff - I think it's far to say that you deserve
95 ;;; what you get if you ask for fast mode.
96 (defconstant float-fast-bit 0)
98 ); eval-when
102 ;;;; Description of the target address space.
104 ;;; Where to put the different spaces.
107 #!+linux
108 (progn
109 (defconstant read-only-space-start #x20000000)
110 (defconstant read-only-space-end #x24000000))
112 #!+osf1
113 (progn
114 (defconstant read-only-space-start #x10000000)
115 (defconstant read-only-space-end #x25000000))
118 (defconstant static-space-start #x28000000)
119 (defconstant static-space-end #x2c000000)
121 (defconstant dynamic-0-space-start #x30000000)
122 (defconstant dynamic-0-space-end #x3fff0000)
124 (defconstant dynamic-1-space-start #x40000000)
125 (defconstant dynamic-1-space-end #x4fff0000)
127 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
128 ;;; backend, so they could probably be removed.
130 ;; The space-register holding the lisp heap.
131 (defconstant lisp-heap-space 4)
133 ;; The space-register holding the C text segment.
134 (defconstant c-text-space 4)
136 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
137 ;;; here, but it seems to be the only port that needs to know the
138 ;;; location of NIL from lisp.
140 ;;;; other miscellaneous constants
142 (defenum (:start 8)
143 halt-trap
144 pending-interrupt-trap
145 error-trap
146 cerror-trap
147 breakpoint-trap
148 fun-end-breakpoint-trap
149 single-step-breakpoint-trap
150 ;; Stepper actually not implemented on Alpha, but these constants
151 ;; are still needed to avoid undefined variable warnings during sbcl
152 ;; build.
153 single-step-around-trap
154 single-step-before-trap)
156 ;;;; static symbols
158 ;;; These symbols are loaded into static space directly after NIL so
159 ;;; that the system can compute their address by adding a constant
160 ;;; amount to NIL.
162 ;;; The fdefn objects for the static functions are loaded into static
163 ;;; space directly after the static symbols. That way, the raw-addr
164 ;;; can be loaded directly out of them by indirecting relative to NIL.
166 (defparameter *static-symbols*
167 (append
168 *common-static-symbols*
169 *c-callable-static-symbols*
170 '()))
172 (defparameter *static-funs*
173 '(length
174 two-arg-+
175 two-arg--
176 two-arg-*
177 two-arg-/
178 two-arg-<
179 two-arg->
180 two-arg-=
181 ;; FIXME: Is this
182 ;; probably need the following as they are defined in
183 ;; arith.lisp: two-arg-<= two-arg->= two-arg-/=
184 ;; a comment from old CMU CL or old old CMU CL or
185 ;; the SBCL alpha port or what? Do we need to worry about it,
186 ;; or can we delete it?
187 two-arg-/=
189 %negate
190 two-arg-and
191 two-arg-ior
192 two-arg-xor
193 two-arg-eqv
194 two-arg-gcd
195 two-arg-lcm))