|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|