|
|
|
@ -28,11 +28,53 @@ namespace mcl { |
|
|
|
|
#ifdef MCL_STATIC_JIT |
|
|
|
|
typedef fp::Unit Unit; |
|
|
|
|
extern "C" { |
|
|
|
|
Unit mclx_Fr_addPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
|
|
|
|
|
Unit mclx_Fp_addPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
Unit mclx_Fp_subPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fp_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fp_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fp_shr1(Unit*, const Unit*); |
|
|
|
|
void mclx_Fp_neg(Unit*, const Unit*); |
|
|
|
|
void mclx_FpDbl_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FpDbl_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FpDbl_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FpDbl_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
Unit mclx_FpDbl_addPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
Unit mclx_FpDbl_subPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FpDbl_mulPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FpDbl_sqrPre(Unit*, const Unit*); |
|
|
|
|
void mclx_FpDbl_mod(Unit*, const Unit*); |
|
|
|
|
void mclx_Fp_mul(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fp_sqr(Unit*, const Unit*); |
|
|
|
|
void mclx_Fp2_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fp2_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fp2_neg(Unit*, const Unit*); |
|
|
|
|
void mclx_Fp2_mul(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fp2_sqr(Unit*, const Unit*); |
|
|
|
|
void mclx_Fp2_mul_xi(Unit*, const Unit*); |
|
|
|
|
|
|
|
|
|
Unit mclx_Fr_addPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
Unit mclx_Fr_subPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr_shr1(Unit*, const Unit*); |
|
|
|
|
void mclx_Fr_neg(Unit*, const Unit*); |
|
|
|
|
void mclx_FrDbl_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FrDbl_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FrDbl_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FrDbl_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
Unit mclx_FrDbl_addPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
Unit mclx_FrDbl_subPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FrDbl_mulPre(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_FrDbl_sqrPre(Unit*, const Unit*); |
|
|
|
|
void mclx_FrDbl_mod(Unit*, const Unit*); |
|
|
|
|
void mclx_Fr_mul(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr_sqr(Unit*, const Unit*); |
|
|
|
|
void mclx_Fr2_add(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr2_sub(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr2_neg(Unit*, const Unit*); |
|
|
|
|
void mclx_Fr2_mul(Unit*, const Unit*, const Unit*); |
|
|
|
|
void mclx_Fr2_sqr(Unit*, const Unit*); |
|
|
|
|
void mclx_Fr2_mul_xi(Unit*, const Unit*); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
@ -327,6 +369,7 @@ struct FpGenerator : Xbyak::CodeGenerator { |
|
|
|
|
private: |
|
|
|
|
void init_inner(Op& op, const char *suf) |
|
|
|
|
{ |
|
|
|
|
const bool isFp = suf && suf[0] == 'F' && suf[1] == 'p'; |
|
|
|
|
op_ = &op; |
|
|
|
|
L(pL_); |
|
|
|
|
p_ = reinterpret_cast<const uint64_t*>(getCurr()); |
|
|
|
@ -382,6 +425,7 @@ private: |
|
|
|
|
setFuncInfo(prof_, suf, "_neg", op.fp_negA_, getCurr()); |
|
|
|
|
align(16); |
|
|
|
|
|
|
|
|
|
if (op.xi_a) { |
|
|
|
|
op.fpDbl_addA_ = gen_fpDbl_add(); |
|
|
|
|
setFuncInfo(prof_, suf, "Dbl_add", op.fpDbl_addA_, getCurr()); |
|
|
|
|
align(16); |
|
|
|
@ -409,6 +453,7 @@ private: |
|
|
|
|
op.fpDbl_modA_ = gen_fpDbl_mod(op); |
|
|
|
|
setFuncInfo(prof_, suf, "Dbl_mod", op.fpDbl_modA_, getCurr()); |
|
|
|
|
align(16); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
op.fp_mulA_ = gen_mul(); |
|
|
|
|
setFuncInfo(prof_, suf, "_mul", op.fp_mulA_, getCurr()); |
|
|
|
@ -463,14 +508,50 @@ private: |
|
|
|
|
align(16); |
|
|
|
|
|
|
|
|
|
#ifdef MCL_STATIC_JIT |
|
|
|
|
const bool isFp = strcmp(suf, "Fp") == 0; |
|
|
|
|
printf("isFp=%d\n", isFp); |
|
|
|
|
if (isFp) { |
|
|
|
|
// Fp, sizeof(Fp) = 48
|
|
|
|
|
op.fp_addPre = mclx_Fp_addPre; |
|
|
|
|
op.fp_addA_ = mclx_Fr_add; |
|
|
|
|
op.fp_subPre = mclx_Fp_subPre; |
|
|
|
|
op.fp_addA_ = mclx_Fp_add; |
|
|
|
|
op.fp_subA_ = mclx_Fp_sub; |
|
|
|
|
op.fp_shr1 = mclx_Fp_shr1; |
|
|
|
|
op.fp_negA_ = mclx_Fp_neg; |
|
|
|
|
op.fpDbl_addA_ = mclx_FpDbl_add; |
|
|
|
|
op.fpDbl_subA_ = mclx_FpDbl_sub; |
|
|
|
|
op.fpDbl_addPre = mclx_FpDbl_addPre; |
|
|
|
|
op.fpDbl_subPre = mclx_FpDbl_subPre; |
|
|
|
|
op.fpDbl_mulPreA_ = mclx_FpDbl_mulPre; |
|
|
|
|
op.fpDbl_sqrPreA_ = mclx_FpDbl_sqrPre; |
|
|
|
|
op.fpDbl_modA_ = mclx_FpDbl_mod; |
|
|
|
|
op.fp_mulA_ = mclx_Fp_mul; |
|
|
|
|
op.fp_sqrA_ = mclx_Fp_sqr; |
|
|
|
|
#if 0 |
|
|
|
|
// op.fp_preInv = mclx_Fp_preInv;
|
|
|
|
|
op.fp2_addA_ = mclx_Fp2_add; |
|
|
|
|
op.fp2_subA_ = mclx_Fp2_sub; |
|
|
|
|
op.fp2_negA_ = mclx_Fp2_neg; |
|
|
|
|
op.fp2_mulA_ = mclx_Fp2_mul; |
|
|
|
|
op.fp2_sqrA_ = mclx_Fp2_sqr; |
|
|
|
|
op.fp2_mul_xiA_ = mclx_Fp2_mul_xi; |
|
|
|
|
#endif |
|
|
|
|
} else { |
|
|
|
|
// Fr, sizeof(Fr) = 32
|
|
|
|
|
op.fp_addPre = mclx_Fr_addPre; |
|
|
|
|
op.fp_subPre = mclx_Fr_subPre; |
|
|
|
|
op.fp_addA_ = mclx_Fr_add; |
|
|
|
|
op.fp_subA_ = mclx_Fr_sub; |
|
|
|
|
op.fp_shr1 = mclx_Fr_shr1; |
|
|
|
|
op.fp_negA_ = mclx_Fr_neg; |
|
|
|
|
op.fpDbl_addA_ = mclx_FpDbl_add; |
|
|
|
|
op.fpDbl_subA_ = mclx_FpDbl_sub; |
|
|
|
|
op.fpDbl_addPre = mclx_FpDbl_addPre; |
|
|
|
|
op.fpDbl_subPre = mclx_FpDbl_subPre; |
|
|
|
|
op.fpDbl_mulPreA_ = mclx_FpDbl_mulPre; |
|
|
|
|
op.fpDbl_sqrPreA_ = mclx_FpDbl_sqrPre; |
|
|
|
|
op.fpDbl_modA_ = mclx_FpDbl_mod; |
|
|
|
|
op.fp_mulA_ = mclx_Fr_mul; |
|
|
|
|
op.fp_sqrA_ = mclx_Fr_sqr; |
|
|
|
|
op.fp_preInv = mclx_Fr_preInv; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|