5bb22132e3e64171e4b880b8ad6085a42ebe7a0f
[sbcl.git] / src / compiler / alpha / parms.lisp
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.
9
10 (in-package "SB!VM")
11
12 (eval-when  (:compile-toplevel :load-toplevel :execute)
13
14 (def!constant n-word-bits 32
15   #!+sb-doc
16   "Number of bits per word where a word holds one lisp descriptor.")
17
18 (def!constant n-byte-bits 8
19   #!+sb-doc
20   "Number of bits per byte where a byte is the smallest addressable object.")
21
22 (def!constant word-shift (1- (integer-length (/ n-word-bits n-byte-bits)))
23   #!+sb-doc
24   "Number of bits to shift between word addresses and byte addresses.")
25
26 (def!constant n-word-bytes (/ n-word-bits n-byte-bits)
27   #!+sb-doc
28   "Number of bytes in a word.")
29
30 (def!constant float-sign-shift 31)
31
32 (def!constant 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 (def!constant single-float-normal-exponent-min 1)
36 (def!constant single-float-normal-exponent-max 254)
37 (def!constant single-float-hidden-bit (ash 1 23))
38 (def!constant single-float-trapping-nan-bit (ash 1 22))
39
40 (def!constant 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 (def!constant double-float-normal-exponent-min 1)
44 (def!constant double-float-normal-exponent-max #x7FE)
45 (def!constant double-float-hidden-bit (ash 1 20))
46 (def!constant double-float-trapping-nan-bit (ash 1 19))
47
48 (def!constant single-float-digits
49   (+ (byte-size single-float-significand-byte) 1))
50
51 (def!constant double-float-digits
52   (+ (byte-size double-float-significand-byte) n-word-bits 1))
53
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)
62
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.
71
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
77 ;;; <machine/fpu.h>
78
79 ;;; trap enables are set in software (fp_control)
80 (def!constant float-inexact-trap-bit        (ash 1 4)) ; rw
81 (def!constant float-underflow-trap-bit      (ash 1 3)) ; rw
82 (def!constant float-overflow-trap-bit       (ash 1 2)) ; ro
83 (def!constant float-divide-by-zero-trap-bit (ash 1 1)) ; ro
84 (def!constant float-invalid-trap-bit        (ash 1 0)) ; ro
85 (defconstant-eqx float-traps-byte          (byte 6  1) #'equalp)  
86
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
90
91 ;;; (We don't actually _have_ "current exceptions" on Alpha; the
92 ;;; hardware only ever sets bits.  So, set this the same as accrued
93 ;;; exceptions)
94 (defconstant-eqx float-exceptions-byte (byte 6 17)  #'equalp)
95
96 ;;; Rounding modes can only be set by frobbing the hardware fpcr directly
97 (def!constant float-round-to-zero     0)
98 (def!constant float-round-to-negative 1)
99 (def!constant float-round-to-nearest  2)
100 (def!constant float-round-to-positive 3)
101 (defconstant-eqx float-rounding-mode   (byte 2 58) #'equalp) 
102
103 ;;; Miscellaneous stuff - I think it's far to say that you deserve
104 ;;; what you get if you ask for fast mode.
105 (def!constant float-fast-bit 0)
106
107 ); eval-when
108
109
110 \f
111 ;;;; Description of the target address space.
112
113 ;;; Where to put the different spaces.
114 ;;;
115
116 #!+linux
117 (progn
118   (def!constant read-only-space-start #x20000000)
119   (def!constant read-only-space-end   #x24000000))
120
121 #!+osf1
122 (progn
123   (defconstant read-only-space-start #x10000000)
124   (defconstant read-only-space-end   #x25000000))
125
126
127 (def!constant static-space-start    #x28000000)
128 (def!constant static-space-end      #x2c000000)
129
130 ;; this is used in PURIFY as part of a sloppy check to see if a pointer
131 ;; is in dynamic space.  Chocolate brownie for the first person to fix it
132 ;; -dan 20010502
133 (def!constant dynamic-space-start   #x30000000)
134 (def!constant dynamic-space-end     #x3fff0000)
135
136 (def!constant dynamic-0-space-start   #x30000000)
137 (def!constant dynamic-0-space-end     #x3fff0000)
138
139 (def!constant dynamic-1-space-start   #x40000000)
140 (def!constant dynamic-1-space-end     #x4fff0000)
141
142 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
143 ;;; backend, so they could probably be removed.
144
145 ;; The space-register holding the lisp heap.
146 (def!constant lisp-heap-space 4)
147
148 ;; The space-register holding the C text segment.
149 (def!constant c-text-space 4)
150
151 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
152 ;;; here, but it seems to be the only port that needs to know the
153 ;;; location of NIL from lisp.
154 \f
155 ;;;; other miscellaneous constants
156
157 (defenum (:suffix -trap :start 8)
158   halt
159   pending-interrupt
160   error
161   cerror
162   breakpoint
163   fun-end-breakpoint
164   single-step-breakpoint)
165
166 (defenum (:prefix trace-table-)
167   normal
168   call-site
169   fun-prologue
170   fun-epilogue)
171 \f
172 ;;;; static symbols
173
174 ;;; These symbols are loaded into static space directly after NIL so
175 ;;; that the system can compute their address by adding a constant
176 ;;; amount to NIL.
177 ;;;
178 ;;; The fdefn objects for the static functions are loaded into static
179 ;;; space directly after the static symbols.  That way, the raw-addr
180 ;;; can be loaded directly out of them by indirecting relative to NIL.
181 ;;;
182 (defparameter *static-symbols*
183   '(t
184
185     ;; The C startup code must fill these in.
186     *posix-argv*
187
188     ;; functions that the C code needs to call
189     maybe-gc
190     sb!kernel::internal-error
191     sb!kernel::control-stack-exhausted-error
192     sb!di::handle-breakpoint
193     sb!di::handle-fun-end-breakpoint
194
195     ;; free pointers
196     *read-only-space-free-pointer*
197     *static-space-free-pointer*
198     *initial-dynamic-space-free-pointer*
199
200     ;; things needed for non-local exit
201     *current-catch-block*
202     *current-unwind-protect-block*
203
204     *binding-stack-start*
205     *control-stack-start*
206     *control-stack-end*
207
208     ;; interrupt handling
209     *free-interrupt-context-index*
210     sb!unix::*interrupts-enabled*
211     sb!unix::*interrupt-pending*))
212
213 (defparameter *static-funs*
214   '(length
215     sb!kernel:two-arg-+
216     sb!kernel:two-arg--
217     sb!kernel:two-arg-*
218     sb!kernel:two-arg-/
219     sb!kernel:two-arg-<
220     sb!kernel:two-arg->
221     sb!kernel:two-arg-=
222     ;; FIXME: Is this
223     ;;     probably need the following as they are defined in 
224     ;;     arith.lisp: two-arg-<= two-arg->= two-arg-/= 
225     ;; a comment from old CMU CL or old old CMU CL or
226     ;; the SBCL alpha port or what? Do we need to worry about it,
227     ;; or can we delete it?
228     eql
229     sb!kernel:%negate
230     sb!kernel:two-arg-and
231     sb!kernel:two-arg-ior
232     sb!kernel:two-arg-xor
233     sb!kernel:two-arg-gcd
234     sb!kernel:two-arg-lcm))