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

  ViewVC Help
Powered by ViewVC 1.1.5