2224bd20f6aacf6e8514f250a426de58eee3aa95
[sbcl.git] / src / compiler / alpha / 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
12 (eval-when  (:compile-toplevel :load-toplevel :execute)
13
14 ;;; number of bits per word where a word holds one lisp descriptor
15 (def!constant n-word-bits 32)
16
17 ;;; the natural width of a machine word (as seen in e.g. register width,
18 ;;; address space)
19 (def!constant n-machine-word-bits 64)
20
21 ;;; number of bits per byte where a byte is the smallest addressable
22 ;;; object
23 (def!constant n-byte-bits 8)
24
25 (def!constant float-sign-shift 31)
26
27 (def!constant single-float-bias 126)
28 (defconstant-eqx single-float-exponent-byte (byte 8 23) #'equalp)
29 (defconstant-eqx single-float-significand-byte (byte 23 0) #'equalp)
30 (def!constant single-float-normal-exponent-min 1)
31 (def!constant single-float-normal-exponent-max 254)
32 (def!constant single-float-hidden-bit (ash 1 23))
33 (def!constant single-float-trapping-nan-bit (ash 1 22))
34
35 (def!constant double-float-bias 1022)
36 (defconstant-eqx double-float-exponent-byte (byte 11 20)   #'equalp)
37 (defconstant-eqx double-float-significand-byte (byte 20 0) #'equalp)
38 (def!constant double-float-normal-exponent-min 1)
39 (def!constant double-float-normal-exponent-max #x7FE)
40 (def!constant double-float-hidden-bit (ash 1 20))
41 (def!constant double-float-trapping-nan-bit (ash 1 19))
42
43 (def!constant single-float-digits
44   (+ (byte-size single-float-significand-byte) 1))
45
46 (def!constant double-float-digits
47   (+ (byte-size double-float-significand-byte) n-word-bits 1))
48
49 ;;; These values are originally from the DEC Assembly Language
50 ;;; Programmers guide.  Where possible we read/write the software
51 ;;; fp_control word, which apparently is necessary for the OS FPU
52 ;;; completion (OS handler which fixes up non-IEEE answers that the
53 ;;; hardware occasionally gives us) to work properly.  The rounding
54 ;;; mode, however, can't be set that way, so we have to deal with that
55 ;;; directly.  (FIXME: we actually don't suport setting the rounding mode
56 ;;; at the moment anyway)
57
58 ;;; Short guide to floating point trap terminology: an "exception" is
59 ;;; cheap and can happen at almost any time.  An exception will only
60 ;;; generate a trap if that trap is enabled, otherwise a default value
61 ;;; will be substituted.  A "trap" will end up somewhere in the
62 ;;; kernel, which may play by its own rules,  (on Alpha it allegedly
63 ;;; actually fixes up some non-IEEE compliant results to get the
64 ;;; _right_ answer) but if something is really wrong will eventually
65 ;;; signal SIGFPE and let us sort it out.
66
67 ;;; Old comment follows: The active bits are actually in (byte 12 52)
68 ;;; of the fpcr. (byte 6 52) contain the exception flags. Bit 63 is the
69 ;;; bitwise logor of all exceptions.  The enable and exception bytes
70 ;;; are in a software control word manipulated via OS functions and the
71 ;;; bits in the SCP match those defs. This mapping follows
72 ;;; <machine/fpu.h>
73
74 ;;; trap enables are set in software (fp_control)
75 (def!constant float-inexact-trap-bit        (ash 1 4)) ; rw
76 (def!constant float-underflow-trap-bit      (ash 1 3)) ; rw
77 (def!constant float-overflow-trap-bit       (ash 1 2)) ; ro
78 (def!constant float-divide-by-zero-trap-bit (ash 1 1)) ; ro
79 (def!constant float-invalid-trap-bit        (ash 1 0)) ; ro
80 (defconstant-eqx float-traps-byte          (byte 6  1) #'equalp)
81
82 ;;; exceptions are also read/written in software (by syscalls, no less).
83 ;;; This is kind of dumb, but has to be done
84 (defconstant-eqx float-sticky-bits     (byte 6 17) #'equalp)    ; fp_control
85
86 ;;; (We don't actually _have_ "current exceptions" on Alpha; the
87 ;;; hardware only ever sets bits.  So, set this the same as accrued
88 ;;; exceptions)
89 (defconstant-eqx float-exceptions-byte (byte 6 17)  #'equalp)
90
91 ;;; Rounding modes can only be set by frobbing the hardware fpcr directly
92 (def!constant float-round-to-zero     0)
93 (def!constant float-round-to-negative 1)
94 (def!constant float-round-to-nearest  2)
95 (def!constant float-round-to-positive 3)
96 (defconstant-eqx float-rounding-mode   (byte 2 58) #'equalp)
97
98 ;;; Miscellaneous stuff - I think it's far to say that you deserve
99 ;;; what you get if you ask for fast mode.
100 (def!constant float-fast-bit 0)
101
102 ); eval-when
103
104
105 \f
106 ;;;; Description of the target address space.
107
108 ;;; Where to put the different spaces.
109 ;;;
110
111 #!+linux
112 (progn
113   (def!constant read-only-space-start #x20000000)
114   (def!constant read-only-space-end   #x24000000))
115
116 #!+osf1
117 (progn
118   (defconstant read-only-space-start #x10000000)
119   (defconstant read-only-space-end   #x25000000))
120
121
122 (def!constant static-space-start    #x28000000)
123 (def!constant static-space-end      #x2c000000)
124
125 (def!constant dynamic-0-space-start   #x30000000)
126 (def!constant dynamic-0-space-end     #x3fff0000)
127
128 (def!constant dynamic-1-space-start   #x40000000)
129 (def!constant dynamic-1-space-end     #x4fff0000)
130
131 ;;; FIXME nothing refers to either of these in alpha or x86 cmucl
132 ;;; backend, so they could probably be removed.
133
134 ;; The space-register holding the lisp heap.
135 (def!constant lisp-heap-space 4)
136
137 ;; The space-register holding the C text segment.
138 (def!constant c-text-space 4)
139
140 ;;; the X86 port defines *nil-value* as (+ *target-static-space-start* #xB)
141 ;;; here, but it seems to be the only port that needs to know the
142 ;;; location of NIL from lisp.
143 \f
144 ;;;; other miscellaneous constants
145
146 (defenum (:suffix -trap :start 8)
147   halt
148   pending-interrupt
149   error
150   cerror
151   breakpoint
152   fun-end-breakpoint
153   single-step-breakpoint)
154
155 (defenum (:prefix trace-table-)
156   normal
157   call-site
158   fun-prologue
159   fun-epilogue)
160 \f
161 ;;;; static symbols
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   (append
173    *common-static-symbols*
174    *c-callable-static-symbols*
175    '()))
176
177 (defparameter *static-funs*
178   '(length
179     sb!kernel:two-arg-+
180     sb!kernel:two-arg--
181     sb!kernel:two-arg-*
182     sb!kernel:two-arg-/
183     sb!kernel:two-arg-<
184     sb!kernel:two-arg->
185     sb!kernel:two-arg-=
186     ;; FIXME: Is this
187     ;;     probably need the following as they are defined in
188     ;;     arith.lisp: two-arg-<= two-arg->= two-arg-/=
189     ;; a comment from old CMU CL or old old CMU CL or
190     ;; the SBCL alpha port or what? Do we need to worry about it,
191     ;; or can we delete it?
192     sb!kernel:two-arg-/=
193     eql
194     sb!kernel:%negate
195     sb!kernel:two-arg-and
196     sb!kernel:two-arg-ior
197     sb!kernel:two-arg-xor
198     sb!kernel:two-arg-eqv
199     sb!kernel:two-arg-gcd
200     sb!kernel:two-arg-lcm))