1 ;;;; the PPC 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 srwi y x n-widetag-bits)))
23 (define-move-vop move-to-character :move
24 (any-reg descriptor-reg) (character-reg))
26 ;;; Move an untagged char to a tagged representation.
27 (define-vop (move-from-character)
28 (:args (x :scs (character-reg)))
29 (:results (y :scs (any-reg descriptor-reg)))
30 (:note "character tagging")
32 (inst slwi y x n-widetag-bits)
33 (inst ori y y character-widetag)))
34 (define-move-vop move-from-character :move
35 (character-reg) (any-reg descriptor-reg))
37 ;;; Move untagged character values.
38 (define-vop (character-move)
41 :load-if (not (location= x y))))
42 (:results (y :scs (character-reg)
43 :load-if (not (location= x y))))
44 (:note "character move")
49 (define-move-vop character-move :move
50 (character-reg) (character-reg))
52 ;;; Move untagged character arguments/return-values.
53 (define-vop (move-character-arg)
57 :load-if (not (sc-is y character-reg))))
59 (:note "character arg move")
65 (storew x fp (tn-offset y))))))
66 (define-move-vop move-character-arg :move-arg
67 (any-reg character-reg) (character-reg))
69 ;;; Use standard MOVE-ARG + coercion to move an untagged character
70 ;;; to a descriptor passing location.
71 (define-move-vop move-arg :move-arg
72 (character-reg) (any-reg descriptor-reg))
74 ;;;; Other operations:
76 (define-vop (char-code)
77 (:translate char-code)
79 (:args (ch :scs (character-reg) :target res))
80 (:arg-types character)
81 (:results (res :scs (any-reg)))
82 (:result-types positive-fixnum)
84 (inst slwi res ch 2)))
86 (define-vop (code-char)
87 (:translate code-char)
89 (:args (code :scs (any-reg) :target res))
90 (:arg-types positive-fixnum)
91 (:results (res :scs (character-reg)))
92 (:result-types character)
94 (inst srwi res code 2)))
96 ;;; Comparison of characters.
97 (define-vop (character-compare)
98 (:args (x :scs (character-reg))
99 (y :scs (character-reg)))
100 (:arg-types character character)
104 (:note "inline comparison")
105 (:variant-vars condition not-condition)
108 (inst b? (if not-p not-condition condition) target)))
110 (define-vop (fast-char=/character character-compare)
114 (define-vop (fast-char</character character-compare)
118 (define-vop (fast-char>/character character-compare)
122 (define-vop (character-compare/c)
123 (:args (x :scs (character-reg)))
124 (:arg-types character (:constant character))
126 (:info target not-p y)
128 (:note "inline comparison")
129 (:variant-vars condition not-condition)
131 (inst cmplwi x (sb!xc:char-code y))
132 (inst b? (if not-p not-condition condition) target)))
134 (define-vop (fast-char=/character/c character-compare/c)
138 (define-vop (fast-char</character/c character-compare/c)
142 (define-vop (fast-char>/character/c character-compare/c)