1 ;;;; x86 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.
17 ;;;; moves and coercions
19 ;;; Move a tagged char to an untagged representation.
20 (define-vop (move-to-base-char)
21 (:args (x :scs (any-reg control-stack) :target al))
22 (:temporary (:sc byte-reg :offset al-offset
23 :from (:argument 0) :to (:eval 0)) al)
25 (:temporary (:sc byte-reg :offset ah-offset :target y
26 :from (:argument 0) :to (:result 0)) ah)
27 (:results (y :scs (base-char-reg base-char-stack)))
28 (:note "character untagging")
32 (define-move-vop move-to-base-char :move
33 (any-reg control-stack) (base-char-reg base-char-stack))
35 ;;; Move an untagged char to a tagged representation.
36 (define-vop (move-from-base-char)
37 (:args (x :scs (base-char-reg base-char-stack) :target ah))
38 (:temporary (:sc byte-reg :offset al-offset :target y
39 :from (:argument 0) :to (:result 0)) al)
40 (:temporary (:sc byte-reg :offset ah-offset
41 :from (:argument 0) :to (:result 0)) ah)
42 (:results (y :scs (any-reg descriptor-reg control-stack)))
43 (:note "character tagging")
45 (move ah x) ; Maybe move char byte.
46 (inst mov al base-char-type) ; x86 to type bits
47 (inst and eax-tn #xffff) ; Remove any junk bits.
49 (define-move-vop move-from-base-char :move
50 (base-char-reg base-char-stack) (any-reg descriptor-reg control-stack))
52 ;;; Move untagged base-char values.
53 (define-vop (base-char-move)
56 :load-if (not (location= x y))))
57 (:results (y :scs (base-char-reg base-char-stack)
58 :load-if (not (location= x y))))
59 (:note "character move")
64 (define-move-vop base-char-move :move
65 (base-char-reg) (base-char-reg base-char-stack))
67 ;;; Move untagged base-char arguments/return-values.
68 (define-vop (move-base-char-argument)
72 :load-if (not (sc-is y base-char-reg))))
74 (:note "character arg move")
81 (make-ea :byte :base fp :disp (- (* (1+ (tn-offset y)) 4)))
83 (define-move-vop move-base-char-argument :move-argument
84 (any-reg base-char-reg) (base-char-reg))
86 ;;; Use standard MOVE-ARGUMENT + coercion to move an untagged base-char
87 ;;; to a descriptor passing location.
88 (define-move-vop move-argument :move-argument
89 (base-char-reg) (any-reg descriptor-reg))
93 (define-vop (char-code)
94 (:translate char-code)
96 (:args (ch :scs (base-char-reg base-char-stack)))
97 (:arg-types base-char)
98 (:results (res :scs (unsigned-reg)))
99 (:result-types positive-fixnum)
101 (inst movzx res ch)))
103 (define-vop (code-char)
104 (:translate code-char)
106 (:args (code :scs (unsigned-reg unsigned-stack) :target eax))
107 (:arg-types positive-fixnum)
108 (:temporary (:sc unsigned-reg :offset eax-offset :target res
109 :from (:argument 0) :to (:result 0))
111 (:results (res :scs (base-char-reg)))
112 (:result-types base-char)
117 ;;; comparison of BASE-CHARs
118 (define-vop (base-char-compare)
119 (:args (x :scs (base-char-reg base-char-stack))
120 (y :scs (base-char-reg)
121 :load-if (not (and (sc-is x base-char-reg)
122 (sc-is y base-char-stack)))))
123 (:arg-types base-char base-char)
127 (:note "inline comparison")
128 (:variant-vars condition not-condition)
131 (inst jmp (if not-p not-condition condition) target)))
133 (define-vop (fast-char=/base-char base-char-compare)
137 (define-vop (fast-char</base-char base-char-compare)
141 (define-vop (fast-char>/base-char base-char-compare)