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-base-char)
18 (:args (x :scs (any-reg descriptor-reg)))
19 (:results (y :scs (base-char-reg)))
20 (:note "character untagging")
22 (inst srwi y x sb!vm:n-widetag-bits)))
24 (define-move-vop move-to-base-char :move
25 (any-reg descriptor-reg) (base-char-reg))
28 ;;; Move an untagged char to a tagged representation.
29 (define-vop (move-from-base-char)
30 (:args (x :scs (base-char-reg)))
31 (:results (y :scs (any-reg descriptor-reg)))
32 (:note "character tagging")
34 (inst slwi y x sb!vm:n-widetag-bits)
35 (inst ori y y sb!vm:base-char-widetag)))
37 (define-move-vop move-from-base-char :move
38 (base-char-reg) (any-reg descriptor-reg))
40 ;;; Move untagged base-char values.
41 (define-vop (base-char-move)
44 :load-if (not (location= x y))))
45 (:results (y :scs (base-char-reg)
46 :load-if (not (location= x y))))
47 (:note "character move")
53 (define-move-vop base-char-move :move
54 (base-char-reg) (base-char-reg))
56 ;;; Move untagged base-char arguments/return-values.
57 (define-vop (move-base-char-arg)
61 :load-if (not (sc-is y base-char-reg))))
63 (:note "character arg move")
69 (storew x fp (tn-offset y))))))
71 (define-move-vop move-base-char-arg :move-arg
72 (any-reg base-char-reg) (base-char-reg))
75 ;;; Use standard MOVE-ARG + coercion to move an untagged base-char
76 ;;; to a descriptor passing location.
77 (define-move-vop move-arg :move-arg
78 (base-char-reg) (any-reg descriptor-reg))
82 ;;;; Other operations:
84 (define-vop (char-code)
85 (:translate char-code)
87 (:args (ch :scs (base-char-reg) :target res))
88 (:arg-types base-char)
89 (:results (res :scs (any-reg)))
90 (:result-types positive-fixnum)
92 (inst slwi res ch 2)))
94 (define-vop (code-char)
95 (:translate code-char)
97 (:args (code :scs (any-reg) :target res))
98 (:arg-types positive-fixnum)
99 (:results (res :scs (base-char-reg)))
100 (:result-types base-char)
102 (inst srwi res code 2)))
105 ;;; Comparison of base-chars.
106 (define-vop (base-char-compare)
107 (:args (x :scs (base-char-reg))
108 (y :scs (base-char-reg)))
109 (:arg-types base-char base-char)
113 (:note "inline comparison")
114 (:variant-vars condition not-condition)
117 (inst b? (if not-p not-condition condition) 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))
135 (:info target not-p y)
137 (:note "inline comparison")
138 (:variant-vars condition not-condition)
140 (inst cmplwi x (sb!xc:char-code y))
141 (inst b? (if not-p not-condition condition) target)))
143 (define-vop (fast-char=/base-char/c base-char-compare/c)
147 (define-vop (fast-char</base-char/c base-char-compare/c)
151 (define-vop (fast-char>/base-char/c base-char-compare/c)