1.0.13.44: bug #414 has disappeared
[sbcl/simd.git] / src / compiler / ppc / char.lisp
blobf0ab8651ff8b353cb73d24c951c3da9f0e62849b
1 ;;;; the PPC 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-character)
18 (:args (x :scs (any-reg descriptor-reg)))
19 (:results (y :scs (character-reg)))
20 (:note "character untagging")
21 (:generator 1
22 (inst srwi y x n-widetag-bits)))
23 (define-move-vop move-to-character :move
24 (any-reg descriptor-reg) (character-reg))
26 ;;; Move an untagged char to a tagged representation.
27 (define-vop (move-from-character)
28 (:args (x :scs (character-reg)))
29 (:results (y :scs (any-reg descriptor-reg)))
30 (:note "character tagging")
31 (:generator 1
32 (inst slwi y x n-widetag-bits)
33 (inst ori y y character-widetag)))
34 (define-move-vop move-from-character :move
35 (character-reg) (any-reg descriptor-reg))
37 ;;; Move untagged character values.
38 (define-vop (character-move)
39 (:args (x :target y
40 :scs (character-reg)
41 :load-if (not (location= x y))))
42 (:results (y :scs (character-reg)
43 :load-if (not (location= x y))))
44 (:note "character move")
45 (:effects)
46 (:affected)
47 (:generator 0
48 (move y x)))
49 (define-move-vop character-move :move
50 (character-reg) (character-reg))
52 ;;; Move untagged character arguments/return-values.
53 (define-vop (move-character-arg)
54 (:args (x :target y
55 :scs (character-reg))
56 (fp :scs (any-reg)
57 :load-if (not (sc-is y character-reg))))
58 (:results (y))
59 (:note "character arg move")
60 (:generator 0
61 (sc-case y
62 (character-reg
63 (move y x))
64 (character-stack
65 (storew x fp (tn-offset y))))))
66 (define-move-vop move-character-arg :move-arg
67 (any-reg character-reg) (character-reg))
69 ;;; Use standard MOVE-ARG + coercion to move an untagged character
70 ;;; to a descriptor passing location.
71 (define-move-vop move-arg :move-arg
72 (character-reg) (any-reg descriptor-reg))
74 ;;;; Other operations:
76 (define-vop (char-code)
77 (:translate char-code)
78 (:policy :fast-safe)
79 (:args (ch :scs (character-reg) :target res))
80 (:arg-types character)
81 (:results (res :scs (any-reg)))
82 (:result-types positive-fixnum)
83 (:generator 1
84 (inst slwi res ch 2)))
86 (define-vop (code-char)
87 (:translate code-char)
88 (:policy :fast-safe)
89 (:args (code :scs (any-reg) :target res))
90 (:arg-types positive-fixnum)
91 (:results (res :scs (character-reg)))
92 (:result-types character)
93 (:generator 1
94 (inst srwi res code 2)))
96 ;;; Comparison of characters.
97 (define-vop (character-compare)
98 (:args (x :scs (character-reg))
99 (y :scs (character-reg)))
100 (:arg-types character character)
101 (:conditional)
102 (:info target not-p)
103 (:policy :fast-safe)
104 (:note "inline comparison")
105 (:variant-vars condition not-condition)
106 (:generator 3
107 (inst cmplw x y)
108 (inst b? (if not-p not-condition condition) target)))
110 (define-vop (fast-char=/character character-compare)
111 (:translate char=)
112 (:variant :eq :ne))
114 (define-vop (fast-char</character character-compare)
115 (:translate char<)
116 (:variant :lt :ge))
118 (define-vop (fast-char>/character character-compare)
119 (:translate char>)
120 (:variant :gt :le))
122 (define-vop (character-compare/c)
123 (:args (x :scs (character-reg)))
124 (:arg-types character (:constant character))
125 (:conditional)
126 (:info target not-p y)
127 (:policy :fast-safe)
128 (:note "inline comparison")
129 (:variant-vars condition not-condition)
130 (:generator 2
131 (inst cmplwi x (sb!xc:char-code y))
132 (inst b? (if not-p not-condition condition) target)))
134 (define-vop (fast-char=/character/c character-compare/c)
135 (:translate char=)
136 (:variant :eq :ne))
138 (define-vop (fast-char</character/c character-compare/c)
139 (:translate char<)
140 (:variant :lt :ge))
142 (define-vop (fast-char>/character/c character-compare/c)
143 (:translate char>)
144 (:variant :gt :le))