fce1a511b6a139c8b3cc1fe7b8c7339cc3d17056
[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
28 ;;; The size in bytes of the GENCGC pages. Should be a multiple of the
29 ;;; architecture code size.
30 (def!constant gencgc-page-size 4096)
31
32 ;;; flags for the generational garbage collector
33 (def!constant pseudo-atomic-interrupted-flag 1)
34 (def!constant pseudo-atomic-flag 4)
35
36 (def!constant float-sign-shift 31)
37
38 (def!constant single-float-bias 126)
39 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
40 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
41 (def!constant single-float-normal-exponent-min 1)
42 (def!constant single-float-normal-exponent-max 254)
43 (def!constant single-float-hidden-bit (ash 1 23))
44 (def!constant single-float-trapping-nan-bit (ash 1 22))
45
46 (def!constant double-float-bias 1022)
47 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
48 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
49 (def!constant double-float-normal-exponent-min 1)
50 (def!constant double-float-normal-exponent-max #x7FE)
51 (def!constant double-float-hidden-bit (ash 1 20))
52 (def!constant double-float-trapping-nan-bit (ash 1 19))
53
54 (def!constant single-float-digits
55   (+ (byte-size single-float-significand-byte) 1))
56
57 (def!constant double-float-digits
58   (+ (byte-size double-float-significand-byte) n-word-bits 1))
59
60
61 (def!constant float-inexact-trap-bit (ash 1 0))
62 (def!constant float-divide-by-zero-trap-bit (ash 1 1))
63 (def!constant float-underflow-trap-bit (ash 1 2))
64 (def!constant float-overflow-trap-bit (ash 1 3))
65 (def!constant float-invalid-trap-bit (ash 1 4))
66
67 (def!constant float-round-to-nearest 0)
68 (def!constant float-round-to-zero 1)
69 (def!constant float-round-to-positive 2)
70 (def!constant float-round-to-negative 3)
71
72 (defconstant-eqx float-rounding-mode (byte 2 0) #'equalp)         ; RD
73 ;;; FIXME I: Beware, all ye who trespass here. Despite its name,
74 ;;; FLOAT-STICKY-BITS is not the byte specifier for sticky bits in the
75 ;;; floating point control word. It is more like "accrued exceptions"
76 ;;; where FLOAT-EXCEPTIONS-BYTE is "current exceptions". Consequently,
77 ;;; on architectures where there is no "current exceptions"
78 ;;; FLOAT-EXCEPTIONS-BYTE and FLOAT-STICKY-BITS had better be the
79 ;;; same.
80 ;;;
81 ;;; FIXME II: So, I've now documented this in comments in the PowerPC
82 ;;; tree. This may not make it easy to find for when new architectures
83 ;;; get backends written...
84 ;;;
85 ;;; CSR, 2002-06-11
86 (defconstant-eqx float-sticky-bits (byte 5 25) #'equalp)
87 (defconstant-eqx float-traps-byte (byte 5 3) #'equalp)
88 (defconstant-eqx float-exceptions-byte (byte 5 25) #'equalp)      ; cexc
89
90 (def!constant float-fast-bit 2)         ; Non-IEEE mode
91
92 \f
93 ;;; Where to put the different spaces.
94
95 (def!constant read-only-space-start #x01000000)
96 (def!constant read-only-space-end   #x04ff8000)
97
98 (def!constant static-space-start    #x08000000)
99 (def!constant static-space-end      #x097fff00)
100
101 #!+linux
102 (progn
103   #!+gencgc
104   (progn
105     (def!constant dynamic-space-start #x50000000)
106     (def!constant dynamic-space-end   #x7ffff000))
107   #!-gencgc
108   (progn
109     (def!constant dynamic-0-space-start #x50000000)
110     (def!constant dynamic-0-space-end   #x67fff000)
111     (def!constant dynamic-1-space-start #x68000000)
112     (def!constant dynamic-1-space-end   #x7ffff000))
113
114   (def!constant linkage-table-space-start #x0a000000)
115   (def!constant linkage-table-space-end   #x0b000000)
116   (def!constant linkage-table-entry-size 16))
117
118 #!+darwin
119 (progn
120   #!+gencgc
121   (progn
122     (def!constant dynamic-space-start #x10000000)
123     (def!constant dynamic-space-end   #x6ffff000))
124   #!-gencgc
125   (progn
126     (def!constant dynamic-0-space-start #x10000000)
127     (def!constant dynamic-0-space-end   #x3ffff000)
128
129     (def!constant dynamic-1-space-start #x40000000)
130     (def!constant dynamic-1-space-end   #x6ffff000))
131
132
133   (def!constant linkage-table-space-start #x0a000000)
134   (def!constant linkage-table-space-end   #x0b000000)
135   (def!constant linkage-table-entry-size 16))
136 \f
137 ;;;; Other miscellaneous constants.
138
139 (defenum (:suffix -trap :start 8)
140   halt
141   pending-interrupt
142   error
143   cerror
144   breakpoint
145   fun-end-breakpoint
146   after-breakpoint
147   fixnum-additive-overflow)
148
149 (defenum (:prefix object-not- :suffix -trap :start 16)
150   list
151   instance)
152
153 (defenum (:prefix trace-table-)
154   normal
155   call-site
156   fun-prologue
157   fun-epilogue)
158
159 \f
160 ;;;; Static symbols.
161
162
163 ;;; These symbols are loaded into static space directly after NIL so
164 ;;; that the system can compute their address by adding a constant
165 ;;; amount to NIL.
166 ;;;
167 ;;; The fdefn objects for the static functions are loaded into static
168 ;;; space directly after the static symbols.  That way, the raw-addr
169 ;;; can be loaded directly out of them by indirecting relative to NIL.
170 ;;;
171 (defparameter *static-symbols*
172   '(t
173
174     ;; The C startup code must fill these in.
175     *posix-argv*
176
177     ;; functions that the C code needs to call
178     sb!impl::sub-gc
179     sb!kernel::internal-error
180     sb!kernel::control-stack-exhausted-error
181     sb!kernel::undefined-alien-variable-error
182     sb!kernel::undefined-alien-function-error
183     sb!di::handle-breakpoint
184     sb!impl::fdefinition-object
185
186     ;; free pointers
187     *read-only-space-free-pointer*
188     *static-space-free-pointer*
189     *initial-dynamic-space-free-pointer*
190
191     ;; things needed for non-local exit
192     *current-catch-block*
193     *current-unwind-protect-block*
194
195     *binding-stack-start*
196     *control-stack-start*
197     *control-stack-end*
198
199     ;; interrupt handling
200     *free-interrupt-context-index*
201     sb!unix::*interrupts-enabled*
202     sb!unix::*interrupt-pending*
203     *gc-inhibit*
204     *gc-pending*
205
206     *restart-lisp-function*
207
208     ;; CLH: 20060210 Taken from x86-64/parms.lisp per JES' suggestion
209     ;; Needed for callbacks to work across saving cores. see
210     ;; ALIEN-CALLBACK-ASSEMBLER-WRAPPER in c-call.lisp for gory
211     ;; details.
212     sb!alien::*enter-alien-callback*))
213
214 (defparameter *static-funs*
215   '(length
216     sb!kernel:two-arg-+
217     sb!kernel:two-arg--
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     eql
227     sb!kernel:%negate
228     sb!kernel:two-arg-and
229     sb!kernel:two-arg-ior
230     sb!kernel:two-arg-xor
231     sb!kernel:two-arg-eqv
232     sb!kernel:two-arg-gcd
233     sb!kernel:two-arg-lcm))
234
235 \f
236 ;;;; Assembler parameters:
237
238 ;;; The number of bits per element in the assemblers code vector.
239 ;;;
240 (defparameter *assembly-unit-length* 8)