0.7.1.20:
[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 (defconstant n-word-bits 32
16   #!+sb-doc
17   "Number of bits per word where a word holds one lisp descriptor.")
18
19 (defconstant n-byte-bits 8
20   #!+sb-doc
21   "Number of bits per byte where a byte is the smallest addressable object.")
22
23 (defconstant word-shift (1- (integer-length (/ n-word-bits n-byte-bits)))
24   #!+sb-doc
25   "Number of bits to shift between word addresses and byte addresses.")
26
27 (defconstant n-word-bytes (/ n-word-bits n-byte-bits)
28   #!+sb-doc
29   "Number of bytes in a word.")
30
31 ;;; FIXME: The following three should probably be rationalized or at
32 ;;; least prefixed with n- where applicable
33 (defconstant fixnum-tag-bits (1- n-lowtag-bits)
34   #!+sb-doc
35   "Number of tag bits used for a fixnum")
36
37 (defconstant fixnum-tag-mask (1- (ash 1 fixnum-tag-bits))
38   #!+sb-doc
39   "Mask to get the fixnum tag")
40
41 (defconstant positive-fixnum-bits (- n-word-bits fixnum-tag-bits 1)
42   #!+sb-doc
43   "Maximum number of bits in a positive fixnum")
44
45 (defconstant float-sign-shift 31)
46
47 (defconstant single-float-bias 126)
48 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
49 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
50 (defconstant single-float-normal-exponent-min 1)
51 (defconstant single-float-normal-exponent-max 254)
52 (defconstant single-float-hidden-bit (ash 1 23))
53 (defconstant single-float-trapping-nan-bit (ash 1 22))
54
55 (defconstant double-float-bias 1022)
56 (defconstant-eqx double-float-exponent-byte (byte 11 20) #'equalp)
57 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
58 (defconstant double-float-normal-exponent-min 1)
59 (defconstant double-float-normal-exponent-max #x7FE)
60 (defconstant double-float-hidden-bit (ash 1 20))
61 (defconstant double-float-trapping-nan-bit (ash 1 19))
62
63 ;;; CMUCL COMMENT:
64 ;;;   X These values are for the x86 80 bit format and are no doubt
65 ;;;   incorrect for the sparc.
66 ;;; FIXME
67 (defconstant long-float-bias 16382)
68 (defconstant-eqx long-float-exponent-byte (byte 15 0) #'equalp)
69 (defconstant-eqx long-float-significand-byte (byte 31 0) #'equalp)
70 (defconstant long-float-normal-exponent-min 1)
71 (defconstant long-float-normal-exponent-max #x7FFE)
72 (defconstant long-float-hidden-bit (ash 1 31))
73 (defconstant long-float-trapping-nan-bit (ash 1 30))
74
75 (defconstant single-float-digits
76   (+ (byte-size single-float-significand-byte) 1))
77
78 (defconstant double-float-digits
79   (+ (byte-size double-float-significand-byte) n-word-bits 1))
80
81 ;;; This looks wrong - CSR
82 (defconstant long-float-digits
83   (+ (byte-size long-float-significand-byte) n-word-bits 1))
84
85 (defconstant float-inexact-trap-bit (ash 1 0))
86 (defconstant float-divide-by-zero-trap-bit (ash 1 1))
87 (defconstant float-underflow-trap-bit (ash 1 2))
88 (defconstant float-overflow-trap-bit (ash 1 3))
89 (defconstant float-invalid-trap-bit (ash 1 4))
90
91 (defconstant float-round-to-nearest 0)
92 (defconstant float-round-to-zero 1)
93 (defconstant float-round-to-positive 2)
94 (defconstant float-round-to-negative 3)
95
96 (defconstant-eqx float-rounding-mode (byte 2 30) #'equalp)        ; RD 
97 (defconstant-eqx float-sticky-bits (byte 5 5) #'equalp)   ; aexc
98 (defconstant-eqx float-traps-byte (byte 5 23) #'equalp)   ; TEM
99 (defconstant-eqx float-exceptions-byte (byte 5 0) #'equalp)       ; cexc
100
101 ;;; According to the SPARC doc (as opposed to FPU doc), the fast mode
102 ;;; bit (EFM) is "reserved", and should always be zero.  However, for
103 ;;; sparc-V8 and sparc-V9, it appears to work, causing denormals to
104 ;;; be truncated to 0 silently.
105 (defconstant float-fast-bit (ash 1 22))
106
107 ); eval-when
108
109 ;;; NUMBER-STACK-DISPLACEMENT
110 ;;;
111 ;;; The number of bytes reserved above the number stack pointer.  These
112 ;;; slots are required by architecture for a place to spill register windows.
113 ;;;
114 ;;; FIXME: Where is this used?
115 (defconstant number-stack-displacement
116   (* 16 n-word-bytes))
117
118 \f
119 ;;;; Description of the target address space.
120
121 ;;; Where to put the different spaces.  Must match the C code!
122 #!+linux
123 (progn
124   (defconstant read-only-space-start #x10000000)
125   (defconstant read-only-space-end #x15000000)
126
127   (defconstant static-space-start    #x28000000)
128   (defconstant static-space-end #x2c000000)
129
130   ;; From alpha/parms.lisp:
131   ;; this is used in PURIFY as part of a sloppy check to see if a pointer
132   ;; is in dynamic space.  Chocolate brownie for the first person to fix it
133   ;; -dan 20010502
134   (defconstant dynamic-space-start   #x30000000)
135   (defconstant dynamic-space-end     #x38000000)
136
137   (defconstant dynamic-0-space-start   #x30000000)
138   (defconstant dynamic-0-space-end     #x38000000)
139   
140   (defconstant dynamic-1-space-start   #x40000000)
141   (defconstant dynamic-1-space-end     #x48000000)
142
143   (defconstant control-stack-start   #x50000000)
144   (defconstant control-stack-end     #x51000000)
145
146   (defconstant binding-stack-start    #x60000000)
147   (defconstant binding-stack-end      #x61000000))
148
149 #!+solaris ; maybe someday.
150 (progn
151   (defparameter target-read-only-space-start #x10000000)
152   (defparameter target-static-space-start    #x28000000)
153   (defparameter target-dynamic-space-start   #x40000000))
154 \f
155 ;;;; other random constants.
156
157 (defenum (:suffix -trap :start 8)
158   halt
159   pending-interrupt
160   error
161   cerror
162   breakpoint
163   fun-end-breakpoint
164   after-breakpoint)
165
166 (defenum (:prefix object-not- :suffix -trap :start 16)
167   list
168   instance)
169
170 (defenum (:prefix trace-table-)
171   normal
172   call-site
173   fun-prologue
174   fun-epilogue)
175 \f
176 ;;;; static symbols.
177
178 ;;; These symbols are loaded into static space directly after NIL so
179 ;;; that the system can compute their address by adding a constant
180 ;;; amount to NIL.
181 ;;;
182 ;;; The fdefn objects for the static functions are loaded into static
183 ;;; space directly after the static symbols.  That way, the raw-addr
184 ;;; can be loaded directly out of them by indirecting relative to NIL.
185 ;;;
186 (defparameter *static-symbols*
187   '(t
188
189     ;; The C startup code must fill these in.
190     *posix-argv*
191     ;;lisp::lisp-environment-list
192     ;;lisp::lisp-command-line-list
193     sb!impl::*!initial-fdefn-objects*
194
195     ;; Functions that the C code needs to call
196     maybe-gc
197     sb!kernel::internal-error
198     sb!di::handle-breakpoint
199     sb!di::handle-fun-end-breakpoint
200
201     ;; Free Pointers.
202     *read-only-space-free-pointer*
203     *static-space-free-pointer*
204     *initial-dynamic-space-free-pointer*
205
206     ;; Things needed for non-local-exit.
207     *current-catch-block*
208     *current-unwind-protect-block*
209
210     ;; Interrupt Handling
211     *free-interrupt-context-index*
212     sb!unix::*interrupts-enabled*
213     sb!unix::*interrupt-pending*
214     ))
215
216 (defparameter *static-funs*
217   '(length
218     two-arg-+ two-arg-- two-arg-* two-arg-/ two-arg-< two-arg-> two-arg-=
219     two-arg-<= two-arg->= two-arg-/= eql %negate
220     two-arg-and two-arg-ior two-arg-xor
221     two-arg-gcd two-arg-lcm
222     ))
223 \f
224 ;;;; Assembler parameters:
225
226 ;;; The number of bits per element in the assemblers code vector.
227 ;;;
228 (defparameter *assembly-unit-length* 8)
229
230 \f
231 ;;;; Pseudo-atomic trap number
232 ;;; KLUDGE
233 #!-linux
234 (defconstant pseudo-atomic-trap 16)
235 #!+linux
236 (defconstant pseudo-atomic-trap #x40)