SPARC gencgc
[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 ;;; flags for the generational garbage collector
26 (def!constant pseudo-atomic-interrupted-flag 1)
27 (def!constant pseudo-atomic-flag
28     ;; Must be (ash 1 (1- sb-vm:n-lowtag-bits)) for cheneygc ALLOCATION.
29     4)
30
31 (def!constant float-sign-shift 31)
32
33 (def!constant single-float-bias 126)
34 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
35 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
36 (def!constant single-float-normal-exponent-min 1)
37 (def!constant single-float-normal-exponent-max 254)
38 (def!constant single-float-hidden-bit (ash 1 23))
39 (def!constant single-float-trapping-nan-bit (ash 1 22))
40
41 (def!constant double-float-bias 1022)
42 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
43 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
44 (def!constant double-float-normal-exponent-min 1)
45 (def!constant double-float-normal-exponent-max #x7FE)
46 (def!constant double-float-hidden-bit (ash 1 20))
47 (def!constant double-float-trapping-nan-bit (ash 1 19))
48
49 ;;; CMUCL COMMENT:
50 ;;;   X These values are for the x86 80 bit format and are no doubt
51 ;;;   incorrect for the sparc.
52 ;;; FIXME
53 (def!constant long-float-bias 16382)
54 (defconstant-eqx long-float-exponent-byte (byte 15 0) #'equalp)
55 (defconstant-eqx long-float-significand-byte (byte 31 0) #'equalp)
56 (def!constant long-float-normal-exponent-min 1)
57 (def!constant long-float-normal-exponent-max #x7FFE)
58 (def!constant long-float-hidden-bit (ash 1 31))
59 (def!constant long-float-trapping-nan-bit (ash 1 30))
60
61 (def!constant single-float-digits
62   (+ (byte-size single-float-significand-byte) 1))
63
64 (def!constant double-float-digits
65   (+ (byte-size double-float-significand-byte) n-word-bits 1))
66
67 ;;; This looks wrong - CSR
68 (def!constant long-float-digits
69   (+ (byte-size long-float-significand-byte) n-word-bits 1))
70
71 (def!constant float-inexact-trap-bit (ash 1 0))
72 (def!constant float-divide-by-zero-trap-bit (ash 1 1))
73 (def!constant float-underflow-trap-bit (ash 1 2))
74 (def!constant float-overflow-trap-bit (ash 1 3))
75 (def!constant float-invalid-trap-bit (ash 1 4))
76
77 (def!constant float-round-to-nearest 0)
78 (def!constant float-round-to-zero 1)
79 (def!constant float-round-to-positive 2)
80 (def!constant float-round-to-negative 3)
81
82 (defconstant-eqx float-rounding-mode (byte 2 30) #'equalp)        ; RD
83 (defconstant-eqx float-sticky-bits (byte 5 5) #'equalp)   ; aexc
84 (defconstant-eqx float-traps-byte (byte 5 23) #'equalp)   ; TEM
85 (defconstant-eqx float-exceptions-byte (byte 5 0) #'equalp)       ; cexc
86
87 ;;; According to the SPARC doc (as opposed to FPU doc), the fast mode
88 ;;; bit (EFM) is "reserved", and should always be zero.  However, for
89 ;;; sparc-V8 and sparc-V9, it appears to work, causing denormals to
90 ;;; be truncated to 0 silently.
91 (def!constant float-fast-bit (ash 1 22))
92
93 ); eval-when
94
95 \f
96 ;;;; Description of the target address space.
97
98 ;;; Where to put the different spaces.  Must match the C code!
99 #!+linux
100 (progn
101   (def!constant linkage-table-space-start #x0f800000)
102   (def!constant linkage-table-space-end   #x10000000)
103
104   (def!constant read-only-space-start     #x11000000)
105   (def!constant read-only-space-end       #x15000000)
106
107   (def!constant static-space-start        #x28000000)
108   (def!constant static-space-end          #x2c000000)
109
110   (def!constant dynamic-0-space-start #x30000000)
111   (def!constant dynamic-0-space-end   #x38000000)
112
113   (def!constant dynamic-1-space-start #x40000000)
114   (def!constant dynamic-1-space-end   #x48000000))
115
116 #!+(and sunos cheneygc) ; might as well start by trying the same numbers
117 (progn
118   (def!constant linkage-table-space-start #x0f800000)
119   (def!constant linkage-table-space-end   #x10000000)
120
121   (def!constant read-only-space-start     #x11000000)
122   (def!constant read-only-space-end       #x15000000)
123
124   (def!constant static-space-start        #x28000000)
125   (def!constant static-space-end          #x2c000000)
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 #!+(and sunos gencgc) ; sensibly small read-only and static spaces
134 (progn
135   (def!constant linkage-table-space-start #x0f800000)
136   (def!constant linkage-table-space-end   #x10000000)
137
138   (def!constant read-only-space-start     #x11000000)
139   (def!constant read-only-space-end       #x110ff000)
140
141   (def!constant static-space-start        #x11100000)
142   (def!constant static-space-end          #x111ff000)
143
144   (def!constant dynamic-space-start       #x30000000)
145   (def!constant dynamic-space-end         (!configure-dynamic-space-end)))
146
147 #!+netbsd ; Need a gap at 0x4000000 for shared libraries
148 (progn
149   (def!constant linkage-table-space-start #x0f800000)
150   (def!constant linkage-table-space-end   #x10000000)
151
152   (def!constant read-only-space-start     #x11000000)
153   (def!constant read-only-space-end       #x15000000)
154
155   (def!constant static-space-start        #x18000000)
156   (def!constant static-space-end          #x1c000000)
157
158   (def!constant dynamic-0-space-start     #x48000000)
159   (def!constant dynamic-0-space-end       #x5ffff000)
160
161   (def!constant dynamic-1-space-start     #x60000000)
162   (def!constant dynamic-1-space-end       #x77fff000))
163
164 ;; Size of one linkage-table entry in bytes. See comment in
165 ;; src/runtime/sparc-arch.c
166 (def!constant linkage-table-entry-size 16)
167
168 \f
169 ;;;; other random constants.
170
171 (defenum (:start 8)
172   halt-trap
173   pending-interrupt-trap
174   error-trap
175   cerror-trap
176   breakpoint-trap
177   fun-end-breakpoint-trap
178   after-breakpoint-trap
179   single-step-around-trap
180   single-step-before-trap
181   #!+gencgc allocation-trap)
182
183 (defenum (:start 24)
184   object-not-list-trap
185   object-not-instance-trap)
186 \f
187 ;;;; static symbols.
188
189 ;;; These symbols are loaded into static space directly after NIL so
190 ;;; that the system can compute their address by adding a constant
191 ;;; amount to NIL.
192 ;;;
193 ;;; The fdefn objects for the static functions are loaded into static
194 ;;; space directly after the static symbols.  That way, the raw-addr
195 ;;; can be loaded directly out of them by indirecting relative to NIL.
196 ;;;
197 (defparameter *static-symbols*
198   (append
199    *common-static-symbols*
200    *c-callable-static-symbols*
201    '(#!+gencgc *restart-lisp-function*)))
202
203 (defparameter *static-funs*
204   '(length
205     two-arg-+ two-arg-- two-arg-* two-arg-/ two-arg-< two-arg-> two-arg-=
206     two-arg-<= two-arg->= two-arg-/= eql %negate
207     two-arg-and two-arg-ior two-arg-xor two-arg-eqv
208     two-arg-gcd two-arg-lcm
209     ))
210 \f
211 ;;;; Assembler parameters:
212
213 ;;; The number of bits per element in the assemblers code vector.
214 (defparameter *assembly-unit-length* 8)
215
216 \f
217 ;;;; Pseudo-atomic trap number
218
219 ;;; KLUDGE: Linux on the SPARC doesn't seem to conform to any kind of
220 ;;; standards at all. So we use an explicitly undefined trap, because
221 ;;; that currently does the right thing. Expect this to break
222 ;;; eventually (but with luck, at that point we'll be able to revert
223 ;;; to the compliant trap number...
224 ;;;
225 ;;; KLUDGE: Maybe this should be called pseudo-atomic-magic-number,
226 ;;; allowing other architectures (which don't necessarily use traps
227 ;;; for pseudo-atomic) to propagate a magic number to C land via
228 ;;; sbcl.h.
229 #!-linux
230 (def!constant pseudo-atomic-trap #x10)
231 #!+linux
232 (def!constant pseudo-atomic-trap #x40)