/[cmucl]/src/compiler/array-tran.lisp
ViewVC logotype

Contents of /src/compiler/array-tran.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.33 - (show annotations)
Sun Apr 27 11:43:43 2003 UTC (10 years, 11 months ago) by gerd
Branch: MAIN
CVS Tags: remove_negative_zero_not_zero
Changes since 1.32: +15 -4 lines
	* src/compiler/array-tran.lisp (svref, schar, char): Define
	source transforms so that they don't accept more than one
	index, for better error messages.
1 ;;; -*- Package: C; Log: C.Log -*-
2 ;;;
3 ;;; **********************************************************************
4 ;;; This code was written as part of the CMU Common Lisp project at
5 ;;; Carnegie Mellon University, and has been placed in the public domain.
6 ;;;
7 (ext:file-comment
8 "$Header: /tiger/var/lib/cvsroots/cmucl/src/compiler/array-tran.lisp,v 1.33 2003/04/27 11:43:43 gerd Exp $")
9 ;;;
10 ;;; **********************************************************************
11 ;;;
12 ;;; This file contains array specific optimizers and transforms.
13 ;;;
14 ;;; Extracted from srctran and extended by William Lott.
15 ;;;
16 (in-package "C")
17
18
19 ;;;; Derive-Type Optimizers
20
21 ;;; ASSERT-ARRAY-RANK -- internal
22 ;;;
23 ;;; Array operations that use a specific number of indices implicitly assert
24 ;;; that the array is of that rank.
25 ;;;
26 (defun assert-array-rank (array rank)
27 (assert-continuation-type
28 array
29 (specifier-type `(array * ,(make-list rank :initial-element '*)))))
30
31 ;;; EXTRACT-ELEMENT-TYPE -- internal
32 ;;;
33 ;;; Array access functions return an object from the array, hence it's
34 ;;; type will be asserted to be array element type.
35 ;;;
36 (defun extract-element-type (array)
37 (let ((type (continuation-type array)))
38 (if (array-type-p type)
39 (array-type-element-type type)
40 *universal-type*)))
41
42 ;;; EXTRACT-UPGRADED-ELEMENT-TYPE -- internal
43 ;;;
44 ;;; Array access functions return an object from the array, hence it's
45 ;;; type is going to be the array upgraded element type.
46 ;;;
47 (defun extract-upgraded-element-type (array)
48 (let ((type (continuation-type array)))
49 (if (array-type-p type)
50 (array-type-specialized-element-type type)
51 *universal-type*)))
52
53 ;;; ASSERT-NEW-VALUE-TYPE -- internal
54 ;;;
55 ;;; The ``new-value'' for array setters must fit in the array, and the
56 ;;; return type is going to be the same as the new-value for setf functions.
57 ;;;
58 (defun assert-new-value-type (new-value array)
59 (let ((type (continuation-type array)))
60 (when (array-type-p type)
61 (assert-continuation-optional-type new-value
62 (array-type-specialized-element-type type))))
63 (continuation-type new-value))
64
65 ;;; Unsupplied-Or-NIL -- Internal
66 ;;;
67 ;;; Return true if Arg is NIL, or is a constant-continuation whose value is
68 ;;; NIL, false otherwise.
69 ;;;
70 (defun unsupplied-or-nil (arg)
71 (declare (type (or continuation null) arg))
72 (or (not arg)
73 (and (constant-continuation-p arg)
74 (not (continuation-value arg)))))
75
76
77 ;;; ARRAY-IN-BOUNDS-P -- derive-type optimizer.
78 ;;;
79 (defoptimizer (array-in-bounds-p derive-type) ((array &rest indices))
80 (assert-array-rank array (length indices))
81 *universal-type*)
82
83 ;;; AREF -- derive-type optimizer.
84 ;;;
85 (defoptimizer (aref derive-type) ((array &rest indices) node)
86 (assert-array-rank array (length indices))
87 ;; If the node continuation has a single use then assert its type.
88 (let ((cont (node-cont node)))
89 (when (= (length (find-uses cont)) 1)
90 (assert-continuation-type cont (extract-upgraded-element-type array))))
91 (extract-upgraded-element-type array))
92
93 ;;; %ASET -- derive-type optimizer.
94 ;;;
95 (defoptimizer (%aset derive-type) ((array &rest stuff))
96 (assert-array-rank array (1- (length stuff)))
97 (assert-new-value-type (car (last stuff)) array))
98
99 ;;; DATA-VECTOR-REF -- derive-type optimizer.
100 ;;;
101 (defoptimizer (data-vector-ref derive-type) ((array index))
102 (extract-upgraded-element-type array))
103
104 ;;; DATA-VECTOR-SET -- derive-type optimizer.
105 ;;;
106 (defoptimizer (data-vector-set derive-type) ((array index new-value))
107 (assert-new-value-type new-value array))
108
109 ;;; %WITH-ARRAY-DATA -- derive-type optimizer.
110 ;;;
111 ;;; Figure out the type of the data vector if we know the argument element
112 ;;; type.
113 ;;;
114 (defoptimizer (%with-array-data derive-type) ((array start end))
115 (let ((atype (continuation-type array)))
116 (when (array-type-p atype)
117 (values-specifier-type
118 `(values (simple-array ,(type-specifier
119 (array-type-element-type atype))
120 (*))
121 index index index)))))
122
123
124 ;;; ARRAY-ROW-MAJOR-INDEX -- derive-type optimizer.
125 ;;;
126 (defoptimizer (array-row-major-index derive-type) ((array &rest indices))
127 (assert-array-rank array (length indices))
128 *universal-type*)
129
130 ;;; ROW-MAJOR-AREF -- derive-type optimizer.
131 ;;;
132 (defoptimizer (row-major-aref derive-type) ((array index))
133 (extract-upgraded-element-type array))
134
135 ;;; %SET-ROW-MAJOR-AREF -- derive-type optimizer.
136 ;;;
137 (defoptimizer (%set-row-major-aref derive-type) ((array index new-value))
138 (assert-new-value-type new-value array))
139
140 ;;; MAKE-ARRAY -- derive-type optimizer.
141 ;;;
142 (defoptimizer (make-array derive-type)
143 ((dims &key initial-element element-type initial-contents
144 adjustable fill-pointer displaced-index-offset displaced-to))
145 (let ((simple (and (unsupplied-or-nil adjustable)
146 (unsupplied-or-nil displaced-to)
147 (unsupplied-or-nil fill-pointer))))
148 (specifier-type
149 `(,(if simple 'simple-array 'array)
150 ,(cond ((not element-type) 't)
151 ((constant-continuation-p element-type)
152 (continuation-value element-type))
153 (t
154 '*))
155 ,(cond ((not simple)
156 '*)
157 ((constant-continuation-p dims)
158 (let ((val (continuation-value dims)))
159 (if (listp val) val (list val))))
160 ((csubtypep (continuation-type dims)
161 (specifier-type 'integer))
162 '(*))
163 (t
164 '*))))))
165
166
167 ;;;; Constructors.
168
169 ;;; VECTOR -- source-transform.
170 ;;;
171 ;;; Convert VECTOR into a make-array followed by setfs of all the elements.
172 ;;;
173 (def-source-transform vector (&rest elements)
174 (if (byte-compiling)
175 (values nil t)
176 (let ((len (length elements))
177 (n -1))
178 (once-only ((n-vec `(make-array ,len)))
179 `(progn
180 ,@(mapcar #'(lambda (el)
181 (once-only ((n-val el))
182 `(locally (declare (optimize (safety 0)))
183 (setf (svref ,n-vec ,(incf n))
184 ,n-val))))
185 elements)
186 ,n-vec)))))
187
188
189 ;;; MAKE-STRING -- source-transform.
190 ;;;
191 ;;; Just convert it into a make-array.
192 ;;;
193 (deftransform make-string ((length &key (element-type 'base-char)
194 (initial-element #\NULL)))
195 `(make-array (the (values index &rest t) length)
196 :element-type element-type
197 :initial-element initial-element))
198
199 (defconstant array-info
200 '((base-char #\NULL 8 vm:simple-string-type)
201 (single-float 0.0s0 32 vm:simple-array-single-float-type)
202 (double-float 0.0d0 64 vm:simple-array-double-float-type)
203 #+long-float (long-float 0.0l0 #+x86 96 #+sparc 128
204 vm:simple-array-long-float-type)
205 (bit 0 1 vm:simple-bit-vector-type)
206 ((unsigned-byte 2) 0 2 vm:simple-array-unsigned-byte-2-type)
207 ((unsigned-byte 4) 0 4 vm:simple-array-unsigned-byte-4-type)
208 ((unsigned-byte 8) 0 8 vm:simple-array-unsigned-byte-8-type)
209 ((unsigned-byte 16) 0 16 vm:simple-array-unsigned-byte-16-type)
210 ((unsigned-byte 32) 0 32 vm:simple-array-unsigned-byte-32-type)
211 ((signed-byte 8) 0 8 vm:simple-array-signed-byte-8-type)
212 ((signed-byte 16) 0 16 vm:simple-array-signed-byte-16-type)
213 ((signed-byte 30) 0 32 vm:simple-array-signed-byte-30-type)
214 ((signed-byte 32) 0 32 vm:simple-array-signed-byte-32-type)
215 ((complex single-float) #C(0.0s0 0.0s0) 64
216 vm:simple-array-complex-single-float-type)
217 ((complex double-float) #C(0.0d0 0.0d0) 128
218 vm:simple-array-complex-double-float-type)
219 #+long-float
220 ((complex long-float) #C(0.0l0 0.0l0) #+x86 192 #+sparc 256
221 vm:simple-array-complex-long-float-type)
222 (t 0 32 vm:simple-vector-type)))
223
224 ;;; MAKE-ARRAY -- source-transform.
225 ;;;
226 ;;; The integer type restriction on the length assures that it will be a
227 ;;; vector. The lack of adjustable, fill-pointer, and displaced-to keywords
228 ;;; assures that it will be simple.
229 ;;;
230 (deftransform make-array ((length &key initial-element element-type)
231 (integer &rest *))
232 (let* ((eltype (cond ((not element-type) t)
233 ((not (constant-continuation-p element-type))
234 (give-up "Element-Type is not constant."))
235 (t
236 (continuation-value element-type))))
237 (len (if (constant-continuation-p length)
238 (continuation-value length)
239 '*))
240 (spec `(simple-array ,eltype (,len)))
241 (eltype-type (specifier-type eltype)))
242 (multiple-value-bind
243 (default-initial-element element-size typecode)
244 (dolist (info array-info
245 (give-up "Cannot open-code creation of ~S" spec))
246 (when (csubtypep eltype-type (specifier-type (car info)))
247 (return (values-list (cdr info)))))
248 (let* ((nwords-form
249 (if (>= element-size vm:word-bits)
250 `(* length ,(/ element-size vm:word-bits))
251 (let ((elements-per-word (/ 32 element-size)))
252 `(truncate (+ length
253 ,(if (eq 'vm:simple-string-type typecode)
254 elements-per-word
255 (1- elements-per-word)))
256 ,elements-per-word))))
257 (constructor
258 `(truly-the ,spec
259 (allocate-vector ,typecode length ,nwords-form))))
260 (values
261 (cond ((and default-initial-element
262 (or (null initial-element)
263 (and (constant-continuation-p initial-element)
264 (eql (continuation-value initial-element)
265 default-initial-element))))
266 (unless (csubtypep (ctype-of default-initial-element)
267 eltype-type)
268 (compiler-note "Default initial element ~s is not a ~s."
269 default-initial-element eltype))
270 constructor)
271 (t
272 `(truly-the ,spec (fill ,constructor initial-element))))
273 '((declare (type index length))))))))
274
275 ;;; MAKE-ARRAY -- transform.
276 ;;;
277 ;;; The list type restriction does not assure that the result will be a
278 ;;; multi-dimensional array. But the lack of
279 ;;;
280 (deftransform make-array ((dims &key initial-element element-type)
281 (list &rest *))
282 (unless (or (null element-type) (constant-continuation-p element-type))
283 (give-up "Element-type not constant; cannot open code array creation"))
284 (unless (constant-continuation-p dims)
285 (give-up "Dimension list not constant; cannot open code array creation"))
286 (let ((dims (continuation-value dims)))
287 (unless (every #'integerp dims)
288 (give-up "Dimension list contains something other than an integer: ~S"
289 dims))
290 (if (= (length dims) 1)
291 `(make-array ',(car dims)
292 ,@(when initial-element
293 '(:initial-element initial-element))
294 ,@(when element-type
295 '(:element-type element-type)))
296 (let* ((total-size (reduce #'* dims))
297 (rank (length dims))
298 (spec `(simple-array
299 ,(cond ((null element-type) t)
300 ((constant-continuation-p element-type)
301 (continuation-value element-type))
302 (t '*))
303 ,(make-list rank :initial-element '*))))
304 `(let ((header (make-array-header vm:simple-array-type ,rank)))
305 (setf (%array-fill-pointer header) ,total-size)
306 (setf (%array-fill-pointer-p header) nil)
307 (setf (%array-available-elements header) ,total-size)
308 (setf (%array-data-vector header)
309 (make-array ,total-size
310 ,@(when element-type
311 '(:element-type element-type))
312 ,@(when initial-element
313 '(:initial-element initial-element))))
314 (setf (%array-displaced-p header) nil)
315 ,@(let ((axis -1))
316 (mapcar #'(lambda (dim)
317 `(setf (%array-dimension header ,(incf axis))
318 ,dim))
319 dims))
320 (truly-the ,spec header))))))
321
322
323 ;;;; Random properties of arrays.
324
325 ;;; Transforms for various random array properties. If the property is know
326 ;;; at compile time because of a type spec, use that constant value.
327
328 ;;; ARRAY-RANK -- transform.
329 ;;;
330 ;;; If we can tell the rank from the type info, use it instead.
331 ;;;
332 (deftransform array-rank ((array))
333 (let ((array-type (continuation-type array)))
334 (unless (array-type-p array-type)
335 (give-up))
336 (let ((dims (array-type-dimensions array-type)))
337 (if (not (listp dims))
338 (give-up "Array rank not known at compile time: ~S" dims)
339 (length dims)))))
340
341 ;;; ARRAY-DIMENSION -- transform.
342 ;;;
343 ;;; If we know the dimensions at compile time, just use it. Otherwise, if
344 ;;; we can tell that the axis is in bounds, convert to %array-dimension
345 ;;; (which just indirects the array header) or length (if it's simple and a
346 ;;; vector).
347 ;;;
348 (deftransform array-dimension ((array axis)
349 (array index))
350 (unless (constant-continuation-p axis)
351 (give-up "Axis not constant."))
352 (let ((array-type (continuation-type array))
353 (axis (continuation-value axis)))
354 (unless (array-type-p array-type)
355 (give-up))
356 (let ((dims (array-type-dimensions array-type)))
357 (unless (listp dims)
358 (give-up
359 "Array dimensions unknown, must call array-dimension at runtime."))
360 (unless (> (length dims) axis)
361 (abort-transform "Array has dimensions ~S, ~D is too large."
362 dims axis))
363 (let ((dim (nth axis dims)))
364 (cond ((integerp dim)
365 dim)
366 ((= (length dims) 1)
367 (ecase (array-type-complexp array-type)
368 ((t)
369 '(%array-dimension array 0))
370 ((nil)
371 '(length array))
372 ((:maybe *)
373 (give-up "Can't tell if array is simple."))))
374 (t
375 '(%array-dimension array axis)))))))
376
377 ;;; LENGTH -- transform.
378 ;;;
379 ;;; If the length has been declared and it's simple, just return it.
380 ;;;
381 (deftransform length ((vector)
382 ((simple-array * (*))))
383 (let ((type (continuation-type vector)))
384 (unless (array-type-p type)
385 (give-up))
386 (let ((dims (array-type-dimensions type)))
387 (unless (and (listp dims) (integerp (car dims)))
388 (give-up "Vector length unknown, must call length at runtime."))
389 (car dims))))
390
391 ;;; LENGTH -- transform.
392 ;;;
393 ;;; All vectors can get their length by using vector-length. If it's simple,
394 ;;; it will extract the length slot from the vector. It it's complex, it will
395 ;;; extract the fill pointer slot from the array header.
396 ;;;
397 (deftransform length ((vector) (vector))
398 '(vector-length vector))
399
400
401 ;;; If a simple array with known dimensions, then vector-length is a
402 ;;; compile-time constant.
403 ;;;
404 (deftransform vector-length ((vector) ((simple-array * (*))))
405 (let ((vtype (continuation-type vector)))
406 (if (array-type-p vtype)
407 (let ((dim (first (array-type-dimensions vtype))))
408 (when (eq dim '*) (give-up))
409 dim)
410 (give-up))))
411
412
413 ;;; ARRAY-TOTAL-SIZE -- transform.
414 ;;;
415 ;;; Again, if we can tell the results from the type, just use it. Otherwise,
416 ;;; if we know the rank, convert into a computation based on array-dimension.
417 ;;; We can wrap a truly-the index around the multiplications because we know
418 ;;; that the total size must be an index.
419 ;;;
420 (deftransform array-total-size ((array)
421 (array))
422 (let ((array-type (continuation-type array)))
423 (unless (array-type-p array-type)
424 (give-up))
425 (let ((dims (array-type-dimensions array-type)))
426 (unless (listp dims)
427 (give-up "Can't tell the rank at compile time."))
428 (if (member '* dims)
429 (do ((form 1 `(truly-the index
430 (* (array-dimension array ,i) ,form)))
431 (i 0 (1+ i)))
432 ((= i (length dims)) form))
433 (reduce #'* dims)))))
434
435 ;;; ARRAY-HAS-FILL-POINTER-P -- transform.
436 ;;;
437 ;;; Only complex vectors have fill pointers.
438 ;;;
439 (deftransform array-has-fill-pointer-p ((array))
440 (let ((array-type (continuation-type array)))
441 (unless (array-type-p array-type)
442 (give-up))
443 (let ((dims (array-type-dimensions array-type)))
444 (if (and (listp dims) (not (= (length dims) 1)))
445 nil
446 (ecase (array-type-complexp array-type)
447 ((t)
448 t)
449 ((nil)
450 nil)
451 (*
452 (give-up "Array type ambiguous; must call ~
453 array-has-fill-pointer-p at runtime.")))))))
454
455 ;;; %CHECK-BOUND -- transform.
456 ;;;
457 ;;; Primitive used to verify indicies into arrays. If we can tell at
458 ;;; compile-time or we are generating unsafe code, don't bother with the VOP.
459 ;;;
460 (deftransform %check-bound ((array dimension index))
461 (unless (constant-continuation-p dimension)
462 (give-up))
463 (let ((dim (continuation-value dimension)))
464 `(the (integer 0 ,dim) index)))
465 ;;;
466 (deftransform %check-bound ((array dimension index) * *
467 :policy (and (> speed safety) (= safety 0)))
468 'index)
469
470
471 ;;; WITH-ROW-MAJOR-INDEX -- internal.
472 ;;;
473 ;;; Handy macro for computing the row-major index given a set of indices. We
474 ;;; wrap each index with a call to %check-bound to assure that everything
475 ;;; works out correctly. We can wrap all the interior arith with truly-the
476 ;;; index because we know the the resultant row-major index must be an index.
477 ;;;
478 (eval-when (compile eval)
479 ;;;
480 (defmacro with-row-major-index ((array indices index &optional new-value)
481 &rest body)
482 `(let (n-indices dims)
483 (dotimes (i (length ,indices))
484 (push (make-symbol (format nil "INDEX-~D" i)) n-indices)
485 (push (make-symbol (format nil "DIM-~D" i)) dims))
486 (setf n-indices (nreverse n-indices))
487 (setf dims (nreverse dims))
488 `(lambda (,',array ,@n-indices ,@',(when new-value (list new-value)))
489 (let* (,@(let ((,index -1))
490 (mapcar #'(lambda (name)
491 `(,name (array-dimension ,',array
492 ,(incf ,index))))
493 dims))
494 (,',index
495 ,(if (null dims)
496 0
497 (do* ((dims dims (cdr dims))
498 (indices n-indices (cdr indices))
499 (last-dim nil (car dims))
500 (form `(%check-bound ,',array
501 ,(car dims)
502 ,(car indices))
503 `(truly-the index
504 (+ (truly-the index
505 (* ,form
506 ,last-dim))
507 (%check-bound
508 ,',array
509 ,(car dims)
510 ,(car indices))))))
511 ((null (cdr dims)) form)))))
512 ,',@body))))
513 ;;;
514 ); eval-when
515
516 ;;; ARRAY-ROW-MAJOR-INDEX -- transform.
517 ;;;
518 ;;; Just return the index after computing it.
519 ;;;
520 (deftransform array-row-major-index ((array &rest indices))
521 (with-row-major-index (array indices index)
522 index))
523
524
525
526 ;;;; Array accessors:
527
528 ;;; SVREF, %SVSET, SCHAR, %SCHARSET, CHAR,
529 ;;; %CHARSET, SBIT, %SBITSET, BIT, %BITSET
530 ;;; -- source transforms.
531 ;;;
532 ;;; We convert all typed array accessors into aref and %aset with type
533 ;;; assertions on the array.
534 ;;;
535 (macrolet ((frob (reffer setter type)
536 `(progn
537 (def-source-transform ,reffer (a &rest i)
538 (if (byte-compiling)
539 (values nil t)
540 `(aref (the ,',type ,a) ,@i)))
541 (def-source-transform ,setter (a &rest i)
542 (if (byte-compiling)
543 (values nil t)
544 `(%aset (the ,',type ,a) ,@i))))))
545 (frob sbit %sbitset (simple-array bit))
546 (frob bit %bitset (array bit)))
547
548 (macrolet ((frob (reffer setter type)
549 `(progn
550 (def-source-transform ,reffer (a i)
551 (if (byte-compiling)
552 (values nil t)
553 `(aref (the ,',type ,a) ,i)))
554 (def-source-transform ,setter (a i v)
555 (if (byte-compiling)
556 (values nil t)
557 `(%aset (the ,',type ,a) ,i ,v))))))
558 (frob svref %svset simple-vector)
559 (frob schar %scharset simple-string)
560 (frob char %charset string))
561
562 ;;; AREF, %ASET -- transform.
563 ;;;
564 ;;; Convert into a data-vector-ref (or set) with the set of indices replaced
565 ;;; with the an expression for the row major index.
566 ;;;
567 (deftransform aref ((array &rest indices))
568 (with-row-major-index (array indices index)
569 (data-vector-ref array index)))
570 ;;;
571 (deftransform %aset ((array &rest stuff))
572 (let ((indices (butlast stuff)))
573 (with-row-major-index (array indices index new-value)
574 (data-vector-set array index new-value))))
575
576 ;;; ROW-MAJOR-AREF, %SET-ROW-MAJOR-AREF -- transform.
577 ;;;
578 ;;; Just convert into a data-vector-ref (or set) after checking that the
579 ;;; index is inside the array total size.
580 ;;;
581 (deftransform row-major-aref ((array index))
582 `(data-vector-ref array (%check-bound array (array-total-size array) index)))
583 ;;;
584 (deftransform %set-row-major-aref ((array index new-value))
585 `(data-vector-set array
586 (%check-bound array (array-total-size array) index)
587 new-value))
588
589
590 ;;;; Bit-vector array operation canonicalization:
591 ;;;
592 ;;; We convert all bit-vector operations to have the result array specified.
593 ;;; This allows any result allocation to be open-coded, and eliminates the need
594 ;;; for any VM-dependent transforms to handle these cases.
595
596 (dolist (fun '(bit-and bit-ior bit-xor bit-eqv bit-nand bit-nor bit-andc1
597 bit-andc2 bit-orc1 bit-orc2))
598 ;;
599 ;; Make a result array if result is NIL or unsupplied.
600 (deftransform fun ((bit-array-1 bit-array-2 &optional result-bit-array)
601 '(bit-vector bit-vector &optional null) '*
602 :eval-name t :policy (>= speed space))
603 `(,fun bit-array-1 bit-array-2
604 (make-array (length bit-array-1) :element-type 'bit)))
605 ;;
606 ;; If result its T, make it the first arg.
607 (deftransform fun ((bit-array-1 bit-array-2 result-bit-array)
608 '(bit-vector bit-vector (member t)) '*
609 :eval-name t)
610 `(,fun bit-array-1 bit-array-2 bit-array-1)))
611
612 ;;; Similar for BIT-NOT, but there is only one arg...
613 ;;;
614 (deftransform bit-not ((bit-array-1 &optional result-bit-array)
615 (bit-vector &optional null) *
616 :policy (>= speed space))
617 '(bit-not bit-array-1
618 (make-array (length bit-array-1) :element-type 'bit)))
619 ;;;
620 (deftransform bit-not ((bit-array-1 result-bit-array)
621 (bit-vector (constant-argument t)))
622 '(bit-not bit-array-1 bit-array-1))
623
624
625 ;;; ARRAY-HEADER-P -- transform.
626 ;;;
627 ;;; Pick off some constant cases.
628 ;;;
629 (deftransform array-header-p ((array) (array))
630 (let ((type (continuation-type array)))
631 (declare (optimize (safety 3)))
632 (unless (array-type-p type)
633 (give-up))
634 (let ((dims (array-type-dimensions type)))
635 (cond ((csubtypep type (specifier-type '(simple-array * (*))))
636 ;; No array header.
637 nil)
638 ((and (listp dims) (> (length dims) 1))
639 ;; Multi-dimensional array, will have a header.
640 t)
641 (t
642 (give-up))))))

  ViewVC Help
Powered by ViewVC 1.1.5