a975b43c255bff1c3e97b6a69ffda891cd236a15
[sbcl.git] / src / compiler / ppc / parms.lisp
1 ;;;; This file contains some parameterizations of various VM
2 ;;;; attributes for the PPC.  This file is separate from other stuff so
3 ;;;; that it can be compiled and loaded earlier.
4
5 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; more information.
7 ;;;;
8 ;;;; This software is derived from the CMU CL system, which was
9 ;;;; written at Carnegie Mellon University and released into the
10 ;;;; public domain. The software is in the public domain and is
11 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
12 ;;;; files for more information.
13
14 (in-package "SB!VM")
15
16 ;;; number of bits per word where a word holds one lisp descriptor
17 (def!constant n-word-bits 32)
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 ;;; number of bits per byte where a byte is the smallest addressable
24 ;;; object
25 (def!constant n-byte-bits 8)
26
27 ;;; flags for the generational garbage collector
28 (def!constant pseudo-atomic-interrupted-flag 1)
29 (def!constant pseudo-atomic-flag 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 (def!constant single-float-digits
50   (+ (byte-size single-float-significand-byte) 1))
51
52 (def!constant double-float-digits
53   (+ (byte-size double-float-significand-byte) n-word-bits 1))
54
55
56 (def!constant float-inexact-trap-bit (ash 1 0))
57 (def!constant float-divide-by-zero-trap-bit (ash 1 1))
58 (def!constant float-underflow-trap-bit (ash 1 2))
59 (def!constant float-overflow-trap-bit (ash 1 3))
60 (def!constant float-invalid-trap-bit (ash 1 4))
61
62 (def!constant float-round-to-nearest 0)
63 (def!constant float-round-to-zero 1)
64 (def!constant float-round-to-positive 2)
65 (def!constant float-round-to-negative 3)
66
67 (defconstant-eqx float-rounding-mode (byte 2 0) #'equalp)         ; RD
68 ;;; FIXME I: Beware, all ye who trespass here. Despite its name,
69 ;;; FLOAT-STICKY-BITS is not the byte specifier for sticky bits in the
70 ;;; floating point control word. It is more like "accrued exceptions"
71 ;;; where FLOAT-EXCEPTIONS-BYTE is "current exceptions". Consequently,
72 ;;; on architectures where there is no "current exceptions"
73 ;;; FLOAT-EXCEPTIONS-BYTE and FLOAT-STICKY-BITS had better be the
74 ;;; same.
75 ;;;
76 ;;; FIXME II: So, I've now documented this in comments in the PowerPC
77 ;;; tree. This may not make it easy to find for when new architectures
78 ;;; get backends written...
79 ;;;
80 ;;; CSR, 2002-06-11
81 (defconstant-eqx float-sticky-bits (byte 5 25) #'equalp)
82 (defconstant-eqx float-traps-byte (byte 5 3) #'equalp)
83 (defconstant-eqx float-exceptions-byte (byte 5 25) #'equalp)      ; cexc
84
85 (def!constant float-fast-bit 2)         ; Non-IEEE mode
86
87 \f
88 ;;;; Where to put the different spaces.
89
90 ;;; On non-gencgc we need large dynamic and static spaces for PURIFY
91 #!-gencgc
92 (progn
93   (def!constant read-only-space-start #x04000000)
94   (def!constant read-only-space-end   #x07ff8000)
95   (def!constant static-space-start    #x08000000)
96   (def!constant static-space-end      #x097fff00)
97
98   (def!constant linkage-table-space-start #x0a000000)
99   (def!constant linkage-table-space-end   #x0b000000))
100
101 ;;; While on gencgc we don't.
102 #!+gencgc
103 (progn
104   (def!constant read-only-space-start #x04000000)
105   (def!constant read-only-space-end   #x040ff000)
106   (def!constant static-space-start    #x04100000)
107   (def!constant static-space-end      #x041ff000)
108
109   (def!constant linkage-table-space-start #x04200000)
110   (def!constant linkage-table-space-end   #x042ff000))
111
112 (def!constant linkage-table-entry-size 16)
113
114 #!+linux
115 (progn
116   #!+gencgc
117   (progn
118     (def!constant dynamic-space-start #x4f000000)
119     (def!constant dynamic-space-end   (!configure-dynamic-space-end)))
120   #!-gencgc
121   (progn
122     (def!constant dynamic-0-space-start #x4f000000)
123     (def!constant dynamic-0-space-end   #x66fff000)
124     (def!constant dynamic-1-space-start #x67000000)
125     (def!constant dynamic-1-space-end   #x7efff000)))
126
127 #!+netbsd
128 (progn
129   #!+gencgc
130   (progn
131     (def!constant dynamic-space-start #x4f000000)
132     (def!constant dynamic-space-end   (!configure-dynamic-space-end)))
133   #!-gencgc
134   (progn
135     (def!constant dynamic-0-space-start #x4f000000)
136     (def!constant dynamic-0-space-end   #x66fff000)
137     (def!constant dynamic-1-space-start #x67000000)
138     (def!constant dynamic-1-space-end   #x7efff000)))
139
140 ;;; Text and data segments start at #x01800000.  Range for randomized
141 ;;; malloc() starts #x20000000 (MAXDSIZ) after end of data seg and
142 ;;; extends 256 MB.  Use 512 - 64 MB for dynamic space so we can run
143 ;;; under default resource limits.
144 ;;; FIXME: MAXDSIZ is a kernel parameter, and can vary as high as 1GB.
145 ;;; These parameters should probably be tested under such a configuration,
146 ;;; as rare as it might or might not be.
147 #!+openbsd
148 (progn
149   #!+gencgc
150   (progn
151     (def!constant dynamic-space-start #x4f000000)
152     (def!constant dynamic-space-end   (!configure-dynamic-space-end)))
153   #!-gencgc
154   (progn
155     (def!constant dynamic-0-space-start #x4f000000)
156     (def!constant dynamic-0-space-end   #x5cfff000)
157     (def!constant dynamic-1-space-start #x5f000000)
158     (def!constant dynamic-1-space-end   #x6cfff000)))
159
160 #!+darwin
161 (progn
162   #!+gencgc
163   (progn
164     (def!constant dynamic-space-start #x10000000)
165     (def!constant dynamic-space-end   (!configure-dynamic-space-end)))
166   #!-gencgc
167   (progn
168     (def!constant dynamic-0-space-start #x10000000)
169     (def!constant dynamic-0-space-end   #x3ffff000)
170
171     (def!constant dynamic-1-space-start #x40000000)
172     (def!constant dynamic-1-space-end   #x6ffff000)))
173 \f
174 ;;;; Other miscellaneous constants.
175
176 (defenum (:start 8)
177   halt-trap
178   pending-interrupt-trap
179   error-trap
180   cerror-trap
181   breakpoint-trap
182   fun-end-breakpoint-trap
183   after-breakpoint-trap
184   fixnum-additive-overflow-trap
185   single-step-around-trap
186   single-step-before-trap)
187
188 (defenum (:start 24)
189   object-not-list-trap
190   object-not-instance-trap)
191 \f
192 ;;;; Static symbols.
193
194
195 ;;; These symbols are loaded into static space directly after NIL so
196 ;;; that the system can compute their address by adding a constant
197 ;;; amount to NIL.
198 ;;;
199 ;;; The fdefn objects for the static functions are loaded into static
200 ;;; space directly after the static symbols.  That way, the raw-addr
201 ;;; can be loaded directly out of them by indirecting relative to NIL.
202 ;;;
203 (defparameter *static-symbols*
204   (append
205    *common-static-symbols*
206    *c-callable-static-symbols*
207    '(
208      #!+gencgc *restart-lisp-function*
209
210      ;; CLH: 20060210 Taken from x86-64/parms.lisp per JES' suggestion
211      ;; Needed for callbacks to work across saving cores. see
212      ;; ALIEN-CALLBACK-ASSEMBLER-WRAPPER in c-call.lisp for gory
213      ;; details.
214      sb!alien::*enter-alien-callback*)))
215
216 (defparameter *static-funs*
217   '(length
218     sb!kernel:two-arg-+
219     sb!kernel:two-arg--
220     sb!kernel:two-arg-*
221     sb!kernel:two-arg-/
222     sb!kernel:two-arg-<
223     sb!kernel:two-arg->
224     sb!kernel:two-arg-=
225     sb!kernel:two-arg-<=
226     sb!kernel:two-arg->=
227     sb!kernel:two-arg-/=
228     eql
229     sb!kernel:%negate
230     sb!kernel:two-arg-and
231     sb!kernel:two-arg-ior
232     sb!kernel:two-arg-xor
233     sb!kernel:two-arg-eqv
234     sb!kernel:two-arg-gcd
235     sb!kernel:two-arg-lcm))
236
237 \f
238 ;;;; Assembler parameters:
239
240 ;;; The number of bits per element in the assemblers code vector.
241 ;;;
242 (defparameter *assembly-unit-length* 8)