Mercurial > hg > CbC > old > device
changeset 466:7c3d8237b625 gcc40
*** empty log message ***
author | kono |
---|---|
date | Mon, 16 May 2005 11:53:56 +0900 |
parents | cdf827b1fcd9 |
children | 32737bad7489 |
files | Changes Makefile conv_func.pl mc-code-ia32.c mc-h-renum.pl tools/conv_func.pl tools/incpri.pl tools/mc-h-renum.pl tools/regs.pl tools/regs_use.pl |
diffstat | 10 files changed, 214 insertions(+), 163 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Tue Mar 01 14:54:15 2005 +0900 +++ b/Changes Mon May 16 11:53:56 2005 +0900 @@ -7147,3 +7147,26 @@ また、あいだが空いているよ。string と const の再利用がいまいちだね。 +Tue Mar 1 14:55:55 JST 2005 + +arm なんだけど、post increment とかあるよね。さぼらずにやろう。 + ldrb ip, [r0, #1]! +あと、arm は、predication をちゃんとやらないとgccには勝てないね。 +まぁ、できないことはないんだろうけど、めんどくさそう。peep hole +的に? まぁ、inline mode でやるしかないでしょうね。 + + sub ip, fp, #68 + ldmia ip!, {r0, r1, r2, r3} + stmia lr!, {r0, r1, r2, r3} + ldmia ip!, {r0, r1, r2, r3} + stmia lr!, {r0, r1, r2, r3} + +これは.... memcpy なのか。 + + + + + + + +
--- a/Makefile Tue Mar 01 14:54:15 2005 +0900 +++ b/Makefile Mon May 16 11:53:56 2005 +0900 @@ -46,15 +46,15 @@ mc-arm : mc-code-arm.o $(COMPLIB) $(CONVERTER) $(CC) $(LDFLAGS) -g mc-code-arm.o $(COMPLIB) $(CONVERTER) -o $@ -conv/conv.h: conv_func.tbl conv_func.pl - perl conv_func.pl -conv/convdef.h: conv_func.tbl conv_func.pl - perl conv_func.pl -conv/null.c: conv_func.tbl conv_func.pl - perl conv_func.pl +conv/conv.h: conv_func.tbl tools/conv_func.pl + perl tools/conv_func.pl +conv/convdef.h: conv_func.tbl tools/conv_func.pl + perl tools/conv_func.pl +conv/null.c: conv_func.tbl tools/conv_func.pl + perl tools/conv_func.pl mc.h-new: - perl mc-h-renum.pl mc.h > mc.h.1 + perl tools/mc-h-renum.pl mc.h > mc.h.1 mv mc.h.1 mc.h check-all: check-all-c check-all-code @@ -121,21 +121,21 @@ # -./$(MC) -Itest/ -s $(TARGET).c check: $(MC) $(TARGET).c - -gcc $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) + -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -./b.out > $(TARGET).gcc.out -./$(MC) -s $(TARGET).c - -gcc $(TARGET).s $(MLIB) + -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).gcc.out $(TARGET).$(MC).out check-code: $(MC) -./$(MC) -s $(TARGET).c - -gcc $(TARGET).s $(MLIB) + -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).code-out $(TARGET).$(MC).out check-code-make: $(MC) -./$(MC) -s $(TARGET).c - -gcc $(TARGET).s $(MLIB) + -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).code-out test/code-gen-all.c: test/code-gen.pl test/code-gen.c @@ -221,65 +221,46 @@ # DO NOT DELETE -mc-code-ia32.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-code-ia32.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-code-ia32.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-code-ia32.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-code-ia32.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.h +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/ppc/_types.h mc.h mc-code-ia32.o: mc-parse.h mc-codegen.h mc-code.h -mc-codegen.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-codegen.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-codegen.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-codegen.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-codegen.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.h -mc-codegen.o: mc-parse.h mc-codegen.h mc-code.h -mc-parse.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-parse.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-parse.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-parse.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-parse.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.h -mc-parse.o: mc-parse.h mc-codegen.h mc-switch.h mc-macro.h conv/conv.h -mc-tree.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-tree.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-tree.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-tree.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-tree.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.h +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/ppc/_types.h mc.h +mc-codegen.o: mc-parse.h mc-codegen.h mc-code.h mc-switch.h mc-inline.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/ppc/_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/ppc/_types.h mc.h mc-tree.o: mc-parse.h -mc-switch.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-switch.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-switch.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-switch.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-switch.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.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/ppc/_types.h mc.h mc-switch.o: mc-parse.h mc-codegen.h mc-code.h -mc-macro.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-macro.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-macro.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-macro.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-macro.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.h -mc-macro.o: mc-parse.h mc-macro.h mc-code.h -conv/c.o: /usr/include/stdio.h /usr/include/sys/types.h -conv/c.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -conv/c.o: /usr/include/machine/types.h /usr/include/ppc/types.h -conv/c.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -conv/c.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.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/ppc/_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/ppc/_types.h mc.h conv/c.o: mc-parse.h conv/conv.h conv/convdef.h conv/c.h conv/c2cbc.o: mc.h conv/cbc2c.o: mc.h -conv/null.o: /usr/include/stdio.h /usr/include/sys/types.h -conv/null.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -conv/null.o: /usr/include/machine/types.h /usr/include/ppc/types.h -conv/null.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -conv/null.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.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/ppc/_types.h mc.h conv/null.o: mc-parse.h conv/conv.h conv/convdef.h conv/null.h -mc-code-powerpc.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-code-powerpc.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-code-powerpc.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-code-powerpc.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-code-powerpc.o: /usr/include/machine/endian.h /usr/include/ppc/endian.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/ppc/_types.h mc-code-powerpc.o: mc.h mc-parse.h mc-code.h mc-codegen.h -mc-code-mips.o: /usr/include/stdio.h /usr/include/sys/types.h -mc-code-mips.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h -mc-code-mips.o: /usr/include/machine/types.h /usr/include/ppc/types.h -mc-code-mips.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h -mc-code-mips.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc.h +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/ppc/_types.h mc.h mc-code-mips.o: mc-parse.h mc-code.h mc-codegen.h
--- a/conv_func.pl Tue Mar 01 14:54:15 2005 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -#!/usr/bin/perl - -$in="conv_func.tbl"; -$out="conv/conv.h"; -$def="conv/convdef.h"; -$nul="conv/null.c"; - -open(IN,"<$in") or die("can't open $in"); -open(OUT,">$out") or die("can't open $out"); -print OUT "/* Do not edit this file. This is automatically generated. */\n"; -print OUT "/* Edit $in */\n"; -open(DEF,">$def") or die("can't open $def"); -print DEF "/* Do not edit this file. This is automatically generated. */\n"; -print DEF "/* Edit $in */\n"; -open(NUL,">$nul") or die("can't open $nul"); -print NUL "/* Do not edit this file. This is automatically generated. */\n"; -print NUL "/* Edit $in */\n"; - -print OUT "typedef struct converter {\n"; - -print NUL "#include <stdio.h>\n"; -print NUL "#include \"mc.h\"\n"; -print NUL "#include \"mc-parse.h\"\n"; - -print NUL "#include \"conv/conv.h\"\n"; -print NUL "#include \"conv/convdef.h\"\n"; -print NUL "#include \"conv/null.h\"\n"; - - -while(<IN>) { - if (/([^\s]*)\s+([_a-zA-Z0-9]*)\((.*)\)/) { - $type=$1; $name=$2; $arg=$3; - # print OUT "$type=$name=$arg\n"; - $return = ($type && $type ne "void")? "return ($type)0;" : ""; - print OUT " $type (*$name)($arg);\n"; - print NUL "static $type\n$name($arg)\n{ $return}\n\n"; - print DEF "static $_"; - } -} - -print OUT "} Converter;\n"; - -foreach $def ('conv/c.h','conv/null.h' ) { - $def =~ m-conv/(.*)\.h-; $m = $1; - open(DEF,">$def") or die("can't open $def"); - print DEF "/* Do not edit this file. This is automatically generated. */\n"; - - print OUT "extern Converter ${m}_converter;\n"; - print DEF "\nextern Converter $1_converter;\n"; - print DEF "\n\n\nConverter $1_converter = {\n"; - open(IN,"<$in") or die("can't open $in"); - while(<IN>) { - if (/([^\s]*)\s+([_a-zA-Z0-9]*)\((.*)\)/) { - $type=$1; $name=$2; $arg=$3; - print DEF " \&$name,\n"; - } - } - print DEF "};\n"; -} -
--- a/mc-code-ia32.c Tue Mar 01 14:54:15 2005 +0900 +++ b/mc-code-ia32.c Mon May 16 11:53:56 2005 +0900 @@ -43,7 +43,7 @@ int code_lassop_p = 0; -static int MAX_REGISTER=6; /* intel386のレジスタを6つまで使う*/ +int MAX_REGISTER=6; /* intel386のレジスタを6つまで使う*/ #define REAL_MAX_REGISTER 8 /* intel386のレジスタが8つということ*/ static int MAX_DATA_REG=4; static int MAX_POINTER=3; @@ -54,7 +54,7 @@ #define REG_VAR 3 // static int MAX_INPUT_REGISTER_VAR = 0; -static int MAX_CODE_INPUT_REGISTER_VAR = 2; +int MAX_CODE_INPUT_REGISTER_VAR = 2; // static int MAX_INPUT_DREGISTER_VAR = 0; // static int MAX_INPUT_FREGISTER_VAR = 0; // static int MAX_CODE_INPUT_DREGISTER_VAR = 0;
--- a/mc-h-renum.pl Tue Mar 01 14:54:15 2005 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -#!/usr/local/bin/perl - -my $mode = 0; - -my $reserve = -1; -my $tags = 1; -my $error = 1; -my $modnum = 0; - -while(<>) { - if(m+/\* reserved word start \*/+) { $mode = 1; } - elsif(m+/\* reserved word end \*/+) { $mode = 0; } - elsif(m+/\* tree node tags start \*/+) { $mode = 2; } - elsif(m+/\* tree node tags end \*/+) { $mode = 0; } - elsif(m+/\* error number start \*/+) { $mode = 3; } - elsif(m+/\* error number end \*/+) { $mode = 0; } - elsif(m+/\* mode start \*/+) { $mode = 4; } - elsif(m+/\* mode end \*/+) { $mode = 0; } - elsif(m+/\* statement start \*/+) { $mode = 5; } - elsif(m+/\* statement end \*/+) { $mode = 0; } - else { - if ($mode==0) { ; } - elsif ($mode==1) { - s/-(\d+)/$reserve--/e; - } elsif ($mode==2) { - s/\s(\d+)/"\t".$tags++/e; - } elsif ($mode==3) { - s/(\d+)/$error++/e; - } elsif ($mode==4) { - s/(\d+)/$modenum++/e; - } elsif ($mode==5) { - s/(\d+)/$tags++/e; - } - } - print; -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/conv_func.pl Mon May 16 11:53:56 2005 +0900 @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +$in="conv_func.tbl"; +$out="conv/conv.h"; +$def="conv/convdef.h"; +$nul="conv/null.c"; + +open(IN,"<$in") or die("can't open $in"); +open(OUT,">$out") or die("can't open $out"); +print OUT "/* Do not edit this file. This is automatically generated. */\n"; +print OUT "/* Edit $in */\n"; +open(DEF,">$def") or die("can't open $def"); +print DEF "/* Do not edit this file. This is automatically generated. */\n"; +print DEF "/* Edit $in */\n"; +open(NUL,">$nul") or die("can't open $nul"); +print NUL "/* Do not edit this file. This is automatically generated. */\n"; +print NUL "/* Edit $in */\n"; + +print OUT "typedef struct converter {\n"; + +print NUL "#include <stdio.h>\n"; +print NUL "#include \"mc.h\"\n"; +print NUL "#include \"mc-parse.h\"\n"; + +print NUL "#include \"conv/conv.h\"\n"; +print NUL "#include \"conv/convdef.h\"\n"; +print NUL "#include \"conv/null.h\"\n"; + + +while(<IN>) { + if (/([^\s]*)\s+([_a-zA-Z0-9]*)\((.*)\)/) { + $type=$1; $name=$2; $arg=$3; + # print OUT "$type=$name=$arg\n"; + $return = ($type && $type ne "void")? "return ($type)0;" : ""; + print OUT " $type (*$name)($arg);\n"; + print NUL "static $type\n$name($arg)\n{ $return}\n\n"; + print DEF "static $_"; + } +} + +print OUT "} Converter;\n"; + +foreach $def ('conv/c.h','conv/null.h' ) { + $def =~ m-conv/(.*)\.h-; $m = $1; + open(DEF,">$def") or die("can't open $def"); + print DEF "/* Do not edit this file. This is automatically generated. */\n"; + + print OUT "extern Converter ${m}_converter;\n"; + print DEF "\nextern Converter $1_converter;\n"; + print DEF "\n\n\nConverter $1_converter = {\n"; + open(IN,"<$in") or die("can't open $in"); + while(<IN>) { + if (/([^\s]*)\s+([_a-zA-Z0-9]*)\((.*)\)/) { + $type=$1; $name=$2; $arg=$3; + print DEF " \&$name,\n"; + } + } + print DEF "};\n"; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/incpri.pl Mon May 16 11:53:56 2005 +0900 @@ -0,0 +1,8 @@ +#!/usr/bin/perl +$d = "0000"; +while(<>) { + s/printf\(\"\#\d+\:/printf\(\"\#$d\:/; + s/printf\(\"([^#])/printf\(\"\#$d\:$1/; + $d++; + print; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mc-h-renum.pl Mon May 16 11:53:56 2005 +0900 @@ -0,0 +1,37 @@ +#!/usr/local/bin/perl + +my $mode = 0; + +my $reserve = -1; +my $tags = 1; +my $error = 1; +my $modnum = 0; + +while(<>) { + if(m+/\* reserved word start \*/+) { $mode = 1; } + elsif(m+/\* reserved word end \*/+) { $mode = 0; } + elsif(m+/\* tree node tags start \*/+) { $mode = 2; } + elsif(m+/\* tree node tags end \*/+) { $mode = 0; } + elsif(m+/\* error number start \*/+) { $mode = 3; } + elsif(m+/\* error number end \*/+) { $mode = 0; } + elsif(m+/\* mode start \*/+) { $mode = 4; } + elsif(m+/\* mode end \*/+) { $mode = 0; } + elsif(m+/\* statement start \*/+) { $mode = 5; } + elsif(m+/\* statement end \*/+) { $mode = 0; } + else { + if ($mode==0) { ; } + elsif ($mode==1) { + s/-(\d+)/$reserve--/e; + } elsif ($mode==2) { + s/\s(\d+)/"\t".$tags++/e; + } elsif ($mode==3) { + s/(\d+)/$error++/e; + } elsif ($mode==4) { + s/(\d+)/$modenum++/e; + } elsif ($mode==5) { + s/(\d+)/$tags++/e; + } + } + print; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/regs.pl Mon May 16 11:53:56 2005 +0900 @@ -0,0 +1,31 @@ +# mips .mask pattern + +@regs = (28,31,16); +@regs = (31,28,23,22,21,20,19,18,17,16); +@regs = (21,20); + +@regs = (31,28); +@fregs = (20..31); + +$mask = 0; +$count = 1; +grep($mask |= (1<<($_)),@regs); +grep($count += $_?1:0 ,@regs); + +$fmask = 0; +$fcount = 1; +grep($fmask |= (1<<($_)),@fregs); +grep($fcount += $_?1:0 ,@fregs); + +# count のルールは良く分からないね。カウントじゃないみたいだな。 +# やっぱりregister saveのoffsetみたいだね (gcc によると) +# + +printf(".mask\t%x,%d\n",$mask,-$count*4); +printf(".fmask\t%x,%d\n",$fmask,-$fcount*4); + +# cprestore +# input variable? +# call するサブルーチンの整数の引数の数か? + +