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