Mercurial > hg > CbC > old > device
changeset 213:8581c314e31a
obsf
author | kono |
---|---|
date | Sat, 24 Apr 2004 00:18:35 +0900 |
parents | 32f54ab63b35 |
children | 4f459364c334 |
files | Changes Makefile mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-code.h mc-codegen.c mc-parse.c mc.h rsyncs test/obsf.c |
diffstat | 11 files changed, 103 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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 って許されるの? + +"" の中のマクロが展開されてしまうんですけど。(ま、そうなんだけど)
--- 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
--- 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) {
--- 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) {
--- 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"); */ }
--- 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);
--- 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);
--- 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);
--- 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
--- 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
--- /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 <stdio.h> + +main(t,_,a) +char *a; +{return!0<t?t<3?main(-79,-13,a+main(-87,1-_, +main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a +)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_, +t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\ +,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\ ++k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\ +l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\ +n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \ +;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#\ +'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/") +:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\ ++1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \ +i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);} +