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-base-char)
18 (:args
(x :scs
(any-reg descriptor-reg
)))
19 (:results
(y :scs
(base-char-reg)))
20 (:note
"character untagging")
22 (inst srl y x 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 sll y x n-widetag-bits
)
35 (inst or y 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))
57 ;;; Move untagged base-char arguments/return-values.
58 (define-vop (move-base-char-arg)
62 :load-if
(not (sc-is y base-char-reg
))))
64 (:note
"character arg move")
70 (storew x fp
(tn-offset y
))))))
72 (define-move-vop move-base-char-arg
:move-arg
73 (any-reg base-char-reg
) (base-char-reg))
76 ;;; Use standard MOVE-ARG + coercion to move an untagged base-char
77 ;;; to a descriptor passing location.
78 (define-move-vop move-arg
:move-arg
79 (base-char-reg) (any-reg descriptor-reg
))
83 ;;;; Other operations:
85 (define-vop (char-code)
86 (:translate char-code
)
88 (:args
(ch :scs
(base-char-reg) :target res
))
89 (:arg-types base-char
)
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
(base-char-reg)))
101 (:result-types base-char
)
103 (inst srl res code n-fixnum-tag-bits
)))
106 ;;; Comparison of base-chars.
107 (define-vop (base-char-compare)
108 (:args
(x :scs
(base-char-reg))
109 (y :scs
(base-char-reg)))
110 (:arg-types base-char base-char
)
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=/base-char base-char-compare
)
125 (define-vop (fast-char</base-char base-char-compare
)
127 (:variant
:ltu
:geu
))
129 (define-vop (fast-char>/base-char base-char-compare
)
131 (:variant
:gtu
:leu
))
133 (define-vop (base-char-compare/c
)
134 (:args
(x :scs
(base-char-reg)))
135 (:arg-types base-char
(:constant base-char
))
137 (:info target not-p y
)
139 (:note
"inline constant comparison")
140 (:variant-vars condition not-condition
)
142 (inst cmp x
(sb!xc
:char-code y
))
143 (inst b
(if not-p not-condition condition
) target
)
146 (define-vop (fast-char=/base-char
/c base-char-compare
/c
)
150 (define-vop (fast-char</base-char
/c base-char-compare
/c
)
152 (:variant
:ltu
:geu
))
154 (define-vop (fast-char>/base-char
/c base-char-compare
/c
)
156 (:variant
:gtu
:leu
))