Mercurial > hg > CbC > old > device
changeset 749:593f15532e76
coe-gen-all.c assembled.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 14 Nov 2010 00:22:33 +0900 |
parents | c2c709727221 |
children | f28900807fd9 |
files | mc-code-i64.c |
diffstat | 1 files changed, 43 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-i64.c Sat Nov 13 22:39:40 2010 +0900 +++ b/mc-code-i64.c Sun Nov 14 00:22:33 2010 +0900 @@ -501,6 +501,7 @@ #endif static void jcond(int l, char cond); +static char * code_cond(int op,int cond); @@ -1625,6 +1626,16 @@ #if FLOAT_CODE if (drexpr_bool(e1,reg)) return; #endif + char *s; + if ((s=code_cond(OP(car(e1)),1))) { + g_expr(list3(LCMP,cadr(e1),caddr(e1))); + if (!use) return; + use_data_reg(reg,1); + printf("\tset%s\t%s\n",s,register_name(reg,1)); + printf("\tmovzbq %s,%s\n",register_name(reg,1),register_name(reg,0)); + return; + } + b_expr(e1,1,e2=fwdlabel(),1); /* including > < ... */ if (use) { use_int(reg); @@ -1632,7 +1643,7 @@ printf("\txorq %s,%s\n",xrn,xrn); jmp(e3=fwdlabel()); fwddef(e2); - printf("\tmovl $1,%s\n",xrn); + printf("\tmovq $1,%s\n",xrn); fwddef(e3); } else { fwddef(e2); @@ -2579,7 +2590,7 @@ printf("\tandb $%ld,%s\n",orn,register_name(reg,1)); else if (datareg&&(orn & ~65535)==~65535) printf("\tandw $%ld,%s\n",orn,register_name(reg,2)); - else if (sz<=SIZE_OF_INT||(datareg&&(orn & ~0xffffffff)==~0xffffffff)) + else if (sz<=SIZE_OF_INT||(datareg&&(orn & ~0xffffffffL)==~0xffffffffL)) printf("\tandl $%ld,%s\n",orn,register_name(reg,4)); else printf("\tandq $%ld,%s\n",orn,crn); @@ -2592,7 +2603,7 @@ printf("\tor $%ld,%s\n",orn,register_name(reg,1)); else if (datareg&&(orn & ~65535)==0) printf("\tor $%ld,%s\n",orn,register_name(reg,2)); - else if (sz<=SIZE_OF_INT||(datareg&&(orn & ~0xffffffff)==0)) + else if (sz<=SIZE_OF_INT||(datareg&&(orn & ~0xffffffffL)==0)) printf("\torl $%ld,%s\n",orn,register_name(reg,4)); else printf("\torq $%ld,%s\n",orn,crn); @@ -2654,7 +2665,7 @@ { /* used in dosiwtch() */ set_ireg(csreg,0); - printf("\tcmpl $%d,%s\n",e,register_name(creg,0)); + printf("\tcmpl $%d,%s\n",e,register_name(creg,SIZE_OF_INT)); jcond(label,cond); } @@ -2708,6 +2719,7 @@ char *s; if (!(s=code_cond(car(e1),1))) return 0; g_expr(list3(CMP,cadr(e1),caddr(e1))); + if (!use) return 1; use_data_reg(reg,1); printf("\tset%s\t%s\n",s,register_name(reg,1)); printf("\tmovzbl %s,%s\n",register_name(reg,1),register_name(reg,SIZE_OF_INT)); @@ -3666,14 +3678,14 @@ #ifdef __APPLE__ int r = get_ptr_cache(ncaddr(e2)); if (cadr(e2)) - printf("\t%s %d(%s)\n",fload(d),cadr(e2),register_name(r,0)); + printf("\t%s %d(%s),%s\n",fload(d),cadr(e2),register_name(r,0),fregister_name(freg)); else - printf("\t%s (%s)\n",fload(d),register_name(r,0)); + printf("\t%s (%s),%s\n",fload(d),register_name(r,0),fregister_name(freg)); #else if (cadr(e2)) - printf("\t%s %s+%d\n",fload(d),(ncaddr(e2))->nm,cadr(e2)); + printf("\t%s %s+%d,%s\n",fload(d),(ncaddr(e2))->nm,cadr(e2),fregister_name(freg)); else - printf("\t%s %s\n",fload(d),(ncaddr(e2))->nm); + printf("\t%s %s,%s\n",fload(d),(ncaddr(e2))->nm,fregister_name(freg)); #endif } @@ -3813,7 +3825,7 @@ float_one_lib_used=1; one = &float_one; } else { - float_one_lib_used=1; + float_one_f_lib_used=1; one = &float_one_f; } r = get_ptr_cache(one); @@ -3837,7 +3849,7 @@ set_freg(reg,0); } frn=fregister_name(reg); - printf("\t%s %s,%s,%s\n",ops,crn,crn,grn); + printf("\t%s %s,%s\n",ops,grn,crn); if (use && reg!=cadr(e2)) printf("\tmovap%s %s,%s\n",d?"d":"s",frn,crn); } else { @@ -3851,7 +3863,7 @@ frn=fregister_name(reg); grn = fregister_name(g = code_dload_1(d)); printf("\t%s %s,0(%s)\n",fload(d),frn,crn); - printf("\t%s %s,%s,%s\n",ops,frn,frn,grn); + printf("\t%s %s,%s\n",ops,grn,frn); printf("\t%s %s,0(%s)\n",fstore(d),frn,crn); } free_register(g); @@ -3873,7 +3885,7 @@ frn=fregister_name(reg); if (use && reg!=cadr(e2)) printf("\tmovap%s %s,%s\n",d?"d":"s",frn,crn); - printf("\t%s %s,%s,%s\n",ops,crn,crn,grn); + printf("\t%s %s,%s\n",ops,grn,crn); } else { g_expr(e2); if (!is_int_reg(creg)) error(-1); @@ -3885,7 +3897,7 @@ frn=fregister_name(reg); grn = fregister_name(g = code_dload_1(d)); printf("\t%s %s,0(%s)\n",fload(d),frn,crn); - printf("\t%s %s,%s,%s\n",ops,grn,frn,grn); + printf("\t%s %s,%s\n",ops,grn,frn); printf("\t%s %s,0(%s)\n",fstore(d),grn,crn); } free_register(g); @@ -3956,7 +3968,7 @@ } else { use_data_reg(reg,0); printf("\tset%s\t%s\n",s,register_name(reg,1)); - printf("\tmovzbl\t%s,%s\n", + printf("\tmovzbq\t%s,%s\n", register_name(reg,1),register_name(reg,0)); } return 1; @@ -4203,14 +4215,13 @@ case LMUL: case LUMUL: case LUDIV: + case LADD: + case LSUB: /* case LDIV: */ return -0x10000000LL<l&&l<0x10000000LL && ilog(l); - case LADD: - case LSUB: case LBAND: case LEOR: case LBOR: - return 1; default: return 0; } @@ -4393,7 +4404,7 @@ xreg = emit_pop(0); /* pop e3 value */ emit_push(); ld_indexx(SIZE_OF_LONGLONG,0,creg,ireg,0); - tosop(op,ireg,xreg); + ltosop(op,ireg,xreg); emit_pop_free(xreg); xreg = emit_pop(0); /* pop e3 value */ printf("\t%s %s,(%s)\n",move(SIZE_OF_LONGLONG),register_name(ireg,0),register_name(xreg,0)) @@ -4428,8 +4439,9 @@ // use_register(creg,csvalue,0); set_ireg(csvalue,0); crn = register_name(creg,0); - printf("\tsubl\t$%d,%s\n",min,crn); - printf("\tcmpl\t$%d,%s\n",max-min,crn); + char *crnl = register_name(creg,SIZE_OF_INT); + printf("\tsubl\t$%d,%s\n",min,crnl); + printf("\tcmpl\t$%d,%s\n",max-min,crnl); printf("\tja\t_%d\n",dlabel); if (delta==1) { #ifdef __APPLE__ @@ -4437,7 +4449,7 @@ printf("\taddq\t%%rbx,%s\n",crn); printf("\tjmp\t*%s\n",crn); #else - printf("\tjmp\t*_%d(,%s,4)\n",l,crn); + printf("\tjmp\t*_%d(,%s,8)\n",l,crn); #endif return; } @@ -4446,7 +4458,7 @@ clear_ptr_cache_reg(REG_EAX); #endif use_register(creg,REG_EAX,1); - crn = "%eax"; + crn = "%rax"; switch(delta) { case 2: @@ -4479,11 +4491,11 @@ printf("\tandl\t%%edx,%%edx\n"); printf("\tjne\t_%d\n",dlabel); #ifdef __APPLE__ - printf("\tmovl\t_%d-(%%rbx,%s,8),%s\n",l,crn,crn); - printf("\taddl\t%%ebx,%s\n",crn); + printf("\tmovq\t_%d-(%%rbx,%s,8),%s\n",l,crn,crn); + printf("\taddq\t%%rbx,%s\n",crn); printf("\tjmp\t*%s\n",crn); #else - printf("\tjmp\t*_%d(,%%eax,4)\n",l); + printf("\tjmp\t*_%d(,%%rax,4)\n",l); #endif break; } @@ -4965,13 +4977,13 @@ { switch(e3) { case FUNCTION: case CONV: case STASS: case ALLOCA: - case LDIV: case LUDIV: case LMOD: case LUMOD: - case LMUL: case LUMUL: - case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT: - case DDIV: case DADD: case DSUB: case DMUL: case DMINUS: + //case LDIV: case LUDIV: case LMOD: case LUMOD: + //case LMUL: case LUMUL: + //case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT: + //case DDIV: case DADD: case DSUB: case DMUL: case DMINUS: case DPOSTINC : case DPREINC : case DASSOP : - case DOP+LT : case DOP+LE : case DOP+GT : case DOP+GE : - case DOP+EQ : case DOP+NEQ: + //case DOP+LT : case DOP+LE : case DOP+GT : case DOP+GE : + //case DOP+EQ : case DOP+NEQ: case RBIT_FIELD: case BASS: case BASSOP: case LCALL: case INLINE: return 1;