{add,sub}S are removed

dev
MITSUNARI Shigeo 9 years ago
parent 1d5230275e
commit 2efd4a8fd6
  1. 4
      src/fp.cpp
  2. 6
      src/fp_proto.hpp
  3. 30
      src/gen.cpp

@ -337,8 +337,8 @@ struct OpeFunc {
#ifdef MCL_USE_LLVM #ifdef MCL_USE_LLVM
#define SET_OP_LLVM(n) \ #define SET_OP_LLVM(n) \
if (mode == FP_LLVM || mode == FP_LLVM_MONT) { \ if (mode == FP_LLVM || mode == FP_LLVM_MONT) { \
fp_addP = mcl_fp_add ## n ##L; \ fp_addP = mcl_fp_add ## n; \
fp_subP = mcl_fp_sub ## n ##L; \ fp_subP = mcl_fp_sub ## n; \
if (!isFullBit) { \ if (!isFullBit) { \
fp_addNC = mcl_fp_addNC ## n; \ fp_addNC = mcl_fp_addNC ## n; \
fp_subNC = mcl_fp_subNC ## n; \ fp_subNC = mcl_fp_subNC ## n; \

@ -13,10 +13,8 @@
extern "C" { extern "C" {
#define MCL_FP_DEF_FUNC(len) \ #define MCL_FP_DEF_FUNC(len) \
void mcl_fp_add ## len ## S(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y, const mcl::fp::Unit* p); \ void mcl_fp_add ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y, const mcl::fp::Unit* p); \
void mcl_fp_add ## len ## L(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y, const mcl::fp::Unit* p); \ void mcl_fp_sub ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y, const mcl::fp::Unit* p); \
void mcl_fp_sub ## len ## S(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y, const mcl::fp::Unit* p); \
void mcl_fp_sub ## len ## L(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y, const mcl::fp::Unit* p); \
void mcl_fp_addNC ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y); \ void mcl_fp_addNC ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y); \
void mcl_fp_subNC ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y); \ void mcl_fp_subNC ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, const mcl::fp::Unit* y); \
void mcl_fp_mul_UnitPre ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, mcl::fp::Unit y); \ void mcl_fp_mul_UnitPre ## len(mcl::fp::Unit* z, const mcl::fp::Unit* x, mcl::fp::Unit y); \

@ -303,6 +303,7 @@ struct Code : public mcl::Generator {
ret(Void); ret(Void);
endFunc(); endFunc();
} }
#if 0
void gen_mcl_fp_addS() void gen_mcl_fp_addS()
{ {
resetGlobalIdx(); resetGlobalIdx();
@ -329,14 +330,15 @@ struct Code : public mcl::Generator {
ret(Void); ret(Void);
endFunc(); endFunc();
} }
void gen_mcl_fp_addL() #endif
void gen_mcl_fp_add()
{ {
resetGlobalIdx(); resetGlobalIdx();
Operand pz(IntPtr, bit); Operand pz(IntPtr, bit);
Operand px(IntPtr, bit); Operand px(IntPtr, bit);
Operand py(IntPtr, bit); Operand py(IntPtr, bit);
Operand pp(IntPtr, bit); Operand pp(IntPtr, bit);
std::string name = "mcl_fp_add" + cybozu::itoa(bit) + "L"; std::string name = "mcl_fp_add" + cybozu::itoa(bit);
mcl_fp_addM[bit] = Function(name, Void, pz, px, py, pp); mcl_fp_addM[bit] = Function(name, Void, pz, px, py, pp);
beginFunc(mcl_fp_addM[bit]); beginFunc(mcl_fp_addM[bit]);
Operand x = load(px); Operand x = load(px);
@ -362,6 +364,7 @@ struct Code : public mcl::Generator {
ret(Void); ret(Void);
endFunc(); endFunc();
} }
#if 0
void gen_mcl_fp_subS() void gen_mcl_fp_subS()
{ {
resetGlobalIdx(); resetGlobalIdx();
@ -387,14 +390,15 @@ struct Code : public mcl::Generator {
ret(Void); ret(Void);
endFunc(); endFunc();
} }
void gen_mcl_fp_subL() #endif
void gen_mcl_fp_sub()
{ {
resetGlobalIdx(); resetGlobalIdx();
Operand pz(IntPtr, bit); Operand pz(IntPtr, bit);
Operand px(IntPtr, bit); Operand px(IntPtr, bit);
Operand py(IntPtr, bit); Operand py(IntPtr, bit);
Operand pp(IntPtr, bit); Operand pp(IntPtr, bit);
std::string name = "mcl_fp_sub" + cybozu::itoa(bit) + "L"; std::string name = "mcl_fp_sub" + cybozu::itoa(bit);
mcl_fp_subM[bit] = Function(name, Void, pz, px, py, pp); mcl_fp_subM[bit] = Function(name, Void, pz, px, py, pp);
beginFunc(mcl_fp_subM[bit]); beginFunc(mcl_fp_subM[bit]);
Operand x = load(px); Operand x = load(px);
@ -403,7 +407,7 @@ struct Code : public mcl::Generator {
y = zext(y, bit + unit); y = zext(y, bit + unit);
Operand vc = sub(x, y); Operand vc = sub(x, y);
Operand v = trunc(vc, bit); Operand v = trunc(vc, bit);
Operand c = lshr(vc, bit + unit - 1); Operand c = lshr(vc, bit);
c = trunc(c, 1); c = trunc(c, 1);
store(v, pz); store(v, pz);
Label carry("carry"); Label carry("carry");
@ -477,7 +481,7 @@ struct Code : public mcl::Generator {
Operand H = lshr(vc, bit); Operand H = lshr(vc, bit);
H = trunc(H, bit); H = trunc(H, bit);
Operand c = lshr(vc, b2u - 1); Operand c = lshr(vc, b2);
c = trunc(c, 1); c = trunc(c, 1);
Operand p = load(pp); Operand p = load(pp);
c = select(c, p, makeImm(bit, 0)); c = select(c, p, makeImm(bit, 0));
@ -750,18 +754,13 @@ struct Code : public mcl::Generator {
gen_mcl_fp_addsubNC(true); gen_mcl_fp_addsubNC(true);
gen_mcl_fp_addsubNC(false); gen_mcl_fp_addsubNC(false);
} }
void gen_short() void gen_addsub()
{ {
gen_mcl_fp_addS(); gen_mcl_fp_add();
gen_mcl_fp_subS(); gen_mcl_fp_sub();
gen_mcl_fpDbl_add(); gen_mcl_fpDbl_add();
gen_mcl_fpDbl_sub(); gen_mcl_fpDbl_sub();
} }
void gen_long()
{
gen_mcl_fp_addL();
gen_mcl_fp_subL();
}
void gen_mul() void gen_mul()
{ {
gen_mulPv(); gen_mulPv();
@ -789,8 +788,7 @@ struct Code : public mcl::Generator {
for (uint32_t i = 64; i <= end; i += unit) { for (uint32_t i = 64; i <= end; i += unit) {
setBit(i); setBit(i);
gen_all(); gen_all();
gen_short(); gen_addsub();
gen_long();
if (i > 64) { if (i > 64) {
gen_mul(); gen_mul();
} }

Loading…
Cancel
Save