From 2efd4a8fd6be296e0c16753af894027b88368cf1 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 13 Jun 2016 06:21:43 +0900 Subject: [PATCH] {add,sub}S are removed --- src/fp.cpp | 4 ++-- src/fp_proto.hpp | 6 ++---- src/gen.cpp | 30 ++++++++++++++---------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/fp.cpp b/src/fp.cpp index b4e44d4..040f491 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -337,8 +337,8 @@ struct OpeFunc { #ifdef MCL_USE_LLVM #define SET_OP_LLVM(n) \ if (mode == FP_LLVM || mode == FP_LLVM_MONT) { \ - fp_addP = mcl_fp_add ## n ##L; \ - fp_subP = mcl_fp_sub ## n ##L; \ + fp_addP = mcl_fp_add ## n; \ + fp_subP = mcl_fp_sub ## n; \ if (!isFullBit) { \ fp_addNC = mcl_fp_addNC ## n; \ fp_subNC = mcl_fp_subNC ## n; \ diff --git a/src/fp_proto.hpp b/src/fp_proto.hpp index 1933537..87c728e 100644 --- a/src/fp_proto.hpp +++ b/src/fp_proto.hpp @@ -13,10 +13,8 @@ extern "C" { #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 ## 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 ## 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_add ## 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(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_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); \ diff --git a/src/gen.cpp b/src/gen.cpp index 1ac2e4f..ea594ed 100644 --- a/src/gen.cpp +++ b/src/gen.cpp @@ -303,6 +303,7 @@ struct Code : public mcl::Generator { ret(Void); endFunc(); } +#if 0 void gen_mcl_fp_addS() { resetGlobalIdx(); @@ -329,14 +330,15 @@ struct Code : public mcl::Generator { ret(Void); endFunc(); } - void gen_mcl_fp_addL() +#endif + void gen_mcl_fp_add() { resetGlobalIdx(); Operand pz(IntPtr, bit); Operand px(IntPtr, bit); Operand py(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); beginFunc(mcl_fp_addM[bit]); Operand x = load(px); @@ -362,6 +364,7 @@ struct Code : public mcl::Generator { ret(Void); endFunc(); } +#if 0 void gen_mcl_fp_subS() { resetGlobalIdx(); @@ -387,14 +390,15 @@ struct Code : public mcl::Generator { ret(Void); endFunc(); } - void gen_mcl_fp_subL() +#endif + void gen_mcl_fp_sub() { resetGlobalIdx(); Operand pz(IntPtr, bit); Operand px(IntPtr, bit); Operand py(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); beginFunc(mcl_fp_subM[bit]); Operand x = load(px); @@ -403,7 +407,7 @@ struct Code : public mcl::Generator { y = zext(y, bit + unit); Operand vc = sub(x, y); Operand v = trunc(vc, bit); - Operand c = lshr(vc, bit + unit - 1); + Operand c = lshr(vc, bit); c = trunc(c, 1); store(v, pz); Label carry("carry"); @@ -477,7 +481,7 @@ struct Code : public mcl::Generator { Operand H = lshr(vc, bit); H = trunc(H, bit); - Operand c = lshr(vc, b2u - 1); + Operand c = lshr(vc, b2); c = trunc(c, 1); Operand p = load(pp); 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(false); } - void gen_short() + void gen_addsub() { - gen_mcl_fp_addS(); - gen_mcl_fp_subS(); + gen_mcl_fp_add(); + gen_mcl_fp_sub(); gen_mcl_fpDbl_add(); gen_mcl_fpDbl_sub(); } - void gen_long() - { - gen_mcl_fp_addL(); - gen_mcl_fp_subL(); - } void gen_mul() { gen_mulPv(); @@ -789,8 +788,7 @@ struct Code : public mcl::Generator { for (uint32_t i = 64; i <= end; i += unit) { setBit(i); gen_all(); - gen_short(); - gen_long(); + gen_addsub(); if (i > 64) { gen_mul(); }