-
-(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 *) ; FIXME: there exists a
- ; FAST-*-C/FIXNUM=>FIXNUM VOP which
- ; should be used for the MOD29 case,
- ; but the MOD32 case cannot accept
- ; immediate arguments.
- (define-modular-backend logxor t))
-
-(macrolet ((define-modular-ash (width regtype)
- (let ((mfun-name (intern (format nil "ASH-LEFT-MOD~A" width)))
- (modvop (intern (format nil "FAST-ASH-LEFT-MOD~A/~A=>~A"
- width regtype regtype)))
- (modcvop (intern (format nil "FAST-ASH-LEFT-MOD~A-C/~A=>~A"
- width regtype regtype)))
- (vop (intern (format nil "FAST-ASH-LEFT/~A=>~A"
- regtype regtype)))
- (cvop (intern (format nil "FAST-ASH-C/~A=>~A"
- regtype regtype))))
+(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 (not (and (or (sc-is x unsigned-stack)
+ (sc-is x signed-stack))
+ (or (sc-is r unsigned-stack)
+ (sc-is r signed-stack))
+ (location= x r)))))
+ (:info y)
+ (:arg-types untagged-num (:constant (or (unsigned-byte 32) (signed-byte 32))))
+ (: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 r unsigned-stack)
+ (sc-is r unsigned-stack))
+ (location= x r)))))
+ (:result-types unsigned-num)
+ (:translate ,function)))
+
+(macrolet ((def (name -c-p)
+ (let ((fun32 (intern (format nil "~S-MOD32" 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)))
+ (vop32u (intern (format nil "FAST-~S-MOD32/WORD=>UNSIGNED" name)))
+ (vop32f (intern (format nil "FAST-~S-MOD32/FIXNUM=>FIXNUM" name)))
+ (vop32cu (intern (format nil "FAST-~S-MOD32-C/WORD=>UNSIGNED" name)))
+ (vop32cf (intern (format nil "FAST-~S-MOD32-C/FIXNUM=>FIXNUM" name)))
+ (sfun30 (intern (format nil "~S-SMOD30" name)))
+ (svop30f (intern (format nil "FAST-~S-SMOD30/FIXNUM=>FIXNUM" name)))
+ (svop30cf (intern (format nil "FAST-~S-SMOD30-C/FIXNUM=>FIXNUM" name))))