version 1.3, 2004/09/27 12:43:07 |
version 1.4, 2004/09/29 08:50:23 |
|
|
#if 0 |
#if 1 |
#include "ca.h" |
#include "ca.h" |
#include "inline.h" |
#include "inline.h" |
#endif |
#endif |
Line 12 typedef struct oZ { |
|
Line 12 typedef struct oZ { |
|
#define IMM_MIN -1073741823 |
#define IMM_MIN -1073741823 |
|
|
/* immediate int -> Z */ |
/* immediate int -> Z */ |
#define IMMTOZ(c,n) ((c)>=IMM_MIN&&(c)<=IMM_MAX?(n)=(Z)(((c)<<1)|1):(n)=immtoz(c)) |
#define IMMTOZ(c,n) (n)=((c)>=IMM_MIN&&(c)<=IMM_MAX?((Z)(((c)<<1)|1)):immtoz(c)) |
/* immediate Z ? */ |
/* immediate Z ? */ |
#define IS_IMM(c) (((unsigned int)c)&1) |
#define IS_IMM(c) (((unsigned int)c)&1) |
/* Z can be conver to immediate ? */ |
/* Z can be conver to immediate ? */ |
#define IS_IMMZ(n) (SL(n) == 1&&BD(n)[0]<=IMM_MAX) |
#define IS_IMMZ(n) (SL(n) == 1&&BD(n)[0]<=IMM_MAX) |
/* Z -> immediate Z */ |
/* Z -> immediate Z */ |
#define IMMZTOZ(n,z) (SL(n)<0?(z)=(Z)(((-BD(n)[0])<<1)|1):(Z)(((BD(n)[0])<<1)|1)) |
#define IMMZTOZ(n,z) (z)=(Z)(SL(n)<0?(((-BD(n)[0])<<1)|1):(((BD(n)[0])<<1)|1)) |
/* Z -> immediate int */ |
/* Z -> immediate int */ |
#define ZTOIMM(c) (((int)(c))>>1) |
#define ZTOIMM(c) (((int)(c))>>1) |
#define ZALLOC(d) ((Z)MALLOC_ATOMIC(TRUESIZE(oZ,(d)-1,int))) |
#define ZALLOC(d) ((Z)MALLOC_ATOMIC(TRUESIZE(oZ,(d)-1,int))) |
|
|
|
|
z_mag(Z n) |
z_mag(Z n) |
{ |
{ |
int n; |
int c,i; |
|
|
if ( !n ) return 0; |
if ( !n ) return 0; |
else if ( IS_IMM(n) ) { |
else if ( IS_IMM(n) ) { |
|
|
Z qtoz(Q n) |
Z qtoz(Q n) |
{ |
{ |
Z r,t; |
Z r,t; |
|
int c; |
|
|
if ( !n ) return 0; |
if ( !n ) return 0; |
else if ( !INT(n) ) |
else if ( !INT(n) ) |
|
|
else { |
else { |
t = (Z)NM(n); |
t = (Z)NM(n); |
if ( IS_IMMZ(t) ) { |
if ( IS_IMMZ(t) ) { |
IMMZTOZ(t,r); |
c = SGN(n) < 0 ? -BD(t)[0] : BD(t)[0]; |
|
IMMTOZ(c,r); |
} else { |
} else { |
r = dupz((Z)t); |
r = dupz((Z)t); |
|
if ( SGN(n) < 0 ) SL(r) = -SL(r); |
} |
} |
if ( SGN(n) < 0 ) SL(r) = -SL(r); |
|
return r; |
return r; |
} |
} |
} |
} |
Line 306 Z mulz(Z n1,Z n2) |
|
Line 308 Z mulz(Z n1,Z n2) |
|
} |
} |
|
|
/* kokokara */ |
/* kokokara */ |
|
#if 0 |
Z divsz(Z n1,Z n2) |
Z divsz(Z n1,Z n2) |
{ |
{ |
int sgn,d1,d2; |
int sgn,d1,d2; |
Line 427 Z array_gcdz(Z *b,int n) |
|
Line 429 Z array_gcdz(Z *b,int n) |
|
gcd = gcdz(gcd,a[i]); |
gcd = gcdz(gcd,a[i]); |
return gcd; |
return gcd; |
} |
} |
|
#endif |
|
|
void _copyz(Z n1,Z n2) |
void _copyz(Z n1,Z n2) |
{ |
{ |
Line 675 int _subz_main(unsigned int *m1,int d1,unsigned int *m |
|
Line 678 int _subz_main(unsigned int *m1,int d1,unsigned int *m |
|
|
|
void printz(Z n) |
void printz(Z n) |
{ |
{ |
int sd; |
int sd,u; |
|
|
if ( !n ) |
if ( !n ) |
fprintf(asir_out,"0"); |
fprintf(asir_out,"0"); |
else { |
else if ( IS_IMM(n) ) { |
|
u = ZTOIMM(n); |
|
fprintf(asir_out,"%d",u); |
|
} else { |
if ( (sd = SL(n)) < 0 ) { SL(n) = -SL(n); fprintf(asir_out,"-"); } |
if ( (sd = SL(n)) < 0 ) { SL(n) = -SL(n); fprintf(asir_out,"-"); } |
printn((N)n); |
printn((N)n); |
if ( sd < 0 ) SL(n) = -SL(n); |
if ( sd < 0 ) SL(n) = -SL(n); |