Mercurial > hg > CbC > old > device
comparison mc-code-powerpc.c @ 366:2d510935c37d
*** empty log message ***
author | kono |
---|---|
date | Wed, 07 Jul 2004 17:34:32 +0900 |
parents | 5ac17fa9d7e0 |
children | 4efbb07f556b |
comparison
equal
deleted
inserted
replaced
365:5ac17fa9d7e0 | 366:2d510935c37d |
---|---|
2483 | 2483 |
2484 int | 2484 int |
2485 code_const_op_p(int op,int v) | 2485 code_const_op_p(int op,int v) |
2486 { | 2486 { |
2487 if (car(v)!=CONST) return 0; | 2487 if (car(v)!=CONST) return 0; |
2488 if (op==BAND||op==DIV||op==UDIV||op==MOD||op==UMOD) return 0; | 2488 if (op==DIV||op==UDIV) return ilog(v); |
2489 if (op==BAND||op==MOD||op==UMOD) return 0; | |
2489 v = cadr(v); | 2490 v = cadr(v); |
2490 return (-32766<v&&v<32767); | 2491 return (-32766<v&&v<32767); |
2491 } | 2492 } |
2492 | 2493 |
2493 void | 2494 void |
2494 oprtc(int op,int creg, int v) | 2495 oprtc(int op,int creg, int v) |
2495 { | 2496 { |
2496 char *crn; | 2497 char *crn; |
2498 int l; | |
2497 use_int(creg); | 2499 use_int(creg); |
2498 crn = register_name(creg); | 2500 crn = register_name(creg); |
2499 v = cadr(v); | 2501 v = cadr(v); |
2500 | 2502 |
2501 switch(op) { | 2503 switch(op) { |
2502 case LSHIFT: | 2504 case LSHIFT: |
2503 case ULSHIFT: | 2505 case ULSHIFT: |
2504 printf("\tslwi %s,%s,%d\n",crn,crn,v); | 2506 printf("\tslwi %s,%s,%d\n",crn,crn,v); |
2505 return; | 2507 return; |
2508 case DIV: | |
2509 v = ilog(v); | |
2506 case RSHIFT: | 2510 case RSHIFT: |
2507 printf("\tsrawi %s,%s,%d\n",crn,crn,v); | 2511 printf("\tsrawi %s,%s,%d\n",crn,crn,v); |
2508 return; | 2512 return; |
2513 case UDIV: | |
2514 v = ilog(v); | |
2509 case URSHIFT: | 2515 case URSHIFT: |
2510 printf("\tsrwi %s,%s,%d\n",crn,crn,v); | 2516 printf("\tsrwi %s,%s,%d\n",crn,crn,v); |
2511 return; | 2517 return; |
2512 case ADD: | 2518 case ADD: |
2513 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,v); | 2519 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,v); |
2528 break; | 2534 break; |
2529 case BOR: | 2535 case BOR: |
2530 printf("\tori %s,%s,lo16(%d)\n",crn,crn,v); | 2536 printf("\tori %s,%s,lo16(%d)\n",crn,crn,v); |
2531 break; | 2537 break; |
2532 case MUL: | 2538 case MUL: |
2533 printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); | |
2534 break; | |
2535 case UMUL: | 2539 case UMUL: |
2536 printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); | 2540 if ((l=ilog(v))) { |
2541 printf("\tslwi %s,%s,%d\n",crn,crn,l); | |
2542 } else | |
2543 printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); | |
2537 break; | 2544 break; |
2538 default: | 2545 default: |
2539 error(-1); | 2546 error(-1); |
2540 } | 2547 } |
2541 } | 2548 } |
2568 } | 2575 } |
2569 | 2576 |
2570 void | 2577 void |
2571 code_cmpdimm(int e, int csreg,int label,int cond) | 2578 code_cmpdimm(int e, int csreg,int label,int cond) |
2572 { | 2579 { |
2580 int reg; | |
2573 /* used in dosiwtch() */ | 2581 /* used in dosiwtch() */ |
2574 if(chk) return; | 2582 if(chk) return; |
2575 inc_cmpflag(); | 2583 inc_cmpflag(); |
2576 if (-32767<e&&e<32767) { | 2584 if (-32767<e&&e<32767) { |
2577 printf("\tcmpwi cr%d,%s,%d\n",cmpflag,register_name(csreg),e); | 2585 printf("\tcmpwi cr%d,%s,%d\n",cmpflag,register_name(csreg),e); |
2578 jcond(label,cond); | 2586 jcond(label,cond); |
2579 } else { | 2587 } else { |
2580 error(-1); /* !? */ | 2588 reg = get_register(); |
2589 code_const(list2(CONST,e),reg); | |
2590 printf("\tcmpw cr%d,%s,%s\n",cmpflag,register_name(csreg),register_name(reg)); | |
2591 jcond(label,cond); | |
2592 free_register(reg); | |
2581 } | 2593 } |
2582 } | 2594 } |
2583 | 2595 |
2584 void | 2596 void |
2585 code_opening(char *filename) | 2597 code_opening(char *filename) |