0.pre8.103:
[sbcl.git] / src / compiler / generic / array.lisp
1 ;;;; generic array operations
2
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.
11 (in-package "SB!VM")
12 \f
13 ;;; (ARRAY NIL) stuff looks the same on all platforms
14 (define-vop (data-vector-ref/simple-array-nil)
15   (:translate data-vector-ref)
16   (:policy :fast-safe)
17   (:args (object :scs (descriptor-reg))
18          (index :scs (unsigned-reg)))
19   (:arg-types simple-array-nil positive-fixnum)
20   (:results (value :scs (descriptor-reg)))
21   (:result-types *)
22   (:vop-var vop)
23   (:save-p :compute-only)
24   (:generator 1
25     (error-call vop nil-array-accessed-error object)))
26
27 ;;; It shouldn't be possible to fall through to here in normal user
28 ;;; code, as the system is smart enough to deduce that there must be
29 ;;; an error upstream, as there are no objects of type NIL that can be
30 ;;; stored in this data vector; however, just in case, we provide this
31 ;;; translation, so that
32 ;;;   (LOCALLY
33 ;;;     (DECLARE (TYPE (SIMPLE-ARRAY NIL (*)) X)
34 ;;;              (OPTIMIZE (SPEED 3) (SAFETY 0)))
35 ;;;     (SB-KERNEL:DATA-VECTOR-SET X 3 'FOO))
36 ;;; signals the right kind of error.
37 (define-vop (data-vector-set/simple-array-nil)
38   (:translate data-vector-set)
39   (:policy :fast-safe)
40   (:args (object :scs (descriptor-reg))
41          (index :scs (unsigned-reg))
42          (value :scs (descriptor-reg)))
43   (:arg-types simple-array-nil positive-fixnum *)
44   (:results (value :scs (descriptor-reg)))
45   (:result-types *)
46   (:vop-var vop)
47   (:save-p :compute-only)
48   (:generator 1
49     (error-call vop nil-array-accessed-error object)))
50 \f
51 ;;; FIXME: There is probably plenty of other array stuff that looks
52 ;;; the same or similar enough to be genericized.  Do so, and move it
53 ;;; here so that a new port doesn't need to do as much work.