0.8.1.50
[sbcl.git] / src / compiler / sparc / 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 \f
12 ;;;; Machine Architecture parameters:
13 (eval-when (:compile-toplevel :load-toplevel :execute)
14
15 (def!constant n-word-bits 32
16   #!+sb-doc
17   "Number of bits per word where a word holds one lisp descriptor.")
18
19 ;;; the natural width of a machine word (as seen in e.g. register width,
20 ;;; address space)
21 (def!constant n-machine-word-bits 32)
22
23 (def!constant n-byte-bits 8
24   #!+sb-doc
25   "Number of bits per byte where a byte is the smallest addressable object.")
26
27 (def!constant word-shift (1- (integer-length (/ n-word-bits n-byte-bits)))
28   #!+sb-doc
29   "Number of bits to shift between word addresses and byte addresses.")
30
31 (def!constant n-word-bytes (/ n-word-bits n-byte-bits)
32   #!+sb-doc
33   "Number of bytes in a word.")
34
35 (def!constant n-fixnum-tag-bits (1- n-lowtag-bits)
36   #!+sb-doc
37   "Number of tag bits used for a fixnum")
38
39 (def!constant fixnum-tag-mask (1- (ash 1 n-fixnum-tag-bits))
40   #!+sb-doc
41   "Mask to get the fixnum tag")
42
43 (def!constant n-positive-fixnum-bits (- n-word-bits n-fixnum-tag-bits 1)
44   #!+sb-doc
45   "Maximum number of bits in a positive fixnum")
46
47 (def!constant float-sign-shift 31)
48
49 (def!constant single-float-bias 126)
50 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
51 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
52 (def!constant single-float-normal-exponent-min 1)
53 (def!constant single-float-normal-exponent-max 254)
54 (def!constant single-float-hidden-bit (ash 1 23))
55 (def!constant single-float-trapping-nan-bit (ash 1 22))
56
57 (def!constant double-float-bias 1022)
58 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
59 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
60 (def!constant double-float-normal-exponent-min 1)
61 (def!constant double-float-normal-exponent-max #x7FE)
62 (def!constant double-float-hidden-bit (ash 1 20))
63 (def!constant double-float-trapping-nan-bit (ash 1 19))
64
65 ;;; CMUCL COMMENT:
66 ;;;   X These values are for the x86 80 bit format and are no doubt
67 ;;;   incorrect for the sparc.
68 ;;; FIXME
69 (def!constant long-float-bias 16382)
70 (defconstant-eqx long-float-exponent-byte (byte 15 0) #'equalp)
71 (defconstant-eqx long-float-significand-byte (byte 31 0) #'equalp)
72 (def!constant long-float-normal-exponent-min 1)
73 (def!constant long-float-normal-exponent-max #x7FFE)
74 (def!constant long-float-hidden-bit (ash 1 31))
75 (def!constant long-float-trapping-nan-bit (ash 1 30))
76
77 (def!constant single-float-digits
78   (+ (byte-size single-float-significand-byte) 1))
79
80 (def!constant double-float-digits
81   (+ (byte-size double-float-significand-byte) n-word-bits 1))
82
83 ;;; This looks wrong - CSR
84 (def!constant long-float-digits
85   (+ (byte-size long-float-significand-byte) n-word-bits 1))
86
87 (def!constant float-inexact-trap-bit (ash 1 0))
88 (def!constant float-divide-by-zero-trap-bit (ash 1 1))
89 (def!constant float-underflow-trap-bit (ash 1 2))
90 (def!constant float-overflow-trap-bit (ash 1 3))
91 (def!constant float-invalid-trap-bit (ash 1 4))
92
93 (def!constant float-round-to-nearest 0)
94 (def!constant float-round-to-zero 1)
95 (def!constant float-round-to-positive 2)
96 (def!constant float-round-to-negative 3)
97
98 (defconstant-eqx float-rounding-mode (byte 2 30) #'equalp)        ; RD 
99 (defconstant-eqx float-sticky-bits (byte 5 5) #'equalp)   ; aexc
100 (defconstant-eqx float-traps-byte (byte 5 23) #'equalp)   ; TEM
101 (defconstant-eqx float-exceptions-byte (byte 5 0) #'equalp)       ; cexc
102
103 ;;; According to the SPARC doc (as opposed to FPU doc), the fast mode
104 ;;; bit (EFM) is "reserved", and should always be zero.  However, for
105 ;;; sparc-V8 and sparc-V9, it appears to work, causing denormals to
106 ;;; be truncated to 0 silently.
107 (def!constant float-fast-bit (ash 1 22))
108
109 ); eval-when
110
111 ;;; NUMBER-STACK-DISPLACEMENT
112 ;;;
113 ;;; The number of bytes reserved above the number stack pointer.  These
114 ;;; slots are required by architecture for a place to spill register windows.
115 ;;;
116 ;;; FIXME: Where is this used?
117 (def!constant number-stack-displacement
118   (* 16 n-word-bytes))
119
120 \f
121 ;;;; Description of the target address space.
122
123 ;;; Where to put the different spaces.  Must match the C code!
124 #!+linux
125 (progn
126   (def!constant read-only-space-start #x10000000)
127   (def!constant read-only-space-end #x15000000)
128
129   (def!constant static-space-start    #x28000000)
130   (def!constant static-space-end #x2c000000)
131
132   ;; From alpha/parms.lisp:
133   ;; this is used in PURIFY as part of a sloppy check to see if a pointer
134   ;; is in dynamic space.  Chocolate brownie for the first person to fix it
135   ;; -dan 20010502
136   (def!constant dynamic-space-start   #x30000000)
137   (def!constant dynamic-space-end     #x38000000)
138
139   (def!constant dynamic-0-space-start   #x30000000)
140   (def!constant dynamic-0-space-end     #x38000000)
141   
142   (def!constant dynamic-1-space-start   #x40000000)
143   (def!constant dynamic-1-space-end     #x48000000))
144
145 #!+sunos ; might as well start by trying the same numbers
146 (progn
147   (def!constant read-only-space-start #x10000000)
148   (def!constant read-only-space-end #x15000000)
149   
150   (def!constant static-space-start    #x28000000)
151   (def!constant static-space-end    #x2c000000)
152
153   (def!constant dynamic-space-start   #x30000000)
154   (def!constant dynamic-space-end     #x38000000)
155
156   (def!constant dynamic-0-space-start   #x30000000)
157   (def!constant dynamic-0-space-end     #x38000000)
158   
159   (def!constant dynamic-1-space-start   #x40000000)
160   (def!constant dynamic-1-space-end     #x48000000))  
161
162 \f
163 ;;;; other random constants.
164
165 (defenum (:suffix -trap :start 8)
166   halt
167   pending-interrupt
168   error
169   cerror
170   breakpoint
171   fun-end-breakpoint
172   after-breakpoint)
173
174 (defenum (:prefix object-not- :suffix -trap :start 16)
175   list
176   instance)
177
178 (defenum (:prefix trace-table-)
179   normal
180   call-site
181   fun-prologue
182   fun-epilogue)
183 \f
184 ;;;; static symbols.
185
186 ;;; These symbols are loaded into static space directly after NIL so
187 ;;; that the system can compute their address by adding a constant
188 ;;; amount to NIL.
189 ;;;
190 ;;; The fdefn objects for the static functions are loaded into static
191 ;;; space directly after the static symbols.  That way, the raw-addr
192 ;;; can be loaded directly out of them by indirecting relative to NIL.
193 ;;;
194 (defparameter *static-symbols*
195   '(t
196
197     ;; The C startup code must fill these in.
198     *posix-argv*
199     sb!impl::*!initial-fdefn-objects*
200
201     ;; functions that the C code needs to call
202     sub-gc
203     sb!kernel::internal-error
204     sb!kernel::control-stack-exhausted-error
205     sb!di::handle-breakpoint
206     sb!di::handle-fun-end-breakpoint
207
208     ;; free pointers
209     *read-only-space-free-pointer*
210     *static-space-free-pointer*
211     *initial-dynamic-space-free-pointer*
212
213     ;; things needed for non-local exit
214     *current-catch-block*
215     *current-unwind-protect-block*
216
217     *binding-stack-start*
218     *control-stack-start*
219     *control-stack-end*
220     
221     ;; interrupt handling
222     *free-interrupt-context-index*
223     sb!unix::*interrupts-enabled*
224     sb!unix::*interrupt-pending*
225     ))
226
227 (defparameter *static-funs*
228   '(length
229     two-arg-+ two-arg-- two-arg-* two-arg-/ two-arg-< two-arg-> two-arg-=
230     two-arg-<= two-arg->= two-arg-/= eql %negate
231     two-arg-and two-arg-ior two-arg-xor
232     two-arg-gcd two-arg-lcm
233     ))
234 \f
235 ;;;; Assembler parameters:
236
237 ;;; The number of bits per element in the assemblers code vector.
238 (defparameter *assembly-unit-length* 8)
239
240 \f
241 ;;;; Pseudo-atomic trap number
242
243 ;;; KLUDGE: Linux on the SPARC doesn't seem to conform to any kind of
244 ;;; standards at all. So we use an explicitly undefined trap, because
245 ;;; that currently does the right thing. Expect this to break
246 ;;; eventually (but with luck, at that point we'll be able to revert
247 ;;; to the compliant trap number...
248 ;;;
249 ;;; KLUDGE: Maybe this should be called pseudo-atomic-magic-number,
250 ;;; allowing other architectures (which don't necessarily use traps
251 ;;; for pseudo-atomic) to propagate a magic number to C land via
252 ;;; sbcl.h.
253 #!-linux
254 (def!constant pseudo-atomic-trap #x10)
255 #!+linux
256 (def!constant pseudo-atomic-trap #x40)