Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 366:2d510935c37d
*** empty log message ***
author | kono |
---|---|
date | Wed, 07 Jul 2004 17:34:32 +0900 |
parents | 5ac17fa9d7e0 |
children | 4efbb07f556b |
line wrap: on
line diff
--- a/mc-code-powerpc.c Wed Jul 07 14:34:25 2004 +0900 +++ b/mc-code-powerpc.c Wed Jul 07 17:34:32 2004 +0900 @@ -2485,7 +2485,8 @@ code_const_op_p(int op,int v) { if (car(v)!=CONST) return 0; - if (op==BAND||op==DIV||op==UDIV||op==MOD||op==UMOD) return 0; + if (op==DIV||op==UDIV) return ilog(v); + if (op==BAND||op==MOD||op==UMOD) return 0; v = cadr(v); return (-32766<v&&v<32767); } @@ -2494,6 +2495,7 @@ oprtc(int op,int creg, int v) { char *crn; + int l; use_int(creg); crn = register_name(creg); v = cadr(v); @@ -2503,9 +2505,13 @@ case ULSHIFT: printf("\tslwi %s,%s,%d\n",crn,crn,v); return; + case DIV: + v = ilog(v); case RSHIFT: printf("\tsrawi %s,%s,%d\n",crn,crn,v); return; + case UDIV: + v = ilog(v); case URSHIFT: printf("\tsrwi %s,%s,%d\n",crn,crn,v); return; @@ -2530,10 +2536,11 @@ printf("\tori %s,%s,lo16(%d)\n",crn,crn,v); break; case MUL: - printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); - break; case UMUL: - printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); + if ((l=ilog(v))) { + printf("\tslwi %s,%s,%d\n",crn,crn,l); + } else + printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); break; default: error(-1); @@ -2570,6 +2577,7 @@ void code_cmpdimm(int e, int csreg,int label,int cond) { + int reg; /* used in dosiwtch() */ if(chk) return; inc_cmpflag(); @@ -2577,7 +2585,11 @@ printf("\tcmpwi cr%d,%s,%d\n",cmpflag,register_name(csreg),e); jcond(label,cond); } else { - error(-1); /* !? */ + reg = get_register(); + code_const(list2(CONST,e),reg); + printf("\tcmpw cr%d,%s,%s\n",cmpflag,register_name(csreg),register_name(reg)); + jcond(label,cond); + free_register(reg); } }