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