Mercurial > hg > CbC > old > device
changeset 555:ac181d7f9c82
IA32 eval order
author | kono |
---|---|
date | Fri, 06 Jan 2006 01:16:52 +0900 |
parents | dc677ac7a744 |
children | ef225b589888 |
files | Changes mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-code.h mc-inline.c |
diffstat | 7 files changed, 63 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Thu Jan 05 23:37:19 2006 +0900 +++ b/Changes Fri Jan 06 01:16:52 2006 +0900 @@ -7894,6 +7894,9 @@ linux kernelは一応、通りました。IA32 でinlineで関数の引数の 呼ばれる順序が変わる。あと、scope.c のinlineがだめだな。 なにか、まずいことをやっているのか? signed? + return list3(COMMA,pexpr(e1),pexpr(e2)); +みたいなことをやると、IA32では引数の呼び出し順序が異なるので、 +p_decl とかがずれるみたいだね。この手のを全部取らないとダメだ。 IA32のis_writableに RLVAR が入るのは何故? @@ -7905,3 +7908,4 @@ ia32 では emit_pop_free で creg かどうか見てるみたいね。それでも いいんだけど... +
--- a/mc-code-arm.c Thu Jan 05 23:37:19 2006 +0900 +++ b/mc-code-arm.c Fri Jan 06 01:16:52 2006 +0900 @@ -81,6 +81,8 @@ #define ENDIAN_L 0 #define ENDIAN_D 1 +int eval_order = NORMAL; + static int reg_sp; /* REGister Stack-Pointer */ static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
--- a/mc-code-ia32.c Thu Jan 05 23:37:19 2006 +0900 +++ b/mc-code-ia32.c Fri Jan 06 01:16:52 2006 +0900 @@ -28,7 +28,7 @@ #define ENDIAN_L 0 #define ENDIAN_D 0 - +int eval_order = REVERSE; #define TEXT_EMIT_MODE 0 #define DATA_EMIT_MODE 1
--- a/mc-code-mips.c Thu Jan 05 23:37:19 2006 +0900 +++ b/mc-code-mips.c Fri Jan 06 01:16:52 2006 +0900 @@ -38,6 +38,7 @@ #define alloca __builtin_alloca\n\ "; +int eval_order = NORMAL; int data_alignment = 0; #define TEXT_EMIT_MODE 0
--- a/mc-code-powerpc.c Thu Jan 05 23:37:19 2006 +0900 +++ b/mc-code-powerpc.c Fri Jan 06 01:16:52 2006 +0900 @@ -39,6 +39,7 @@ static void ascii(char *s); +int eval_order = NORMAL; static int creg;
--- a/mc-code.h Thu Jan 05 23:37:19 2006 +0900 +++ b/mc-code.h Fri Jan 06 01:16:52 2006 +0900 @@ -10,6 +10,9 @@ extern char *l_include_path[]; /* library including path */ extern int disp_offset; /* displacement offset in code and function */ +#define NORMAL 0 +#define REVERSE 1 +extern int eval_order; extern int MAX_REGISTER; extern int MAX_REGISTGER_VAR;
--- a/mc-inline.c Thu Jan 05 23:37:19 2006 +0900 +++ b/mc-inline.c Fri Jan 06 01:16:52 2006 +0900 @@ -456,67 +456,85 @@ pbinop(int op,int e1,int e2) { // we should call binop here, but we don't know the type... - return list3(op,pexpr(e1),pexpr(e2)); + int e = pexpr(e1); + return list3(op,e,pexpr(e2)); } static int prexpr(int op,int e1,int e2) { - return list3(op,pexpr(e1),pexpr(e2)); + int e = pexpr(e1); + return list3(op,e,pexpr(e2)); } static int plor(int op,int e1,int e2) { - return list3(op,pexpr(e1),pexpr(e2)); + int e = pexpr(e1); + return list3(op,e,pexpr(e2)); } static int pland(int op,int e1,int e2) { - return list3(op,pexpr(e1),pexpr(e2)); + int e = pexpr(e1); + return list3(op,e,pexpr(e2)); } static int psassign(int e) { - return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); + int e1 = pexpr(cadr(e)); + int e2 = pexpr(caddr(e)); + return list4(car(e),e1,e2,cadddr(e)); } static int passign(int e) { - return list3(car(e),pexpr(cadr(e)),pexpr(caddr(e))); + int e1 = pexpr(cadr(e)); + int e2 = pexpr(caddr(e)); + return list3(car(e),e1,e2); } static int passop(int e) { - return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); + int e1 = pexpr(cadr(e)); + int e2 = pexpr(caddr(e)); + return list4(car(e),e1,e2,cadddr(e)); } static int pdassign(int e) { - return list3(car(e),pexpr(cadr(e)),pexpr(caddr(e))); + int e1 = pexpr(cadr(e)); + int e2 = pexpr(caddr(e)); + return list3(car(e),e1,e2); } static int pdassop(int e) { - return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); + int e1 = pexpr(cadr(e)); + int e2 = pexpr(caddr(e)); + return list4(car(e),e1,e2,cadddr(e)); } static int plassign(int e) { - return list3(car(e),pexpr(cadr(e)),pexpr(caddr(e))); + int e1 = pexpr(cadr(e)); + int e2 = pexpr(caddr(e)); + return list3(car(e),e1,e2); } static int plassop(int e) { - return list4(car(e),pexpr(cadr(e)),pexpr(caddr(e)),cadddr(e)); + int e1 = pexpr(cadr(e)); + int e2 = pexpr(caddr(e)); + return list4(car(e),e1,e2,cadddr(e)); } static int @@ -528,7 +546,8 @@ static int pcomma(int e1,int e2) { - return list3(COMMA,pexpr(e1),pexpr(e2)); + int e = pexpr(cadr(e1)); + return list3(COMMA,e,pexpr(e2)); } static int @@ -704,11 +723,12 @@ static int p_goto(int e) { - int e1,lb; + int e1,lb,e2; if ((e1=caddr(e))) { switch(car(e1)) { case RINDIRECT: e1=pexpr(e1); break; - case CODE: e1=list3(CODE,pexpr(cadr(e1)),pexpr(caddr(e1))); break; + case CODE: e2=pexpr(cadr(e1)); + e1=list3(CODE,e2,pexpr(caddr(e1))); break; case FLABEL: /* error(-1); */ break; case IVAR: lb = cadr(e1); @@ -946,11 +966,12 @@ #endif return pbinop(car(e1),e2,caddr(e1)); case LCOND: case DCOND: case FCOND: case COND: case UCOND: case LUCOND: - e3 = pexpr(e2); - if (car(e3)==CONST) return - caddr(e1)? pexpr(cadr(e3)?caddr(e1):cadddr(e1)) : - pexpr(cadr(e3)?e3:cadddr(e1)); // GNU extension h?:g - return list4(car(e1),e3,pexpr(caddr(e1)),pexpr(cadddr(e1))); + e2 = pexpr(e2); + if (car(e2)==CONST) return + caddr(e1)? pexpr(cadr(e2)?caddr(e1):cadddr(e1)) : + pexpr(cadr(e2)?e2:cadddr(e1)); // GNU extension h?:g + e3=pexpr(caddr(e1)); + return list4(car(e1),e2,e3,pexpr(cadddr(e1))); case STASS: return psassign(e1); case ASS: case CASS: case SASS: @@ -975,7 +996,7 @@ case BUILTINP: return list2(CONST,is_const(pexpr(e2))); case COMMA: - return pcomma(pexpr(e2),pexpr(caddr(e1))); + return pcomma(e2,caddr(e1)); case RETURN: case ENVIRONMENT: case LCALL: @@ -1065,6 +1086,7 @@ int e2,e3,t,e4,e5,dots; int ret_type = function_type(cadddr(e),&dots); int fargtype; + int evals = 0; NMTBL *anptr; checkret(); @@ -1116,12 +1138,20 @@ // should contain correct argument variable name // if (anptr) printf("## var %s\n",anptr->nm); // else printf("## var 0\n"); - g_expr_u(assign_expr0(arg,e4,anptr->ty,t)); + if (eval_order==REVERSE) { + evals=list2(assign_expr0(arg,e4,anptr->ty,t),evals); + } else + g_expr_u(assign_expr0(arg,e4,anptr->ty,t)); } narg ++; fargtype = cadr(fargtype); } caddr(e) = reverse0(e5); // make it normal + if (eval_order==REVERSE) { + for(;evals;evals=cadr(evals)) { + g_expr_u(car(evals)); + } + } no_args: e2 = pexpr(parse); pdisp = sdisp;