-(define-vop (merge-bits)
- (:translate merge-bits)
- (:args (shift :scs (signed-reg unsigned-reg))
- (prev :scs (unsigned-reg))
- (next :scs (unsigned-reg)))
- (:arg-types tagged-num unsigned-num unsigned-num)
- (:temporary (:scs (unsigned-reg) :to (:result 0)) temp)
- (:temporary (:scs (unsigned-reg) :to (:result 0) :target result) res)
- (:results (result :scs (unsigned-reg)))
- (:result-types unsigned-num)
- (:policy :fast-safe)
- (:generator 4
- (let ((done (gen-label)))
- (inst srl next shift res)
- (inst beq shift done)
- (inst subq zero-tn shift temp)
- (inst sll prev temp temp)
- (inst bis res temp res)
- (emit-label done)
- (move res result))))
-
-(define-source-transform 32bit-logical-not (x)
- `(logand (lognot (the (unsigned-byte 32) ,x)) #.(1- (ash 1 32))))
-
-(deftransform 32bit-logical-and ((x y))
- '(logand x y))
-
-(define-source-transform 32bit-logical-nand (x y)
- `(32bit-logical-not (32bit-logical-and ,x ,y)))
-
-(deftransform 32bit-logical-or ((x y))
- '(logior x y))
-
-(define-source-transform 32bit-logical-nor (x y)
- `(logand (lognor (the (unsigned-byte 32) ,x) (the (unsigned-byte 32) ,y))
- #.(1- (ash 1 32))))
-
-(deftransform 32bit-logical-xor ((x y))
- '(logxor x y))
-
-(define-source-transform 32bit-logical-eqv (x y)
- `(logand (logeqv (the (unsigned-byte 32) ,x) (the (unsigned-byte 32) ,y))
- #.(1- (ash 1 32))))
-
-(define-source-transform 32bit-logical-orc1 (x y)
- `(logand (logorc1 (the (unsigned-byte 32) ,x) (the (unsigned-byte 32) ,y))
- #.(1- (ash 1 32))))
-
-(define-source-transform 32bit-logical-orc2 (x y)
- `(logand (logorc2 (the (unsigned-byte 32) ,x) (the (unsigned-byte 32) ,y))
- #.(1- (ash 1 32))))
-
-(define-source-transform 32bit-logical-andc1 (x y)
- `(logandc1 (the (unsigned-byte 32) ,x) (the (unsigned-byte 32) ,y)))
-
-(define-source-transform 32bit-logical-andc2 (x y)
- `(logandc2 (the (unsigned-byte 32) ,x) (the (unsigned-byte 32) ,y)))
-