Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 189:f53d70110377
immediate instructions.
author | kono |
---|---|
date | Mon, 01 Dec 2003 21:18:45 +0900 |
parents | dffcccf8b1cb |
children | c193120ee2a6 |
line wrap: on
line diff
--- a/mc-code-powerpc.c Mon Dec 01 20:07:57 2003 +0900 +++ b/mc-code-powerpc.c Mon Dec 01 21:18:45 2003 +0900 @@ -1750,6 +1750,54 @@ regv[creg]=1; } +int +code_const_op_p(int op,int v) +{ + if (op==BAND||op==DIV||op==UDIV||op==MOD||op==UMOD) return 0; + return (-127<v&&v<128); +} + +void +oprtc(int op,int v) +{ + char *crn = register_name(creg); + + switch(op) { + case LSHIFT: + case ULSHIFT: + printf("\tslwi %s,%s,%d\n",crn,crn,v); + return; + case RSHIFT: + printf("\tsrawi %s,%s,%d\n",crn,crn,v); + return; + case URSHIFT: + printf("\tsrwi %s,%s,%d\n",crn,crn,v); + return; + case ADD: + printf("\taddi %s,%s,lo16(%d)\n",crn,crn,v); + break; + case SUB: + printf("\tsubi %s,%s,lo16(%d)\n",crn,crn,v); + break; + case CMP: + printf("\tcmpwi cr0,%s,lo16(%d)\n",crn,v); + break; + case EOR: + printf("\txori %s,%s,lo16(%d)\n",crn,crn,v); + break; + case BOR: + 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); + break; + default: + error(-1); + } +} void shift(char *op, int reg)