diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index c660fc6..9638f25 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -97,6 +97,7 @@ typedef uint64_t Unit; const size_t UnitBitSize = sizeof(Unit) * 8; const size_t maxOpUnitSize = (MCL_MAX_BIT_SIZE + UnitBitSize - 1) / UnitBitSize; +#define MCL_MAX_UNIT_SIZE ((MCL_MAX_BIT_SIZE + CYBOZU_OS_BIT - 1) / CYBOZU_OS_BIT) struct FpGenerator; struct Op; diff --git a/src/fp.cpp b/src/fp.cpp index a8015fd..2cce788 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -422,28 +422,30 @@ void Op::init(const std::string& mstr, size_t maxBitSize, Mode mode) case 2: setOp<2>(*this, mode); break; case 3: setOp<3>(*this, mode); break; case 4: setOp<4>(*this, mode); break; // 256 if 64-bit +#if MCL_MAX_UNIT_SIZE >= 6 case 5: setOp<5>(*this, mode); break; case 6: setOp<6>(*this, mode); break; +#endif +#if MCL_MAX_UNIT_SIZE >= 9 case 7: setOp<7>(*this, mode); break; case 8: setOp<8>(*this, mode); break; - case 9: setOp<9>(*this, mode); break; // 576 if 64-bit -#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE >= 768 + case 9: setOp<9>(*this, mode); break; // 521 if 64-bit +#endif +#if MCL_MAX_UNIT_SIZE >= 12 case 10: setOp<10>(*this, mode); break; case 11: setOp<11>(*this, mode); break; case 12: setOp<12>(*this, mode); break; // 768 if 64-bit #endif -#if CYBOZU_OS_BIT == 32 +#if MCL_MAX_UNIT_SIZE >= 14 case 13: setOp<13>(*this, mode); break; case 14: setOp<14>(*this, mode); break; - case 15: setOp<15>(*this, mode); break; - case 16: setOp<16>(*this, mode); break; - case 17: setOp<17>(*this, mode); break; // 544 if 32-bit #endif -#if CYBOZU_OS_BIT == 64 && MCL_MAX_BIT_SIZE == 1024 - case 13: setOp<13>(*this, mode); break; - case 14: setOp<14>(*this, mode); break; +#if MCL_MAX_UNIT_SIZE >= 16 case 15: setOp<15>(*this, mode); break; - case 16: setOp<16>(*this, mode); break; + case 16: setOp<16>(*this, mode); break; // 1024 if 64-bit +#endif +#if MCL_MAX_UNIT_SIZE >= 17 + case 17: setOp<17>(*this, mode); break; // 521 if 32-bit #endif default: throw cybozu::Exception("Op::init:not:support") << N << mstr; diff --git a/src/low_func_llvm.hpp b/src/low_func_llvm.hpp index 294c022..a96f3fa 100644 --- a/src/low_func_llvm.hpp +++ b/src/low_func_llvm.hpp @@ -54,30 +54,37 @@ MCL_DEF_LLVM_FUNC(1) MCL_DEF_LLVM_FUNC(2) MCL_DEF_LLVM_FUNC(3) MCL_DEF_LLVM_FUNC(4) +#if MCL_MAX_UNIT_SIZE >= 6 MCL_DEF_LLVM_FUNC(5) MCL_DEF_LLVM_FUNC(6) +#endif +#if MCL_MAX_UNIT_SIZE >= 9 MCL_DEF_LLVM_FUNC(7) MCL_DEF_LLVM_FUNC(8) MCL_DEF_LLVM_FUNC(9) -#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE >= 768 +#endif +#if MCL_MAX_UNIT_SIZE >= 12 MCL_DEF_LLVM_FUNC(10) MCL_DEF_LLVM_FUNC(11) MCL_DEF_LLVM_FUNC(12) #endif -#if CYBOZU_OS_BIT == 32 +#if MCL_MAX_UNIT_SIZE >= 14 MCL_DEF_LLVM_FUNC(13) MCL_DEF_LLVM_FUNC(14) +#endif +#if MCL_MAX_UNIT_SIZE >= 16 MCL_DEF_LLVM_FUNC(15) +#if CYBOZU_OS_BIT == 32 MCL_DEF_LLVM_FUNC(16) -MCL_DEF_LLVM_FUNC(17) -#endif -#if CYBOZU_OS_BIT == 64 && MCL_MAX_BIT_SIZE == 1024 -MCL_DEF_LLVM_FUNC(14) -//MCL_DEF_LLVM_FUNC(16) +#else /// QQQ : check speed template<>const void3u MontRed<16, Ltag>::f = &mcl_fp_montRed16L; template<>const void3u MontRed<16, LBMI2tag>::f = &mcl_fp_montRed16Lbmi2; #endif +#endif +#if MCL_MAX_UNIT_SIZE >= 17 +MCL_DEF_LLVM_FUNC(17) +#endif } } // mcl::fp diff --git a/src/proto.hpp b/src/proto.hpp index ea78a4b..380e38e 100644 --- a/src/proto.hpp +++ b/src/proto.hpp @@ -41,26 +41,30 @@ MCL_FP_DEF_FUNC(1) MCL_FP_DEF_FUNC(2) MCL_FP_DEF_FUNC(3) MCL_FP_DEF_FUNC(4) +#if MCL_MAX_UNIT_SIZE >= 6 MCL_FP_DEF_FUNC(5) MCL_FP_DEF_FUNC(6) +#endif +#if MCL_MAX_UNIT_SIZE >= 9 MCL_FP_DEF_FUNC(7) MCL_FP_DEF_FUNC(8) MCL_FP_DEF_FUNC(9) -#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE >= 768 +#endif +#if MCL_MAX_UNIT_SIZE >= 12 MCL_FP_DEF_FUNC(10) MCL_FP_DEF_FUNC(11) MCL_FP_DEF_FUNC(12) #endif -#if CYBOZU_OS_BIT == 32 +#if MCL_MAX_UNIT_SIZE >= 14 MCL_FP_DEF_FUNC(13) MCL_FP_DEF_FUNC(14) +#endif +#if MCL_MAX_UNIT_SIZE >= 16 MCL_FP_DEF_FUNC(15) MCL_FP_DEF_FUNC(16) -MCL_FP_DEF_FUNC(17) #endif -#if CYBOZU_OS_BIT == 64 && MCL_MAX_BIT_SIZE == 1024 -MCL_FP_DEF_FUNC(14) -MCL_FP_DEF_FUNC(16) +#if MCL_MAX_UNIT_SIZE >= 17 +MCL_FP_DEF_FUNC(17) #endif MCL_FP_DEF_FUNC_SPECIAL(L)