Mercurial > hg > CbC > old > device
changeset 757:7cb7dd01507f
i64 contiue... unsigned int assignment fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 16 Nov 2010 19:44:54 +0900 |
parents | e333c95586bd |
children | 7a19e49db6ac |
files | mc-code-i64.c |
diffstat | 1 files changed, 22 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-i64.c Tue Nov 16 19:36:40 2010 +0900 +++ b/mc-code-i64.c Tue Nov 16 19:44:54 2010 +0900 @@ -1400,30 +1400,35 @@ sz==SIZE_OF_INT?(sign?"movslq":"movl"):"movq"; } +static int +regu(int sign,int sz,int u) { + return sz==SIZE_OF_INT?(sign?u:SIZE_OF_INT):u; +} + void code_crgvar(int e1,int creg,int sign,int sz){ use_int(creg); #ifdef __APPLE__ NMTBL *nptr = ncaddr(e1); if (nptr->sc==STATIC && !(is_code(nptr)||is_function(nptr))) { - printf("\t%s _%s+%d(%%rip),%s\n", cload(sign,sz),nptr->nm,cadr(e1),register_name(creg,0)); + printf("\t%s _%s+%d(%%rip),%s\n", cload(sign,sz),nptr->nm,cadr(e1),register_name(creg,regu(sign,sz,0))); return; } int r = get_ptr_cache(ncaddr(e1)); if (cadr(e1)) { printf("\t%s %d(%s),%s\n", cload(sign,sz),cadr(e1),register_name(r,0), - register_name(creg,0)); + register_name(creg,regu(sign,sz,0))); } else { printf("\t%s (%s),%s\n", cload(sign,sz), - register_name(r,0), register_name(creg,0)); + register_name(r,0), register_name(creg,regu(sign,sz,0))); } #else if (cadr(e1)) { printf("\t%s %s+%d,%s\n",cload(sign,sz), - nptr->nm,cadr(e1),register_name(creg,0)); + nptr->nm,cadr(e1),register_name(creg,regu(sign,sz,0))); } else printf("\t%s %s,%s\n",cload(sign,sz), - nptr->nm,register_name(creg,0)); + nptr->nm,register_name(creg,regu(sign,sz,0))); #endif } @@ -1492,7 +1497,7 @@ code_crlvar(int e2,int reg,int sign,int sz) { use_int(reg); printf("\t%s ",cload(sign,sz)); lvar(e2); - printf(",%s\n",register_name(reg,0)); + printf(",%s\n",register_name(reg,regu(sign,sz,0))); } @@ -1569,7 +1574,7 @@ use_int(reg); printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==SIZE_OF_SHORT)?"addw":"addl",dir,xrn); if (use) - printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,0)); + printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,regu(sign,sz,0))); } @@ -1589,7 +1594,7 @@ xrn = register_name((e2=emit_pop(0)),0); use_int(reg); if (use) - printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,0)); + printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,regu(sign,sz,0))); printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==SIZE_OF_SHORT)?"addw":"addl",dir,xrn); emit_pop_free(e2); } @@ -2358,7 +2363,7 @@ op=cload(sign,byte); crn = register_name(creg,0); use_int(reg); - printf("\t%s %d(%s),%s\n",op,offset,crn,register_name(reg,0)); + printf("\t%s %d(%s),%s\n",op,offset,crn,register_name(reg,regu(sign,byte,0))); } #if FLOAT_CODE @@ -2696,10 +2701,10 @@ } if (n) printf("\t%s %d(%s),%s\n",cload(sign,byte),n, - register_name(xreg,0),register_name(reg,0)); + register_name(xreg,0),register_name(reg,regu(sign,byte,0))); else printf("\t%s (%s),%s\n",cload(sign,byte), - register_name(xreg,0),register_name(reg,0)); + register_name(xreg,0),register_name(reg,regu(sign,byte,0))); } int @@ -3677,9 +3682,9 @@ int td = get_dregister(d); char *dbs = d?"d":"s"; printf(" cmpq $0, %s\n",u); - printf(" js f1\n"); + printf(" js 1f\n"); printf(" cvtsi2s%sq %s,%s\n",dbs,u,dn); - printf(" jmp f2\n"); + printf(" jmp 2f\n"); printf("1:\n"); printf(" movq %s, %s\n",u,t); printf(" shrq %s\n",t); @@ -4858,7 +4863,7 @@ } else { use_int(adr); use_int(reg); - printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,0), + printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,regu(sign,size,0)), register_name(reg,0)); /* shift left */ if ((i=32-bitsize-bitpos)) @@ -4924,7 +4929,7 @@ loprtc(LLSHIFT,value,list2(CONST,bitpos)); /* make and-mask */ printf("\tpushq %s\n",register_name(adr,0)); - printf("\t%s %d(%s),%s\n",cload(sign,size),4,register_name(adr,0), + printf("\t%s %d(%s),%s\n",cload(sign,size),4,register_name(adr,regu(sign,size,0)), register_name(adr,0)); mask = make_mask(64-bitpos-bitsize,63-bitpos); make_mask_and_or_l(mask,value); @@ -5004,7 +5009,7 @@ lc = lcadr(value); lc <<= bitpos; - printf("\t%s %d(%s),%s\n",cload(sign,size),4,register_name(adr,0), + printf("\t%s %d(%s),%s\n",cload(sign,size),4,register_name(adr,regu(sign,size,0)), register_name(lvalue,0)); /* make and-mask upper */ mask = make_mask(64-bitpos-bitsize,63-bitpos); @@ -5015,7 +5020,7 @@ #endif } else { lvalue = get_register(); - printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,0), + printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,regu(sign,size,0)), register_name(lvalue,0)); /* shift left */ c = cadr(value);