b90d8a8d23cce05e0ac4c4d703b44dd6bb3f7549
[sbcl/simd.git] / src / compiler / generic / early-objdef.lisp
blobb90d8a8d23cce05e0ac4c4d703b44dd6bb3f7549
1 ;;;; type-based constants
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!VM")
14 ;;; FIXME: It's clever using :SUFFIX -LOWTAG for these things, but
15 ;;; it's a pain for people just learning to find their way around the
16 ;;; code who want to use lexical search to figure out where things
17 ;;; like EVEN-FIXNUM-LOWTAG are defined. Remove the :SUFFIXes and just
18 ;;; expand out the full names. Or even define them in DEF
19 ;;; EVEN-FIXNUM-LOWTAG style so searches like
20 ;;; 'def.*even-fixnum-lowtag' can find them.
22 ;;; Tags for the main low-level types are stored in the low n (usually three)
23 ;;; bits to identify the type of a machine word. Certain constraints
24 ;;; apply:
25 ;;; * EVEN-FIXNUM-LOWTAG and ODD-FIXNUM-LOWTAG must be 0 and 4: code
26 ;;; which shifts left two places to convert raw integers to tagged
27 ;;; fixnums is ubiquitous.
28 ;;; * LIST-POINTER-LOWTAG + N-WORD-BYTES = OTHER-POINTER-LOWTAG: NIL
29 ;;; is both a cons and a symbol (at the same address) and depends on this.
30 ;;; See the definition of SYMBOL in objdef.lisp
31 ;;; * OTHER-POINTER-LOWTAG > 4: Some code in the SPARC backend,
32 ;;; which uses bit 2 of the ALLOC register to indicate that
33 ;;; PSEUDO-ATOMIC is on, doesn't strip the low bits of reg_ALLOC
34 ;;; before ORing in OTHER-POINTER-LOWTAG within a PSEUDO-ATOMIC
35 ;;; section.
36 ;;; * OTHER-IMMEDIATE-0-LOWTAG are spaced 4 apart: various code wants to
37 ;;; iterate through these
38 ;;; * Allocation code on Alpha wants lowtags for heap-allocated
39 ;;; objects to be odd.
40 ;;; (These are just the ones we know about as of sbcl-0.7.1.22. There
41 ;;; might easily be more, since these values have stayed highly
42 ;;; constrained for more than a decade, an inviting target for
43 ;;; inventive abstraction-phobic maintainers.:-)
44 (eval-when (:compile-toplevel :load-toplevel :execute)
45 ;; The EVAL-WHEN is necessary (at least for Lispworks), because the
46 ;; second DEFENUM uses the value of OTHER-IMMEDIATE-0-LOWTAG, which is
47 ;; defined in the first DEFENUM. -- AL 20000216
48 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
49 (defenum (:suffix -lowtag)
50 even-fixnum
51 instance-pointer
52 other-immediate-0
53 pad0 pad1 pad2
54 other-immediate-1
55 list-pointer
56 odd-fixnum
57 fun-pointer
58 other-immediate-2
59 pad3 pad4 pad5
60 other-immediate-3
61 other-pointer)
62 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
63 (defenum (:suffix -lowtag)
64 even-fixnum
65 instance-pointer
66 other-immediate-0
67 list-pointer
68 odd-fixnum
69 fun-pointer
70 other-immediate-1
71 other-pointer))
73 (def!constant nil-value
74 (+ static-space-start n-word-bytes other-pointer-lowtag))
76 ;;; the heap types, stored in 8 bits of the header of an object on the
77 ;;; heap, to identify the type of the heap object (which'll be at
78 ;;; least two machine words, often more)
79 ;;;
80 ;;; Note: the order specified here is not critical for correctness,
81 ;;; but (FIXME) with %TEST-HEADERS as currently defined, BIGNUM must
82 ;;; be first, and COMPLEX-ARRAY must be last.
83 ;;;
84 ;;; However, for efficiency, we prefer contiguous sets of widetags for
85 ;;; "similar" objects, so that type checking can be done with a range
86 ;;; check, rather than several individual checks.
87 ;;;
88 ;;; * BIGNUM + RATIO (+ FIXNUM) = RATIONAL
89 ;;;
90 ;;; * SINGLE-FLOAT + DOUBLE-FLOAT + LONG-FLOAT = FLOAT
91 ;;;
92 ;;; * RATIONAL + FLOAT = REAL
93 ;;;
94 ;;; * (FIXME: COMPLEX example, which needs fixing anyway -- see
95 ;;; UPGRADED-COMPLEX-PART-TYPE)
96 ;;;
97 ;;; * SIMPLE-ARRAY-* = (SIMPLE-ARRAY * (*))
98 ;;;
99 ;;; * SIMPLE-ARRAY-NIL + SIMPLE-BASE-STRING = SIMPLE-STRING
101 ;;; * SIMPLE-ARRAY + COMPLEX-ARRAYOID = (SATISFIES ARRAY-HEADER-P)
103 ;;; In addition, with
104 ;;; sufficient care we can cause extra combinations to appear with
105 ;;; differences in only one bit, permitting a more efficient type
106 ;;; test. As an example, if SIMPLE-BASE-STRING = 0xA6 and
107 ;;; COMPLEX-BASE-STRING = 0xE6, then the type test for BASE-STRING is
109 ;;; AND tag, ~0x40, tag
110 ;;; ANDcc tag, 0xA6, tag
111 ;;; JNE tag, label
113 ;;; rather than two separate tests and jumps
114 (defenum (:suffix -widetag
115 ;; The first widetag must be greater than SB!VM:LOWTAG-LIMIT
116 ;; otherwise code in generic/early-type-vops will suffer
117 ;; a long, horrible death. --njf, 2004-08-09
118 :start (+ (ash 1 n-lowtag-bits) other-immediate-0-lowtag)
119 :step 4)
120 ;; NOTE: the binary numbers off to the side are only valid for 32-bit
121 ;; ports; add #b1000 if you want to know the values for 64-bit ports.
122 ;; And note that the numbers get a little scrambled further down.
123 ;; --njf, 2004-08-09
124 bignum ; 00001010
125 ratio ; 00001110
126 single-float ; 00010010
127 double-float ; 00010110
128 complex ; 00011010
129 complex-single-float ; 00011110
130 complex-double-float ; 00100010
132 code-header ; 00100110
134 simple-fun-header ; 00101010
135 closure-header ; 00101110
136 funcallable-instance-header ; 00110010
138 return-pc-header ; 00110110
139 value-cell-header ; 00111010
140 symbol-header ; 00111110
141 character ; 01000010
142 sap ; 01000110
143 unbound-marker ; 01001010
144 weak-pointer ; 01001110
145 instance-header ; 01010010
146 fdefn ; 01010110
148 no-tls-value-marker ; 01011010
149 #!-(and sb-lutex sb-thread)
150 unused01
151 #!+(and sb-lutex sb-thread)
152 lutex ; 01011110
153 unused02 ; 01100010
154 unused03 ; 01100110
155 unused04 ; 01101010
156 unused05 ; 01101110
157 unused06 ; 01110010
158 unused07 ; 01110110
159 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
160 unused08 ; 01111010
161 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
162 unused09 ; 01111110
164 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
165 unused10 ; 10000010
166 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
167 unused11 ; 10000110
169 simple-array-unsigned-byte-2 ; 10001010
170 simple-array-unsigned-byte-4 ; 10001110
171 simple-array-unsigned-byte-7 ; 10010010
172 simple-array-unsigned-byte-8 ; 10010110
173 simple-array-unsigned-byte-15 ; 10011010
174 simple-array-unsigned-byte-16 ; 10011110
175 simple-array-nil ; 10100010
176 simple-base-string ; 10100110
177 #!+sb-unicode simple-character-string
178 simple-bit-vector ; 10101010
179 simple-vector ; 10101110
180 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
181 simple-array-unsigned-byte-29 ; 10110010
182 simple-array-unsigned-byte-31 ; 10110110
183 simple-array-unsigned-byte-32 ; 10111010
184 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
185 simple-array-unsigned-byte-60
186 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
187 simple-array-unsigned-byte-63
188 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
189 simple-array-unsigned-byte-64
190 simple-array-signed-byte-8 ; 10111110
191 simple-array-signed-byte-16 ; 11000010
192 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
193 simple-array-signed-byte-30 ; 11000110
194 simple-array-signed-byte-32 ; 11001010
195 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
196 simple-array-signed-byte-61
197 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
198 simple-array-signed-byte-64
199 simple-array-single-float ; 11001110
200 simple-array-double-float ; 11010010
201 simple-array-complex-single-float ; 11010110
202 simple-array-complex-double-float ; 11011010
203 simple-array ; 11011110
204 complex-vector-nil ; 11100010
205 complex-base-string ; 11100110
206 #!+sb-unicode complex-character-string
207 complex-bit-vector ; 11101010
208 complex-vector ; 11101110
209 complex-array ; 11110010
211 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
212 unused12 ; 11110110
213 #!+(and #.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
214 (not sb-unicode))
215 unused13 ; 11111010
216 #!+(and #.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
217 (not sb-unicode))
218 unused14 ; 11111110
221 ;;; the different vector subtypes
222 (defenum (:prefix vector- :suffix -subtype)
223 normal
224 unused
225 valid-hashing)