# HG changeset patch # User kono # Date 1082733515 -32400 # Node ID 8581c314e31a46a6a7b8c33aa7470ee12c3b17ec # Parent 32f54ab63b35ec083c1ba98d1cb8961da231ef2f obsf diff -r 32f54ab63b35 -r 8581c314e31a Changes --- a/Changes Fri Apr 23 03:27:01 2004 +0900 +++ b/Changes Sat Apr 24 00:18:35 2004 +0900 @@ -3953,3 +3953,15 @@ あと、もう少し! でも、2,3日かかりそう。 loprtc も、あった方がいいんじゃない? (まね....) +Fri Apr 23 14:40:02 JST 2004 + +あとは、switch, inline, stdargs, alloca かな。 asm もあるか。 +asm は、ちょっと趣旨から外れるからいいか。 + +PowerPC のalloca は、おかしい。おかしいよな。 + +join いれるの? + +a?a,b:a,b って許されるの? + +"" の中のマクロが展開されてしまうんですけど。(ま、そうなんだけど) diff -r 32f54ab63b35 -r 8581c314e31a Makefile --- a/Makefile Fri Apr 23 03:27:01 2004 +0900 +++ b/Makefile Sat Apr 24 00:18:35 2004 +0900 @@ -20,7 +20,7 @@ cp mc-$(ARCH) mc TAGS: - tags mc-code-powerpc.c mc-code.h mc-codegen.c mc-codegen.h \ + ctags mc-code-powerpc.c mc-code.h mc-codegen.c mc-codegen.h \ mc-parse.c mc-tree.c mc.h conv/c.c conv/c.h \ conv/conv.h conv/convdef.h conv/null.c diff -r 32f54ab63b35 -r 8581c314e31a mc-code-ia32.c --- a/mc-code-ia32.c Fri Apr 23 03:27:01 2004 +0900 +++ b/mc-code-ia32.c Sat Apr 24 00:18:35 2004 +0900 @@ -2173,6 +2173,9 @@ } +int code_lconst_op_p(int op,int e) {return 0;} +void loprtc(int op,int e) {} + void emit_lpop_free(int e1) { diff -r 32f54ab63b35 -r 8581c314e31a mc-code-mips.c --- a/mc-code-mips.c Fri Apr 23 03:27:01 2004 +0900 +++ b/mc-code-mips.c Sat Apr 24 00:18:35 2004 +0900 @@ -2842,6 +2842,9 @@ } +int code_lconst_op_p(int op,int e) {return 0;} +void loprtc(int op,int e) {} + void emit_lpop_free(int e1) { diff -r 32f54ab63b35 -r 8581c314e31a mc-code-powerpc.c --- a/mc-code-powerpc.c Fri Apr 23 03:27:01 2004 +0900 +++ b/mc-code-powerpc.c Sat Apr 24 00:18:35 2004 +0900 @@ -1985,7 +1985,6 @@ } void - oprtc(int op,int v) { char *crn = register_name(creg); @@ -3438,6 +3437,50 @@ if(oreg!=creg) free_register(oreg); } +int code_lconst_op_p(int op,int e) {return 0;} + +loprtc(int op,int v) +{ + char *crn = register_name(creg); + + switch(op) { + case LSHIFT: + case ULSHIFT: + printf("\tslwi %s,%s,%d\n",crn,crn,v); + return; + case RSHIFT: + printf("\tsrawi %s,%s,%d\n",crn,crn,v); + return; + case URSHIFT: + printf("\tsrwi %s,%s,%d\n",crn,crn,v); + return; + case ADD: + printf("\taddi %s,%s,lo16(%d)\n",crn,crn,v); + break; + case SUB: + printf("\tsubi %s,%s,lo16(%d)\n",crn,crn,v); + break; + case CMP: + printf("\tcmpwi cr0,%s,lo16(%d)\n",crn,v); + break; + case EOR: + printf("\txori %s,%s,lo16(%d)\n",crn,crn,v); + break; + case BOR: + printf("\tori %s,%s,lo16(%d)\n",crn,crn,v); + break; + case MUL: + printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); + break; + case UMUL: + printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v); + break; + default: + error(-1); + } +} + + void emit_lpop_free(int xreg) { @@ -3717,6 +3760,11 @@ if (float_zero_lib_used) emit_lib(float_zero_lib); if (i2d_lib_used) emit_lib(i2d_lib); #endif +#if LONGLONG_CODE +#if FLOAT_CODE + if (asld_lib_used) emit_lib(d2u_lib); +#endif +#endif global_table(); /* printf("\t.ident \"Micro-C compiled\"\n"); */ } diff -r 32f54ab63b35 -r 8581c314e31a mc-code.h --- a/mc-code.h Fri Apr 23 03:27:01 2004 +0900 +++ b/mc-code.h Sat Apr 24 00:18:35 2004 +0900 @@ -169,6 +169,8 @@ extern void ltosop(int,int); extern void emit_lpop_free(int); extern void emit_lpush(); +extern int code_lconst_op_p(int op,int e); +extern void loprtc(int op,int e); extern void code_i2ll(int creg); extern void code_i2ull(int creg); extern void code_u2ll(int creg); diff -r 32f54ab63b35 -r 8581c314e31a mc-codegen.c --- a/mc-codegen.c Fri Apr 23 03:27:01 2004 +0900 +++ b/mc-codegen.c Sat Apr 24 00:18:35 2004 +0900 @@ -1182,6 +1182,11 @@ e2 = cadr(e1); op = car(e1); e3 = caddr(e1); + if (code_lconst_op_p(op,e3)) { + g_expr(e2); + loprtc(op,e3); + return; + } g_expr(e3); emit_lpush(); g_expr(e2); diff -r 32f54ab63b35 -r 8581c314e31a mc-parse.c --- a/mc-parse.c Fri Apr 23 03:27:01 2004 +0900 +++ b/mc-parse.c Sat Apr 24 00:18:35 2004 +0900 @@ -1393,10 +1393,10 @@ /* f(a,b,c) { int c; short a; char* b;} case */ // fprintf(stderr,"arg_reorder old:\n"); - for(j=new_arg;j;j=cadr(j)) { - n=(NMTBL *)caddr(j); +// for(j=new_arg;j;j=cadr(j)) { +// n=(NMTBL *)caddr(j); // fprintf(stderr,"dsp %d %s sz %d type %d\n",n->dsp,n->nm,cadddr(j),car(j)); - } +// } // fprintf(stderr,"arg_reorder new:\n"); for(j=arg;j;j=cadr(j)) { n=(NMTBL *)caddr(j); @@ -1406,6 +1406,10 @@ // if (n1==n) break; } // fprintf(stderr,"dsp %d %s %s sz %d type %d\n",dsp,n->nm,n1->nm,cadddr(i),car(i)); + if (!i) { + /* f(a,b,c) { int c; } case (what?!) */ + i = j; + } if(n->sc==LVAR) { n->dsp = dsp; car(j)=car(i); @@ -2276,7 +2280,7 @@ e1=rvalue(e1); getsym(0); conv->cond1_(); - e2=rvalue(expr2()); + e2=rvalue(expr0()); t=type; conv->cond2_(); checksym(COLON); diff -r 32f54ab63b35 -r 8581c314e31a mc.h --- a/mc.h Fri Apr 23 03:27:01 2004 +0900 +++ b/mc.h Sat Apr 24 00:18:35 2004 +0900 @@ -11,7 +11,7 @@ #endif #define FLOAT_CODE 1 -#define LONGLONG_CODE 1 +#define LONGLONG_CODE 0 #define SIZE_INT 4 diff -r 32f54ab63b35 -r 8581c314e31a rsyncs --- a/rsyncs Fri Apr 23 03:27:01 2004 +0900 +++ b/rsyncs Sat Apr 24 00:18:35 2004 +0900 @@ -3,7 +3,7 @@ --exclude '*.o' --exclude '*.s' --exclude mc --exclude mc1 \ --exclude mc-ia32 --exclude mc-powerpc --exclude CVS \ --exclude '*.bak' --exclude '*.out' \ - kono@"$1":~/src/device /root + kono@"$1":~/src/device $HOME # touch Makefile *.c conv_* *.h */*.[hc] # make clean cp .gdbinit.ia32 .gdbinit diff -r 32f54ab63b35 -r 8581c314e31a test/obsf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/obsf.c Sat Apr 24 00:18:35 2004 +0900 @@ -0,0 +1,18 @@ +#include + +main(t,_,a) +char *a; +{return!0