Mercurial > hg > CbC > old > device
comparison mc-code-powerpc.c @ 433:b9566a04b6e2
*** empty log message ***
author | kono |
---|---|
date | Wed, 03 Nov 2004 13:28:09 +0900 (2004-11-03) |
parents | f8ebd7e1c644 |
children | d3e6359f8501 |
comparison
equal
deleted
inserted
replaced
432:f8ebd7e1c644 | 433:b9566a04b6e2 |
---|---|
1393 } else { | 1393 } else { |
1394 fwddef(e2); | 1394 fwddef(e2); |
1395 } | 1395 } |
1396 } | 1396 } |
1397 | 1397 |
1398 char * | 1398 #define code_gt(cond) (cond?"gt":"le") |
1399 code_gt(int cond) { | 1399 |
1400 return (cond?"gt":"le"); | 1400 #define code_ugt(cond) (cond?"gt":"le") |
1401 } | 1401 |
1402 | 1402 #define code_ge(cond) (cond?"ge":"lt") |
1403 char * | 1403 |
1404 code_ugt(int cond) { | 1404 #define code_uge(cond) (cond?"ge":"lt") |
1405 return (cond?"gt":"le"); | 1405 |
1406 } | 1406 #define code_eq(cond) (cond?"eq":"ne") |
1407 | |
1408 char * | |
1409 code_ge(int cond) { | |
1410 return (cond?"ge":"lt"); | |
1411 } | |
1412 | |
1413 char * | |
1414 code_uge(int cond) { | |
1415 return (cond?"ge":"lt"); | |
1416 } | |
1417 | |
1418 char * | |
1419 code_eq(int cond) { | |
1420 return (cond?"eq":"ne"); | |
1421 } | |
1422 | 1407 |
1423 static int cmpflag = 0; | 1408 static int cmpflag = 0; |
1424 | 1409 |
1425 static void | 1410 static void |
1426 inc_cmpflag() | 1411 inc_cmpflag() |
2670 | 2655 |
2671 void | 2656 void |
2672 rexpr(int e1, int l1, int cond,int t) | 2657 rexpr(int e1, int l1, int cond,int t) |
2673 { | 2658 { |
2674 char *s; | 2659 char *s; |
2675 switch(car(e1)) { | 2660 switch(car(e1)+BNOT*(!cond)) { |
2676 case GT: s=code_gt(cond); break; | 2661 case GT: s=code_gt(1); break; |
2677 case UGT: s=code_ugt(cond); break; | 2662 case UGT: s=code_ugt(1); break; |
2678 case GE: s=code_ge(cond); break; | 2663 case GE: s=code_ge(1); break; |
2679 case UGE: s=code_uge(cond); break; | 2664 case UGE: s=code_uge(1); break; |
2680 case LT: s=code_ge(!cond); break; | 2665 case LT: s=code_ge(!1); break; |
2681 case ULT: s=code_uge(!cond);break; | 2666 case ULT: s=code_uge(!1);break; |
2682 case LE: s=code_gt(!cond); break; | 2667 case LE: s=code_gt(!1); break; |
2683 case ULE: s=code_ugt(!cond);break; | 2668 case ULE: s=code_ugt(!1);break; |
2684 case EQ: s=code_eq(cond); break; | 2669 case EQ: s=code_eq(1); break; |
2685 case NEQ: s=code_eq(!cond); break; | 2670 case NEQ: s=code_eq(!1); break; |
2671 case GT+BNOT: s=code_gt(0); break; | |
2672 case UGT+BNOT: s=code_ugt(0); break; | |
2673 case GE+BNOT: s=code_ge(0); break; | |
2674 case UGE+BNOT: s=code_uge(0); break; | |
2675 case LT+BNOT: s=code_ge(!0); break; | |
2676 case ULT+BNOT: s=code_uge(!0);break; | |
2677 case LE+BNOT: s=code_gt(!0); break; | |
2678 case ULE+BNOT: s=code_ugt(!0);break; | |
2679 case EQ+BNOT: s=code_eq(0); break; | |
2680 case NEQ+BNOT: s=code_eq(!0); break; | |
2686 default: error(-1); | 2681 default: error(-1); |
2687 } | 2682 } |
2688 g_expr(list3((t==INT?CMP:UCMP),cadr(e1),caddr(e1))); | 2683 g_expr(list3((t==INT?CMP:UCMP),cadr(e1),caddr(e1))); |
2689 printf("\tb%s cr%d,L_%d\n",s,cmpflag,l1); | 2684 printf("\tb%s cr%d,L_%d\n",s,cmpflag,l1); |
2690 } | 2685 } |
3922 tosop(op1,regv_l(e3),regv_l(reg)); | 3917 tosop(op1,regv_l(e3),regv_l(reg)); |
3923 cr1 = cmpflag; | 3918 cr1 = cmpflag; |
3924 | 3919 |
3925 l2 = fwdlabel(); | 3920 l2 = fwdlabel(); |
3926 // cond==0 jump on false condtion ( if(x) => rexpr(.. cond=0 ...) ) | 3921 // cond==0 jump on false condtion ( if(x) => rexpr(.. cond=0 ...) ) |
3927 switch(op) { | 3922 switch(op+(!cond)*BNOT) { |
3928 case LOP+GT: | 3923 case LOP+GT: |
3929 case LOP+GE: | 3924 case LOP+GE: |
3930 pcond(code_gt(1),cr0,cond?l1:l2); | 3925 pcond(code_gt(1),cr0,1?l1:l2); |
3931 pcond(code_eq(0),cr0,cond?l2:l1); | 3926 pcond(code_eq(0),cr0,1?l2:l1); |
3932 break; | 3927 break; |
3933 case LOP+UGT: | 3928 case LOP+UGT: |
3934 case LOP+UGE: | 3929 case LOP+UGE: |
3935 pcond(code_ugt(1),cr0,cond?l1:l2); | 3930 pcond(code_ugt(1),cr0,1?l1:l2); |
3936 pcond(code_eq(0), cr0,cond?l2:l1); | 3931 pcond(code_eq(0), cr0,1?l2:l1); |
3937 break; | 3932 break; |
3938 case LOP+EQ: | 3933 case LOP+EQ: |
3939 pcond(code_eq(0),cr0,(cond?l2:l1)); | 3934 pcond(code_eq(0),cr0,(1?l2:l1)); |
3940 pcond(code_eq(cond),cr1,l1); | 3935 pcond(code_eq(cond),cr1,l1); |
3941 break; | 3936 break; |
3942 case LOP+NEQ: | 3937 case LOP+NEQ: |
3943 pcond(code_eq(0),cr0,(cond?l1:l2)); | 3938 pcond(code_eq(0),cr0,(1?l1:l2)); |
3944 pcond(code_eq(!cond),cr1,l1); | 3939 pcond(code_eq(!1),cr1,l1); |
3940 break; | |
3941 case LOP+GT+BNOT: | |
3942 case LOP+GE+BNOT: | |
3943 pcond(code_gt(1),cr0,0?l1:l2); | |
3944 pcond(code_eq(0),cr0,0?l2:l1); | |
3945 break; | |
3946 case LOP+UGT+BNOT: | |
3947 case LOP+UGE+BNOT: | |
3948 pcond(code_ugt(1),cr0,0?l1:l2); | |
3949 pcond(code_eq(0), cr0,0?l2:l1); | |
3950 break; | |
3951 case LOP+EQ+BNOT: | |
3952 pcond(code_eq(0),cr0,(0?l2:l1)); | |
3953 pcond(code_eq(0),cr1,l1); | |
3954 break; | |
3955 case LOP+NEQ+BNOT: | |
3956 pcond(code_eq(0),cr0,(0?l1:l2)); | |
3957 pcond(code_eq(!0),cr1,l1); | |
3945 break; | 3958 break; |
3946 default: | 3959 default: |
3947 error(-1); | 3960 error(-1); |
3948 } | 3961 } |
3949 switch(op) { | 3962 switch(op+BNOT*(!cond)) { |
3950 case LOP+GT: pcond(code_gt(cond), cr1,l1); break; | 3963 case LOP+GT: pcond(code_gt(1), cr1,l1); break; |
3951 case LOP+GE: pcond(code_ge(cond), cr1,l1); break; | 3964 case LOP+GE: pcond(code_ge(1), cr1,l1); break; |
3952 case LOP+UGT: pcond(code_ugt(cond), cr1,l1); break; | 3965 case LOP+UGT: pcond(code_ugt(1), cr1,l1); break; |
3953 case LOP+UGE: pcond(code_uge(cond), cr1,l1); break; | 3966 case LOP+UGE: pcond(code_uge(1), cr1,l1); break; |
3967 case LOP+GT+BNOT: pcond(code_gt(0), cr1,l1); break; | |
3968 case LOP+GE+BNOT: pcond(code_ge(0), cr1,l1); break; | |
3969 case LOP+UGT+BNOT: pcond(code_ugt(0), cr1,l1); break; | |
3970 case LOP+UGE+BNOT: pcond(code_uge(0), cr1,l1); break; | |
3954 } | 3971 } |
3955 fwddef(l2); | 3972 fwddef(l2); |
3956 emit_lpop_free(e3); | 3973 emit_lpop_free(e3); |
3957 } | 3974 } |
3958 | 3975 |