Mercurial > hg > CbC > old > device
changeset 200:d83291712bf7
test routine
author | kono |
---|---|
date | Thu, 08 Apr 2004 22:18:27 +0900 |
parents | 117772cc77b2 |
children | 3ae7e188416f |
files | test/code-gen.c test/code-gen.pl |
diffstat | 2 files changed, 501 insertions(+), 124 deletions(-) [+] |
line wrap: on
line diff
--- a/test/code-gen.c Thu Apr 08 20:43:40 2004 +0900 +++ b/test/code-gen.c Thu Apr 08 22:18:27 2004 +0900 @@ -14,32 +14,12 @@ int i1,i2; short s1,s2; unsinged short us1,us2; -#if FLOAT_CODE - float f0,f1; - double d0,d1; -#endif -#if LONGLONG_CODE - long long l0,l1; - unsigned long long ul0,ul1; -#endif i1 = 1; i2 = -2; s1 = -1; s2 = -3; us1 = 65535; us2 = 65535; printf("code_lvar %d %d %d %d %u %u\n",i1,i2,s1,s2,us1,us2); c1 = -1; c2 = -3; uc1 = 65535; uc2 = 65535; printf("code_lvar %d %d %u %u\n",c1,c2,uc1,uc2); -#if FLOAT_CODE - f0 = 0.0; f1 = 0.2; - d0 = 10; d1 = 10e10; - printf("code_lvar float %f %f %g %g\n",i1,i2,f0,f1,d0,d1); -#endif -#if LOGNLONG_CODE - l0 = 123123123LL; - l1 = 123123123LL; - ul0 = 123123123LL; - ul1 = 123123123LL; - printf("code_lvar long long %ll %ll %ull %ull\n",i1,i2,f0,f1,d0,d1); -#endif } // code_label(int labelno) @@ -88,35 +68,12 @@ printf("code_gvar %d %d %u %u %u %u\n",i1,i2,s1,s2,us1,us2); c1 = -1; c2 = -3; uc1 = 65535; uc2 = 65535; printf("code_gvar %d %d %u %u\n",c1,c2,uc1,uc2); -#if FLOAT_CODE - f0 = 0.0; f1 = 0.2; - d0 = 10; d1 = 10e10; - printf("code_gvar float %f %f %g %g\n",i1,i2,f0,f1,d0,d1); -#endif -#if LOGNLONG_CODE - l0 = 123123123LL; - l1 = 123123123LL; - ul0 = 123123123LL; - ul1 = 123123123LL; - printf("code_gvar long long %ll %ll %ull %ull\n",i1,i2,f0,f1,d0,d1); -#endif + s_i1 = 1; s_i2 = 2; s_s1 = -1; s_s2 = -3; s_us1 = 65535; s_us2 = 65535; printf("code_gvar %d %d %u %u %u %u\n",s_i1,s_i2,s1,s_s2,s_us1,s_us2); s_c1 = -1; s_c2 = -3; s_uc1 = 65535; s_uc2 = 65535; printf("code_gvar %d %d %u %u\n",s_c1,s_c2,s_uc1,s_uc2); -#if FLOAT_CODE - s_f0 = 0.0; s_f1 = 0.2; - s_d0 = 10; s_d1 = 10e10; - printf("code_gvar float %f %f %g %g\n",s_i1,s_i2,s_f0,s_f1,s_d0,s_d1); -#endif -#if LOGNLONG_CODE - l0 = 123123123LL; - l1 = 123123123LL; - ul0 = 123123123LL; - ul1 = 123123123LL; - printf("code_gvar long long %ll %ll %ull %ull\n",s_i1,s_i2,s_f0,s_f1,s_d0,s_d1); -#endif } // code_register(int e2,int creg) @@ -128,32 +85,12 @@ register int i1,i2; register short s1,s2; register unsinged short us1,us2; -#if FLOAT_CODE - register float f0,f1; - register double d0,d1; -#endif -#if LONGLONG_CODE - register long long l0,l1; - register unsigned long long ul0,ul1; -#endif i1 = 1; i2 = -2; s1 = -1; s2 = -3; us1 = 65535; us2 = 65535; printf("code_lvar %d %d %u %u %u %u\n",i1,i2,s1,s2,us1,us2); c1 = -1; c2 = -3; uc1 = 65535; uc2 = 65535; printf("code_gvar %d %d %u %u\n",c1,c2,uc1,uc2); -#if FLOAT_CODE - f0 = 0.0; f1 = 0.2; - d0 = 10; d1 = 10e10; - printf("code_lvar float %f %f %g %g\n",i1,i2,f0,f1,d0,d1); -#endif -#if LOGNLONG_CODE - l0 = 123123123LL; - l1 = 123123123LL; - ul0 = 123123123LL; - ul1 = 123123123LL; - printf("code_lvar long long %ll %ll %ull %ull\n",i1,i2,f0,f1,d0,d1); -#endif } // code_fname(NMTBL *n,int creg) @@ -205,6 +142,15 @@ // code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) void +code_upostinc() +{ + unsinged int i,j; + i = 123123123;j = 0; + printf("code_upreinc %d %d\n",i++,j--); +} + +// code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) +void code_postinc() { int i,j; @@ -212,6 +158,15 @@ printf("code_preinc %d %d\n",i++,j--); } +// code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) +void +code_upreinc() +{ + unsigned int i,j; + i = 123123123;j = 0; + printf("code_upreinc %d %d\n",++i,--j); +} + // code_return(int creg) int @@ -220,6 +175,7 @@ return 1; } +#if FLOAT_CODE float code_return_float() { @@ -231,12 +187,15 @@ { return 1.0; } +#endif +#if LONGLONG_CODE long long code_return_longlong() { return 10LL; } +#endif struct aa { char a[100]; } a0; struct aa @@ -323,14 +282,7 @@ int i1,i2; short s1,s2; unsinged short us1,us2; -#if FLOAT_CODE - float f0,f1; - double d0,d1; -#endif -#if LONGLONG_CODE - long long l0,l1; - unsigned long long ul0,ul1; -#endif + i1 = 1; i2 = -2; s1 = -1; s2 = -3; us1 = 65535; us2 = 65535; c1 = -1; c2 = -3; uc1 = 65535; uc2 = 65535; @@ -339,20 +291,6 @@ us1 && printf("code_bool local 3\n"); c1 && printf("code_bool local 4\n"); uc1 && printf("code_bool local 5\n"); -#if FLOAT_CODE - f0 = 0.0; f1 = 0.2; - d0 = 10; d1 = 10e10; - f0 && printf("code_bool local 6\n"); - d0 && printf("code_bool local 7\n"); -#endif -#if LOGNLONG_CODE - l0 = 123123123LL; - l1 = 123123123LL; - ul0 = 123123123LL; - ul1 = 123123123LL; - l0 && printf("code_bool local 8\n"); - ul0 && printf("code_bool local 9\n"); -#endif } void @@ -366,20 +304,6 @@ us1 && printf("code_bool global 3\n"); c1 && printf("code_bool global 4\n"); uc1 && printf("code_bool global 5\n"); -#if FLOAT_CODE - f0 = 0.0; f1 = 0.2; - d0 = 10; d1 = 10e10; - f0 && printf("code_bool global 6\n"); - d0 && printf("code_bool global 7\n"); -#endif -#if LOGNLONG_CODE - l0 = 123123123LL; - l1 = 123123123LL; - ul0 = 123123123LL; - ul1 = 123123123LL; - l0 && printf("code_bool global 8\n"); - ul0 && printf("code_bool global 9\n"); -#endif } void @@ -390,14 +314,7 @@ register int i1,i2; register short s1,s2; register unsinged short us1,us2; -#if FLOAT_CODE - register float f0,f1; - register double d0,d1; -#endif -#if LONGLONG_CODE - register long long l0,l1; - register unsigned long long ul0,ul1; -#endif + i1 = 1; i2 = -2; s1 = -1; s2 = -3; us1 = 65535; us2 = 65535; c1 = -1; c2 = -3; uc1 = 65535; uc2 = 65535; @@ -406,20 +323,6 @@ us1 && printf("code_bool register 3\n"); c1 && printf("code_bool register 4\n"); uc1 && printf("code_bool register 5\n"); -#if FLOAT_CODE - f0 = 0.0; f1 = 0.2; - d0 = 10; d1 = 10e10; - f0 && printf("code_bool register 6\n"); - d0 && printf("code_bool register 7\n"); -#endif -#if LOGNLONG_CODE - l0 = 123123123LL; - l1 = 123123123LL; - ul0 = 123123123LL; - ul1 = 123123123LL; - l0 && printf("code_bool register 8\n"); - ul0 && printf("code_bool register 9\n"); -#endif } @@ -1108,47 +1011,509 @@ #if LONGLONG_CODE // lrexpr(int e1, int e2,int l1, int op) +void +code_lbool() +{ + printf("code_bool long long %d %d %d %d %d %d\n", + l1>l0,ul1>ul0,l1>=l0,ul1>=ul0,ul1==ul0,l1!=l0); +} + // int lpop_register() // code_lregister(int e2,int reg) +code_register() +{ + register long long l0,l1; + register unsigned long long ul0,ul1; + l0 = 123123123LL; + l1 = 123123123LL; + ul0 = 123123123LL; + ul1 = 123123123LL; + printf("code_lvar long long %ll %ll %ull %ull\n",i1,i2,f0,f1,d0,d1); +} + // code_cmp_lregister(int reg) +void +code_cmp_lregister() +{ + register long long l0,l1; + register unsigned long long ul0,ul1; + l0 = 123123123LL; + l1 = 123123123LL; + ul0 = 123123123LL; + ul1 = 123123123LL; + l0 && printf("code_bool register 8\n"); + ul0 && printf("code_bool register 9\n"); +} + // code_cmp_lrgvar(int e1,int e2) +void +code_cmp_lrgvar() +{ + l0 = 123123123LL; + l1 = 123123123LL; + ul0 = 123123123LL; + ul1 = 123123123LL; + l0 && printf("code_bool global 8\n"); + ul0 && printf("code_bool global 9\n"); +} // code_cmp_lrlvar(int e1,int e2) +void +code_cmp_lrlvar() +{ + long long l0,l1; + unsigned long long ul0,ul1; + l0 = 123123123LL; + l1 = 123123123LL; + ul0 = 123123123LL; + ul1 = 123123123LL; + l0 && printf("code_bool local 8\n"); + ul0 && printf("code_bool local 9\n"); +} + // code_lassign(int e1,int e2) // code_lassign_gvar(int e1,int e2) // code_lassign_lvar(int e1,int e2) // code_lassign_lregister(int e2,int reg) +void +code_lassign() +{ + long long i1,i2; + unsigned long long ui1,ui2; + long long *pi1,*pi2; + unsigned long long *pui1,*pui2; + + i1 = -555; i2= 555; + ui1 = 632423423; ui2= 32394234; + pi1 = &i1; + pi2 = &i2; + pui1 = &ui1; + pui2 = &ui2; + + *(pi2+i1+i2) = 3; + *(pui2+i1+i2) = 3; + printf("code_rindirect %lld %lld %llu %llu\n",*pi1,*pi2,*pui1,*pui2); +} + // code_lconst(int e1,int e2) // code_lneg(int e1,int e2) +void +code_lneg() +{ + long long i,j; + i = 123123123;j = -32423; + printf("code_neg %lld %lld\n",-i,-j); +} + // code_lrgvar(int e1,int e2) +void +code_lrgvar() +{ + l0 = 123123123LL; + l1 = 123123123LL; + ul0 = 123123123LL; + ul1 = 123123123LL; + printf("code_lrgvar long long %ll %ll %ull %ull\n",i1,i2,f0,f1,d0,d1); + s_l0 = 123123123LL; + s_l1 = 123123123LL; + s_ul0 = 123123123LL; + s_ul1 = 123123123LL; + printf("code_lrgvar long long %ll %ll %ull %ull\n",s_i1,s_i2,s_f0,s_f1,s_d0,s_d1); +} + // code_lrlvar(int e1,int e2) +void +code_lrlvar() +{ + long long l0,l1; + unsigned long long ul0,ul1; + l0 = 123123123LL; + l1 = 123123123LL; + ul0 = 123123123LL; + ul1 = 123123123LL; + printf("code_lvar long long %ll %ll %ull %ull\n",i1,i2,f0,f1,d0,d1); +} + // ltosop(int e1,int e2) +void +ltosop() +{ + long long i1,i2,i; + unsigned long long ui1,ui2,u; + i1 = -555; i2= 555; + ui1 = 632423423; ui2= 32394234; + + i = i1 + i2; + printf("ltosop 1 %lld\n",i1); + i = i1 - i2; + printf("ltosop 2 %lld\n",i1); + i = i1 / i2; + printf("ltosop 3 %lld\n",i1); + i = i1 * i2; + printf("ltosop 4 %lld\n",i1); + i = i1 | i2; + printf("ltosop 5 %lld\n",i1); + i = i1 & i2; + printf("ltosop 6 %lld\n",i1); + i = i1 ^ i2; + printf("ltosop 7 %lld\n",i1); + i = i1 << i2; + printf("ltosop 8 %lld\n",i1); + i = i1 >> i2; + printf("ltosop 9 %lld\n",i1); + + u = u1 + u2; + printf("ltosop 1 %llud\n",u1); + u = u1 - u2; + printf("ltosop 2 %llud\n",u1); + u = u1 / u2; + printf("ltosop 3 %llud\n",u1); + u = u1 * u2; + printf("ltosop 4 %llud\n",u1); + u = u1 | u2; + printf("ltosop 5 %llud\n",u1); + u = u1 & u2; + printf("ltosop 6 %llud\n",u1); + u = u1 ^ u2; + printf("ltosop 7 %llud\n",u1); + u = u1 << u2; + printf("ltosop 8 %llud\n",u1); + u = u1 >> u2; + printf("ltosop 9 %llud\n",u1); +} + // code_i2ll(int creg) +void code_i2ll() +{ + long long d; + int i; + i = 2342342342; + d = i; + printf("code_i2ll %lld\n",d); +} // code_i2ull(int creg) +void code_i2ull() +{ + unsigned long long d; + int i; + i = 2342342342; + d = i; + printf("code_i2ull %lld\n",d); +} // code_u2ll(int creg) +void code_u2ll() +{ + long long d; + unsigned int i; + i = 2342342342; + d = i; + printf("code_u2ll %lld\n",d); +} // code_u2ull(int creg) +void code_i2ull() +{ + unsigned long long d; + unsigned int i; + i = 2342342342; + d = i; + printf("code_u2ull %ulld\n",d); +} // code_ll2i(int creg) +void code_ll2i() +{ + long long d; + int i; + d = 2342342342; + i = d; + printf("code_ll2i %d\n",i); +} // code_ll2u(int creg) +void code_ll2u() +{ + long long d; + unsigned int i; + d = 2342342342; + i = d; + printf("code_ll2i %ud\n",i); +} // code_ull2i(int creg) +void code_ull2i() +{ + unsigned long long d; + int i; + d = 2342342342; + i = d; + printf("code_ull2i %d\n",i); +} // code_ull2u(int creg) +void code_ull2u() +{ + unsigned long long d; + unsigned int i; + d = 2342342342; + i = d; + printf("code_ll2i %ud\n",i); +} #if FLOAT_CODE // code_d2ll(int creg) +void code_d2ll() +{ + long long d; + double i; + i = 2342342342; + d = i; + printf("code_d2ll %lld\n",d); +} // code_d2ull(int creg) +void code_d2ull() +{ + unsigned long long d; + double i; + i = 2342342342; + d = i; + printf("code_d2ll %ulld\n",d); +} // code_f2ll(int creg) +void code_f2ll() +{ + long long d; + float i; + i = 2342342342; + d = i; + printf("code_d2ll %lld\n",d); +} // code_f2ull(int creg) +void code_f2ull() +{ + unsigned long long d; + float i; + i = 2342342342; + d = i; + printf("code_d2ll %ulld\n",d); +} // code_ll2d(int creg) +void code_ll2d() +{ + long long d; + double i; + d = 2342342342; + i = d; + printf("code_d2ll %g\n",i); +} // code_ll2f(int creg) +void code_ll2f() +{ + long long d; + float i; + d = 2342342342; + i = d; + printf("code_d2ll %g\n",i); +} // code_ull2d(int creg) +void code_ull2d() +{ + long long d; + double i; + d = 2342342342; + i = d; + printf("code_d2ll %g\n",i); +} // code_ull2f(int creg) -// code_ull2ll(int creg) -// code_ull2ull(int creg) +void code_ull2f() +{ + long long d; + float i; + d = 2342342342; + i = d; + printf("code_d2ll %g\n",i); +} #endif #if LONGLONG_CODE // code_lpreinc(int e1,int e2,int reg) +void +code_lpreinc() +{ + long long i,j; + i = 123123123;j = 0; + printf("code_preinc %lld %lld\n",++i,--j); +} + // code_lpostinc(int e1,int e2,int reg) +void +code_lpostinc() +{ + long long i,j; + i = 123123123;j = 0; + printf("code_preinc %lld %lld\n",i++,j--); +} + +// code_lpreinc(int e1,int e2,int reg) +void +code_lupreinc() +{ + unsigned long long i,j; + i = 123123123;j = 0; + printf("code_preinc %ulld %ulld\n",++i,--j); +} + +// code_lpostinc(int e1,int e2,int reg) +void +code_lupostinc() +{ + unsigned long long i,j; + i = 123123123;j = 0; + printf("code_preinc %ulld %ulld\n",i++,j--); +} + // code_lassop(int op) +// code_register_assop(int e2,int op,int byte) +code_register_lassop() +{ + register long long i1; + register unsigned long long ui1; + i1 = -555; + ui1 = 632423423; + + i1 += 3; + printf("code_register_lassop 1 %d\n",i1); + i1 -= 3; + printf("code_register_lassop 2 %d\n",i1); + i1 /= 3; + printf("code_register_lassop 3 %d\n",i1); + i1 *= 3; + printf("code_register_lassop 4 %d\n",i1); + i1 |= 234; + printf("code_register_lassop 5 %d\n",i1); + i1 &= 2324234234234234; + printf("code_register_lassop 6 %d\n",i1); + i1 ^= 5523234234234234; + printf("code_register_lassop 7 %d\n",i1); + i1 <<= 3; + printf("code_register_lassop 8 %d\n",i1); + i1 >>= 3; + printf("code_register_lassop 9 %d\n",i1); + + ui1 += 3; + printf("code_register_lassop 1 %ud\n",i1); + ui1 -= 3; + printf("code_register_lassop 2 %ud\n",i1); + ui1 /= 3; + printf("code_register_lassop 3 %ud\n",i1); + ui1 *= 3; + printf("code_register_lassop 4 %ud\n",i1); + ui1 |= 234; + printf("code_register_lassop 5 %ud\n",i1); + ui1 &= 2324234234234234; + printf("code_register_lassop 6 %ud\n",i1); + ui1 ^= 5523234234234234; + printf("code_register_lassop 7 %ud\n",i1); + ui1 <<= 3; + printf("code_register_lassop 8 %ud\n",i1); + ui1 >>= 3; + printf("code_register_lassop 9 %ud\n",i1); +} + +// code_lassop(int op,int byte,int sign) +code_lassop() +{ + long long i1,i2; + unsigned long long ui1,ui2; + i1 = -555; i2= 555; + ui1 = 632423423; ui2= 32394234; + + i1 += 3; + printf("code_lassop 1 %d\n",i1); + i1 -= 3; + printf("code_lassop 2 %d\n",i1); + i1 /= 3; + printf("code_lassop 3 %d\n",i1); + i1 *= 3; + printf("code_lassop 4 %d\n",i1); + i1 |= 234; + printf("code_lassop 5 %d\n",i1); + i1 &= 2324234234234234; + printf("code_lassop 6 %d\n",i1); + i1 ^= 5523234234234234; + printf("code_lassop 7 %d\n",i1); + i1 <<= 3; + printf("code_lassop 8 %d\n",i1); + i1 >>= 3; + printf("code_lassop 9 %d\n",i1); + + ui1 += 3; + printf("code_lassop 1 %ud\n",i1); + ui1 -= 3; + printf("code_lassop 2 %ud\n",i1); + ui1 /= 3; + printf("code_lassop 3 %ud\n",i1); + ui1 *= 3; + printf("code_lassop 4 %ud\n",i1); + ui1 |= 234; + printf("code_lassop 5 %ud\n",i1); + ui1 &= 2324234234234234; + printf("code_lassop 6 %ud\n",i1); + ui1 ^= 5523234234234234; + printf("code_lassop 7 %ud\n",i1); + ui1 <<= 3; + printf("code_lassop 8 %ud\n",i1); + ui1 >>= 3; + printf("code_lassop 9 %ud\n",i1); +} + +// code_lgt(int cond) + +void code_lgt() +{ + if (l0>l1) + printf("code_lgt 1\n"); + else + printf("code_lgt 0\n"); +} + +// code_lugt(int cond) +void code_lugt() +{ + if (ul0>ul1) + printf("code_lugt 1\n"); + else + printf("code_lugt 0\n"); +} + +// code_lge(int cond) +void code_lge() +{ + if (l0>=l1) + printf("code_lge 1\n"); + else + printf("code_lge 0\n"); +} + +// code_luge(int cond) +void code_luge() +{ + if (ul0>=ul1) + printf("code_luge 1\n"); + else + printf("code_luge 0\n"); +} + +// code_leq(int cond) +void code_leq() +{ + if (ul0==ul1) + printf("code_leq 1\n"); + else + printf("code_leq 0\n"); + if (l0!=l1) + printf("code_lneq 1\n"); + else + printf("code_lneq 0\n"); +} + + + #endif /* end */