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