diff --git a/src/cmp/cmpopt-bits.lsp b/src/cmp/cmpopt-bits.lsp index de66ade93..d0dddcb75 100644 --- a/src/cmp/cmpopt-bits.lsp +++ b/src/cmp/cmpopt-bits.lsp @@ -29,8 +29,8 @@ (define-compiler-macro ldb (&whole whole bytespec integer) (if (inline-bytespec bytespec) (with-clean-symbols (%pos %size) - `(with-let-type-check ((%size ,(second bytespec) unsigned-byte) - (%pos ,(third bytespec) unsigned-byte)) + `(with-let*-type-check ((%size ,(second bytespec) unsigned-byte) + (%pos ,(third bytespec) unsigned-byte)) (logand (lognot (ash -1 %size)) (ash ,integer (- %pos))))) whole)) @@ -42,22 +42,30 @@ (define-compiler-macro mask-field (&whole whole bytespec integer) (if (inline-bytespec bytespec) (with-clean-symbols (%pos %size) - `(with-let-type-check ((%size ,(second bytespec) unsigned-byte) - (%pos ,(third bytespec) unsigned-byte)) + `(with-let*-type-check ((%size ,(second bytespec) unsigned-byte) + (%pos ,(third bytespec) unsigned-byte)) (logand (ash (lognot (ash -1 %size)) %pos) ,integer))) whole)) -#+(or) -(define-compiler-macro dpb (&whole bytespec integer newbyte) +(define-compiler-macro dpb (&whole whole newbyte bytespec integer) (if (inline-bytespec bytespec) - (let ((size (second bytespec)) - (pos (third bytespec))) - (with-clean-symbols (%pos %size) - `(with-let-type-check ((%size ,(second bytespec) unsigned-byte) - (%pos ,(third bytespec) unsigned-byte)) - (logand (ash (lognot (ash -1 %size)) %pos) - ,integer)))) + (with-clean-symbols (%pos %size %mask) + `(with-let*-type-check ((%size ,(second bytespec) unsigned-byte) + (%pos ,(third bytespec) unsigned-byte) + (%mask (ash (lognot (ash -1 %size)) %pos) t)) + (logior (logandc2 ,integer %mask) + (logand (ash ,newbyte %pos) %mask)))) + whole)) + +(define-compiler-macro deposit-field (&whole whole newbyte bytespec integer) + (if (inline-bytespec bytespec) + (with-clean-symbols (%pos %size %mask) + `(with-let*-type-check ((%size ,(second bytespec) unsigned-byte) + (%pos ,(third bytespec) unsigned-byte) + (%mask (ash (lognot (ash -1 %size)) %pos) t)) + (logior (logandc2 ,integer %mask) + (logand ,newbyte %mask)))) whole)) ;;; diff --git a/src/cmp/cmptype.lsp b/src/cmp/cmptype.lsp index df232a642..fc41a96bb 100644 --- a/src/cmp/cmptype.lsp +++ b/src/cmp/cmptype.lsp @@ -204,9 +204,9 @@ value `(assert-type-if-known ,value ,type))) -(defmacro with-let-type-check (triplets &body body &environment env) +(defmacro with-let*-type-check (triplets &body body &environment env) (flet ((wrap (let-or-macro var value body) - `(,let-or-macro ((,var ',value)) + `(,let-or-macro ((,var ,value)) ,body))) (loop with body = `(progn ,@body) for (var value type) in (reverse triplets) @@ -217,5 +217,5 @@ (if (or (eq new-value env) ; not constant (not (typep new-value type))) (wrap 'let var `(assert-type-if-known ,value ,type) body) - (wrap 'symbol-macrolet var value body))))) + (wrap 'symbol-macrolet var (si::maybe-quote value) body))))) finally (return body))))