1 ;;;; the Sparc 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)))
20 (:note "character untagging")
22 (inst srl y x n-widetag-bits)))
24 (define-move-vop move-to-character :move
25 (any-reg descriptor-reg) (character-reg))
28 ;;; Move an untagged char to a tagged representation.
29 (define-vop (move-from-character)
30 (:args (x :scs (character-reg)))
31 (:results (y :scs (any-reg descriptor-reg)))
32 (:note "character tagging")
34 (inst sll y x n-widetag-bits)
35 (inst or y character-widetag)))
37 (define-move-vop move-from-character :move
38 (character-reg) (any-reg descriptor-reg))
40 ;;; Move untagged character values.
41 (define-vop (character-move)
44 :load-if (not (location= x y))))
45 (:results (y :scs (character-reg)
46 :load-if (not (location= x y))))
47 (:note "character move")
53 (define-move-vop character-move :move
54 (character-reg) (character-reg))
57 ;;; Move untagged character arguments/return-values.
58 (define-vop (move-character-arg)
62 :load-if (not (sc-is y character-reg))))
64 (:note "character arg move")
70 (storew x fp (tn-offset y))))))
72 (define-move-vop move-character-arg :move-arg
73 (any-reg character-reg) (character-reg))
76 ;;; Use standard MOVE-ARG + coercion to move an untagged character
77 ;;; to a descriptor passing location.
78 (define-move-vop move-arg :move-arg
79 (character-reg) (any-reg descriptor-reg))
83 ;;;; Other operations:
85 (define-vop (char-code)
86 (:translate char-code)
88 (:args (ch :scs (character-reg) :target res))
89 (:arg-types character)
90 (:results (res :scs (any-reg)))
91 (:result-types positive-fixnum)
93 (inst sll res ch n-fixnum-tag-bits)))
95 (define-vop (code-char)
96 (:translate code-char)
98 (:args (code :scs (any-reg) :target res))
99 (:arg-types positive-fixnum)
100 (:results (res :scs (character-reg)))
101 (:result-types character)
103 (inst srl res code n-fixnum-tag-bits)))
106 ;;; Comparison of characters.
107 (define-vop (character-compare)
108 (:args (x :scs (character-reg))
109 (y :scs (character-reg)))
110 (:arg-types character character)
114 (:note "inline comparison")
115 (:variant-vars condition not-condition)
118 (inst b (if not-p not-condition condition) target)
121 (define-vop (fast-char=/character character-compare)
125 (define-vop (fast-char</character character-compare)
127 (:variant :ltu :geu))
129 (define-vop (fast-char>/character character-compare)
131 (:variant :gtu :leu))
133 (define-vop (character-compare/c)
134 (:args (x :scs (character-reg)))
135 (:arg-types character (:constant
136 #+sb-xc-host base-char
137 #-sb-xc-host (character-set ((0 . 4095)))))
139 (:info target not-p y)
141 (:note "inline constant comparison")
142 (:variant-vars condition not-condition)
144 (inst cmp x (sb!xc:char-code y))
145 (inst b (if not-p not-condition condition) target)
148 (define-vop (fast-char=/character/c character-compare/c)
152 (define-vop (fast-char</character/c character-compare/c)
154 (:variant :ltu :geu))
156 (define-vop (fast-char>/character/c character-compare/c)
158 (:variant :gtu :leu))