From 8a0e159dcd95137122e507663907c864fdc318ba Mon Sep 17 00:00:00 2001 From: jasonmoxham Date: Wed, 2 Sep 2009 15:52:19 +0000 Subject: [PATCH] add mpn_add/sublsh_nc to try.exe --- tests/devel/try.c | 30 ++++++++++++++++++++++++++++++ tests/refmpn.c | 12 +++++++++++- tests/tests.h | 2 ++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/devel/try.c b/tests/devel/try.c index 93542b91..97d9d065 100644 --- a/tests/devel/try.c +++ b/tests/devel/try.c @@ -679,12 +679,15 @@ validate_sqrtrem (void) //#define TYPE_DIVREM_EUCLIDEAN_QR_2 118 #define TYPE_ADDLSH_N 120 #define TYPE_SUBLSH_N 121 + #define TYPE_INCLSH_N 122 #define TYPE_DECLSH_N 123 #define TYPE_ADDERR1_N 124 #define TYPE_SUBERR1_N 125 #define TYPE_ADDERR2_N 126 #define TYPE_SUBERR2_N 127 +#define TYPE_ADDLSH_NC 128 +#define TYPE_SUBLSH_NC 129 #define TYPE_EXTRA 150 @@ -995,6 +998,22 @@ param_init (void) p->src[1]=1; p->shift=1; REFERENCE (refmpn_sublsh_n); + + p = ¶m[TYPE_ADDLSH_NC]; + p->dst[0]=1; + p->src[0]=1; + p->src[1]=1; + p->shift=1; + p->carry=CARRY_LIMB; + REFERENCE (refmpn_addlsh_nc); + + p = ¶m[TYPE_SUBLSH_NC]; + p->dst[0]=1; + p->src[0]=1; + p->src[1]=1; + p->shift=1; + p->carry=CARRY_LIMB; + REFERENCE (refmpn_sublsh_nc); p = ¶m[TYPE_INCLSH_N]; p->dst[0]=1; @@ -1691,6 +1710,12 @@ const struct choice_t choice_array[] = { #if HAVE_NATIVE_mpn_sublsh_n { TRY(mpn_sublsh_n), TYPE_SUBLSH_N }, #endif +#if HAVE_NATIVE_mpn_addlsh_nc + { TRY(mpn_addlsh_nc), TYPE_ADDLSH_NC }, +#endif +#if HAVE_NATIVE_mpn_sublsh_nc + { TRY(mpn_sublsh_nc), TYPE_SUBLSH_NC }, +#endif #if HAVE_NATIVE_mpn_inclsh_n { TRY_FUNFUN(mpn_inclsh_n), TYPE_INCLSH_N }, #endif @@ -2345,6 +2370,11 @@ call (struct each_t *e, tryfun_t function) e->retval = CALLING_CONVENTIONS (function) (e->d[0].p, e->s[0].p, e->s[1].p, size,shift); break; + case TYPE_ADDLSH_NC: + case TYPE_SUBLSH_NC: + e->retval = CALLING_CONVENTIONS (function) + (e->d[0].p, e->s[0].p, e->s[1].p, size,shift,carry); + break; case TYPE_INCLSH_N: case TYPE_DECLSH_N: e->retval = CALLING_CONVENTIONS (function) diff --git a/tests/refmpn.c b/tests/refmpn.c index a99c2404..155b0998 100644 --- a/tests/refmpn.c +++ b/tests/refmpn.c @@ -718,6 +718,14 @@ refmpn_sublsh1_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n) mp_limb_t refmpn_addlsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n,unsigned int c) +{return refmpn_addlsh_nc(rp,up,vp,n,c,0);} + +mp_limb_t +refmpn_sublsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n,unsigned int c) +{return refmpn_sublsh_nc(rp,up,vp,n,c,0);} + +mp_limb_t +refmpn_addlsh_nc (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n,unsigned int c,mp_limb_t cin) { mp_limb_t cy; mp_ptr tp; @@ -730,13 +738,14 @@ refmpn_addlsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n,unsigned int tp = refmpn_malloc_limbs (n); cy = refmpn_lshift (tp, vp, n, c); + tp[0] |= cin >> (GMP_NUMB_BITS-c); cy += refmpn_add_n (rp, up, tp, n); free (tp); return cy; } mp_limb_t -refmpn_sublsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n,unsigned int c) +refmpn_sublsh_nc (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n,unsigned int c,mp_limb_t cin) { mp_limb_t cy; mp_ptr tp; @@ -749,6 +758,7 @@ refmpn_sublsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n,unsigned int tp = refmpn_malloc_limbs (n); cy = refmpn_lshift (tp, vp, n, c); + tp[0] |= cin >> (GMP_NUMB_BITS-c); cy += refmpn_sub_n (rp, up, tp, n); free (tp); return cy; diff --git a/tests/tests.h b/tests/tests.h index b1c37f5a..299e0954 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -191,6 +191,8 @@ int refmpn_addsub_n __GMP_PROTO ((mp_ptr rp, mp_srcptr xp, mp_srcptr yp, mp_srcp mp_limb_t refmpn_addlsh1_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size)); mp_limb_t refmpn_addlsh_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size,unsigned int)); mp_limb_t refmpn_sublsh_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size,unsigned int)); +mp_limb_t refmpn_addlsh_nc __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size,unsigned int,mp_limb_t)); +mp_limb_t refmpn_sublsh_nc __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size,unsigned int,mp_limb_t)); mp_limb_t refmpn_inclsh_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,unsigned int)); mp_limb_t refmpn_declsh_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,unsigned int)); mp_limb_t refmpn_addmul_1 __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,