diff --git a/include/mcl/fp_generator.hpp b/include/mcl/fp_generator.hpp index 04457b3..559e253 100644 --- a/include/mcl/fp_generator.hpp +++ b/include/mcl/fp_generator.hpp @@ -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(); gen_preInv(); + + op.fp_neg = Xbyak::CastTo(neg_); + op.fp_add = Xbyak::CastTo(add_); + op.fp_sub = Xbyak::CastTo(sub_); + op.fp_addNC = Xbyak::CastTo(addNC_); + op.fp_subNC = Xbyak::CastTo(subNC_); + op.fp_mul = Xbyak::CastTo(mul_); + op.fp_sqr = Xbyak::CastTo(sqr_); + + if (pn <= 4) { + if (montRed_) { + op.fp_mod = Xbyak::CastTo(montRed_); + } + op.fp_preInv = Xbyak::CastTo(preInv_); + } } void gen_addSubNC(bool isAdd) { diff --git a/src/fp.cpp b/src/fp.cpp index 49e8e36..f3b1ef6 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -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(fg->neg_); - op.fp_add = Xbyak::CastTo(fg->add_); - op.fp_sub = Xbyak::CastTo(fg->sub_); - op.fp_addNC = Xbyak::CastTo(fg->addNC_); - op.fp_subNC = Xbyak::CastTo(fg->subNC_); - op.fp_mul = Xbyak::CastTo(fg->mul_); - op.fp_sqr = Xbyak::CastTo(fg->sqr_); if (N <= 4) { - if (fg->montRed_) { - op.fp_mod = Xbyak::CastTo(fg->montRed_); - } - op.fp_preInv = Xbyak::CastTo(op.fg->preInv_); op.fp_invOp = &invOpForMontC; initInvTbl(op); } - #endif }