d81cf12eb795249444aa774408acdf6e5a5b960e
[sbcl.git] / src / compiler / alpha / subprim.lisp
1 ;;;; linkage information for standard static functions, and random vops
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
12 (in-package "SB!VM")
13 \f
14 ;;;; LENGTH
15
16 (define-vop (length/list)
17   (:translate length)
18   (:args (object :scs (descriptor-reg) :target ptr))
19   (:arg-types list)
20   (:temporary (:scs (descriptor-reg) :from (:argument 0)) ptr)
21   (:temporary (:scs (non-descriptor-reg)) temp)
22   (:temporary (:scs (any-reg) :type fixnum :to (:result 0) :target result)
23               count)
24   (:results (result :scs (any-reg descriptor-reg)))
25   (:policy :fast-safe)
26   (:vop-var vop)
27   (:save-p :compute-only)
28   (:generator 50
29     (move object ptr)
30     (move zero-tn count)
31     
32     LOOP
33     
34     (inst cmpeq ptr null-tn temp)
35     (inst bne temp done)
36     
37     (inst and ptr lowtag-mask temp)
38     (inst xor temp list-pointer-lowtag temp)
39     (inst bne temp not-list)
40     
41     (loadw ptr ptr cons-cdr-slot list-pointer-lowtag)
42     (inst addq count (fixnumize 1) count)
43     (inst br zero-tn loop)
44     
45     NOT-LIST
46     (cerror-call vop done object-not-list-error ptr)
47     
48     DONE
49     (move count result)))
50        
51 (define-static-fun length (object) :translate length)