move setting of op

dev
MITSUNARI Shigeo 9 years ago
parent dcf1602828
commit 8dbb713772
  1. 17
      include/mcl/fp_generator.hpp
  2. 12
      src/fp.cpp

@ -195,7 +195,7 @@ struct FpGenerator : Xbyak::CodeGenerator {
@param p [in] pointer to prime
@param pn [in] length of prime
*/
void init(Op& /*op*/, const uint64_t *p, int pn)
void init(Op& op, const uint64_t *p, int pn)
{
if (pn < 2) throw cybozu::Exception("mcl:FpGenerator:small pn") << pn;
p_ = p;
@ -239,6 +239,21 @@ struct FpGenerator : Xbyak::CodeGenerator {
gen_shr1();
preInv_ = getCurr<int2op>();
gen_preInv();
op.fp_neg = Xbyak::CastTo<void2u>(neg_);
op.fp_add = Xbyak::CastTo<void3u>(add_);
op.fp_sub = Xbyak::CastTo<void3u>(sub_);
op.fp_addNC = Xbyak::CastTo<void3u>(addNC_);
op.fp_subNC = Xbyak::CastTo<void3u>(subNC_);
op.fp_mul = Xbyak::CastTo<void3u>(mul_);
op.fp_sqr = Xbyak::CastTo<void2u>(sqr_);
if (pn <= 4) {
if (montRed_) {
op.fp_mod = Xbyak::CastTo<void2u>(montRed_);
}
op.fp_preInv = Xbyak::CastTo<int2u>(preInv_);
}
}
void gen_addSubNC(bool isAdd)
{

@ -365,22 +365,10 @@ static void initForMont(Op& op, const Unit *p, Mode mode)
if (fg == 0) return;
fg->init(op, p, (int)N);
op.fp_neg = Xbyak::CastTo<void2u>(fg->neg_);
op.fp_add = Xbyak::CastTo<void3u>(fg->add_);
op.fp_sub = Xbyak::CastTo<void3u>(fg->sub_);
op.fp_addNC = Xbyak::CastTo<void3u>(fg->addNC_);
op.fp_subNC = Xbyak::CastTo<void3u>(fg->subNC_);
op.fp_mul = Xbyak::CastTo<void3u>(fg->mul_);
op.fp_sqr = Xbyak::CastTo<void2u>(fg->sqr_);
if (N <= 4) {
if (fg->montRed_) {
op.fp_mod = Xbyak::CastTo<void2u>(fg->montRed_);
}
op.fp_preInv = Xbyak::CastTo<int2u>(op.fg->preInv_);
op.fp_invOp = &invOpForMontC;
initInvTbl(op);
}
#endif
}

Loading…
Cancel
Save