comparison mc-code-powerpc.c @ 438:626d705471d5 lazy-branch

Unexecuted code in conditional. Lazy jmp code generation.
author kono
date Mon, 15 Nov 2004 20:33:30 +0900
parents d92786033042
children a531bbf572e3
comparison
equal deleted inserted replaced
437:49d4483d5110 438:626d705471d5
2651 printf("\tmfcr %s\n",rn); 2651 printf("\tmfcr %s\n",rn);
2652 printf("\trlwinm %s,%s,%d,1\n",rn,rn,t+flag); 2652 printf("\trlwinm %s,%s,%d,1\n",rn,rn,t+flag);
2653 return 1; 2653 return 1;
2654 } 2654 }
2655 2655
2656 void 2656 int
2657 rexpr(int e1, int l1, int cond,int t) 2657 rexpr(int e1, int l1, int cond,int t)
2658 { 2658 {
2659 char *s; 2659 char *s;
2660 switch(car(e1)+BNOT*(!cond)) { 2660 switch(car(e1)+BNOT*(!cond)) {
2661 case GT: s=code_gt(1); break; 2661 case GT: s=code_gt(1); break;
2680 case NEQ+BNOT: s=code_eq(!0); break; 2680 case NEQ+BNOT: s=code_eq(!0); break;
2681 default: error(-1); 2681 default: error(-1);
2682 } 2682 }
2683 g_expr(list3((t==INT?CMP:UCMP),cadr(e1),caddr(e1))); 2683 g_expr(list3((t==INT?CMP:UCMP),cadr(e1),caddr(e1)));
2684 printf("\tb%s cr%d,L_%d\n",s,cmpflag,l1); 2684 printf("\tb%s cr%d,L_%d\n",s,cmpflag,l1);
2685 return l1;
2685 } 2686 }
2686 2687
2687 static void 2688 static void
2688 jcond(int l, char cond) 2689 jcond(int l, char cond)
2689 { 2690 {
2696 } 2697 }
2697 2698
2698 void 2699 void
2699 jmp(int l) 2700 jmp(int l)
2700 { 2701 {
2701 control=0;
2702 if (chk) return; 2702 if (chk) return;
2703 printf("\tb\tL_%d\n",l); 2703 printf("\tb\tL_%d\n",l);
2704 } 2704 }
2705 2705
2706 extern void 2706 extern void
3782 printf("\tmfcr %s\n",rn); 3782 printf("\tmfcr %s\n",rn);
3783 printf("\trlwinm %s,%s,%d,1\n",rn,rn,t+flag); 3783 printf("\trlwinm %s,%s,%d,1\n",rn,rn,t+flag);
3784 return 1; 3784 return 1;
3785 } 3785 }
3786 3786
3787 void 3787 int
3788 drexpr(int e1, int e2,int l1, int op,int cond) 3788 drexpr(int e1, int e2,int l1, int op,int cond)
3789 { 3789 {
3790 if (!cond) { 3790 if (!cond) {
3791 switch(op) { 3791 switch(op) {
3792 case FOP+GT: 3792 case FOP+GT:
3793 drexpr(e2,e1,l1,FOP+GE,1); return; 3793 return drexpr(e2,e1,l1,FOP+GE,1);
3794 case FOP+GE: 3794 case FOP+GE:
3795 drexpr(e2,e1,l1,FOP+GT,1); return; 3795 return drexpr(e2,e1,l1,FOP+GT,1);
3796 case FOP+EQ: 3796 case FOP+EQ:
3797 op=FOP+NEQ; break; 3797 op=FOP+NEQ; break;
3798 case FOP+NEQ: 3798 case FOP+NEQ:
3799 op=FOP+EQ; break; 3799 op=FOP+EQ; break;
3800 case DOP+GT: 3800 case DOP+GT:
3801 drexpr(e2,e1,l1,DOP+GE,1); return; 3801 return drexpr(e2,e1,l1,DOP+GE,1);
3802 case DOP+GE: 3802 case DOP+GE:
3803 drexpr(e2,e1,l1,DOP+GT,1); return; 3803 return drexpr(e2,e1,l1,DOP+GT,1);
3804 case DOP+EQ: 3804 case DOP+EQ:
3805 op=DOP+NEQ; break; 3805 op=DOP+NEQ; break;
3806 case DOP+NEQ: 3806 case DOP+NEQ:
3807 op=DOP+EQ; break; 3807 op=DOP+EQ; break;
3808 } 3808 }
3820 break; 3820 break;
3821 case DOP+NEQ: case FOP+NEQ: 3821 case DOP+NEQ: case FOP+NEQ:
3822 printf("\tbne\tcr%d,L_%d\n",cmpflag,l1); 3822 printf("\tbne\tcr%d,L_%d\n",cmpflag,l1);
3823 break; 3823 break;
3824 } 3824 }
3825 return l1;
3825 } 3826 }
3826 3827
3827 int emit_dpop(int d) 3828 int emit_dpop(int d)
3828 { 3829 {
3829 int xreg,reg; 3830 int xreg,reg;
3895 } else { 3896 } else {
3896 return CMP; 3897 return CMP;
3897 } 3898 }
3898 } 3899 }
3899 3900
3900 void 3901 int
3901 lrexpr(int e1, int e2,int l1, int op,int cond) 3902 lrexpr(int e1, int e2,int l1, int op,int cond)
3902 { 3903 {
3903 int reg; 3904 int reg;
3904 int e3; 3905 int e3;
3905 int l2; 3906 int l2;
3969 case LOP+UGT+BNOT: pcond(code_ugt(0), cr1,l1); break; 3970 case LOP+UGT+BNOT: pcond(code_ugt(0), cr1,l1); break;
3970 case LOP+UGE+BNOT: pcond(code_uge(0), cr1,l1); break; 3971 case LOP+UGE+BNOT: pcond(code_uge(0), cr1,l1); break;
3971 } 3972 }
3972 fwddef(l2); 3973 fwddef(l2);
3973 emit_lpop_free(e3); 3974 emit_lpop_free(e3);
3975 return l1;
3974 } 3976 }
3975 3977
3976 int 3978 int
3977 emit_lpop() 3979 emit_lpop()
3978 { 3980 {