0.8.1.50
[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 ;;; the natural width of a machine word (as seen in e.g. register width,
19 ;;; address space)
20 (def!constant n-machine-word-bits 64)
21
22 (def!constant n-byte-bits 8
23   #!+sb-doc
24   "Number of bits per byte where a byte is the smallest addressable object.")
25
26 (def!constant word-shift (1- (integer-length (/ n-word-bits n-byte-bits)))
27   #!+sb-doc
28   "Number of bits to shift between word addresses and byte addresses.")
29
30 (def!constant n-word-bytes (/ n-word-bits n-byte-bits)
31   #!+sb-doc
32   "Number of bytes in a word.")
33
34 (def!constant float-sign-shift 31)
35
36 (def!constant single-float-bias 126)
37 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
38 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
39 (def!constant single-float-normal-exponent-min 1)
40 (def!constant single-float-normal-exponent-max 254)
41 (def!constant single-float-hidden-bit (ash 1 23))
42 (def!constant single-float-trapping-nan-bit (ash 1 22))
43
44 (def!constant double-float-bias 1022)
45 (defconstant-eqx double-float-exponent-byte (byte 11 20)   #'equalp)
46 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
47 (def!constant double-float-normal-exponent-min 1)
48 (def!constant double-float-normal-exponent-max #x7FE)
49 (def!constant double-float-hidden-bit (ash 1 20))
50 (def!constant double-float-trapping-nan-bit (ash 1 19))
51
52 (def!constant single-float-digits
53   (+ (byte-size single-float-significand-byte) 1))
54
55 (def!constant double-float-digits
56   (+ (byte-size double-float-significand-byte) n-word-bits 1))
57
58 ;;; These values are originally from the DEC Assembly Language
59 ;;; Programmers guide.  Where possible we read/write the software
60 ;;; fp_control word, which apparently is necessary for the OS FPU
61 ;;; completion (OS handler which fixes up non-IEEE answers that the
62 ;;; hardware occasionally gives us) to work properly.  The rounding
63 ;;; mode, however, can't be set that way, so we have to deal with that
64 ;;; directly.  (FIXME: we actually don't suport setting the rounding mode
65 ;;; at the moment anyway)
66
67 ;;; Short guide to floating point trap terminology: an "exception" is
68 ;;; cheap and can happen at almost any time.  An exception will only
69 ;;; generate a trap if that trap is enabled, otherwise a default value
70 ;;; will be substituted.  A "trap" will end up somewhere in the
71 ;;; kernel, which may play by its own rules,  (on Alpha it allegedly
72 ;;; actually fixes up some non-IEEE compliant results to get the
73 ;;; _right_ answer) but if something is really wrong will eventually
74 ;;; signal SIGFPE and let us sort it out.
75
76 ;;; Old comment follows: The active bits are actually in (byte 12 52)
77 ;;; of the fpcr. (byte 6 52) contain the exception flags. Bit 63 is the
78 ;;; bitwise logor of all exceptions.  The enable and exception bytes
79 ;;; are in a software control word manipulated via OS functions and the
80 ;;; bits in the SCP match those defs. This mapping follows
81 ;;; <machine/fpu.h>
82
83 ;;; trap enables are set in software (fp_control)
84 (def!constant float-inexact-trap-bit        (ash 1 4)) ; rw
85 (def!constant float-underflow-trap-bit      (ash 1 3)) ; rw
86 (def!constant float-overflow-trap-bit       (ash 1 2)) ; ro
87 (def!constant float-divide-by-zero-trap-bit (ash 1 1)) ; ro
88 (def!constant float-invalid-trap-bit        (ash 1 0)) ; ro
89 (defconstant-eqx float-traps-byte          (byte 6  1) #'equalp)  
90
91 ;;; exceptions are also read/written in software (by syscalls, no less).
92 ;;; This is kind of dumb, but has to be done
93 (defconstant-eqx float-sticky-bits     (byte 6 17) #'equalp)    ; fp_control
94
95 ;;; (We don't actually _have_ "current exceptions" on Alpha; the
96 ;;; hardware only ever sets bits.  So, set this the same as accrued
97 ;;; exceptions)
98 (defconstant-eqx float-exceptions-byte (byte 6 17)  #'equalp)
99
100 ;;; Rounding modes can only be set by frobbing the hardware fpcr directly
101 (def!constant float-round-to-zero     0)
102 (def!constant float-round-to-negative 1)
103 (def!constant float-round-to-nearest  2)
104 (def!constant float-round-to-positive 3)
105 (defconstant-eqx float-rounding-mode   (byte 2 58) #'equalp) 
106
107 ;;; Miscellaneous stuff - I think it's far to say that you deserve
108 ;;; what you get if you ask for fast mode.
109 (def!constant float-fast-bit 0)
110
111 ); eval-when
112
113
114 \f
115 ;;;; Description of the target address space.
116
117 ;;; Where to put the different spaces.
118 ;;;
119
120 #!+linux
121 (progn
122   (def!constant read-only-space-start #x20000000)
123   (def!constant read-only-space-end   #x24000000))
124
125 #!+osf1
126 (progn
127   (defconstant read-only-space-start #x10000000)
128   (defconstant read-only-space-end   #x25000000))
129
130
131 (def!constant static-space-start    #x28000000)
132 (def!constant static-space-end      #x2c000000)
133
134 ;; this is used in PURIFY as part of a sloppy check to see if a pointer
135 ;; is in dynamic space.  Chocolate brownie for the first person to fix it
136 ;; -dan 20010502
137 (def!constant dynamic-space-start   #x30000000)
138 (def!constant dynamic-space-end     #x3fff0000)
139
140 (def!constant dynamic-0-space-start   #x30000000)
141 (def!constant dynamic-0-space-end     #x3fff0000)
142
143 (def!constant dynamic-1-space-start   #x40000000)
144 (def!constant dynamic-1-space-end     #x4fff0000)
145
146 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
147 ;;; backend, so they could probably be removed.
148
149 ;; The space-register holding the lisp heap.
150 (def!constant lisp-heap-space 4)
151
152 ;; The space-register holding the C text segment.
153 (def!constant c-text-space 4)
154
155 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
156 ;;; here, but it seems to be the only port that needs to know the
157 ;;; location of NIL from lisp.
158 \f
159 ;;;; other miscellaneous constants
160
161 (defenum (:suffix -trap :start 8)
162   halt
163   pending-interrupt
164   error
165   cerror
166   breakpoint
167   fun-end-breakpoint
168   single-step-breakpoint)
169
170 (defenum (:prefix trace-table-)
171   normal
172   call-site
173   fun-prologue
174   fun-epilogue)
175 \f
176 ;;;; static symbols
177
178 ;;; These symbols are loaded into static space directly after NIL so
179 ;;; that the system can compute their address by adding a constant
180 ;;; amount to NIL.
181 ;;;
182 ;;; The fdefn objects for the static functions are loaded into static
183 ;;; space directly after the static symbols.  That way, the raw-addr
184 ;;; can be loaded directly out of them by indirecting relative to NIL.
185 ;;;
186 (defparameter *static-symbols*
187   '(t
188
189     ;; The C startup code must fill these in.
190     *posix-argv*
191
192     ;; functions that the C code needs to call
193     sub-gc
194     sb!kernel::internal-error
195     sb!kernel::control-stack-exhausted-error
196     sb!di::handle-breakpoint
197     sb!di::handle-fun-end-breakpoint
198
199     ;; free pointers
200     *read-only-space-free-pointer*
201     *static-space-free-pointer*
202     *initial-dynamic-space-free-pointer*
203
204     ;; things needed for non-local exit
205     *current-catch-block*
206     *current-unwind-protect-block*
207
208     *binding-stack-start*
209     *control-stack-start*
210     *control-stack-end*
211
212     ;; interrupt handling
213     *free-interrupt-context-index*
214     sb!unix::*interrupts-enabled*
215     sb!unix::*interrupt-pending*))
216
217 (defparameter *static-funs*
218   '(length
219     sb!kernel:two-arg-+
220     sb!kernel:two-arg--
221     sb!kernel:two-arg-*
222     sb!kernel:two-arg-/
223     sb!kernel:two-arg-<
224     sb!kernel:two-arg->
225     sb!kernel:two-arg-=
226     ;; FIXME: Is this
227     ;;     probably need the following as they are defined in 
228     ;;     arith.lisp: two-arg-<= two-arg->= two-arg-/= 
229     ;; a comment from old CMU CL or old old CMU CL or
230     ;; the SBCL alpha port or what? Do we need to worry about it,
231     ;; or can we delete it?
232     eql
233     sb!kernel:%negate
234     sb!kernel:two-arg-and
235     sb!kernel:two-arg-ior
236     sb!kernel:two-arg-xor
237     sb!kernel:two-arg-gcd
238     sb!kernel:two-arg-lcm))