# HG changeset patch # User kono # Date 1085155070 -32400 # Node ID 5b50813d0c455f7c04c2521101ae8581ae8b3255 # Parent d5467cf30f58cc13c15766d9992b52a016821f8a MIPS 90% test passed. Self compile core dumped. diff -r d5467cf30f58 -r 5b50813d0c45 Changes --- a/Changes Fri May 21 21:29:40 2004 +0900 +++ b/Changes Sat May 22 00:57:50 2004 +0900 @@ -4385,3 +4385,6 @@ ということは、set_[dl]operand の問題か。 やっぱり register parallel assign を書くのが簡単だよね。 + +slt/beq ってのが、うまく動いてないみたいね。 + diff -r d5467cf30f58 -r 5b50813d0c45 mc-code-mips.c --- a/mc-code-mips.c Fri May 21 21:29:40 2004 +0900 +++ b/mc-code-mips.c Sat May 22 00:57:50 2004 +0900 @@ -1347,7 +1347,7 @@ char * code_ge(int cond) { - return code_gt(cond); + return code_gt(!cond); } char * @@ -1898,6 +1898,8 @@ if(scalar(t)) { nargs ++ ; reg_arg++; } else if (t==LONGLONG||t==ULONGLONG||t==DOUBLE) { + if (*preg_arg%2==1) reg_arg++; // alignment + if (*pnargs%2==1) nargs++; // alignment nargs ++ ; reg_arg++; nargs ++ ; reg_arg++; } else if (t==FLOAT) { @@ -1923,7 +1925,7 @@ if(scalar(t)) { if (mode==AS_SAVE) { return get_register_var(0); - } else if (reg_arg>=MAX_INPUT_REGISTER_VAR) { + } else if (reg_arg+1>MAX_INPUT_REGISTER_VAR) { return list2(LVAR,caller_arg_offset_v(nargs)); } else return get_input_register_var(reg_arg,0,0); @@ -2464,10 +2466,18 @@ case SUB: printf("\tsubu %s,%s,%s\n",crn,crn,orn); break; + case CMPGE: + printf("\tslt %s,%s,%s\n",crn,crn,orn); + cmpreg = creg; + break; case CMP: printf("\tslt %s,%s,%s\n",crn,orn,crn); cmpreg = creg; break; + case UCMPGE: + printf("\tsltu %s,%s,%s\n",crn,crn,orn); + cmpreg = creg; + break; case UCMP: printf("\tsltu %s,%s,%s\n",crn,orn,crn); cmpreg = creg; @@ -2640,15 +2650,21 @@ void rexpr(int e1, int l1, char *s,int t) { - int op; - if (car(e1)==EQ||car(e1)==NEQ) { - op = s?CMPEQ:CMPNEQ; - g_expr(list3(op,cadr(e1),caddr(e1))); - printf(",$L_%d\n",l1); + int op = car(e1); + if (op==EQ||op==NEQ) { + op = s?CMPEQ:CMPNEQ; + g_expr(list3(op,cadr(e1),caddr(e1))); + printf(",$L_%d\n",l1); } else { - op = t==INT?CMP:UCMP; - g_expr(list3(op,cadr(e1),caddr(e1))); - printf("\tb%s %s,$0,$L_%d\n",s,register_name(cmpreg),l1); + if (t==INT) { + if (op==LE||op==GE) op=CMPGE; + else op=CMP; + } else { + if (op==ULE||op==UGE) op=UCMPGE; + else op=UCMP; + } + g_expr(list3(op,cadr(e1),caddr(e1))); + printf("\tb%s %s,$0,$L_%d\n",s,register_name(cmpreg),l1); } } @@ -4010,11 +4026,14 @@ lcmp(int op,int cond) { if (op==LOP+EQ||op==LOP+NEQ) { - op=((op==LOP+EQ)^cond)?CMPNEQ:CMPEQ; + return ((op==LOP+EQ)^cond)?CMPNEQ:CMPEQ; + } else if (op==LOP+UGT||op==LOP+UGE) { + return UCMP; + } else if (op==LOP+LE||op==LOP+GE) { + return CMPGE; } else { - op = (op==LOP+UGT||op==LOP+UGE)?UCMP:CMP; + return CMP; } - return op; } void @@ -4034,7 +4053,7 @@ case LOP+GT: pcond(op,code_gt(cond),l1); break; case LOP+GE: - pcond(op,code_ge(!cond),l1); break; + pcond(op,code_ge(cond),l1); break; case LOP+EQ: pcond(op,code_eq(cond),l1); break; case LOP+NEQ: @@ -4055,7 +4074,7 @@ case LOP+GT: pcond(op,code_gt(cond),l1); break; case LOP+GE: - pcond(op,code_ge(!cond),l1); break; + pcond(op,code_ge(cond),l1); break; case LOP+EQ: pcond(op,code_eq(cond),l1); break; case LOP+NEQ: diff -r d5467cf30f58 -r 5b50813d0c45 mc-codegen.c --- a/mc-codegen.c Fri May 21 21:29:40 2004 +0900 +++ b/mc-codegen.c Sat May 22 00:57:50 2004 +0900 @@ -340,7 +340,7 @@ case MOD: case UMOD: case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT: case ADD: case SUB: case BAND: case EOR: case BOR: case CMP: case CMPGE: - case UCMP: case CMPEQ: case CMPNEQ: + case UCMP: case CMPEQ: case CMPNEQ: case UCMPGE: machinop(e1); return INT; #if FLOAT_CODE diff -r d5467cf30f58 -r 5b50813d0c45 mc-parse.c --- a/mc-parse.c Fri May 21 21:29:40 2004 +0900 +++ b/mc-parse.c Sat May 22 00:57:50 2004 +0900 @@ -2138,7 +2138,8 @@ { if(scalar(type)) return e2; #if FLOAT_CODE - if (car(e2)==DCONST||car(e2)==FCONST) return list2(CONST,(unsigned)dcadr(e2)); + // if (car(e2)==DCONST||car(e2)==FCONST) return list2(CONST,(unsigned)dcadr(e2)); + if (car(e2)==DCONST||car(e2)==FCONST) return list2(CONST,(int)dcadr(e2)); if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2U); if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2U); #endif diff -r d5467cf30f58 -r 5b50813d0c45 mc.h --- a/mc.h Fri May 21 21:29:40 2004 +0900 +++ b/mc.h Sat May 22 00:57:50 2004 +0900 @@ -232,15 +232,16 @@ #define LOR 56 #define ASS 57 #define UCMP 58 -#define CMPGE 59 -#define CMPEQ 60 -#define CMPNEQ 61 -#define ASSOP 62 -#define COMMA 63 +#define UCMPGE 59 +#define CMPGE 60 +#define CMPEQ 61 +#define CMPNEQ 62 +#define ASSOP 63 +#define COMMA 64 -#define CASS 64 -#define CASSOP 65 -#define CUASSOP 66 +#define CASS 65 +#define CASSOP 66 +#define CUASSOP 67 #define SASS (SOP+CASS) #define SASSOP (SOP+CASSOP) @@ -297,13 +298,13 @@ #define LBOR (LOP+BOR) -#define STASS 67 +#define STASS 68 #define BINARY_ARGS(i) (MUL<=(i%SOP)&&(i%SOP)<=STASS) /* tarnary argments */ -#define COND 68 +#define COND 69 #define SCOND (SOP+COND) #define DCOND (DOP+COND) #define FCOND (FOP+COND) @@ -313,19 +314,19 @@ /* not appeared as tags */ -#define I2I 69 -#define I2U 70 -#define I2D 71 -#define I2F 72 -#define I2LL 73 -#define I2ULL 74 +#define I2I 70 +#define I2U 71 +#define I2D 72 +#define I2F 73 +#define I2LL 74 +#define I2ULL 75 -#define U2I 75 -#define U2U 76 -#define U2D 77 -#define U2F 78 -#define U2LL 79 -#define U2ULL 80 +#define U2I 76 +#define U2U 77 +#define U2D 78 +#define U2F 79 +#define U2LL 80 +#define U2ULL 81 #define D2I (DOP+I2I) #define D2U (DOP+I2U) @@ -355,17 +356,17 @@ #define ULL2LL (LOP+U2LL) #define ULL2ULL (LOP+U2ULL) -#define LPAR 81 -#define RPAR 82 -#define LBRA 83 -#define RBRA 84 -#define LC 85 -#define RC 86 -#define COLON 87 -#define SM 88 -#define PERIOD 89 -#define ARROW 90 -#define CNAME 91 +#define LPAR 82 +#define RPAR 83 +#define LBRA 84 +#define RBRA 85 +#define LC 86 +#define RC 87 +#define COLON 88 +#define SM 89 +#define PERIOD 90 +#define ARROW 91 +#define CNAME 92 /* tree node tags end */ diff -r d5467cf30f58 -r 5b50813d0c45 test/short.c --- a/test/short.c Fri May 21 21:29:40 2004 +0900 +++ b/test/short.c Sat May 22 00:57:50 2004 +0900 @@ -6,8 +6,8 @@ unsigned short b[100]; unsigned char c[100]; -short data[] = {10,20,-40}; -unsigned short udata[] = {10,20,-40}; +short data[] = {10,20,-40,-50}; +unsigned short udata[] = {10,20,-40,-50}; short f(short i,unsigned short j,unsigned short k,short m,short a); unsigned