Skip to content

Instantly share code, notes, and snippets.

@pkhuong
Last active August 29, 2015 14:00
Show Gist options
  • Save pkhuong/11125384 to your computer and use it in GitHub Desktop.
Save pkhuong/11125384 to your computer and use it in GitHub Desktop.
(define-vop (bignum-mult-and-add-3-arg)
(:translate sb!bignum:%multiply-and-add)
(:policy :fast-safe)
(:args (x :scs (unsigned-reg) :to :result)
(y :scs (unsigned-reg) :to :result)
(carry-in :scs (unsigned-reg) :target lo))
(:arg-types unsigned-num unsigned-num unsigned-num)
(:results (hi :scs (unsigned-reg) :from :eval)
(lo :scs (unsigned-reg) :from (:argument 2)))
(:result-types unsigned-num unsigned-num)
(:generator 2
(move lo carry-in)
(inst eor hi hi hi) ; call this zeroize and figure it out later
(inst umlal lo hi x y)))
(define-vop (bignum-mult-and-add-4-arg)
(:translate sb!bignum:%multiply-and-add)
(:policy :fast-safe)
(:args (x :scs (unsigned-reg) :to :result)
(y :scs (unsigned-reg) :to :result)
(prev :scs (unsigned-reg) :to :eval)
(carry-in :scs (unsigned-reg) :to :eval))
(:arg-types unsigned-num unsigned-num unsigned-num unsigned-num)
(:results (hi :scs (unsigned-reg) :from :eval)
(lo :scs (unsigned-reg) :from :eval))
(:result-types unsigned-num unsigned-num)
(:generator 2
(inst adds lo carry-in prev)
(inst eor hi hi hi)
(inst mov :cs hi 1)
(inst umlal lo hi x y)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment