1 ;;; -*- Package: C; Log: C.Log -*-
3 ;;; **********************************************************************
4 ;;; This code was written as part of the CMU Common Lisp project at
5 ;;; Carnegie Mellon University, and has been placed in the public domain.
9 ;;; **********************************************************************
13 ;;; This file contains the RT VM definition of character operations.
15 ;;; Written by Rob MacLachlan
16 ;;; Converted for the Alpha by Sean Hallgren.
23 ;;;; Moves and coercions:
25 ;;; Move a tagged char to an untagged representation.
27 (define-vop (move-to-base-char)
28 (:args (x :scs (any-reg descriptor-reg)))
29 (:results (y :scs (base-char-reg)))
31 (inst srl x sb!vm:type-bits y)))
33 (define-move-vop move-to-base-char :move
34 (any-reg descriptor-reg) (base-char-reg))
37 ;;; Move an untagged char to a tagged representation.
39 (define-vop (move-from-base-char)
40 (:args (x :scs (base-char-reg)))
41 (:results (y :scs (any-reg descriptor-reg)))
43 (inst sll x sb!vm:type-bits y)
44 (inst bis y sb!vm:base-char-type y)))
46 (define-move-vop move-from-base-char :move
47 (base-char-reg) (any-reg descriptor-reg))
49 ;;; Move untagged base-char values.
51 (define-vop (base-char-move)
54 :load-if (not (location= x y))))
55 (:results (y :scs (base-char-reg)
56 :load-if (not (location= x y))))
62 (define-move-vop base-char-move :move
63 (base-char-reg) (base-char-reg))
66 ;;; Move untagged base-char arguments/return-values.
68 (define-vop (move-base-char-argument)
72 :load-if (not (sc-is y base-char-reg))))
79 (storew x fp (tn-offset y))))))
81 (define-move-vop move-base-char-argument :move-argument
82 (any-reg base-char-reg) (base-char-reg))
85 ;;; Use standard MOVE-ARGUMENT + coercion to move an untagged base-char
86 ;;; to a descriptor passing location.
88 (define-move-vop move-argument :move-argument
89 (base-char-reg) (any-reg descriptor-reg))
93 ;;;; Other operations:
95 (define-vop (char-code)
96 (:translate char-code)
98 (:args (ch :scs (base-char-reg) :target res))
99 (:arg-types base-char)
100 (:results (res :scs (any-reg)))
101 (:result-types positive-fixnum)
103 (inst sll ch 2 res)))
105 (define-vop (code-char)
106 (:translate code-char)
108 (:args (code :scs (any-reg) :target res))
109 (:arg-types positive-fixnum)
110 (:results (res :scs (base-char-reg)))
111 (:result-types base-char)
113 (inst srl code 2 res)))
116 ;;; Comparison of base-chars.
118 (define-vop (base-char-compare)
119 (:args (x :scs (base-char-reg))
120 (y :scs (base-char-reg)))
121 (:arg-types base-char base-char)
122 (:temporary (:scs (non-descriptor-reg)) temp)
126 (:note "inline comparison")
130 (:eq (inst cmpeq x y temp))
131 (:lt (inst cmplt x y temp))
132 (:gt (inst cmplt y x temp)))
134 (inst beq temp target)
135 (inst bne temp target))))
137 (define-vop (fast-char=/base-char base-char-compare)
141 (define-vop (fast-char</base-char base-char-compare)
145 (define-vop (fast-char>/base-char base-char-compare)