+(defmacro define-mod-binop ((name prototype) function)
+ `(define-vop (,name ,prototype)
+ (:args (x :target r :scs (unsigned-reg signed-reg)
+ :load-if (not (and (or (sc-is x unsigned-stack)
+ (sc-is x signed-stack))
+ (or (sc-is y unsigned-reg)
+ (sc-is y signed-reg))
+ (or (sc-is r unsigned-stack)
+ (sc-is r signed-stack))
+ (location= x r))))
+ (y :scs (unsigned-reg signed-reg unsigned-stack signed-stack)))
+ (:arg-types untagged-num untagged-num)
+ (:results (r :scs (unsigned-reg signed-reg) :from (:argument 0)
+ :load-if (not (and (or (sc-is x unsigned-stack)
+ (sc-is x signed-stack))
+ (or (sc-is y unsigned-reg)
+ (sc-is y unsigned-reg))
+ (or (sc-is r unsigned-stack)
+ (sc-is r unsigned-stack))
+ (location= x r)))))
+ (:result-types unsigned-num)
+ (:translate ,function)))
+(defmacro define-mod-binop-c ((name prototype) function)
+ `(define-vop (,name ,prototype)
+ (:args (x :target r :scs (unsigned-reg signed-reg)
+ :load-if t))
+ (:info y)
+ (:arg-types untagged-num (:constant (or (unsigned-byte 64) (signed-byte 64))))
+ (:results (r :scs (unsigned-reg signed-reg) :from (:argument 0)
+ :load-if t))
+ (:result-types unsigned-num)
+ (:translate ,function)))
+
+(macrolet ((def (name -c-p)
+ (let ((fun64 (intern (format nil "~S-MOD64" name)))
+ (vopu (intern (format nil "FAST-~S/UNSIGNED=>UNSIGNED" name)))
+ (vopcu (intern (format nil "FAST-~S-C/UNSIGNED=>UNSIGNED" name)))
+ (vopf (intern (format nil "FAST-~S/FIXNUM=>FIXNUM" name)))
+ (vopcf (intern (format nil "FAST-~S-C/FIXNUM=>FIXNUM" name)))
+ (vop64u (intern (format nil "FAST-~S-MOD64/WORD=>UNSIGNED" name)))
+ (vop64f (intern (format nil "FAST-~S-MOD64/FIXNUM=>FIXNUM" name)))
+ (vop64cu (intern (format nil "FAST-~S-MOD64-C/WORD=>UNSIGNED" name)))
+ (vop64cf (intern (format nil "FAST-~S-MOD64-C/FIXNUM=>FIXNUM" name)))
+ (funfx (intern (format nil "~S-MODFX" name)))
+ (vopfxf (intern (format nil "FAST-~S-MODFX/FIXNUM=>FIXNUM" name)))
+ (vopfxcf (intern (format nil "FAST-~S-MODFX-C/FIXNUM=>FIXNUM" name))))
+ `(progn
+ (define-modular-fun ,fun64 (x y) ,name :untagged nil 64)
+ (define-modular-fun ,funfx (x y) ,name :tagged t
+ #.(- n-word-bits n-fixnum-tag-bits))
+ (define-mod-binop (,vop64u ,vopu) ,fun64)
+ (define-vop (,vop64f ,vopf) (:translate ,fun64))
+ (define-vop (,vopfxf ,vopf) (:translate ,funfx))
+ ,@(when -c-p
+ `((define-mod-binop-c (,vop64cu ,vopcu) ,fun64)
+ (define-vop (,vopfxcf ,vopcf) (:translate ,funfx))))))))
+ (def + t)
+ (def - t)
+ (def * t))