reduce code generator if MCL_MAX_BIT_SIZE=256

dev
MITSUNARI Shigeo 8 years ago
parent ec691ce5e0
commit 7849c6d82d
  1. 1
      include/mcl/op.hpp
  2. 22
      src/fp.cpp
  3. 21
      src/low_func_llvm.hpp
  4. 16
      src/proto.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;

@ -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;

@ -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

@ -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)

Loading…
Cancel
Save