message
[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 ;;; number of bits per word where a word holds one lisp descriptor
15 (def!constant n-word-bits 32)
16
17 ;;; the natural width of a machine word (as seen in e.g. register width,
18 ;;; address space)
19 (def!constant n-machine-word-bits 64)
20
21 ;;; number of bits per byte where a byte is the smallest addressable
22 ;;; object
23 (def!constant n-byte-bits 8)
24
25 (def!constant float-sign-shift 31)
26
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))
34
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))
42
43 (def!constant single-float-digits
44   (+ (byte-size single-float-significand-byte) 1))
45
46 (def!constant double-float-digits
47   (+ (byte-size double-float-significand-byte) n-word-bits 1))
48
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)
57
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.
66
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
72 ;;; <machine/fpu.h>
73
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)  
81
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
85
86 ;;; (We don't actually _have_ "current exceptions" on Alpha; the
87 ;;; hardware only ever sets bits.  So, set this the same as accrued
88 ;;; exceptions)
89 (defconstant-eqx float-exceptions-byte (byte 6 17)  #'equalp)
90
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) 
97
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)
101
102 ); eval-when
103
104
105 \f
106 ;;;; Description of the target address space.
107
108 ;;; Where to put the different spaces.
109 ;;;
110
111 #!+linux
112 (progn
113   (def!constant read-only-space-start #x20000000)
114   (def!constant read-only-space-end   #x24000000))
115
116 #!+osf1
117 (progn
118   (defconstant read-only-space-start #x10000000)
119   (defconstant read-only-space-end   #x25000000))
120
121
122 (def!constant static-space-start    #x28000000)
123 (def!constant static-space-end      #x2c000000)
124
125 ;; this is used in PURIFY as part of a sloppy check to see if a pointer
126 ;; is in dynamic space.  Chocolate brownie for the first person to fix it
127 ;; -dan 20010502
128 (def!constant dynamic-space-start   #x30000000)
129 (def!constant dynamic-space-end     #x3fff0000)
130
131 (def!constant dynamic-0-space-start   #x30000000)
132 (def!constant dynamic-0-space-end     #x3fff0000)
133
134 (def!constant dynamic-1-space-start   #x40000000)
135 (def!constant dynamic-1-space-end     #x4fff0000)
136
137 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
138 ;;; backend, so they could probably be removed.
139
140 ;; The space-register holding the lisp heap.
141 (def!constant lisp-heap-space 4)
142
143 ;; The space-register holding the C text segment.
144 (def!constant c-text-space 4)
145
146 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
147 ;;; here, but it seems to be the only port that needs to know the
148 ;;; location of NIL from lisp.
149 \f
150 ;;;; other miscellaneous constants
151
152 (defenum (:suffix -trap :start 8)
153   halt
154   pending-interrupt
155   error
156   cerror
157   breakpoint
158   fun-end-breakpoint
159   single-step-breakpoint)
160
161 (defenum (:prefix trace-table-)
162   normal
163   call-site
164   fun-prologue
165   fun-epilogue)
166 \f
167 ;;;; static symbols
168
169 ;;; These symbols are loaded into static space directly after NIL so
170 ;;; that the system can compute their address by adding a constant
171 ;;; amount to NIL.
172 ;;;
173 ;;; The fdefn objects for the static functions are loaded into static
174 ;;; space directly after the static symbols.  That way, the raw-addr
175 ;;; can be loaded directly out of them by indirecting relative to NIL.
176 ;;;
177 (defparameter *static-symbols*
178   '(t
179
180     ;; The C startup code must fill these in.
181     *posix-argv*
182
183     ;; functions that the C code needs to call
184     sub-gc
185     sb!kernel::internal-error
186     sb!kernel::control-stack-exhausted-error
187     sb!kernel::undefined-alien-variable-error
188     sb!kernel::undefined-alien-function-error
189     sb!di::handle-breakpoint
190     sb!di::handle-fun-end-breakpoint
191
192     ;; free pointers
193     *read-only-space-free-pointer*
194     *static-space-free-pointer*
195     *initial-dynamic-space-free-pointer*
196
197     ;; things needed for non-local exit
198     *current-catch-block*
199     *current-unwind-protect-block*
200
201     *binding-stack-start*
202     *control-stack-start*
203     *control-stack-end*
204
205     ;; interrupt handling
206     *free-interrupt-context-index*
207     sb!unix::*interrupts-enabled*
208     sb!unix::*interrupt-pending*))
209
210 (defparameter *static-funs*
211   '(length
212     sb!kernel:two-arg-+
213     sb!kernel:two-arg--
214     sb!kernel:two-arg-*
215     sb!kernel:two-arg-/
216     sb!kernel:two-arg-<
217     sb!kernel:two-arg->
218     sb!kernel:two-arg-=
219     ;; FIXME: Is this
220     ;;     probably need the following as they are defined in 
221     ;;     arith.lisp: two-arg-<= two-arg->= two-arg-/= 
222     ;; a comment from old CMU CL or old old CMU CL or
223     ;; the SBCL alpha port or what? Do we need to worry about it,
224     ;; or can we delete it?
225     eql
226     sb!kernel:%negate
227     sb!kernel:two-arg-and
228     sb!kernel:two-arg-ior
229     sb!kernel:two-arg-xor
230     sb!kernel:two-arg-eqv
231     sb!kernel:two-arg-gcd
232     sb!kernel:two-arg-lcm))