1 ;;;; the MIPS 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))
27 ;;; Move an untagged char to a tagged representation.
28 (define-vop (move-from-character)
29 (:args (x :scs (character-reg)))
30 (:results (y :scs (any-reg descriptor-reg)))
31 (:note "character tagging")
33 (inst sll y x n-widetag-bits)
34 (inst or y character-widetag)))
36 (define-move-vop move-from-character :move
37 (character-reg) (any-reg descriptor-reg))
39 ;;; Move untagged character values.
40 (define-vop (character-move)
43 :load-if (not (location= x y))))
44 (:results (y :scs (character-reg)
45 :load-if (not (location= x y))))
46 (:note "character move")
52 (define-move-vop character-move :move
53 (character-reg) (character-reg))
55 ;;; Move untagged character arguments/return-values.
56 (define-vop (move-character-arg)
60 :load-if (not (sc-is y character-reg))))
62 (:note "character arg move")
68 (storew x fp (tn-offset y))))))
70 (define-move-vop move-character-arg :move-arg
71 (any-reg character-reg) (character-reg))
73 ;;; Use standard MOVE-ARG + coercion to move an untagged character to
74 ;;; a descriptor passing location.
75 (define-move-vop move-arg :move-arg
76 (character-reg) (any-reg descriptor-reg))
78 ;;;; Other operations:
79 (define-vop (char-code)
80 (:translate char-code)
82 (:args (ch :scs (character-reg) :target res))
83 (:arg-types character)
84 (:results (res :scs (any-reg)))
85 (:result-types positive-fixnum)
87 (inst sll res ch n-fixnum-tag-bits)))
89 (define-vop (code-char)
90 (:translate code-char)
92 (:args (code :scs (any-reg) :target res))
93 (:arg-types positive-fixnum)
94 (:results (res :scs (character-reg)))
95 (:result-types character)
97 (inst srl res code n-fixnum-tag-bits)))
99 ;;; Comparison of characters.
100 (define-vop (character-compare)
101 (:args (x :scs (character-reg))
102 (y :scs (character-reg)))
103 (:arg-types character character)
104 (:temporary (:scs (non-descriptor-reg)) temp)
108 (:note "inline comparison")
109 (:variant-vars condition)
111 (three-way-comparison x y condition :unsigned not-p target temp)))
113 (define-vop (fast-char=/character character-compare)
117 (define-vop (fast-char</character character-compare)
121 (define-vop (fast-char>/character character-compare)