Mercurial > hg > CbC > old > device
changeset 433:b9566a04b6e2
*** empty log message ***
author | kono |
---|---|
date | Wed, 03 Nov 2004 13:28:09 +0900 |
parents | f8ebd7e1c644 |
children | 6927ec51c1d7 |
files | mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c |
diffstat | 4 files changed, 71 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-arm.c Sun Oct 31 12:20:30 2004 +0900 +++ b/mc-code-arm.c Wed Nov 03 13:28:09 2004 +0900 @@ -1792,31 +1792,6 @@ } } -char * -code_gt(int cond) { - return (cond?"le":"gt"); -} - -char * -code_ugt(int cond) { - return (cond?"ls":"hi"); -} - -char * -code_ge(int cond) { - return (cond?"lt":"ge"); -} - -char * -code_uge(int cond) { - return (cond?"lo":"hs"); -} - -char * -code_eq(int cond) { - return (cond?"ne":"eq"); -} - void code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) { @@ -6069,7 +6044,7 @@ } else { // use_int(adr); use_int(reg); - code_ld(cload(0,0),reg,0,adr,cext_at(0,0)); + code_ld(cload(size,sign),reg,0,adr,cext_at(0,0)); /* shift left */ if ((i=32-bitsize-bitpos)) oprtc(LSHIFT,reg,list2(CONST,i));
--- a/mc-code-ia32.c Sun Oct 31 12:20:30 2004 +0900 +++ b/mc-code-ia32.c Wed Nov 03 13:28:09 2004 +0900 @@ -968,27 +968,27 @@ } } -char * +static char * code_gt(int cond) { return (cond?"g":"le"); } -char * +static char * code_ugt(int cond) { return (cond?"a":"be"); } -char * +static char * code_ge(int cond) { return (cond?"ge":"l"); } -char * +static char * code_uge(int cond) { return (cond?"ae":"b"); } -char * +static char * code_eq(int cond) { return (cond?"e":"ne"); }
--- a/mc-code-mips.c Sun Oct 31 12:20:30 2004 +0900 +++ b/mc-code-mips.c Wed Nov 03 13:28:09 2004 +0900 @@ -1435,31 +1435,6 @@ } } -char * -code_gt(int cond) { - return (cond?"ne":"eq"); -} - -char * -code_ugt(int cond) { - return code_gt(cond); -} - -char * -code_ge(int cond) { - return code_gt(!cond); -} - -char * -code_uge(int cond) { - return code_gt(!cond); -} - -char * -code_eq(int cond) { - return cond?"":0; -} - void code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) {
--- a/mc-code-powerpc.c Sun Oct 31 12:20:30 2004 +0900 +++ b/mc-code-powerpc.c Wed Nov 03 13:28:09 2004 +0900 @@ -1395,30 +1395,15 @@ } } -char * -code_gt(int cond) { - return (cond?"gt":"le"); -} - -char * -code_ugt(int cond) { - return (cond?"gt":"le"); -} - -char * -code_ge(int cond) { - return (cond?"ge":"lt"); -} - -char * -code_uge(int cond) { - return (cond?"ge":"lt"); -} - -char * -code_eq(int cond) { - return (cond?"eq":"ne"); -} +#define code_gt(cond) (cond?"gt":"le") + +#define code_ugt(cond) (cond?"gt":"le") + +#define code_ge(cond) (cond?"ge":"lt") + +#define code_uge(cond) (cond?"ge":"lt") + +#define code_eq(cond) (cond?"eq":"ne") static int cmpflag = 0; @@ -2672,17 +2657,27 @@ rexpr(int e1, int l1, int cond,int t) { char *s; - switch(car(e1)) { - case GT: s=code_gt(cond); break; - case UGT: s=code_ugt(cond); break; - case GE: s=code_ge(cond); break; - case UGE: s=code_uge(cond); break; - case LT: s=code_ge(!cond); break; - case ULT: s=code_uge(!cond);break; - case LE: s=code_gt(!cond); break; - case ULE: s=code_ugt(!cond);break; - case EQ: s=code_eq(cond); break; - case NEQ: s=code_eq(!cond); break; + switch(car(e1)+BNOT*(!cond)) { + case GT: s=code_gt(1); break; + case UGT: s=code_ugt(1); break; + case GE: s=code_ge(1); break; + case UGE: s=code_uge(1); break; + case LT: s=code_ge(!1); break; + case ULT: s=code_uge(!1);break; + case LE: s=code_gt(!1); break; + case ULE: s=code_ugt(!1);break; + case EQ: s=code_eq(1); break; + case NEQ: s=code_eq(!1); break; + case GT+BNOT: s=code_gt(0); break; + case UGT+BNOT: s=code_ugt(0); break; + case GE+BNOT: s=code_ge(0); break; + case UGE+BNOT: s=code_uge(0); break; + case LT+BNOT: s=code_ge(!0); break; + case ULT+BNOT: s=code_uge(!0);break; + case LE+BNOT: s=code_gt(!0); break; + case ULE+BNOT: s=code_ugt(!0);break; + case EQ+BNOT: s=code_eq(0); break; + case NEQ+BNOT: s=code_eq(!0); break; default: error(-1); } g_expr(list3((t==INT?CMP:UCMP),cadr(e1),caddr(e1))); @@ -3924,33 +3919,55 @@ l2 = fwdlabel(); // cond==0 jump on false condtion ( if(x) => rexpr(.. cond=0 ...) ) - switch(op) { + switch(op+(!cond)*BNOT) { case LOP+GT: case LOP+GE: - pcond(code_gt(1),cr0,cond?l1:l2); - pcond(code_eq(0),cr0,cond?l2:l1); + pcond(code_gt(1),cr0,1?l1:l2); + pcond(code_eq(0),cr0,1?l2:l1); break; case LOP+UGT: case LOP+UGE: - pcond(code_ugt(1),cr0,cond?l1:l2); - pcond(code_eq(0), cr0,cond?l2:l1); + pcond(code_ugt(1),cr0,1?l1:l2); + pcond(code_eq(0), cr0,1?l2:l1); break; case LOP+EQ: - pcond(code_eq(0),cr0,(cond?l2:l1)); + pcond(code_eq(0),cr0,(1?l2:l1)); pcond(code_eq(cond),cr1,l1); break; case LOP+NEQ: - pcond(code_eq(0),cr0,(cond?l1:l2)); - pcond(code_eq(!cond),cr1,l1); + pcond(code_eq(0),cr0,(1?l1:l2)); + pcond(code_eq(!1),cr1,l1); + break; + case LOP+GT+BNOT: + case LOP+GE+BNOT: + pcond(code_gt(1),cr0,0?l1:l2); + pcond(code_eq(0),cr0,0?l2:l1); + break; + case LOP+UGT+BNOT: + case LOP+UGE+BNOT: + pcond(code_ugt(1),cr0,0?l1:l2); + pcond(code_eq(0), cr0,0?l2:l1); + break; + case LOP+EQ+BNOT: + pcond(code_eq(0),cr0,(0?l2:l1)); + pcond(code_eq(0),cr1,l1); + break; + case LOP+NEQ+BNOT: + pcond(code_eq(0),cr0,(0?l1:l2)); + pcond(code_eq(!0),cr1,l1); break; default: error(-1); } - switch(op) { - case LOP+GT: pcond(code_gt(cond), cr1,l1); break; - case LOP+GE: pcond(code_ge(cond), cr1,l1); break; - case LOP+UGT: pcond(code_ugt(cond), cr1,l1); break; - case LOP+UGE: pcond(code_uge(cond), cr1,l1); break; + switch(op+BNOT*(!cond)) { + case LOP+GT: pcond(code_gt(1), cr1,l1); break; + case LOP+GE: pcond(code_ge(1), cr1,l1); break; + case LOP+UGT: pcond(code_ugt(1), cr1,l1); break; + case LOP+UGE: pcond(code_uge(1), cr1,l1); break; + case LOP+GT+BNOT: pcond(code_gt(0), cr1,l1); break; + case LOP+GE+BNOT: pcond(code_ge(0), cr1,l1); break; + case LOP+UGT+BNOT: pcond(code_ugt(0), cr1,l1); break; + case LOP+UGE+BNOT: pcond(code_uge(0), cr1,l1); break; } fwddef(l2); emit_lpop_free(e3);