Mercurial > hg > CbC > old > device
changeset 198:ef6f0c2d932f
*** empty log message ***
author | kono |
---|---|
date | Thu, 08 Apr 2004 20:10:21 +0900 |
parents | b5f49f32c2ee |
children | 117772cc77b2 |
files | test/code-gen.c |
diffstat | 1 files changed, 426 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/test/code-gen.c Thu Apr 08 18:35:19 2004 +0900 +++ b/test/code-gen.c Thu Apr 08 20:10:21 2004 +0900 @@ -551,81 +551,464 @@ #endif - // code_assign_gvar(int e2,int creg,int byte) // code_assign_lvar(int e2,int creg,int byte) // code_assign_register(int e2,int byte,int creg) // code_assign(int e2,int byte,int creg) + +void +code_assign() +{ + int i1,i2; + unsigned int ui1,ui2; + int *pi1,*pi2; + unsigned int *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 %d %d %u %u\n",*pi1,*pi2,*pui1,*pui2); +} + // code_register_assop(int e2,int op,int byte) +code_register_assop() +{ + register int i1; + register unsigned int ui1; + i1 = -555; + ui1 = 632423423; + + i1 += 3; + printf("code_assop 1 %d\n",i1); + i1 -= 3; + printf("code_assop 2 %d\n",i1); + i1 /= 3; + printf("code_assop 3 %d\n",i1); + i1 *= 3; + printf("code_assop 4 %d\n",i1); + i1 |= 234; + printf("code_assop 5 %d\n",i1); + i1 &= 2324234234234234; + printf("code_assop 6 %d\n",i1); + i1 ^= 5523234234234234; + printf("code_assop 7 %d\n",i1); + i1 <<= 3; + printf("code_assop 8 %d\n",i1); + i1 >>= 3; + printf("code_assop 9 %d\n",i1); + + ui1 += 3; + printf("code_assop 1 %ud\n",i1); + ui1 -= 3; + printf("code_assop 2 %ud\n",i1); + ui1 /= 3; + printf("code_assop 3 %ud\n",i1); + ui1 *= 3; + printf("code_assop 4 %ud\n",i1); + ui1 |= 234; + printf("code_assop 5 %ud\n",i1); + ui1 &= 2324234234234234; + printf("code_assop 6 %ud\n",i1); + ui1 ^= 5523234234234234; + printf("code_assop 7 %ud\n",i1); + ui1 <<= 3; + printf("code_assop 8 %ud\n",i1); + ui1 >>= 3; + printf("code_assop 9 %ud\n",i1); +} + // code_assop(int op,int byte,int sign) +code_assop() +{ + int i1,i2; + unsigned int ui1,ui2; + i1 = -555; i2= 555; + ui1 = 632423423; ui2= 32394234; + + i1 += 3; + printf("code_assop 1 %d\n",i1); + i1 -= 3; + printf("code_assop 2 %d\n",i1); + i1 /= 3; + printf("code_assop 3 %d\n",i1); + i1 *= 3; + printf("code_assop 4 %d\n",i1); + i1 |= 234; + printf("code_assop 5 %d\n",i1); + i1 &= 2324234234234234; + printf("code_assop 6 %d\n",i1); + i1 ^= 5523234234234234; + printf("code_assop 7 %d\n",i1); + i1 <<= 3; + printf("code_assop 8 %d\n",i1); + i1 >>= 3; + printf("code_assop 9 %d\n",i1); + + ui1 += 3; + printf("code_assop 1 %ud\n",i1); + ui1 -= 3; + printf("code_assop 2 %ud\n",i1); + ui1 /= 3; + printf("code_assop 3 %ud\n",i1); + ui1 *= 3; + printf("code_assop 4 %ud\n",i1); + ui1 |= 234; + printf("code_assop 5 %ud\n",i1); + ui1 &= 2324234234234234; + printf("code_assop 6 %ud\n",i1); + ui1 ^= 5523234234234234; + printf("code_assop 7 %ud\n",i1); + ui1 <<= 3; + printf("code_assop 8 %ud\n",i1); + ui1 >>= 3; + printf("code_assop 9 %ud\n",i1); +} + + + // tosop(int op,int oreg) -// case LSHIFT: -// case ULSHIFT: -// case RSHIFT: -// case URSHIFT: -// case ADD: -// case SUB: -// case CMP: -// case BAND: -// case EOR: -// case BOR: -// case MUL: -// case UMUL: -// case DIV: -// case UDIV: -// case MOD: -// case UMOD: +void +tosop() +{ + int i1,i2,i; + unsigned int ui1,ui2,u; + i1 = -555; i2= 555; + ui1 = 632423423; ui2= 32394234; + + i = i1 + i2; + printf("tosop 1 %d\n",i1); + i = i1 - i2; + printf("tosop 2 %d\n",i1); + i = i1 / i2; + printf("tosop 3 %d\n",i1); + i = i1 * i2; + printf("tosop 4 %d\n",i1); + i = i1 | i2; + printf("tosop 5 %d\n",i1); + i = i1 & i2; + printf("tosop 6 %d\n",i1); + i = i1 ^ i2; + printf("tosop 7 %d\n",i1); + i = i1 << i2; + printf("tosop 8 %d\n",i1); + i = i1 >> i2; + printf("tosop 9 %d\n",i1); + + u = u1 + u2; + printf("tosop 1 %ud\n",u1); + u = u1 - u2; + printf("tosop 2 %ud\n",u1); + u = u1 / u2; + printf("tosop 3 %ud\n",u1); + u = u1 * u2; + printf("tosop 4 %ud\n",u1); + u = u1 | u2; + printf("tosop 5 %ud\n",u1); + u = u1 & u2; + printf("tosop 6 %ud\n",u1); + u = u1 ^ u2; + printf("tosop 7 %ud\n",u1); + u = u1 << u2; + printf("tosop 8 %ud\n",u1); + u = u1 >> u2; + printf("tosop 9 %ud\n",u1); +} // oprtc(int op,int v) - -// ld_indexx(int byte, int n, int xreg,int sign) - -// rexpr(int e1, int l1, char *s,int t) +void +oprtc() +{ + int i1,i; + unsigned int ui1,u; + i1 = -555; + ui1 = 632423423; -// jcond(int l, char cond) + i = i1 + 3; + printf("oprtc 1 %d\n",i1); + i = i1 - 3; + printf("oprtc 2 %d\n",i1); + i = i1 / 3; + printf("oprtc 3 %d\n",i1); + i = i1 * 3; + printf("oprtc 4 %d\n",i1); + i = i1 | 234234234; + printf("oprtc 5 %d\n",i1); + i = i1 & 234234234234; + printf("oprtc 6 %d\n",i1); + i = i1 ^ 234234234234; + printf("oprtc 7 %d\n",i1); + i = i1 << 5; + printf("oprtc 8 %d\n",i1); + i = i1 >> 5; + printf("oprtc 9 %d\n",i1); -// jmp(int l) -// code_enter(char *name) + u = u1 + 3; + printf("oprtc 1 %ud\n",u1); + u = u1 - 3; + printf("oprtc 2 %ud\n",u1); + u = u1 / 3; + printf("oprtc 3 %ud\n",u1); + u = u1 * 3; + printf("oprtc 4 %ud\n",u1); + u = u1 | 234234234; + printf("oprtc 5 %ud\n",u1); + u = u1 & 234234234; + printf("oprtc 6 %ud\n",u1); + u = u1 ^ 23234234234; + printf("oprtc 7 %ud\n",u1); + u = u1 << 5; + printf("oprtc 8 %ud\n",u1); + u = u1 >> 5; + printf("oprtc 9 %ud\n",u1); +} + #if FLOAT_CODE // code_cmp_dregister(int e2,int d) +void +code_cmp_dregister() +{ + register float f0,f1; + register double d0,d1; + f0 = 0.0; f1 = 0.2; + d0 = 10; d1 = 10e10; + f0 && printf("code_bool register 6\n"); + d0 && printf("code_bool register 7\n"); + +} + // code_dregister(int e2,int freg,int d) +code_dregister() +{ + register float f0,f1; + register double d0,d1; + 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); +} + // code_dassign_gvar(int e2,int freg,int d) // code_dassign_lvar(int e2,int freg,int d) +// code_dassign_dregister(int e2,int d,int freg) + // code_dassign(int e2,int freg,int d) -// code_dassign_dregister(int e2,int d,int freg) +void +code_dassign() +{ + float i1,i2; + double ui1,ui2; + float *pi1,*pi2; + double *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_dassign %g %g %g %g\n",*pi1,*pi2,*pui1,*pui2); +} + // code_dconst(int e2,int freg,int d) // code_dneg(int freg,int d) +// code_dneg(int creg) +void +code_dneg() +{ + float i,j; + double di,dj; + i = 123123123;j = -32423; + di = 123123123;dj = -32423; + printf("code_dneg %g %g\n",-i,-j); + printf("code_dneg %g %g\n",-di,-dj); +} + // code_d2i(int freg0) +void code_d2i() +{ + double d; + int i; + d = 0.1; + i = d; + printf("code_d2i %d\n",i); +} // code_i2d(int creg0) +void code_i2d() +{ + double d; + int i; + i = 24234342342; + d = i; + printf("code_i2d %g\n",d); +} // code_d2u(int freg0) +void code_d2u() +{ + double d; + unsigned int i; + d = 0.1; + i = d; + printf("code_d2u %ud\n",i); +} // code_u2d(int creg0) -// code_d2f(int freg) -// code_f2d(int freg) -// code_f2i(int freg) code_d2i(freg); -// code_f2u(int freg) code_d2u(freg); -// code_i2f(int creg) code_i2d(creg); -// code_u2f(int creg) code_u2d(creg); +void code_u2d() +{ + double d; + unsigned int i; + i = 24234342342; + d = i; + printf("code_u2d %g\n",d); +} +// code_f2i(int freg0) +void code_f2i() +{ + float d; + int i; + d = 0.1; + i = d; + printf("code_d2i %d\n",i); +} +// code_i2f(int creg0) +void code_i2f() +{ + float d; + int i; + i = 24234342342; + d = i; + printf("code_i2f %g\n",d); +} +// code_f2u(int freg0) +void code_f2u() +{ + float d; + unsigned int i; + d = 0.1; + i = d; + printf("code_f2u %ud\n",i); +} +// code_u2f(int creg0) +void code_u2f() +{ + float d; + unsigned int i; + i = 24234342342; + d = i; + printf("code_u2f %g\n",d); +} + // code_drgvar(int e2,int d,int freg) +void +code_dgvar() +{ + 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); + 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); +} + // code_drlvar(int e2,int d,int freg) +void +code_dlvar() +{ + float f0,f1; + double d0,d1; + 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); +} + + // code_cmp_drgvar(int e2,int d) +void +code_cmp_d_global() +{ + f0 = 0.0; f1 = 0.2; + d0 = 10; d1 = 10e10; + f0 && printf("code_bool global 6\n"); + d0 && printf("code_bool global 7\n"); +} + + // code_cmp_drlvar(int e2,int d) +void +code_cmp_d() +{ + float f0,f1; + double d0,d1; + f0 = 0.0; f1 = 0.2; + d0 = 10; d1 = 10e10; + f0 && printf("code_bool local 6\n"); + d0 && printf("code_bool local 7\n"); +} + // dtosop(int op,int e1) -// case FADD: -// case DADD: opn="fadd"; break; -// case FSUB: -// case DSUB: opn="fsub"; break; -// case FDIV: -// case DDIV: opn="fdiv"; break; -// case FMUL: -// case DMUL: opn="fmul"; break; -// case FCMP: -// case DCMP: -// case FCMPGE: -// case DCMPGE: +void +dtosop() +{ + double i1,i2,i; + float ui1,ui2,u; + i1 = -555; i2= 555; + ui1 = 632423423; ui2= 32394234; + + i = i1 + i2; + printf("dtosop 1 %g\n",i1); + i = i1 - i2; + printf("dtosop 2 %g\n",i1); + i = i1 / i2; + printf("dtosop 3 %g\n",i1); + i = i1 * i2; + printf("dtosop 4 %g\n",i1); + u = u1 + u2; + printf("dtosop 1 %g\n",u1); + u = u1 - u2; + printf("dtosop 2 %g\n",u1); + u = u1 / u2; + printf("tosop 3 %g\n",u1); + u = u1 * u2; + printf("dtosop 4 %g\n",u1); +} + // code_dassop(int op,int d) +code_dassop() +{ + double i1,i2; + float ui1,ui2; + i1 = -555; i2= 555; + ui1 = 632423423; ui2= 32394234; + + i1 += 3; + printf("code_dassop 1 %g\n",i1); + i1 -= 3; + printf("code_dassop 2 %g\n",i1); + i1 /= 3; + printf("code_dassop 3 %g\n",i1); + i1 *= 3; + printf("code_dassop 4 %g\n",i1); + + ui1 += 3; + printf("code_dassop 1 %g\n",i1); + ui1 -= 3; + printf("code_dassop 2 %g\n",i1); + ui1 /= 3; + printf("code_dassop 3 %g\n",i1); + ui1 *= 3; + printf("code_dassop 4 %g\n",i1); +} + + // code_dpreinc(int e1,int e2,int d,int reg) // code_dpostinc(int e1,int e2,int d,int reg) // drexpr(int e1, int e2,int l1, int op)