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-character)
18 (:args (x :scs (any-reg descriptor-reg)))
19 (:results (y :scs (character-reg)))
21 (inst srl x n-widetag-bits y)))
22 (define-move-vop move-to-character :move
23 (any-reg descriptor-reg) (character-reg))
25 ;;; Move an untagged char to a tagged representation.
26 (define-vop (move-from-character)
27 (:args (x :scs (character-reg)))
28 (:results (y :scs (any-reg descriptor-reg)))
30 (inst sll x n-widetag-bits y)
31 (inst bis y character-widetag y)))
32 (define-move-vop move-from-character :move
33 (character-reg) (any-reg descriptor-reg))
35 ;;; Move untagged character values.
36 (define-vop (character-move)
39 :load-if (not (location= x y))))
40 (:results (y :scs (character-reg)
41 :load-if (not (location= x y))))
46 (define-move-vop character-move :move
47 (character-reg) (character-reg))
49 ;;; Move untagged character arguments/return-values.
50 (define-vop (move-character-arg)
54 :load-if (not (sc-is y character-reg))))
61 (storew x fp (tn-offset y))))))
62 (define-move-vop move-character-arg :move-arg
63 (any-reg character-reg) (character-reg))
65 ;;; Use standard MOVE-ARG + coercion to move an untagged character
66 ;;; to a descriptor passing location.
68 (define-move-vop move-arg :move-arg
69 (character-reg) (any-reg descriptor-reg))
72 (define-vop (char-code)
73 (:translate char-code)
75 (:args (ch :scs (character-reg) :target res))
76 (:arg-types character)
77 (:results (res :scs (any-reg)))
78 (:result-types positive-fixnum)
80 (inst sll ch n-fixnum-tag-bits res)))
82 (define-vop (code-char)
83 (:translate code-char)
85 (:args (code :scs (any-reg) :target res))
86 (:arg-types positive-fixnum)
87 (:results (res :scs (character-reg)))
88 (:result-types character)
90 (inst srl code n-fixnum-tag-bits res)))
92 ;;;; comparison of CHARACTERs
94 (define-vop (character-compare)
95 (:args (x :scs (character-reg))
96 (y :scs (character-reg)))
97 (:arg-types character character)
98 (:temporary (:scs (non-descriptor-reg)) temp)
102 (:note "inline comparison")
106 (:eq (inst cmpeq x y temp))
107 (:lt (inst cmplt x y temp))
108 (:gt (inst cmplt y x temp)))
110 (inst beq temp target)
111 (inst bne temp target))))
113 (define-vop (fast-char=/character character-compare)
117 (define-vop (fast-char</character character-compare)
121 (define-vop (fast-char>/character character-compare)
125 (define-vop (character-compare/c)
126 (:args (x :scs (character-reg)))
127 (:arg-types character (:constant character))
128 (:temporary (:scs (non-descriptor-reg)) temp)
130 (:info target not-p y)
132 (:note "inline constant comparison")
136 (:eq (inst cmpeq x (sb!xc:char-code y) temp))
137 (:lt (inst cmplt x (sb!xc:char-code y) temp))
138 (:gt (inst cmple x (sb!xc:char-code y) temp)))
141 (inst bne temp target)
142 (inst beq temp target))
144 (inst beq temp target)
145 (inst bne temp target)))))
147 (define-vop (fast-char=/character/c character-compare/c)
151 (define-vop (fast-char</character/c character-compare/c)
155 (define-vop (fast-char>/character/c character-compare/c)