Mercurial > hg > CbC > old > device
changeset 704:6e6dc2d644ed
*** empty log message ***
author | kono |
---|---|
date | Wed, 24 Oct 2007 00:13:06 +0900 |
parents | 874adc2528f9 |
children | 0554b7f985ee |
files | Makefile Makefile.ia32 mc-codegen.c mc-inline.c mc-parse.c mc.h test/comp.c |
diffstat | 7 files changed, 163 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Tue Oct 23 16:19:09 2007 +0900 +++ b/Makefile Wed Oct 24 00:13:06 2007 +0900 @@ -267,3 +267,61 @@ # DO NOT DELETE +mc-code-ia32.o: /usr/include/stdio.h /usr/include/_types.h +mc-code-ia32.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-code-ia32.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-code-ia32.o: mc-parse.h mc-codegen.h mc-code.h mc-include.c +mc-codegen.o: /usr/include/stdio.h /usr/include/_types.h +mc-codegen.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-codegen.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-codegen.o: mc-parse.h mc-codegen.h mc-code.h mc-switch.h mc-inline.h +mc-codegen.o: conv/conv.h +mc-parse.o: /usr/include/stdio.h /usr/include/_types.h +mc-parse.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-parse.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-parse.o: mc-parse.h mc-codegen.h mc-switch.h mc-macro.h mc-inline.h +mc-parse.o: conv/conv.h +mc-tree.o: /usr/include/stdio.h /usr/include/_types.h +mc-tree.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-tree.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-tree.o: mc-parse.h mc-codegen.h +mc-switch.o: /usr/include/stdio.h /usr/include/_types.h +mc-switch.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-switch.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-switch.o: mc-parse.h mc-codegen.h mc-code.h +mc-inline.o: /usr/include/stdio.h /usr/include/_types.h +mc-inline.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-inline.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-inline.o: mc-parse.h mc-codegen.h mc-switch.h mc-code.h mc-inline.h +mc-macro.o: /usr/include/stdio.h /usr/include/_types.h +mc-macro.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-macro.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-macro.o: mc-parse.h mc-macro.h mc-codegen.h mc-code.h +conv/c.o: /usr/include/stdio.h /usr/include/_types.h +conv/c.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +conv/c.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +conv/c.o: mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h conv/c.h +conv/c2cbc.o: /usr/include/stdio.h /usr/include/_types.h +conv/c2cbc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +conv/c2cbc.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +conv/c2cbc.o: mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h conv/c2cbc.h +conv/cbc2c.o: /usr/include/stdio.h /usr/include/_types.h +conv/cbc2c.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +conv/cbc2c.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +conv/cbc2c.o: mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h conv/cbc2c.h +conv/null.o: /usr/include/stdio.h /usr/include/_types.h +conv/null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +conv/null.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +conv/null.o: mc-parse.h conv/conv.h conv/convdef.h conv/null.h +mc-code-arm.o: /usr/include/stdio.h /usr/include/_types.h +mc-code-arm.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-code-arm.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-code-arm.o: mc-parse.h mc-code.h mc-codegen.h +mc-code-powerpc.o: /usr/include/stdio.h /usr/include/_types.h +mc-code-powerpc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-code-powerpc.o: /usr/include/machine/_types.h /usr/include/i386/_types.h +mc-code-powerpc.o: mc.h mc-parse.h mc-code.h mc-codegen.h mc-include.c +mc-code-mips.o: /usr/include/stdio.h /usr/include/_types.h +mc-code-mips.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h +mc-code-mips.o: /usr/include/machine/_types.h /usr/include/i386/_types.h mc.h +mc-code-mips.o: mc-parse.h mc-code.h mc-codegen.h mc-include.c
--- a/Makefile.ia32 Tue Oct 23 16:19:09 2007 +0900 +++ b/Makefile.ia32 Wed Oct 24 00:13:06 2007 +0900 @@ -1,5 +1,4 @@ -# CC = gcc -std=c99 -CC = cc +CC = gcc -std=c99 $(CCEXT) # -O3 MCFLAGS = -DUSE_CODE_KEYWORD CFLAGS = -g -O -Wall -I. $(MCFLAGS) @@ -26,6 +25,9 @@ all: mc +ppc: + make ARCH=powerpc CCEXT="-arch ppc" check-all + mc: mc-$(ARCH) cp mc-$(ARCH) mc @@ -37,19 +39,19 @@ mc-inline.h mc-inline.c \ conv/conv.h conv/convdef.h conv/null.c -mc-powerpc :mc-include.c mc-code-powerpc.o $(COMPLIB) $(CONVERTER) +mc-powerpc :conv/conv.h mc-include.c mc-code-powerpc.o $(COMPLIB) $(CONVERTER) $(CC) $(LDFLAGS) -g mc-code-powerpc.o $(COMPLIB) $(CONVERTER) -o $@ -mc-ia32 :mc-include.c mc-code-ia32.o $(COMPLIB) $(CONVERTER) +mc-ia32 :conv/conv.h mc-include.c mc-code-ia32.o $(COMPLIB) $(CONVERTER) $(CC) $(LDFLAGS) -g mc-code-ia32.o $(COMPLIB) $(CONVERTER) -o $@ -mc-mips :mc-include.c mc-code-mips.o $(COMPLIB) $(CONVERTER) +mc-mips :conv/conv.h mc-include.c mc-code-mips.o $(COMPLIB) $(CONVERTER) $(CC) $(LDFLAGS) -g mc-code-mips.o $(COMPLIB) $(CONVERTER) -o $@ -mc-arm :mc-include.c mc-code-arm.o $(COMPLIB) $(CONVERTER) +mc-arm :conv/conv.h mc-include.c mc-code-arm.o $(COMPLIB) $(CONVERTER) $(CC) $(LDFLAGS) -g mc-code-arm.o $(COMPLIB) $(CONVERTER) -o $@ -mc-spu :mc-include.c mc-code-spu.o $(COMPLIB) $(CONVERTER) +mc-spu :conv/conv.h mc-include.c mc-code-spu.o $(COMPLIB) $(CONVERTER) $(CC) $(LDFLAGS) -g mc-code-spu.o $(COMPLIB) $(CONVERTER) -o $@ conv/conv.h: conv_func.tbl tools/conv_func.pl @@ -89,6 +91,7 @@ make check TARGET=test/tmp12 make check TARGET=test/tmp5 make check TARGET=test/tmp7 + make check-inline TARGET=test/tmp7 make check TARGET=test/tmp8 make check TARGET=test/tmp9 make check TARGET=test/enum @@ -132,7 +135,7 @@ make check-code$(MK) TARGET=test/throw make check-code$(MK) TARGET=test/too-long-argument -check-nkf: +check-nkf: mc ( cd nkf203; $(CC) -g -o nkf1 nkf.c utf8tbl.c ) ( cd nkf203; ../mc-$(ARCH) -s nkf.c utf8tbl.c ) ( cd nkf203; $(CC) -g -o nkf nkf.s utf8tbl.s )
--- a/mc-codegen.c Tue Oct 23 16:19:09 2007 +0900 +++ b/mc-codegen.c Wed Oct 24 00:13:06 2007 +0900 @@ -723,6 +723,8 @@ b_expr(int e1, char cond, int l1,int err) { int e2,l2,t; + code_save_stacks(); + if (!control) return l1; l2 = 0; e2=cadr(e1); @@ -4101,6 +4103,7 @@ { int lastexp0; if (!inmode) { + code_save_stacks(); // because of statment expression if (cslabel==0) { if (!control) error(CSERR); // no execute code in switch checkjmp(0);
--- a/mc-inline.c Tue Oct 23 16:19:09 2007 +0900 +++ b/mc-inline.c Wed Oct 24 00:13:06 2007 +0900 @@ -1528,7 +1528,7 @@ pvartable = p_vartable(arg_disp, /* number of arg */ caddr(e1) /* number of local parameter */); - replace = is_code(fnptr); + replace = (is_code(fnptr)||toplevel); /* function arguments type */ fargtype = n->dsp; // we cannot do destruct reverse here @@ -1639,13 +1639,20 @@ cslabel = -1; retpending = 0; - ret_reg_mode = 0; - ret_register = 5555; inline_lvars = 0; retlabel = fwdlabel(); enter_inline(n,e,toplevel); + if (toplevel) { + code_set_return_register(0); // fnptr required + ret_reg_mode = 1; + ret_register = code_get_fixed_creg(USE_CREG,ret_type); + } else { + ret_reg_mode = 0; + ret_register = 555; + } + // partial evaluation of parse tree // constant propergation, etc. parse = pexpr(parse);
--- a/mc-parse.c Tue Oct 23 16:19:09 2007 +0900 +++ b/mc-parse.c Wed Oct 24 00:13:06 2007 +0900 @@ -1129,16 +1129,14 @@ getsym(0); t=LONGLONG; if (sym==INT) getsym(0); - // else if (sym==UNSIGNED) { t=ULONGLONG; getsym(0); break; } -> 3 lines - else if (sym==UNSIGNED) { - if(getsym(0)==INT) getsym(0); - t=ULONGLONG; break; - } // + else if (sym==UNSIGNED) { + if(getsym(0)==INT) getsym(0); + t=ULONGLONG; break; + } // } else if(sym==DOUBLE) { getsym(0); t=DOUBLE; } else if(sym==INT) { getsym(0); - // } else if(sym==UNSIGNED) { t=UNSIGNED; getsym(0); } -> 4 lines } else if(sym==UNSIGNED) { if(getsym(0)==INT) getsym(0); t=UNSIGNED; @@ -4910,9 +4908,26 @@ Tokenizer */ +#if 0 +extern int +getsym0(int sc); + extern int getsym(int sc) { + int a = getsym0(sc); + fprintf(stderr,"sym = %d, %s glineno %d\n", a, nptr?nptr->nm?nptr->nm:"":"", + glineno); + return a; +} + +extern int +getsym0(int sc) +#else +extern int +getsym(int sc) +#endif +{ NMTBL *nlist,*nptr0,*nptrm; char c;
--- a/mc.h Tue Oct 23 16:19:09 2007 +0900 +++ b/mc.h Wed Oct 24 00:13:06 2007 +0900 @@ -578,7 +578,7 @@ extern void print_expr(int e, FILE *vout); -#if 1 +#if 0 extern int heapsize; #define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<=0)error(-1);_k;}) #else
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/comp.c Wed Oct 24 00:13:06 2007 +0900 @@ -0,0 +1,59 @@ +extern int printf(const char *,...); + +int heapsize; +#if 1 +#define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<=0)error(-1);_k;}) +#else +#define CHECK_HEAP(b) (b) +#endif + +#define car(e) (heap[(int)(CHECK_HEAP(e))]) + +#define cadr(e) (heap[((int)(CHECK_HEAP(e)))+1]) + +#define caddr(e) (heap[((int)(CHECK_HEAP(e)))+2]) + +#define cadddr(e) (heap[((int)(CHECK_HEAP(e)))+3]) + +#define caddddr(e) (heap[((int)(CHECK_HEAP(e)))+4]) + +#define HEAP_SIZE (1024) + +#if 0 +int heap0[HEAP_SIZE]; +int *heap = heap0; +#else +int heap[HEAP_SIZE]; +#endif + +int v; + +void +error(int v) +{ + printf("error %d\n",v); +} + +int +main() +{ + int j; + + heapsize = HEAP_SIZE; + + for(j=1;j<5;j++) + caddr(j) = j; + v = 5; + + for(j=0;j<5;j++) + printf("%d\n",caddr(j)); + + for(j=1,v=5;j<5;j++,v++) + caddr(v) = cadr(j); + + for(j=5;j<=v;j++) + printf("%d\n",caddr(j)); + + caddr(HEAP_SIZE+5); + +}