1 ;;;; the Alpha VM definition of character operations
3 ;;;; This software is part of the SBCL system. See the README file for
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.
14 ;;;; moves and coercions
16 ;;; Move a tagged char to an untagged representation.
17 (define-vop (move-to-base-char)
18 (:args (x :scs (any-reg descriptor-reg)))
19 (:results (y :scs (base-char-reg)))
21 (inst srl x n-widetag-bits y)))
23 (define-move-vop move-to-base-char :move
24 (any-reg descriptor-reg) (base-char-reg))
26 ;;; Move an untagged char to a tagged representation.
27 (define-vop (move-from-base-char)
28 (:args (x :scs (base-char-reg)))
29 (:results (y :scs (any-reg descriptor-reg)))
31 (inst sll x n-widetag-bits y)
32 (inst bis y base-char-widetag y)))
34 (define-move-vop move-from-base-char :move
35 (base-char-reg) (any-reg descriptor-reg))
37 ;;; Move untagged base-char values.
38 (define-vop (base-char-move)
41 :load-if (not (location= x y))))
42 (:results (y :scs (base-char-reg)
43 :load-if (not (location= x y))))
49 (define-move-vop base-char-move :move
50 (base-char-reg) (base-char-reg))
52 ;;; Move untagged base-char arguments/return-values.
53 (define-vop (move-base-char-arg)
57 :load-if (not (sc-is y base-char-reg))))
64 (storew x fp (tn-offset y))))))
66 (define-move-vop move-base-char-arg :move-arg
67 (any-reg base-char-reg) (base-char-reg))
70 ;;; Use standard MOVE-ARG + coercion to move an untagged base-char
71 ;;; to a descriptor passing location.
73 (define-move-vop move-arg :move-arg
74 (base-char-reg) (any-reg descriptor-reg))
78 (define-vop (char-code)
79 (:translate char-code)
81 (:args (ch :scs (base-char-reg) :target res))
82 (:arg-types base-char)
83 (:results (res :scs (any-reg)))
84 (:result-types positive-fixnum)
88 (define-vop (code-char)
89 (:translate code-char)
91 (:args (code :scs (any-reg) :target res))
92 (:arg-types positive-fixnum)
93 (:results (res :scs (base-char-reg)))
94 (:result-types base-char)
96 (inst srl code 2 res)))
98 ;;;; comparison of BASE-CHARs
100 (define-vop (base-char-compare)
101 (:args (x :scs (base-char-reg))
102 (y :scs (base-char-reg)))
103 (:arg-types base-char base-char)
104 (:temporary (:scs (non-descriptor-reg)) temp)
108 (:note "inline comparison")
112 (:eq (inst cmpeq x y temp))
113 (:lt (inst cmplt x y temp))
114 (:gt (inst cmplt y x temp)))
116 (inst beq temp target)
117 (inst bne temp target))))
119 (define-vop (fast-char=/base-char base-char-compare)
123 (define-vop (fast-char</base-char base-char-compare)
127 (define-vop (fast-char>/base-char base-char-compare)
131 (define-vop (base-char-compare/c)
132 (:args (x :scs (base-char-reg)))
133 (:arg-types base-char (:constant base-char))
134 (:temporary (:scs (non-descriptor-reg)) temp)
136 (:info target not-p y)
138 (:note "inline constant comparison")
142 (:eq (inst cmpeq x (sb!xc:char-code y) temp))
143 (:lt (inst cmplt x (sb!xc:char-code y) temp))
144 (:gt (inst cmple x (sb!xc:char-code y) temp)))
147 (inst bne temp target)
148 (inst beq temp target))
150 (inst beq temp target)
151 (inst bne temp target)))))
153 (define-vop (fast-char=/base-char/c base-char-compare/c)
157 (define-vop (fast-char</base-char/c base-char-compare/c)
161 (define-vop (fast-char>/base-char/c base-char-compare/c)