1 (in-package "SB-ROTATE-BYTE")
3 (define-vop (%32bit-rotate-byte/c)
5 (:translate %unsigned-32-rotate-byte)
6 (:note "inline 32-bit constant rotation")
8 (:args (integer :scs (sb-vm::unsigned-reg) :target res))
9 (:arg-types (:constant (integer -31 31)) sb-vm::unsigned-byte-32)
10 (:results (res :scs (sb-vm::unsigned-reg)))
11 (:result-types sb-vm::unsigned-byte-32)
13 ;; the 0 case is an identity operation and should be
14 ;; DEFTRANSFORMed away.
15 (aver (not (= count 0)))
17 (inst rotlwi res integer count)
18 (inst rotrwi res integer (- count)))))
20 (define-vop (%32bit-rotate-byte-fixnum/c)
22 (:translate %unsigned-32-rotate-byte)
23 (:note "inline 32-bit constant rotation")
25 (:args (integer :scs (sb-vm::any-reg) :target res))
26 (:arg-types (:constant (integer -31 31)) sb-vm::positive-fixnum)
27 (:results (res :scs (sb-vm::unsigned-reg)))
28 (:result-types sb-vm::unsigned-byte-32)
30 (aver (not (= count 0)))
32 ;; FIXME: all these 2s should be n-fixnum-tag-bits.
34 ((> count 2) (inst rotlwi res integer (- count 2)))
35 (t (inst rotrwi res integer (- 2 count))))))
37 (macrolet ((def (name arg-type)
40 (:translate %unsigned-32-rotate-byte)
41 (:note "inline 32-bit rotation")
42 (:args (count :scs (sb-vm::signed-reg))
43 (integer :scs (sb-vm::unsigned-reg) :target res))
44 (:arg-types sb-vm::tagged-num ,arg-type)
45 (:temporary (:scs (sb-vm::unsigned-reg) :from (:argument 0))
47 (:results (res :scs (sb-vm::unsigned-reg)))
48 (:result-types sb-vm::unsigned-byte-32)
50 (let ((label (gen-label))
54 (inst addi realcount count 32)
55 (inst rotlw res integer realcount)
58 (inst rotlw res integer count)
60 (def %32bit-rotate-byte sb-vm::unsigned-byte-32)
61 ;; FIXME: see x86-vm.lisp
62 (def %32bit-rotate-byte-fixnum sb-vm::positive-fixnum))