469d8963012ebc7369af91880b5370e7fca4e0c1
[sbcl.git] / src / compiler / hppa / char.lisp
1 (in-package "SB!VM")
2
3 \f
4 ;;;; Moves and coercions:
5
6 ;;; Move a tagged char to an untagged representation.
7 ;;;
8 (define-vop (move-to-base-char)
9   (:args (x :scs (any-reg descriptor-reg)))
10   (:results (y :scs (base-char-reg)))
11   (:generator 1
12     (inst srl x n-widetag-bits y)))
13 ;;;
14 (define-move-vop move-to-base-char :move
15   (any-reg descriptor-reg) (base-char-reg))
16
17 ;;; Move an untagged char to a tagged representation.
18 ;;;
19 (define-vop (move-from-base-char)
20   (:args (x :scs (base-char-reg)))
21   (:results (y :scs (any-reg descriptor-reg)))
22   (:generator 1
23     (inst sll x n-widetag-bits y)
24     (inst addi base-char-widetag y y)))
25 ;;;
26 (define-move-vop move-from-base-char :move
27   (base-char-reg) (any-reg descriptor-reg))
28
29 ;;; Move untagged base-char values.
30 ;;;
31 (define-vop (base-char-move)
32   (:args (x :target y
33             :scs (base-char-reg)
34             :load-if (not (location= x y))))
35   (:results (y :scs (base-char-reg)
36                :load-if (not (location= x y))))
37   (:effects)
38   (:affected)
39   (:generator 0
40     (move x y)))
41 ;;;
42 (define-move-vop base-char-move :move
43   (base-char-reg) (base-char-reg))
44
45
46 ;;; Move untagged base-char arguments/return-values.
47 ;;;
48 (define-vop (move-base-char-argument)
49   (:args (x :target y
50             :scs (base-char-reg))
51          (fp :scs (any-reg)
52              :load-if (not (sc-is y base-char-reg))))
53   (:results (y))
54   (:generator 0
55     (sc-case y
56       (base-char-reg
57        (move x y))
58       (base-char-stack
59        (storew x fp (tn-offset y))))))
60 ;;;
61 (define-move-vop move-base-char-argument :move-arg
62   (any-reg base-char-reg) (base-char-reg))
63
64
65 ;;; Use standard MOVE-ARGUMENT + coercion to move an untagged base-char
66 ;;; to a descriptor passing location.
67 ;;;
68 (define-move-vop move-argument :move-arg
69   (base-char-reg) (any-reg descriptor-reg))
70
71
72 \f
73 ;;;; Other operations:
74
75 (define-vop (char-code)
76   (:translate char-code)
77   (:policy :fast-safe)
78   (:args (ch :scs (base-char-reg) :target res))
79   (:arg-types base-char)
80   (:results (res :scs (unsigned-reg)))
81   (:result-types positive-fixnum)
82   (:generator 1
83     (move ch res)))
84
85 (define-vop (code-char)
86   (:translate code-char)
87   (:policy :fast-safe)
88   (:args (code :scs (unsigned-reg) :target res))
89   (:arg-types positive-fixnum)
90   (:results (res :scs (base-char-reg)))
91   (:result-types base-char)
92   (:generator 1
93     (move code res)))
94
95 \f
96 ;;; Comparison of base-chars.
97 ;;;
98 (define-vop (base-char-compare)
99   (:args (x :scs (base-char-reg))
100          (y :scs (base-char-reg)))
101   (:arg-types base-char base-char)
102   (:conditional)
103   (:info target not-p)
104   (:policy :fast-safe)
105   (:note "inline comparison")
106   (:variant-vars cond)
107   (:generator 3
108     (inst bc cond not-p x y target)))
109
110 (define-vop (fast-char=/base-char base-char-compare)
111   (:translate char=)
112   (:variant :=))
113
114 (define-vop (fast-char</base-char base-char-compare)
115   (:translate char<)
116   (:variant :<<))
117
118 (define-vop (fast-char>/base-char base-char-compare)
119   (:translate char>)
120   (:variant :>>))