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