0.8.15:
[sbcl/smoofra.git] / src / compiler / sparc / char.lisp
blob7438fd913452fb31b8148371b02dd9466e756f5a
1 ;;;; the Sparc VM definition of character operations
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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.
12 (in-package "SB!VM")
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")
21 (:generator 1
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")
33 (:generator 1
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)
42 (:args (x :target y
43 :scs (base-char-reg)
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")
48 (:effects)
49 (:affected)
50 (:generator 0
51 (move y x)))
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)
59 (:args (x :target y
60 :scs (base-char-reg))
61 (fp :scs (any-reg)
62 :load-if (not (sc-is y base-char-reg))))
63 (:results (y))
64 (:note "character arg move")
65 (:generator 0
66 (sc-case y
67 (base-char-reg
68 (move y x))
69 (base-char-stack
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)
87 (:policy :fast-safe)
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)
92 (:generator 1
93 (inst sll res ch n-fixnum-tag-bits)))
95 (define-vop (code-char)
96 (:translate code-char)
97 (:policy :fast-safe)
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)
102 (:generator 1
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)
111 (:conditional)
112 (:info target not-p)
113 (:policy :fast-safe)
114 (:note "inline comparison")
115 (:variant-vars condition not-condition)
116 (:generator 3
117 (inst cmp x y)
118 (inst b (if not-p not-condition condition) target)
119 (inst nop)))
121 (define-vop (fast-char=/base-char base-char-compare)
122 (:translate char=)
123 (:variant :eq :ne))
125 (define-vop (fast-char</base-char base-char-compare)
126 (:translate char<)
127 (:variant :ltu :geu))
129 (define-vop (fast-char>/base-char base-char-compare)
130 (:translate char>)
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))
136 (:conditional)
137 (:info target not-p y)
138 (:policy :fast-safe)
139 (:note "inline constant comparison")
140 (:variant-vars condition not-condition)
141 (:generator 2
142 (inst cmp x (sb!xc:char-code y))
143 (inst b (if not-p not-condition condition) target)
144 (inst nop)))
146 (define-vop (fast-char=/base-char/c base-char-compare/c)
147 (:translate char=)
148 (:variant :eq :ne))
150 (define-vop (fast-char</base-char/c base-char-compare/c)
151 (:translate char<)
152 (:variant :ltu :geu))
154 (define-vop (fast-char>/base-char/c base-char-compare/c)
155 (:translate char>)
156 (:variant :gtu :leu))