0.8.5.29:
[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 (def!constant n-word-bits 32
17   "Number of bits per word where a word holds one lisp descriptor.")
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 (def!constant n-byte-bits 8
24   "Number of bits per byte where a byte is the smallest addressable object.")
25
26 (def!constant word-shift (1- (integer-length (/ n-word-bits n-byte-bits)))
27   "Number of bits to shift between word addresses and byte addresses.")
28
29 (def!constant n-word-bytes (/ n-word-bits n-byte-bits)
30   "Number of bytes in a word.")
31
32
33 (def!constant float-sign-shift 31)
34
35 (def!constant single-float-bias 126)
36 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
37 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
38 (def!constant single-float-normal-exponent-min 1)
39 (def!constant single-float-normal-exponent-max 254)
40 (def!constant single-float-hidden-bit (ash 1 23))
41 (def!constant single-float-trapping-nan-bit (ash 1 22))
42
43 (def!constant double-float-bias 1022)
44 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
45 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
46 (def!constant double-float-normal-exponent-min 1)
47 (def!constant double-float-normal-exponent-max #x7FE)
48 (def!constant double-float-hidden-bit (ash 1 20))
49 (def!constant double-float-trapping-nan-bit (ash 1 19))
50
51 (def!constant single-float-digits
52   (+ (byte-size single-float-significand-byte) 1))
53
54 (def!constant double-float-digits
55   (+ (byte-size double-float-significand-byte) n-word-bits 1))
56
57
58 (def!constant float-inexact-trap-bit (ash 1 0))
59 (def!constant float-divide-by-zero-trap-bit (ash 1 1))
60 (def!constant float-underflow-trap-bit (ash 1 2))
61 (def!constant float-overflow-trap-bit (ash 1 3))
62 (def!constant float-invalid-trap-bit (ash 1 4))
63
64 (def!constant float-round-to-nearest 0)
65 (def!constant float-round-to-zero 1)
66 (def!constant float-round-to-positive 2)
67 (def!constant float-round-to-negative 3)
68
69 (defconstant-eqx float-rounding-mode (byte 2 0) #'equalp)         ; RD
70 ;;; FIXME I: Beware, all ye who trespass here. Despite its name,
71 ;;; FLOAT-STICKY-BITS is not the byte specifier for sticky bits in the
72 ;;; floating point control word. It is more like "accrued exceptions"
73 ;;; where FLOAT-EXCEPTIONS-BYTE is "current exceptions". Consequently,
74 ;;; on architectures where there is no "current exceptions"
75 ;;; FLOAT-EXCEPTIONS-BYTE and FLOAT-STICKY-BITS had better be the
76 ;;; same. 
77 ;;;
78 ;;; FIXME II: So, I've now documented this in comments in the PowerPC
79 ;;; tree. This may not make it easy to find for when new architectures
80 ;;; get backends written...
81 ;;;
82 ;;; CSR, 2002-06-11
83 (defconstant-eqx float-sticky-bits (byte 5 25) #'equalp)
84 (defconstant-eqx float-traps-byte (byte 5 3) #'equalp)
85 (defconstant-eqx float-exceptions-byte (byte 5 25) #'equalp)      ; cexc
86
87 (def!constant float-fast-bit 2)         ; Non-IEEE mode
88
89
90 ;;; NUMBER-STACK-DISPLACEMENT
91 ;;;
92 ;;; The number of bytes reserved above the number stack pointer.  These
93 ;;; slots are required by architecture, mostly (?) to make C backtrace
94 ;;; work. This must be a power of 2 - see BYTES-REQUIRED-FOR-NUMBER-STACK.
95 ;;; 
96 (def!constant number-stack-displacement
97   (* #!-darwin 2
98      #!+darwin 8
99      n-word-bytes))
100 \f
101
102 ;;; Where to put the different spaces.
103
104 (def!constant read-only-space-start #x01000000)
105 (def!constant read-only-space-end   #x04ff8000)
106
107 (def!constant static-space-start    #x08000000)
108 (def!constant static-space-end      #x097fff00)
109
110 ;;; FIXME: this is a gross violation of OAOO, done purely to support
111 ;;; the #define of DYNAMIC_SPACE_SIZE in validate.c -- CSR, 2002-02-25
112 ;;; (these numbers should match dynamic-0-*)
113 (def!constant dynamic-space-start   #x40000000)
114 (def!constant dynamic-space-end     #x47fff000)
115
116 ;;; nothing _seems_ to be using these addresses 
117 (def!constant dynamic-0-space-start #x40000000)
118 (def!constant dynamic-0-space-end   #x47fff000)
119 (def!constant dynamic-1-space-start #x48000000)
120 (def!constant dynamic-1-space-end   #x4ffff000)
121
122
123
124 \f
125 ;;;; Other random constants.
126
127 (defenum (:suffix -trap :start 8)
128   halt
129   pending-interrupt
130   error
131   cerror
132   breakpoint
133   fun-end-breakpoint
134   after-breakpoint
135   fixnum-additive-overflow)
136
137 (defenum (:prefix object-not- :suffix -trap :start 16)
138   list
139   instance)
140
141 (defenum (:prefix trace-table-)
142   normal
143   call-site
144   fun-prologue
145   fun-epilogue)
146
147 \f
148 ;;;; Static symbols.
149
150
151 ;;; These symbols are loaded into static space directly after NIL so
152 ;;; that the system can compute their address by adding a constant
153 ;;; amount to NIL.
154 ;;;
155 ;;; The fdefn objects for the static functions are loaded into static
156 ;;; space directly after the static symbols.  That way, the raw-addr
157 ;;; can be loaded directly out of them by indirecting relative to NIL.
158 ;;;
159 (defparameter *static-symbols*
160   '(t
161
162     ;; The C startup code must fill these in.
163     *posix-argv*
164
165     ;; functions that the C code needs to call
166     sb!impl::sub-gc
167     sb!kernel::internal-error
168     sb!kernel::control-stack-exhausted-error
169     sb!di::handle-breakpoint
170     sb!impl::fdefinition-object
171
172     ;; free pointers
173     *read-only-space-free-pointer*
174     *static-space-free-pointer*
175     *initial-dynamic-space-free-pointer*
176
177     ;; things needed for non-local exit
178     *current-catch-block*
179     *current-unwind-protect-block*
180
181     *binding-stack-start*
182     *control-stack-start*
183     *control-stack-end*
184
185     ;; interrupt handling
186     *free-interrupt-context-index*
187     sb!unix::*interrupts-enabled*
188     sb!unix::*interrupt-pending*
189
190
191     ))
192
193 (defparameter *static-funs*
194   '(length
195     sb!kernel:two-arg-+
196     sb!kernel:two-arg--
197     sb!kernel:two-arg-*
198     sb!kernel:two-arg-/
199     sb!kernel:two-arg-<
200     sb!kernel:two-arg->
201     sb!kernel:two-arg-=
202     sb!kernel:two-arg-<=
203     sb!kernel:two-arg->=   
204     sb!kernel:two-arg-/=
205     eql
206     sb!kernel:%negate
207     sb!kernel:two-arg-and
208     sb!kernel:two-arg-ior
209     sb!kernel:two-arg-xor
210     sb!kernel:two-arg-eqv
211     sb!kernel:two-arg-gcd
212     sb!kernel:two-arg-lcm))
213
214 \f
215 ;;;; Assembler parameters:
216
217 ;;; The number of bits per element in the assemblers code vector.
218 ;;;
219 (defparameter *assembly-unit-length* 8)