0.7.3.18:
[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   (def!constant static-space-start    #x28000000)
122   (def!constant static-space-end      #x2c000000)
123
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
126   ;; -dan 20010502
127   (def!constant dynamic-space-start   #x30000000)
128   (def!constant dynamic-space-end     #x3fff0000)
129
130   (def!constant dynamic-0-space-start   #x30000000)
131   (def!constant dynamic-0-space-end     #x3fff0000)
132   
133   (def!constant dynamic-1-space-start   #x40000000)
134   (def!constant dynamic-1-space-end     #x4fff0000)
135
136   (def!constant control-stack-start   #x50000000)
137   (def!constant control-stack-end     #x51000000)
138
139   (def!constant binding-stack-start    #x70000000)
140   (def!constant binding-stack-end      #x71000000))
141
142 #!+osf1                                 ;as if
143 (progn
144   (defparameter read-only-space-start #x10000000)
145   (defparameter static-space-start    #x28000000)
146   (defparameter dynamic-space-start   #x30000000))
147
148
149 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
150 ;;; backend, so they could probably be removed.
151
152 ;; The space-register holding the lisp heap.
153 (def!constant lisp-heap-space 4)
154
155 ;; The space-register holding the C text segment.
156 (def!constant c-text-space 4)
157
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.
161 \f
162 ;;;; other miscellaneous constants
163
164 (defenum (:suffix -trap :start 8)
165   halt
166   pending-interrupt
167   error
168   cerror
169   breakpoint
170   fun-end-breakpoint
171   single-step-breakpoint)
172
173 (defenum (:prefix trace-table-)
174   normal
175   call-site
176   fun-prologue
177   fun-epilogue)
178 \f
179 ;;;; static symbols
180
181 ;;; These symbols are loaded into static space directly after NIL so
182 ;;; that the system can compute their address by adding a constant
183 ;;; amount to NIL.
184 ;;;
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.
188 ;;;
189 (defparameter *static-symbols*
190   '(t
191
192     ;; The C startup code must fill these in.
193     *posix-argv*
194     ;;lisp::lisp-environment-list
195     ;;lisp::lisp-command-line-list
196     sb!impl::*!initial-fdefn-objects*
197
198     ;; Functions that the C code needs to call
199     maybe-gc
200     sb!kernel::internal-error
201     sb!di::handle-breakpoint
202     sb!di::handle-fun-end-breakpoint
203
204     ;; free Pointers
205     *read-only-space-free-pointer*
206     *static-space-free-pointer*
207     *initial-dynamic-space-free-pointer*
208
209     ;; things needed for non-local exit
210     *current-catch-block*
211     *current-unwind-protect-block*
212
213     ;; interrupt handling
214     *free-interrupt-context-index*
215     sb!unix::*interrupts-enabled*
216     sb!unix::*interrupt-pending*))
217
218 (defparameter *static-funs*
219   '(length
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     sb!kernel:two-arg-=
227     ;; FIXME: Is this
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?
233     eql
234     sb!kernel:%negate
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))