X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fmips%2Farith.lisp;h=6d73c2bbe0211f6bc2a303abf08d85c8b6afdcdd;hb=6a7ffd51f991961a59c4496bd80aaa89698231f9;hp=9ae3a6417fc7ff8df59041b636f4ea5fd8dd2209;hpb=f22313c8b2cb104a088b8d901688f73c20a6161a;p=sbcl.git diff --git a/src/compiler/mips/arith.lisp b/src/compiler/mips/arith.lisp index 9ae3a64..6d73c2b 100644 --- a/src/compiler/mips/arith.lisp +++ b/src/compiler/mips/arith.lisp @@ -667,16 +667,30 @@ (inst sll r num amount))))) ;;;; Modular arithmetic -(define-modular-fun +-mod32 (x y) + 32) -(define-vop (fast-+-mod32/unsigned=>unsigned fast-+/unsigned=>unsigned) - (:translate +-mod32)) -(define-vop (fast-+-mod32-c/unsigned=>unsigned fast-+-c/unsigned=>unsigned) - (:translate +-mod32)) -(define-modular-fun --mod32 (x y) - 32) -(define-vop (fast---mod32/unsigned=>unsigned fast--/unsigned=>unsigned) - (:translate --mod32)) -(define-vop (fast---mod32-c/unsigned=>unsigned fast---c/unsigned=>unsigned) - (:translate --mod32)) + +(macrolet ((define-modular-backend (fun &optional constantp) + (collect ((forms)) + (dolist (info '((29 fixnum) (32 unsigned))) + (destructuring-bind (width regtype) info + (let ((mfun-name (intern (format nil "~A-MOD~A" fun width))) + (mvop (intern (format nil "FAST-~A-MOD~A/~A=>~A" + fun width regtype regtype))) + (mcvop (intern (format nil "FAST-~A-MOD~A-C/~A=>~A" + fun width regtype regtype))) + (vop (intern (format nil "FAST-~A/~A=>~A" + fun regtype regtype))) + (cvop (intern (format nil "FAST-~A-C/~A=>~A" + fun regtype regtype)))) + (forms `(define-modular-fun ,mfun-name (x y) ,fun ,width)) + (forms `(define-vop (,mvop ,vop) + (:translate ,mfun-name))) + (when constantp + (forms `(define-vop (,mcvop ,cvop) + (:translate ,mfun-name))))))) + `(progn ,@(forms))))) + (define-modular-backend + t) + (define-modular-backend - t) + (define-modular-backend logxor t)) (define-vop (fast-ash-left-mod32-c/unsigned=>unsigned fast-ash-c/unsigned=>unsigned) @@ -702,14 +716,6 @@ (:generator 1 (inst nor r x zero-tn))) -(define-modular-fun logxor-mod32 (x y) logxor 32) -(define-vop (fast-logxor-mod32/unsigned=>unsigned - fast-logxor/unsigned=>unsigned) - (:translate logxor-mod32)) -(define-vop (fast-logxor-mod32-c/unsigned=>unsigned - fast-logxor-c/unsigned=>unsigned) - (:translate logxor-mod32)) - (define-modular-fun lognor-mod32 (x y) lognor 32) (define-vop (fast-lognor-mod32/unsigned=>unsigned fast-lognor/unsigned=>unsigned)