/[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.19.2.3 - (hide annotations)
Tue May 23 16:36:59 2000 UTC (13 years, 10 months ago) by pw
Branch: RELENG_18
Changes since 1.19.2.2: +10 -10 lines
This set of revisions brings the RELENG_18 branch up to HEAD in preparation
for an 18c release.
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 pw 1.19.2.3 "$Header: /tiger/var/lib/cvsroots/cmucl/src/compiler/array-tran.lisp,v 1.19.2.3 2000/05/23 16:36:59 pw 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 pw 1.19.2.2 ;;; 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 pw 1.19.2.2 ;;; 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 pw 1.19.2.2 (defoptimizer (aref derive-type) ((array &rest indices) node)
85 wlott 1.4 (assert-array-rank array (length indices))
86 pw 1.19.2.2 ;; If the node continuation has a single use then assert its type.
87     (let ((cont (node-cont node)))
88     (when (= (length (find-uses cont)) 1)
89     (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 pw 1.19.2.2 (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 pw 1.19.2.2 (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 pw 1.19.2.2 (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 pw 1.19.2.2 :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 pw 1.19.2.2 #+long-float (long-float 0.0l0 #+x86 96 #+sparc 128
205     vm:simple-array-long-float-type)
206 wlott 1.1 (bit 0 1 vm:simple-bit-vector-type)
207     ((unsigned-byte 2) 0 2 vm:simple-array-unsigned-byte-2-type)
208     ((unsigned-byte 4) 0 4 vm:simple-array-unsigned-byte-4-type)
209     ((unsigned-byte 8) 0 8 vm:simple-array-unsigned-byte-8-type)
210     ((unsigned-byte 16) 0 16 vm:simple-array-unsigned-byte-16-type)
211     ((unsigned-byte 32) 0 32 vm:simple-array-unsigned-byte-32-type)
212 pw 1.19.2.3 ((signed-byte 8) 0 8 vm:simple-array-signed-byte-8-type)
213     ((signed-byte 16) 0 16 vm:simple-array-signed-byte-16-type)
214     ((signed-byte 30) 0 32 vm:simple-array-signed-byte-30-type)
215     ((signed-byte 32) 0 32 vm:simple-array-signed-byte-32-type)
216     ((complex single-float) #C(0.0s0 0.0s0) 64
217     vm:simple-array-complex-single-float-type)
218     ((complex double-float) #C(0.0d0 0.0d0) 128
219     vm:simple-array-complex-double-float-type)
220     #+long-float
221 pw 1.19.2.2 ((complex long-float) #C(0.0l0 0.0l0) #+x86 192 #+sparc 256
222     vm:simple-array-complex-long-float-type)
223 wlott 1.1 (t 0 32 vm:simple-vector-type)))
224    
225     ;;; MAKE-ARRAY -- source-transform.
226     ;;;
227     ;;; The integer type restriction on the length assures that it will be a
228     ;;; vector. The lack of adjustable, fill-pointer, and displaced-to keywords
229     ;;; assures that it will be simple.
230     ;;;
231     (deftransform make-array ((length &key initial-element element-type)
232     (integer &rest *))
233     (let* ((eltype (cond ((not element-type) t)
234     ((not (constant-continuation-p element-type))
235     (give-up "Element-Type is not constant."))
236     (t
237     (continuation-value element-type))))
238     (len (if (constant-continuation-p length)
239     (continuation-value length)
240     '*))
241     (spec `(simple-array ,eltype (,len)))
242     (eltype-type (specifier-type eltype)))
243     (multiple-value-bind
244     (default-initial-element element-size typecode)
245     (dolist (info array-info
246     (give-up "Cannot open-code creation of ~S" spec))
247     (when (csubtypep eltype-type (specifier-type (car info)))
248     (return (values-list (cdr info)))))
249 wlott 1.6 (let* ((nwords-form
250     (if (>= element-size vm:word-bits)
251     `(* length ,(/ element-size vm:word-bits))
252     (let ((elements-per-word (/ 32 element-size)))
253     `(truncate (+ length
254     ,(if (eq 'vm:simple-string-type typecode)
255     elements-per-word
256     (1- elements-per-word)))
257     ,elements-per-word))))
258     (constructor
259     `(truly-the ,spec
260     (allocate-vector ,typecode length ,nwords-form))))
261 wlott 1.1 (values
262 pw 1.19.2.2 (cond ((and default-initial-element
263     (or (null initial-element)
264     (and (constant-continuation-p initial-element)
265     (eql (continuation-value initial-element)
266     default-initial-element))))
267     (unless (csubtypep (ctype-of default-initial-element)
268     eltype-type)
269     (compiler-note "Default initial element ~s is not a ~s."
270     default-initial-element eltype))
271     constructor)
272     (t
273     `(truly-the ,spec (fill ,constructor initial-element))))
274 wlott 1.1 '((declare (type index length))))))))
275    
276     ;;; MAKE-ARRAY -- transform.
277     ;;;
278     ;;; The list type restriction does not assure that the result will be a
279     ;;; multi-dimensional array. But the lack of
280     ;;;
281     (deftransform make-array ((dims &key initial-element element-type)
282     (list &rest *))
283     (unless (or (null element-type) (constant-continuation-p element-type))
284     (give-up "Element-type not constant; cannot open code array creation"))
285     (unless (constant-continuation-p dims)
286     (give-up "Dimension list not constant; cannot open code array creation"))
287     (let ((dims (continuation-value dims)))
288     (unless (every #'integerp dims)
289 wlott 1.6 (give-up "Dimension list contains something other than an integer: ~S"
290 wlott 1.1 dims))
291     (if (= (length dims) 1)
292     `(make-array ',(car dims)
293     ,@(when initial-element
294     '(:initial-element initial-element))
295     ,@(when element-type
296     '(:element-type element-type)))
297     (let* ((total-size (reduce #'* dims))
298     (rank (length dims))
299     (spec `(simple-array
300     ,(cond ((null element-type) t)
301     ((constant-continuation-p element-type)
302     (continuation-value element-type))
303     (t '*))
304     ,(make-list rank :initial-element '*))))
305     `(let ((header (make-array-header vm:simple-array-type ,rank)))
306     (setf (%array-fill-pointer header) ,total-size)
307     (setf (%array-fill-pointer-p header) nil)
308     (setf (%array-available-elements header) ,total-size)
309     (setf (%array-data-vector header)
310     (make-array ,total-size
311     ,@(when element-type
312     '(:element-type element-type))
313     ,@(when initial-element
314     '(:initial-element initial-element))))
315     (setf (%array-displaced-p header) nil)
316     ,@(let ((axis -1))
317     (mapcar #'(lambda (dim)
318     `(setf (%array-dimension header ,(incf axis))
319     ,dim))
320     dims))
321     (truly-the ,spec header))))))
322    
323    
324     ;;;; Random properties of arrays.
325    
326     ;;; Transforms for various random array properties. If the property is know
327     ;;; at compile time because of a type spec, use that constant value.
328    
329     ;;; ARRAY-RANK -- transform.
330     ;;;
331     ;;; If we can tell the rank from the type info, use it instead.
332     ;;;
333     (deftransform array-rank ((array))
334     (let ((array-type (continuation-type array)))
335     (unless (array-type-p array-type)
336     (give-up))
337     (let ((dims (array-type-dimensions array-type)))
338     (if (not (listp dims))
339     (give-up "Array rank not known at compile time: ~S" dims)
340     (length dims)))))
341    
342     ;;; ARRAY-DIMENSION -- transform.
343     ;;;
344     ;;; If we know the dimensions at compile time, just use it. Otherwise, if
345     ;;; we can tell that the axis is in bounds, convert to %array-dimension
346     ;;; (which just indirects the array header) or length (if it's simple and a
347     ;;; vector).
348     ;;;
349     (deftransform array-dimension ((array axis)
350     (array index))
351     (unless (constant-continuation-p axis)
352     (give-up "Axis not constant."))
353     (let ((array-type (continuation-type array))
354     (axis (continuation-value axis)))
355     (unless (array-type-p array-type)
356     (give-up))
357     (let ((dims (array-type-dimensions array-type)))
358     (unless (listp dims)
359     (give-up
360     "Array dimensions unknown, must call array-dimension at runtime."))
361     (unless (> (length dims) axis)
362     (abort-transform "Array has dimensions ~S, ~D is too large."
363     dims axis))
364     (let ((dim (nth axis dims)))
365     (cond ((integerp dim)
366     dim)
367     ((= (length dims) 1)
368     (ecase (array-type-complexp array-type)
369     ((t)
370     '(%array-dimension array 0))
371     ((nil)
372     '(length array))
373     (*
374     (give-up "Can't tell if array is simple."))))
375     (t
376     '(%array-dimension array axis)))))))
377    
378     ;;; LENGTH -- transform.
379     ;;;
380     ;;; If the length has been declared and it's simple, just return it.
381     ;;;
382     (deftransform length ((vector)
383     ((simple-array * (*))))
384     (let ((type (continuation-type vector)))
385     (unless (array-type-p type)
386     (give-up))
387     (let ((dims (array-type-dimensions type)))
388     (unless (and (listp dims) (integerp (car dims)))
389     (give-up "Vector length unknown, must call length at runtime."))
390     (car dims))))
391    
392     ;;; LENGTH -- transform.
393     ;;;
394     ;;; All vectors can get their length by using vector-length. If it's simple,
395     ;;; it will extract the length slot from the vector. It it's complex, it will
396     ;;; extract the fill pointer slot from the array header.
397     ;;;
398     (deftransform length ((vector) (vector))
399     '(vector-length vector))
400    
401 ram 1.7
402     ;;; If a simple array with known dimensions, then vector-length is a
403     ;;; compile-time constant.
404     ;;;
405     (deftransform vector-length ((vector) ((simple-array * (*))))
406     (let ((vtype (continuation-type vector)))
407     (if (array-type-p vtype)
408     (let ((dim (first (array-type-dimensions vtype))))
409     (when (eq dim '*) (give-up))
410     dim)
411     (give-up))))
412    
413    
414 wlott 1.1 ;;; ARRAY-TOTAL-SIZE -- transform.
415     ;;;
416     ;;; Again, if we can tell the results from the type, just use it. Otherwise,
417     ;;; if we know the rank, convert into a computation based on array-dimension.
418     ;;; We can wrap a truly-the index around the multiplications because we know
419     ;;; that the total size must be an index.
420     ;;;
421     (deftransform array-total-size ((array)
422     (array))
423     (let ((array-type (continuation-type array)))
424     (unless (array-type-p array-type)
425     (give-up))
426     (let ((dims (array-type-dimensions array-type)))
427     (unless (listp dims)
428 wlott 1.2 (give-up "Can't tell the rank at compile time."))
429     (if (member '* dims)
430     (do ((form 1 `(truly-the index
431     (* (array-dimension array ,i) ,form)))
432     (i 0 (1+ i)))
433     ((= i (length dims)) form))
434     (reduce #'* dims)))))
435 wlott 1.1
436     ;;; ARRAY-HAS-FILL-POINTER-P -- transform.
437     ;;;
438     ;;; Only complex vectors have fill pointers.
439     ;;;
440     (deftransform array-has-fill-pointer-p ((array))
441     (let ((array-type (continuation-type array)))
442     (unless (array-type-p array-type)
443     (give-up))
444     (let ((dims (array-type-dimensions array-type)))
445     (if (and (listp dims) (not (= (length dims) 1)))
446     nil
447     (ecase (array-type-complexp array-type)
448     ((t)
449     t)
450     ((nil)
451     nil)
452     (*
453     (give-up "Array type ambiguous; must call ~
454     array-has-fill-pointer-p at runtime.")))))))
455    
456     ;;; %CHECK-BOUND -- transform.
457     ;;;
458     ;;; Primitive used to verify indicies into arrays. If we can tell at
459     ;;; compile-time or we are generating unsafe code, don't bother with the VOP.
460     ;;;
461     (deftransform %check-bound ((array dimension index))
462     (unless (constant-continuation-p dimension)
463     (give-up))
464     (let ((dim (continuation-value dimension)))
465     `(the (integer 0 ,dim) index)))
466     ;;;
467     (deftransform %check-bound ((array dimension index) * *
468     :policy (and (> speed safety) (= safety 0)))
469     'index)
470    
471    
472     ;;; WITH-ROW-MAJOR-INDEX -- internal.
473     ;;;
474     ;;; Handy macro for computing the row-major index given a set of indices. We
475     ;;; wrap each index with a call to %check-bound to assure that everything
476     ;;; works out correctly. We can wrap all the interior arith with truly-the
477     ;;; index because we know the the resultant row-major index must be an index.
478     ;;;
479     (eval-when (compile eval)
480     ;;;
481     (defmacro with-row-major-index ((array indices index &optional new-value)
482     &rest body)
483     `(let (n-indices dims)
484     (dotimes (i (length ,indices))
485     (push (make-symbol (format nil "INDEX-~D" i)) n-indices)
486     (push (make-symbol (format nil "DIM-~D" i)) dims))
487     (setf n-indices (nreverse n-indices))
488     (setf dims (nreverse dims))
489     `(lambda (,',array ,@n-indices ,@',(when new-value (list new-value)))
490     (let* (,@(let ((,index -1))
491     (mapcar #'(lambda (name)
492     `(,name (array-dimension ,',array
493     ,(incf ,index))))
494     dims))
495     (,',index
496     ,(if (null dims)
497     0
498     (do* ((dims dims (cdr dims))
499     (indices n-indices (cdr indices))
500     (last-dim nil (car dims))
501     (form `(%check-bound ,',array
502     ,(car dims)
503     ,(car indices))
504     `(truly-the index
505     (+ (truly-the index
506     (* ,form
507     ,last-dim))
508     (%check-bound
509     ,',array
510     ,(car dims)
511     ,(car indices))))))
512     ((null (cdr dims)) form)))))
513     ,',@body))))
514     ;;;
515     ); eval-when
516    
517     ;;; ARRAY-ROW-MAJOR-INDEX -- transform.
518     ;;;
519     ;;; Just return the index after computing it.
520     ;;;
521     (deftransform array-row-major-index ((array &rest indices))
522     (with-row-major-index (array indices index)
523     index))
524    
525    
526    
527     ;;;; Array accessors:
528    
529     ;;; SVREF, %SVSET, SCHAR, %SCHARSET, CHAR,
530     ;;; %CHARSET, SBIT, %SBITSET, BIT, %BITSET
531     ;;; -- source transforms.
532     ;;;
533     ;;; We convert all typed array accessors into aref and %aset with type
534     ;;; assertions on the array.
535     ;;;
536     (macrolet ((frob (reffer setter type)
537     `(progn
538     (def-source-transform ,reffer (a &rest i)
539 ram 1.16 (if (byte-compiling)
540 ram 1.15 (values nil t)
541     `(aref (the ,',type ,a) ,@i)))
542 wlott 1.1 (def-source-transform ,setter (a &rest i)
543 ram 1.16 (if (byte-compiling)
544 ram 1.15 (values nil t)
545     `(%aset (the ,',type ,a) ,@i))))))
546 wlott 1.1 (frob svref %svset simple-vector)
547     (frob schar %scharset simple-string)
548     (frob char %charset string)
549     (frob sbit %sbitset (simple-array bit))
550     (frob bit %bitset (array bit)))
551    
552     ;;; AREF, %ASET -- transform.
553     ;;;
554     ;;; Convert into a data-vector-ref (or set) with the set of indices replaced
555     ;;; with the an expression for the row major index.
556     ;;;
557     (deftransform aref ((array &rest indices))
558     (with-row-major-index (array indices index)
559     (data-vector-ref array index)))
560     ;;;
561     (deftransform %aset ((array &rest stuff))
562     (let ((indices (butlast stuff)))
563     (with-row-major-index (array indices index new-value)
564     (data-vector-set array index new-value))))
565    
566     ;;; ROW-MAJOR-AREF, %SET-ROW-MAJOR-AREF -- transform.
567     ;;;
568     ;;; Just convert into a data-vector-ref (or set) after checking that the
569     ;;; index is inside the array total size.
570     ;;;
571     (deftransform row-major-aref ((array index))
572     `(data-vector-ref array (%check-bound array (array-total-size array) index)))
573     ;;;
574     (deftransform %set-row-major-aref ((array index new-value))
575     `(data-vector-set array
576     (%check-bound array (array-total-size array) index)
577     new-value))
578 ram 1.7
579    
580     ;;;; Bit-vector array operation canonicalization:
581     ;;;
582     ;;; We convert all bit-vector operations to have the result array specified.
583     ;;; This allows any result allocation to be open-coded, and eliminates the need
584     ;;; for any VM-dependent transforms to handle these cases.
585    
586     (dolist (fun '(bit-and bit-ior bit-xor bit-eqv bit-nand bit-nor bit-andc1
587     bit-andc2 bit-orc1 bit-orc2))
588     ;;
589     ;; Make a result array if result is NIL or unsupplied.
590     (deftransform fun ((bit-array-1 bit-array-2 &optional result-bit-array)
591 ram 1.14 '(bit-vector bit-vector &optional null) '*
592 ram 1.7 :eval-name t :policy (>= speed space))
593     `(,fun bit-array-1 bit-array-2
594     (make-array (length bit-array-1) :element-type 'bit)))
595     ;;
596     ;; If result its T, make it the first arg.
597     (deftransform fun ((bit-array-1 bit-array-2 result-bit-array)
598 ram 1.14 '(bit-vector bit-vector (member t)) '*
599 ram 1.7 :eval-name t)
600     `(,fun bit-array-1 bit-array-2 bit-array-1)))
601    
602     ;;; Similar for BIT-NOT, but there is only one arg...
603     ;;;
604     (deftransform bit-not ((bit-array-1 &optional result-bit-array)
605     (bit-vector &optional null) *
606     :policy (>= speed space))
607     '(bit-not bit-array-1
608     (make-array (length bit-array-1) :element-type 'bit)))
609     ;;;
610     (deftransform bit-not ((bit-array-1 result-bit-array)
611     (bit-vector (constant-argument t)))
612 ram 1.17 '(bit-not bit-array-1 bit-array-1))
613 dtc 1.19.2.1
614    
615     ;;; ARRAY-HEADER-P -- transform.
616     ;;;
617     ;;; Pick off some constant cases.
618     ;;;
619     (deftransform array-header-p ((array) (array))
620     (let ((type (continuation-type array)))
621     (declare (optimize (safety 3)))
622     (unless (array-type-p type)
623     (give-up))
624     (let ((dims (array-type-dimensions type)))
625     (cond ((csubtypep type (specifier-type '(simple-array * (*))))
626     ;; No array header.
627     nil)
628     ((and (listp dims) (> (length dims) 1))
629     ;; Multi-dimensional array, will have a header.
630     t)
631     (t
632     (give-up))))))

  ViewVC Help
Powered by ViewVC 1.1.5