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