|
|
|
@ -22,50 +22,6 @@ void destroyFpGenerator(FpGenerator*) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
//void setOp(mcl::fp::Op& op, const Unit* p, size_t pBitLen)
|
|
|
|
|
void setOp(mcl::fp::Op&, const Unit*, size_t) |
|
|
|
|
{ |
|
|
|
|
#if 0 |
|
|
|
|
#ifdef USE_MONT_FP |
|
|
|
|
if (pBitLen <= 128) { op = fp::MontFp<tag, 128>::init(p); } |
|
|
|
|
#if CYBOZU_OS_BIT == 32 |
|
|
|
|
else if (pBitLen <= 160) { static fp::MontFp<tag, 160> f; op = f.init(p); } |
|
|
|
|
#endif |
|
|
|
|
else if (pBitLen <= 192) { static fp::MontFp<tag, 192> f; op = f.init(p); } |
|
|
|
|
#if CYBOZU_OS_BIT == 32 |
|
|
|
|
else if (pBitLen <= 224) { static fp::MontFp<tag, 224> f; op = f.init(p); } |
|
|
|
|
#endif |
|
|
|
|
else if (pBitLen <= 256) { static fp::MontFp<tag, 256> f; op = f.init(p); } |
|
|
|
|
else if (pBitLen <= 384) { static fp::MontFp<tag, 384> f; op = f.init(p); } |
|
|
|
|
else if (pBitLen <= 448) { static fp::MontFp<tag, 448> f; op = f.init(p); } |
|
|
|
|
#if CYBOZU_OS_BIT == 32 |
|
|
|
|
else if (pBitLen <= 544) { static fp::MontFp<tag, 544> f; op = f.init(p); } |
|
|
|
|
#else |
|
|
|
|
else if (pBitLen <= 576) { static fp::MontFp<tag, 576> f; op = f.init(p); } |
|
|
|
|
#endif |
|
|
|
|
else { static fp::MontFp<tag, maxBitN> f; op = f.init(p); } |
|
|
|
|
#else |
|
|
|
|
if (pBitLen <= 128) { op = fp::FixedFp<tag, 128>::init(p); } |
|
|
|
|
#if CYBOZU_OS_BIT == 32 |
|
|
|
|
else if (pBitLen <= 160) { static fp::FixedFp<tag, 160> f; op = f.init(p); } |
|
|
|
|
#endif |
|
|
|
|
else if (pBitLen <= 192) { static fp::FixedFp<tag, 192> f; op = f.init(p); } |
|
|
|
|
#if CYBOZU_OS_BIT == 32 |
|
|
|
|
else if (pBitLen <= 224) { static fp::FixedFp<tag, 224> f; op = f.init(p); } |
|
|
|
|
#endif |
|
|
|
|
else if (pBitLen <= 256) { static fp::FixedFp<tag, 256> f; op = f.init(p); } |
|
|
|
|
else if (pBitLen <= 384) { static fp::FixedFp<tag, 384> f; op = f.init(p); } |
|
|
|
|
else if (pBitLen <= 448) { static fp::FixedFp<tag, 448> f; op = f.init(p); } |
|
|
|
|
#if CYBOZU_OS_BIT == 32 |
|
|
|
|
else if (pBitLen <= 544) { static fp::FixedFp<tag, 544> f; op = f.init(p); } |
|
|
|
|
#else |
|
|
|
|
else if (pBitLen <= 576) { static fp::FixedFp<tag, 576> f; op = f.init(p); } |
|
|
|
|
#endif |
|
|
|
|
else { static fp::FixedFp<tag, maxBitN> f; op = f.init(p); } |
|
|
|
|
#endif |
|
|
|
|
assert(op.N <= maxUnitN); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<size_t bitN> |
|
|
|
|
struct OpeFunc { |
|
|
|
@ -168,9 +124,9 @@ struct OpeFunc { |
|
|
|
|
|
|
|
|
|
#ifdef MCL_USE_LLVM |
|
|
|
|
#define SET_OP_LLVM(n) \ |
|
|
|
|
op.addG = mcl_fp_add ## n ##S; \
|
|
|
|
|
op.subG = mcl_fp_sub ## n ##S; \
|
|
|
|
|
op.mulPreG = mcl_fp_mulPre ## n; |
|
|
|
|
op.addP = mcl_fp_add ## n ##S; \
|
|
|
|
|
op.subP = mcl_fp_sub ## n ##S; \
|
|
|
|
|
op.mulPreP = mcl_fp_mulPre ## n; |
|
|
|
|
#else |
|
|
|
|
#define SET_OP_LLVM(n) |
|
|
|
|
#endif |
|
|
|
@ -180,15 +136,15 @@ struct OpeFunc { |
|
|
|
|
op.isZero = OpeFunc<n>::isZeroC; \
|
|
|
|
|
op.clear = OpeFunc<n>::clearC; \
|
|
|
|
|
op.copy = OpeFunc<n>::copyC; \
|
|
|
|
|
op.negG = OpeFunc<n>::negC; \
|
|
|
|
|
op.negP = OpeFunc<n>::negC; \
|
|
|
|
|
op.invOp = OpeFunc<n>::invOp; \
|
|
|
|
|
op.addG = OpeFunc<n>::addC; \
|
|
|
|
|
op.subG = OpeFunc<n>::subC; \
|
|
|
|
|
op.mulPreG = OpeFunc<n>::mulPreC; \
|
|
|
|
|
op.modG = OpeFunc<n>::modC; \
|
|
|
|
|
op.addP = OpeFunc<n>::addC; \
|
|
|
|
|
op.subP = OpeFunc<n>::subC; \
|
|
|
|
|
op.mulPreP = OpeFunc<n>::mulPreC; \
|
|
|
|
|
op.modP = OpeFunc<n>::modC; \
|
|
|
|
|
SET_OP_LLVM(n) |
|
|
|
|
|
|
|
|
|
void initOpByLLVM(Op& op, const Unit* /*p*/, size_t bitLen) |
|
|
|
|
void setOp(mcl::fp::Op& op, const Unit* /*p*/, size_t bitLen) |
|
|
|
|
{ |
|
|
|
|
assert(sizeof(mp_limb_t) == sizeof(Unit)); |
|
|
|
|
const size_t UnitBitN = sizeof(Unit) * 8; |
|
|
|
|