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