Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 230:d60c6c31f63a
*** empty log message ***
author | kono |
---|---|
date | Wed, 28 Apr 2004 15:06:01 +0900 |
parents | d793c84b3679 |
children | f5efe15629d4 |
line wrap: on
line diff
--- a/mc-code-powerpc.c Wed Apr 28 00:02:59 2004 +0900 +++ b/mc-code-powerpc.c Wed Apr 28 15:06:01 2004 +0900 @@ -261,7 +261,8 @@ */ int arg_offset = 24; int arg_offset1 = 24; int disp_offset = -12; -#define func_disp_offset 60 +// #define func_disp_offset 60 +#define func_disp_offset 68 #define r1_offset func_disp_offset+12 int code_disp_offset = 0; int jump_offset = 0; #define CODE_LVAR l+code_disp_offset @@ -1011,7 +1012,24 @@ static char *cload(int sz) { return sz==1?"lbz":sz==size_of_short?"lhz":"lwz"; } static char *cstore(int sz) { return sz==1?"stb":sz==size_of_short?"sth":"stw"; } -static char *cext(int sz) { return sz==size_of_short?"extsh":"extsb"; } + +static void +cext(int sign,int sz,int reg) +{ + char *crn = register_name(reg); + if (sign) { + if (sz==1) + printf("\textsb %s,%s\n",crn,crn); + else if (sz==size_of_short) + printf("\textsh %s,%s\n",crn,crn); + } else { + if (sz==1) + printf("\trlwinm %s,%s,0,0xff\n",crn,crn); + else if (sz==size_of_short) + printf("\trlwinm %s,%s,0,0xffff\n",crn,crn); + } +} + void code_label(int labelno) @@ -1044,8 +1062,7 @@ crn = register_name(reg); printf("\t%s %s,0(%s)\n",cload(sz),crn, register_name(get_ptr_cache((NMTBL*)cadr(e1)))); - if (sign) - printf("\t%s %s,%s\n",cext(sz),crn,crn); + cext(sign,sz,reg); } @@ -1072,14 +1089,9 @@ lvar_intro(e2); printf("\t%s %s,",cload(sz),register_name(reg)); lvar(e2); - if (sign) - printf("\t%s %s,%s\n",cext(sz),register_name(reg),register_name(reg)); + cext(sign,sz,reg); } - - - - void code_fname(NMTBL *n,int reg) { int r; @@ -1150,8 +1162,7 @@ drn = register_name(reg); } printf("\t%s %s,0(%s)\n",cload(sz),drn,xrn); - if (use && sign && sz!=size_of_int) - printf("\t%s %s,%s\n",cext(sz),drn,drn); + if (use) cext(sign,sz,dreg); printf("\taddi %s,%s,%d\n",drn,drn,dir); printf("\t%s %s,0(%s)\n",cstore(sz),drn,xrn); } @@ -1181,8 +1192,7 @@ xrn = register_name(reg); } printf("\t%s %s,0(%s)\n",cload(sz),xrn,crn); - if (use && sign && sz!=size_of_int) - printf("\t%s %s,%s\n",cext(sz),xrn,xrn); + if (use) cext(sign,sz,reg); printf("\taddi %s,%s,%d\n",nrn,xrn,dir); printf("\t%s %s,0(%s)\n",cstore(sz),nrn,crn); free_register(nreg); @@ -1260,6 +1270,7 @@ crn = register_name(reg); r = get_ptr_cache((NMTBL*)cadr(e1)); printf("\t%s %s,0(%s)\n",cload(sz),crn,register_name(r)); + cext(0,sz,r); printf("\tcmpwi cr0,%s,0\n",crn); } @@ -1272,6 +1283,7 @@ lvar_intro(e2); printf("\t%s %s,",cload(sz),crn); lvar(e2); + cext(0,sz,reg); code_cmp_register(reg); } @@ -2814,6 +2826,7 @@ return; } rrn = register_name((r=get_register())); + use_reg(r); // to clear ptr cache printf(" \t.data\n\t.align 3\n"); lb=fwdlabel(); printf("L_%d:\n",lb); @@ -3324,9 +3337,9 @@ case LOP+LE: pcond(code_gt(!cond),l1); break; case LOP+UGT: - pcond(code_ugt(cond),l1); break; + pcond(code_ugt(!cond),l1); break; case LOP+UGE: - pcond(code_uge(cond),l1); break; + pcond(code_uge(!cond),l1); break; default: error(-1); } @@ -3345,9 +3358,9 @@ case LOP+LE: pcond(code_gt(!cond),l1); break; case LOP+UGT: - pcond(code_ugt(cond),l1); break; + pcond(code_ugt(!cond),l1); break; case LOP+UGE: - pcond(code_uge(cond),l1); break; + pcond(code_uge(!cond),l1); break; default: error(-1); }