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