Mercurial > hg > CbC > old > device
changeset 238:d64e9a6a66bd
ia32 long long code written.
check compile error.
author | kono |
---|---|
date | Fri, 30 Apr 2004 14:46:09 +0900 |
parents | 1933266f1efa |
children | 1849e0079f08 |
files | mc-code-ia32.c mc-code-powerpc.c mc-code.h mc-codegen.c |
diffstat | 4 files changed, 161 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-ia32.c Fri Apr 30 11:47:51 2004 +0900 +++ b/mc-code-ia32.c Fri Apr 30 14:46:09 2004 +0900 @@ -27,6 +27,8 @@ static int creg; +int code_lassop_p = 0; + int size_of_int = 4; int size_of_short = 2; int size_of_float = 4; @@ -113,9 +115,10 @@ static int dreg; /* general temporal register */ -static int ia32regs[REAL_MAX_REGISTER]; -static int ia32regv[REAL_MAX_REGISTER]; -static int ia32rname[REAL_MAX_REGISTER]; +#define REAL_MAX_LREGISTER 1 +static int ia32regs[REAL_MAX_REGISTER+REAL_MAX_LREGISTER]; +static int ia32regv[REAL_MAX_REGISTER+REAL_MAX_LREGISTER]; +static int ia32rname[REAL_MAX_REGISTER+REAL_MAX_LREGISTER]; static int *regv = ia32regv; static int *regs = ia32regs; @@ -258,6 +261,12 @@ void free_register(int i) { /* いらなくなったレジスタを開放 */ regv[i]=regs[i]=0; + if(i==REAL_MAX_REGISTER) { +/*###265 [cc] error: `REG_DSI' undeclared (first use in this function)%%%*/ +/*###265 [cc] error: for each function it appears in.)%%%*/ +/*###265 [cc] error: (Each undeclared identifier is reported only once%%%*/ + regv[virtual(REG_ESI)]=regv[virtual(REG_DSI)]=0; + } } int @@ -288,6 +297,15 @@ int get_lregister_var(NMTBL *n) { + int h,l; + h = virtual(REG_ESI); + l = virtual(REG_EDI); + if (regv[REAL_MAX_REGISTER]==0&®s[h]==0&®s[l]==0) { + regs[h]=regs[l]=1; + regv[h]=regv[l]=1; + regv[REAL_MAX_REGISTER]=1; + return list2(LREGISTER,REAL_MAX_REGISTER); + } return list2(LVAR,new_lvar(size_of_longlong)); } @@ -325,7 +343,7 @@ free_all_register(void) { int i; - for(i=0;i<MAX_REGISTER;i++) { + for(i=0;i<MAX_REGISTER+REAL_MAX_REGISTER;i++) { regs[i]=regv[i]=0; } creg = get_register(); @@ -1101,6 +1119,7 @@ regv[save]=0; if (ret_type==DOUBLE||ret_type==FLOAT) { fregv[freg]=1; regv[creg]=0; +/*###1119 [cc] error: `ret_tpye' undeclared (first use in this function)%%%*/ } else if (ret_type==LONGLONG||ret_tpye==ULONGLONG) { fregv[freg]=0; regv[creg]=0; } else if (ret_type==VOID) { @@ -1191,10 +1210,19 @@ { char *crn = register_name(creg,0); if(rname[creg]==REG_EAX) { +/*###1209 [cc] error: `op' undeclared (first use in this function)%%%*/ +/*###1209 [cc] warning: format argument is not a pointer (arg 3)%%%*/ +/*###1209 [cc] warning: too many arguments for format%%%*/ printf("\tmovl %d(%s),%%edx\n",op,offset+size_of_int,crn); +/*###1210 [cc] warning: format argument is not a pointer (arg 3)%%%*/ +/*###1210 [cc] warning: too many arguments for format%%%*/ printf("\tmovl %d(%s),%%eax\n",op,offset,crn); } else { +/*###1212 [cc] warning: too many arguments for format%%%*/ +/*###1212 [cc] warning: format argument is not a pointer (arg 3)%%%*/ printf("\tmovl %d(%s),%%eax\n",op,offset,crn); +/*###1213 [cc] warning: format argument is not a pointer (arg 3)%%%*/ +/*###1213 [cc] warning: too many arguments for format%%%*/ printf("\tmovl %d(%s),%%edx\n",op,offset+size_of_int,crn); } } @@ -1202,8 +1230,10 @@ int code_lrindirect(int e1, int reg, int offset, int us) { +/*###1220 [cc] warning: unused variable `crn'%%%*/ char *crn; g_expr(e1); +/*###1222 [cc] warning: implicit declaration of function `use_longlong'%%%*/ use_longlong(reg); lload(creg,offset); return LONGLONG; @@ -2222,8 +2252,10 @@ emit_lpush(); g_expr(e2); e3 = emit_lpop(); +/*###2240 [cc] error: `lreg' undeclared (first use in this function)%%%*/ reg = lreg; +/*###2242 [cc] warning: too few arguments for format%%%*/ printf("\tsubl %edx,4(%%esp)\n"); switch(op) { case LOP+GT: @@ -2245,6 +2277,7 @@ default: error(-1); } +/*###2263 [cc] warning: too few arguments for format%%%*/ printf("\tsubl %eax,(%%esp)\n"); switch(op) { case LOP+GT: @@ -2276,12 +2309,20 @@ void code_lregister(int e2,int reg) { - error(-1); + use_longlong(reg); + printf("\tmovl %%edx,%%esi\n"); + printf("\tmovl %%eax,%%edi\n"); } void code_cmp_lregister(int reg) { - error(-1); + char *crn; + use_int(reg); + crn = register_name(reg,0); + printf("\tmovl %s,%%esi\n",crn); +/*###2305 [cc] error: `rcrn' undeclared (first use in this function)%%%*/ + printf("\torl %s,%%edi\n",rcrn); + printf("\ttestl %s,%s\n",crn,crn); } void code_cmp_lrgvar(int e1,int e2) @@ -2292,7 +2333,7 @@ crn = register_name(e2,0); printf("\tmovl %s,%s\n",n,crn); printf("\torl %s+4,%s\n",n,crn); - printf("\ttestl %s,%s\n",crn); + printf("\ttestl %s,%s\n",crn,crn); } void code_cmp_lrlvar(int e1,int e2) @@ -2302,6 +2343,7 @@ crn = register_name(e2,0); printf("\tmovl %s,%d(%%dbp)\n",crn,lvar(e1)); printf("\trol %s,%d(%%dbp)\n",crn,lvar(e1)+4); +/*###2327 [cc] warning: too few arguments for format%%%*/ printf("\ttestl %s,%s\n",crn); } @@ -2310,6 +2352,7 @@ char *rn; // e1 = e2 use_longlong(e2); +/*###2335 [cc] error: too few arguments to function `register_name'%%%*/ rn = register_name(e1); printf("\tmovl %%eax,(%s)\n",rn); printf("\tmovl %%edx,4(%s)\n",rn); @@ -2317,6 +2360,7 @@ void code_lassign_gvar(int e1,int e2) { +/*###2342 [cc] warning: unused variable `crn'%%%*/ char *n,*crn; n = ((NMTBL*)cadr(e1))->nm; use_longlong(e2); @@ -2333,12 +2377,22 @@ void code_lassign_lregister(int e2,int reg) { - error(-1); + use_longlong(reg); +/*###2359 [cc] error: too few arguments to function `register_name'%%%*/ +/*###2359 [cc] error: `rn' undeclared (first use in this function)%%%*/ + rn = register_name(e2); + printf("\tmovl %%edi,(%s)\n",rn); + printf("\tmovl %%esi,4(%s)\n",rn); +/*###2362 [cc] warning: too many arguments for format%%%*/ + printf("\tmovl %%edi,%%eax\n",rn); +/*###2363 [cc] warning: too many arguments for format%%%*/ + printf("\tmovl %%esi,%%edx\n",rn); } static int code_l1(long long d) { +/*###2369 [cc] error: `ll0' undeclared (first use in this function)%%%*/ int *i = (int *)&ll0; int *j = (int *)&d; return (i[1] == 1)?j[1]:j[0]; } @@ -2346,6 +2400,7 @@ static int code_l2(long long d) { +/*###2376 [cc] error: `ll0' undeclared (first use in this function)%%%*/ int *i = (int *)&ll0; int *j = (int *)&d; return (i[1] == 1)?j[0]:j[1]; } @@ -2368,6 +2423,7 @@ void code_lrgvar(int e1,int e2) { +/*###2398 [cc] warning: unused variable `crn'%%%*/ char *n,*crn; n = ((NMTBL*)cadr(e1))->nm; use_longlong(e2); @@ -2390,10 +2446,13 @@ use_longlong(reg); opl = 0; call=0; +/*###2420 [cc] error: `op' undeclared (first use in this function)%%%*/ switch(op) { case LLSHIFT: case LULSHIFT: +/*###2423 [cc] error: parse error before ';' token%%%*/ printf("\tmovl %%ecx,4(%%esp)\n";); +/*###2424 [cc] error: parse error before ';' token%%%*/ printf("\tpopl %%ecx\n";); printf("\tshldl %%eax,%%edx\n"); printf("\tsall %%cl,%%eax\n"); @@ -2405,7 +2464,9 @@ printf("\tpopl %%ecx\n"); return; case LRSHIFT: +/*###2435 [cc] error: parse error before ';' token%%%*/ printf("\tmovl %%ecx,4(%%esp)\n";); +/*###2436 [cc] error: parse error before ';' token%%%*/ printf("\tpopl %%ecx\n";); printf("\tshrdl %%eax,%%edx\n"); printf("\tsarl %%cl,%%eax\n"); @@ -2417,7 +2478,9 @@ printf("\tpopl %%ecx\n"); return; case LURSHIFT: +/*###2447 [cc] error: parse error before ';' token%%%*/ printf("\tmovl %%ecx,4(%%esp)\n";); +/*###2448 [cc] error: parse error before ';' token%%%*/ printf("\tpopl %%ecx\n";); printf("\tshrdl %%eax,%%edx\n"); printf("\tshrl %%cl,%%eax\n"); @@ -2437,8 +2500,11 @@ case LBOR: opl=oph="orl"; break; case LMUL: case LUMUL: +/*###2467 [cc] error: parse error before ';' token%%%*/ printf("\tpushl %%edx\n";); +/*###2468 [cc] error: parse error before ';' token%%%*/ printf("\tpushl %%eax\n";); +/*###2469 [cc] error: parse error before ';' token%%%*/ printf("\tpushl %%ecx\n";); // 4 c_l // 8 c_h @@ -2447,9 +2513,12 @@ printf("\tmull 12(%%esp)\n"); // c_l*o_l -> %edx,%eax printf("\tmovl 4(%%esp),%%ecx\n"); // c_l->%ecx printf("\timull 16(%%esp),%%ecx\n"); // c_l*o_h->%ecx +/*###2477 [cc] warning: too many arguments for format%%%*/ +/*###2477 [cc] error: `h' undeclared (first use in this function)%%%*/ printf("\taddl %%ecx,%%edx\n",h); // %edx+%ecx->%edx printf("\tmovl 8(%%esp),%%ecx\n"); // c_h->%ecx printf("\timull 12(%%esp),%%ecx\n"); // c_h*o_l->%ecx +/*###2480 [cc] warning: too many arguments for format%%%*/ printf("\taddl %%ecx,%%edx\n",h); // %edx+%ecx->%edx printf("\tpopl %%ecx\n"); printf("\tladd $16,%%esp\n"); @@ -2463,10 +2532,14 @@ if (opl) { printf("\t%s (%%esp),%%eax\n\t%s 4(%%esp),%%edx\n",opl,oph); emit_lpop_free(e2); +/*###2493 [cc] error: parse error before "if"%%%*/ +/*###2493 [cc] error: `eles' undeclared (first use in this function)%%%*/ } eles if (call) { printf("\tcall %s\n",call); +/*###2495 [cc] warning: too few arguments for format%%%*/ printf("\tladd $16,%esp\n"); } +/*###2497 [cc] error: parse error before '}' token%%%*/ } int code_lconst_op_p(int op,int e) { @@ -2480,6 +2553,7 @@ case LADD: case LSUB: case LBAND +/*###2510 [cc] error: parse error before "case"%%%*/ case LEOR: case LBOR: return 1; @@ -2490,6 +2564,7 @@ void loprtc(int op,int reg,int e) { char *opl,*oph; +/*###2520 [cc] warning: unused variable `lb'%%%*/ int lb; int vl = code_l1(lcadr(e)); int vh = code_l2(lcadr(e)); @@ -2532,14 +2607,17 @@ void emit_lpush() { +/*###2562 [cc] warning: too few arguments for format%%%*/ printf("\tpush %edx\n\tpushl %eax\n"); } void code_i2ll() { +/*###2567 [cc] warning: unused variable `reg'%%%*/ int reg = USE_CREG; if (virtual(REG_EAX)!=creg) printf("\tmovl %s,%%eax\n",register_name(creg,0)); +/*###2570 [cc] warning: implicit declaration of function `use_longlong0'%%%*/ use_longlong0(); printf("\tcltd\n"); } @@ -2551,6 +2629,7 @@ void code_u2ll() { +/*###2581 [cc] warning: unused variable `reg'%%%*/ int reg = USE_CREG; if (virtual(REG_EAX)!=creg) printf("\tmovl %s,%%eax\n",register_name(creg,0)); @@ -2598,7 +2677,9 @@ printf("\tfldcw 0(%%esp)\n"); printf("\tfistpll 12(%%esp)\n"); printf("\tfldcw 2(%%esp)\n"); +/*###2628 [cc] warning: too few arguments for format%%%*/ printf("\tmovl 12(%esp),%%eax\n"); +/*###2629 [cc] warning: too few arguments for format%%%*/ printf("\tmovl 16(%esp),%%edx\n"); printf("\taddl $40,%%esp\n"); } @@ -2655,21 +2736,60 @@ void code_lpreinc(int e1,int e2,int reg) { - + int dir = caddr(e1); + int creg0; + char *crn; + if (car(e2)==LREGISTER) { + use_longlong(reg); + printf("\taddl %%edi,%%edi,%d\n",dir); + printf("\tadcl %%esi,%%esi,%d\n",dir); + printf("\tmovl %%edi,%%eax\n"); + printf("\tmovl %%esi,%%edx\n"); + return; + } + g_expr(e2); + crn = register_name(creg0=creg,0); + printf("\taddl $%d,(%s)\n",dir,crn); +/*###2699 [cc] error: parse error before ':' token%%%*/ + printf("\tadcl $%d,4(%s)\n",dir>0?:0:-1,crn); + use_longlong(reg); + lload(creg0,0); } void code_lpostinc(int e1,int e2,int reg) { - + int dir = caddr(e1); + int creg0; + char *crn; + if (car(e2)==LREGISTER) { + use_longlong(reg); + printf("\tmovl %%edi,%%eax\n"); + printf("\tmovl %%esi,%%edx\n"); + printf("\taddl %%edi,%%edi,%d\n",dir); + printf("\tadcl %%esi,%%esi,%d\n",dir); + return; + } + g_expr(e2); + crn = register_name(creg0=creg,0); + printf("\taddl $%d,(%s)\n",dir,crn); +/*###2720 [cc] error: parse error before ':' token%%%*/ + printf("\tadcl $%d,4(%s)\n",dir>0?:0:-1,crn); + use_longlong(reg); + lload(creg0,0); +/*###2723 [cc] warning: too many arguments for format%%%*/ + printf("\taddl $%d,%%eax\n",-dir,crn); +/*###2724 [cc] error: parse error before ':' token%%%*/ + printf("\tadcl $%d,%%edx\n",-dir>0?:0:-1,crn); } void code_lassop(int op,int reg) { - + error(-1); } void code_register_lassop(int reg,int op) { + error(-1); }
--- a/mc-code-powerpc.c Fri Apr 30 11:47:51 2004 +0900 +++ b/mc-code-powerpc.c Fri Apr 30 14:46:09 2004 +0900 @@ -37,6 +37,8 @@ static int freg,ireg,lreg; +int code_lassop_p = 1; + int size_of_int = 4; int size_of_short = 2; int size_of_float = 4;
--- a/mc-code.h Fri Apr 30 11:47:51 2004 +0900 +++ b/mc-code.h Fri Apr 30 14:46:09 2004 +0900 @@ -27,6 +27,8 @@ #define REG_LVAR_OFFSET 2 +extern int code_lassop_p; + extern void code_init(); extern void gexpr_code_init(void); extern int get_register_var(NMTBL *n);
--- a/mc-codegen.c Fri Apr 30 11:47:51 2004 +0900 +++ b/mc-codegen.c Fri Apr 30 14:46:09 2004 +0900 @@ -1454,14 +1454,14 @@ op = cadddr(e1); g_expr(e3); - emit_dpush(d); - g_expr(e2); if (car(e2)==DREGISTER||car(e2)==FREGISTER) { code_register_dassop(cadr(e2),op,d); if (use) code_dregister(cadr(e2),USE_CREG,d); return; } + emit_dpush(d); + g_expr(e2); code_dassop(op,USE_CREG,d); return; } @@ -1470,10 +1470,17 @@ #if LONGLONG_CODE +static int +long_sign(int op) +{ + return (op==LUDIV||op==LUMOD||op==LULSHIFT||op==LURSHIFT)?ULONGLONG:LONGLONG; +} + void lassop(int e1) { int e2,e3,op; + int n,t; /* e2 op= e3 */ e2 = cadr(e1); @@ -1481,15 +1488,30 @@ e3 = caddr(e1); op = cadddr(e1); + if (!code_lassop_p||car(e3)==LCONST) { + /* e2 = e2 op e3; */ + t = long_sign(op); + if (car(e2)==LREGISTER||car(e2)==LVAR||car(e2)==GVAR) { + g_expr(assign_expr0(e2,list3(op,rvalue_t(e2,t),e3),t,t)); + } + /* new = &e2 */ + /* *new = *new op e3 */ + n = list2(LVAR,new_lvar(size_of_int)); + g_expr(assign_expr0(n,list2(ADDRESS,e2),INT,INT)); + g_expr(assign_expr0(list2(INDIRECT,n),list3(op,n,e3),t,t)); + free_lvar(cadr(n)); + return; + } + g_expr(e3); - emit_lpush(); - g_expr(e2); if (car(e2)==LREGISTER) { code_register_lassop(cadr(e2),op); if (use) code_lregister(cadr(e2),USE_CREG); return; } + emit_lpush(); + g_expr(e2); code_lassop(op,USE_CREG); return; }