• R/O
  • SSH

CbC: Commit

micro-C base Continuation based C


Commit MetaInfo

Revisionad4c31417536a3e55ca59614c388d47c481c081f (tree)
Zeit2011-09-24 02:11:52
AutorShinji KONO <kono@ie.u...>
CommiterShinji KONO

Log Message

i64 parallel assignment

Ändern Zusammenfassung

Diff

diff -r d3e503684b5d -r ad4c31417536 Makefile.i64
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.i64 Sat Sep 24 02:11:52 2011 +0900
@@ -0,0 +1,290 @@
1+GCC = gcc
2+CC = $(GCC) -std=c99 $(CCEXT) $(M) -fgnu89-inline
3+# -O3
4+# MCFLAG = -DUSE_CODE_KEYWORD
5+CFLAGS = -g -Wall -I. $(MCFLAG) # -O
6+# CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
7+# LDFLAGS = -pg
8+# for Linux Zaurus
9+# CFLAGS = -fsigned-char -pipe -g -I. -I/home/zaurus/develop/include
10+CFLAGS1 = -g -I.
11+BASE=0
12+STAGE=1
13+MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE)
14+ARCH=i64
15+MC=mc-$(ARCH)
16+MLIB = -lm
17+PRINTF= # printf.c
18+CONVERTER=conv/c.o conv/null.o conv/c2cbc.o conv/cbc2c.o
19+COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o mc-inline.o
20+# CODE=mc-code-ia32.c
21+CODE=mc-code-$(ARCH).c
22+GCC_INCLUDE=`perl tools/find-gcc-include-path -p $(CC)`
23+#
24+#
25+TARGET=test/simp
26+
27+all: mc tags
28+
29+predefined:
30+ $(CC) -xc -E -dM /dev/null
31+
32+ppc:
33+ make ARCH=powerpc CCEXT="-arch ppc" check-all
34+
35+ia32:
36+ make ARCH=ia32 CCEXT="-m32" check-all
37+
38+ia32-make-code-check:
39+ make ARCH=ia32 CCEXT="-m32" MK=-make check-all-code
40+
41+mc: mc-$(ARCH)
42+ cp mc-$(ARCH) mc
43+
44+mc-i64 :conv/conv.h mc-include.c mc-code-i64.o $(COMPLIB) $(CONVERTER)
45+ $(CC) $(LDFLAGS) -g mc-code-i64.o $(COMPLIB) $(CONVERTER) -o $@
46+
47+mc-powerpc :conv/conv.h mc-include.c mc-code-powerpc.o $(COMPLIB) $(CONVERTER)
48+ $(CC) $(LDFLAGS) -g mc-code-powerpc.o $(COMPLIB) $(CONVERTER) -o $@
49+
50+mc-ia32 :conv/conv.h mc-include.c mc-code-ia32.o $(COMPLIB) $(CONVERTER)
51+ $(CC) $(LDFLAGS) -g mc-code-ia32.o $(COMPLIB) $(CONVERTER) -o $@
52+
53+mc-mips :conv/conv.h mc-include.c mc-code-mips.o $(COMPLIB) $(CONVERTER)
54+ $(CC) $(LDFLAGS) -g mc-code-mips.o $(COMPLIB) $(CONVERTER) -o $@
55+
56+mc-arm :conv/conv.h mc-include.c mc-code-arm.o $(COMPLIB) $(CONVERTER)
57+ $(CC) $(LDFLAGS) -g mc-code-arm.o $(COMPLIB) $(CONVERTER) -o $@
58+
59+mc-spu :conv/conv.h mc-include.c mc-code-spu.o $(COMPLIB) $(CONVERTER)
60+ $(CC) $(LDFLAGS) -g mc-code-spu.o $(COMPLIB) $(CONVERTER) -o $@
61+
62+conv/conv.h: conv_func.tbl tools/conv_func.pl
63+ perl tools/conv_func.pl
64+conv/convdef.h: conv_func.tbl tools/conv_func.pl
65+ perl tools/conv_func.pl
66+conv/null.c: conv_func.tbl tools/conv_func.pl
67+ perl tools/conv_func.pl
68+
69+mc-include.c:
70+ perl tools/find-gcc-include-path -l $(CC) > mc-include.c
71+
72+mc.h-new:
73+ perl tools/mc-h-renum.pl mc.h > mc.h.1
74+ mv mc.h.1 mc.h
75+
76+check-all: check-all-c check-all-code
77+
78+check-all-c:
79+ make check TARGET=test/basic
80+ make check-inline TARGET=test/basic
81+ make check TARGET=test/call
82+ make check TARGET=test/fact0
83+ make check TARGET=test/float
84+ make check TARGET=test/ifdef
85+ make check TARGET=test/int
86+ make check TARGET=test/macro
87+ make check TARGET=test/regargs
88+ make check TARGET=test/short
89+ make check TARGET=test/simp
90+ make check TARGET=test/simp0
91+ make check TARGET=test/simp1
92+ make check TARGET=test/static
93+ make check-inline TARGET=test/static
94+ make check TARGET=test/tmp
95+ make check TARGET=test/tmp10
96+ make check TARGET=test/tmp11
97+ make check TARGET=test/tmp12
98+ make check TARGET=test/tmp5
99+ make check TARGET=test/tmp7
100+ make check-inline TARGET=test/tmp7
101+ make check TARGET=test/tmp8
102+ make check TARGET=test/tmp9
103+ make check TARGET=test/enum
104+ make check TARGET=test/obsf
105+ make check TARGET=test/obsf2
106+ make check TARGET=test/long
107+ make check TARGET=test/tstdarg
108+ make check TARGET=test/switch
109+ make check-inline TARGET=test/switch
110+ make check TARGET=test/strinit
111+ make check-inline TARGET=test/strinit
112+ make check TARGET=test/code-gen-all
113+ make check-inline TARGET=test/code-gen-all
114+ make check TARGET=test/bitfield
115+ make check TARGET=test/bitfield1
116+ make check-inline TARGET=test/bitfield1
117+ make check TARGET=test/cext
118+ make check TARGET=test/const
119+ make check TARGET=test/void_code
120+ make check TARGET=test/putenemy
121+ make check TARGET=test/inline
122+ make check TARGET=test/ps2
123+ make check-inline TARGET=test/ps2
124+ make check TARGET=test/offset
125+ make check TARGET=test/multi
126+ make check-inline TARGET=test/multi
127+ make check TARGET=test/comp
128+ make check-inline TARGET=test/comp
129+# make check TARGET=test/scope STDFLAG="-std=gnu99"
130+# make check-inline TARGET=test/scope STDFLAG="-std=gnu99"
131+#MK =-make
132+MK=
133+check-all-code:
134+ make check-code$(MK) TARGET=test/arg
135+ make check-code$(MK) TARGET=test/conv
136+ make check-code$(MK) TARGET=test/conv1
137+ make check-code$(MK) TARGET=test/fact-a
138+ make check-code$(MK) TARGET=test/fact
139+ make check-code$(MK) TARGET=test/goto
140+ make check-code$(MK) TARGET=test/test1
141+ make check-code$(MK) TARGET=test/test2
142+ make check-code$(MK) TARGET=test/tmpa
143+ make check-code$(MK) TARGET=test/tmp1
144+ make check-code$(MK) TARGET=test/tmp2
145+ make check-code$(MK) TARGET=test/tmp4
146+ make check-code$(MK) TARGET=test/tmp6
147+ make check-code$(MK) TARGET=test/tmpb
148+ make check-code-inline TARGET=test/tmpb
149+ make check-code$(MK) TARGET=test/scope
150+ make check-code-inline TARGET=test/scope
151+ # make check-code$(MK) TARGET=test/throw
152+ make check-code$(MK) TARGET=test/too-long-argument
153+
154+check-nkf: mc
155+ ( cd nkf203; $(CC) -g -o nkf1 nkf.c utf8tbl.c )
156+ ( cd nkf203; ../mc-$(ARCH) -s nkf.c utf8tbl.c )
157+ ( cd nkf203; $(CC) -g -o nkf nkf.s utf8tbl.s )
158+ ( cd nkf203; perl test.pl )
159+
160+# -./$(MC) -Itest/ -s $(TARGET).c
161+
162+check: mc $(MC) $(TARGET).c
163+ -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
164+ -./b.out > $(TARGET).gcc.out
165+ -./$(MC) $(MCFLAG) -s $(TARGET).c
166+ -$(CC) $(TARGET).s $(MLIB)
167+ -./a.out > $(TARGET).$(MC).out
168+ -diff $(TARGET).gcc.out $(TARGET).$(MC).out
169+
170+check-inline: mc $(MC) $(TARGET).c
171+ -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
172+ -./b.out > $(TARGET).gcc.out
173+ -./$(MC) $(MCFLAG) -s -DINLINE=inline $(TARGET).c
174+ -$(CC) $(TARGET).s $(MLIB)
175+ -./a.out > $(TARGET).$(MC).out
176+ -diff $(TARGET).gcc.out $(TARGET).$(MC).out
177+
178+check-code: mc $(MC)
179+ -./$(MC) $(MCFLAG) -s $(TARGET).c
180+ -$(CC) $(TARGET).s $(MLIB)
181+ -./a.out > $(TARGET).$(MC).out
182+ -diff $(TARGET).code-out $(TARGET).$(MC).out
183+check-code-inline: mc $(MC)
184+ -./$(MC) $(MCFLAG) -s -DINLINE=inline $(TARGET).c
185+ -$(CC) $(TARGET).s $(MLIB)
186+ -./a.out > $(TARGET).$(MC).out
187+ -diff $(TARGET).code-out $(TARGET).$(MC).out
188+check-code-make: mc $(MC)
189+ -./$(MC) $(MCFLAG) -s $(TARGET).c
190+ -$(CC) $(TARGET).s $(MLIB)
191+ -./a.out > $(TARGET).code-out
192+
193+check-flip: mc $(MC)
194+ -$(CC) -DFLIP -c test/basic2.c
195+ -$(CC) basic2.o test/basic2.c
196+ ./a.out
197+ -./$(MC) -s test/basic2.c
198+ -$(CC) test/basic2.s -DFLIP test/basic2.c
199+ ./a.out
200+ -./$(MC) -DFLIP -s test/basic2.c
201+ -$(CC) test/basic2.s test/basic2.c
202+ ./a.out
203+
204+test/code-gen-all.c: test/code-gen.pl test/code-gen.c
205+ perl test/code-gen.pl < test/code-gen.c > test/code-gen-all.c
206+
207+incpri:
208+ perl tools/incpri.pl test/*.c
209+
210+tags: tags-$(ARCH)
211+
212+tags-$(ARCH):
213+ ctags mc.h mc-code.h mc-code-$(ARCH).c mc-codegen.c mc-codegen.h \
214+ mc-parse.h mc-tree.c mc-inline.h mc-switch.h \
215+ mc-macro.h mc-macro.c \
216+ conv/c.c conv/c.h \
217+ conv/conv.h conv/convdef.h
218+
219+tar :
220+ make clean
221+ tar cBf - . | gzip > ../comp.tgz
222+
223+depend : mc.h mc-include.c
224+ makedepend -I$(GCC_INCLUDE) mc-code-ia32.c mc-code.h mc-codegen.c mc-codegen.h \
225+ mc-parse.c mc-tree.c mc-switch.c mc-switch.h mc.h \
226+ mc-inline.c mc-macro.c mc-macro.h mc-parse.h \
227+ conv/c.c conv/c.h conv/c2cbc.c conv/c2cbc.h conv/cbc2c.c \
228+ conv/cbc2c.h conv/conv.h conv/convdef.h conv/null.c conv/null.h \
229+ mc-code-arm.c \
230+ mc-code-powerpc.c \
231+ mc-code-mips.c
232+
233+clean :
234+ -rm -rf mc mc-spu mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i mc-include.c *.dSYM
235+
236+mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
237+ $(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
238+
239+mc2 : b00.s b01.s b02.s b03.s mc-macro.o mc-inline.o $(CONVERTER)
240+ $(CC) -g -o $@ $(PRINTF) b00.s b01.s b02.s b03.s b04.s mc-macro.o mc-inline.o $(CONVERTER)
241+
242+b00.s : mc-parse.c $(MC)
243+ ./$(MC) $(MCFLAG) -s -ob00.s mc-parse.c
244+b01.s : $(CODE) $(MC)
245+ ./$(MC) $(MCFLAG) -s -ob01.s $(CODE)
246+b02.s : mc-codegen.c $(MC)
247+ ./$(MC) $(MCFLAG) -s -ob02.s mc-codegen.c
248+b03.s : mc-tree.c $(MC)
249+ ./$(MC) $(MCFLAG) -s -ob03.s mc-tree.c
250+b04.s : mc-switch.c $(MC)
251+ ./$(MC) $(MCFLAG) -s -ob04.s mc-switch.c
252+
253+b10.s : mc-parse.c mc1
254+ ./mc1 $(MCFLAG) -s -ob10.s mc-parse.c
255+b11.s : $(CODE) $(PRINTF) mc1
256+ ./mc1 $(MCFLAG) -s -ob11.s $(CODE)
257+b12.s : mc-codegen.c mc1
258+ ./mc1 $(MCFLAG) -s -ob12.s mc-codegen.c
259+b13.s : mc-tree.c mc1
260+ ./mc1 $(MCFLAG) -s -ob13.s mc-tree.c
261+b14.s : mc-switch.c mc1
262+ ./mc1 $(MCFLAG) -s -ob14.s mc-switch.c
263+
264+b20.s : mc-parse.c mc2
265+ ./mc2 $(MCFLAG) -s -ob20.s mc-parse.c
266+b21.s : $(CODE) $(PRINTF) mc2
267+ ./mc2 $(MCFLAG) -s -ob21.s $(CODE)
268+b22.s : mc-codegen.c mc2
269+ ./mc2 $(MCFLAG) -s -ob22.s mc-codegen.c
270+b23.s : mc-tree.c mc2
271+ ./mc2 $(MCFLAG) -s -ob23.s mc-tree.c
272+b24.s : mc-switch.c mc1
273+ ./mc2 $(MCFLAG) -s -ob24.s mc-switch.c
274+
275+diff : b00.s b01.s b02.s b03.s b04.s b10.s b11.s b12.s b13.s b14.s
276+ -diff b00.s b10.s
277+ -diff b01.s b11.s
278+ -diff b02.s b12.s
279+ -diff b03.s b13.s
280+ -diff b04.s b14.s
281+
282+diff2 : b00.s b01.s b02.s b03.s b04.s b20.s b21.s b22.s b23.s b24.s
283+ -diff b00.s b20.s
284+ -diff b01.s b21.s
285+ -diff b02.s b22.s
286+ -diff b03.s b23.s
287+ -diff b04.s b24.s
288+
289+
290+# DO NOT DELETE
diff -r d3e503684b5d -r ad4c31417536 mc-codegen.c
--- a/mc-codegen.c Wed Sep 21 16:17:09 2011 +0900
+++ b/mc-codegen.c Sat Sep 24 02:11:52 2011 +0900
@@ -1042,7 +1042,7 @@
10421042 /* source (after) list2(tag,disp) */
10431043 /* source list list3(e,cdr,sz) */
10441044
1045-#define DEBUG_PARALLEL_ASSIGN 0
1045+#define DEBUG_PARALLEL_ASSIGN 1
10461046
10471047 static int is_writable(int);
10481048
@@ -1193,7 +1193,7 @@
11931193 for(target0=*target;target0; target0=cadr(target0)) {
11941194 t=car(target0); s=cadddr(target0);
11951195 sz=size(ty=caddr(target0));
1196- if(car(t)==car(s) && cadr(t)==cadr(s)) {
1196+ if(is_same_type(t,s) && cadr(t)==cadr(s)) {
11971197 /*書き込み先が自分自身*/
11981198 #if DEBUG_PARALLEL_ASSIGN
11991199 if (lsrc) printf("## remove same %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
@@ -1295,8 +1295,10 @@
12951295 {
12961296 int ce1=car(e1);
12971297 int ce2=car(e2);
1298+ if (ce1==ce2) return 1;
12981299 if (ce1==LVAR) {
12991300 switch(ce2) {
1301+ case LRLVAR: case LURLVAR: return lp64;
13001302 case RLVAR: case CRLVAR: case FRLVAR: case DRLVAR:
13011303 case SRLVAR: case SURLVAR: case CURLVAR: case LVAR:
13021304 case URLVAR:
@@ -1304,8 +1306,9 @@
13041306 }
13051307 } else if (ce2==LVAR) {
13061308 switch(ce1) {
1309+ case LRLVAR: case LURLVAR: return lp64;
13071310 case RLVAR: case CRLVAR: case FRLVAR: case DRLVAR:
1308- case SRLVAR: case SURLVAR: case CURLVAR: case LRLVAR: case LVAR:
1311+ case SRLVAR: case SURLVAR: case CURLVAR: case LVAR:
13091312 case URLVAR:
13101313 return 1;
13111314 }
@@ -1327,6 +1330,10 @@
13271330 return 1;
13281331 }
13291332 #endif
1333+ } else if (ce1==REGISTER) {
1334+ if (lp64 && ce2==LREGISTER) return 1;
1335+ } else if (ce2==REGISTER) {
1336+ if (lp64 && ce1==LREGISTER) return 1;
13301337 }
13311338 return 0;
13321339 }
@@ -1337,7 +1344,7 @@
13371344 switch(car(e1)) {
13381345 case GVAR :
13391346 case LVAR :
1340- case RLVAR : // this is wrong, but ia32 generates this.
1347+ case RLVAR : case LRLVAR: case URLVAR: case LURLVAR: // this is wrong, but ia32 generates this.
13411348 case REGISTER :
13421349 return size_of_int;
13431350 case FREGISTER :
diff -r d3e503684b5d -r ad4c31417536 test/cbc_return.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/cbc_return.c Sat Sep 24 02:11:52 2011 +0900
@@ -0,0 +1,35 @@
1+#include<stdio.h>
2+typedef void (*RET_FUNC)(int, void *);
3+
4+void g(RET_FUNC func)
5+{
6+ func(33, NULL);
7+}
8+
9+int f_cbc()
10+{
11+ //__label__ _cbc_exit0;
12+ //int retval;
13+ void *ret;
14+
15+ ret = _CbC_return;
16+
17+ printf("#0016:f0: fp = 0x%x\n", __builtin_frame_address(0));
18+ printf("#0017:__return_func = %x\n", ret);
19+ g(ret);
20+
21+ printf("#0020:not good\n");
22+ return 0;
23+//_cbc_exit0:
24+ //printf("#0023:f1: fp = 0x%x\n", __builtin_frame_address(0));
25+ //return retval;
26+}
27+
28+int main(int argc, char **argv)
29+{
30+ int t;
31+ printf("#0030:main before: fp = 0x%x\n", __builtin_frame_address(0));
32+ t = f_cbc();
33+ printf("#0032:f_cbc = %d\n", t);
34+ printf("#0033:main after: fp = 0x%x\n", __builtin_frame_address(0));
35+}
diff -r d3e503684b5d -r ad4c31417536 test/cloop.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/cloop.c Sat Sep 24 02:11:52 2011 +0900
@@ -0,0 +1,57 @@
1+int printf(const char *,...);
2+
3+char c[] = {0,1,2,3,4,5,6,7,8,9};
4+short s[] = {0,1,2,3,4,5,6,7,8,9};
5+int j[] = {0,1,2,3,4,5,6,7,8,9};
6+long long l[] = {0,1,2,3,4,5,6,7,8,9};
7+
8+void
9+f(char *c,short *s, int *j, long long *l)
10+{
11+ int i;
12+ for( i = 0;i<10;i++) {
13+ printf("%d ",c[i]);
14+ }
15+ for( i = 0;i<10;i++) {
16+ printf("%d ",s[i]);
17+ }
18+ for( i = 0;i<10;i++) {
19+ printf("%d ",j[i]);
20+ }
21+ for( i = 0;i<10;i++) {
22+ printf("%lld ",l[i]);
23+ }
24+ printf("\n");
25+}
26+
27+void
28+st(char *c,short *s, int *j, long long *l)
29+{
30+ int i;
31+ for( i = 0;i<10;i++) {
32+ c[i] = i;
33+ printf("\n");
34+ }
35+ for( i = 0;i<10;i++) {
36+ s[i] = i;
37+ printf("\n");
38+ }
39+ for( i = 0;i<10;i++) {
40+ j[i] = i;
41+ printf("\n");
42+ }
43+ for( i = 0;i<10;i++) {
44+ l[i] = i;
45+ printf("\n");
46+ }
47+}
48+
49+int
50+main()
51+{
52+ f(c,s,j,l);
53+ st(c,s,j,l);
54+ f(c,s,j,l);
55+}
56+
57+/* end */
Show on old repository browser